-->

Load Dll without execute dllmain function

2019-04-17 03:08发布

问题:

I want to load special dll without execute dllmain function.

I think, set a breakpoint at dllmain can solve this problem.

But I don't know How can I do?

Also I want call dll's export function.

I have tried to use LoadLibraryEx with dont_resolve_dll_references, but it occurs error with dll's function call.

How can I solve this? Please give me your idea.

Thanks.

回答1:

Well as explained here:

An optional entry point into a dynamic-link library (DLL). When the system starts or terminates a process or thread, it calls the entry-point function for each loaded DLL using the first thread of the process. The system also calls the entry-point function for a DLL when it is loaded or unloaded using the LoadLibrary and FreeLibrary functions.

calling the DllMain is an OS feature mandatory (although implementing that function is optional) if you use the standard way in loading and executing a dynamic library. So there is no official way in doing this.



回答2:

As explained in this question: Win32 API to enumerate dll export functions?

You can use LoadLibraryEx with the DONT_RESOLVE_DLL_REFERENCES flag, even though use of that flag is strongly discouraged. If so you will likely have to free and reload the dll if you actually want to use it.



标签: dll mfc cracking