Closed luismk closed 4 years ago
@luismk I'm not sure what are you trying, but just to be sure DllMain is not supported and we don't have the urgent plans to support this soon (at least by me).
Please use P/Invoke export functions instead. Or Please clarify your problem.
what I am trying to do is edit an application's memory while it is running when arriving at DLLMAIN attach would go through the memory editing method Is there any other point I can use instead of DLLMAIN?
LoadLibrary + GetProcAddress: https://github.com/3F/DllExport/wiki/Examples
I am trying to do is edit an application's memory while it is running
WriteProcessMemory ? or maybe this https://github.com/3F/Conari ?
Is very, but very idiot, but keeping in mind that the program that you will load the dll is yours, you can hook the LoadLibrary and manually call a certain dll export of your dll; If isn't your program, well, I think you can forget about implement the DLLMain in your C# program; because you will need do reverse engineering to replace the DLLMain functionality and we know that this is not very cool... If you only want a function to be called in your dll automatically, I think you can do a dll wrapper to any library of your target program, like the d3d9.dll; dinput8.dll and etc, then when your program use the dll he will call your library. The dll unload event can be 'emulated' using hooks too, maybe hook the ExitProcess for example
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
@3F
I think they want to implement DllMain
by c# or give a hook when the dll is attach/detach
@gitlsl,
That's I said above. Currently, only IMAGE_EXPORT_DIRECTORY related records.
I have some ideas, but more likely I will consider this task only within the new project as I already voiced in other threads.
@marcussacana suggesting a library extension? I have the same dll in another C / C ++ language but as I deal better with Csharp I found it easier to implement it again, as @gitlsl suggested the main dll should be accepted in C # it would make life easier, I hope new development update ^^
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return dllmainincsharp(hModule,ul_reason_for_call,lpReserved);
}
can we do some shellcode make the unmanaged dllmain
code like above ,
then export a dllmainincsharp
in c#?
@gitlsl, Read this https://github.com/3F/DllExport/issues/45#issuecomment-317802099
I close this issue as duplicate of #5 since this is finally about supporting the DllMain entry point. Please continue there and follow the news.
I'm trying to implement this is all in C ++ for C # https://github.com/luismk/ProjectG/blob/master/ProjectG/Main.cpp I've done 98% of the codes, but main dll doesn't work I've tried everything, but for some reason I can't maybe i'm doing it wrong the point is not affected at all I even put a dump code if the method was called by the executable
Could someone give me a light?