看了网上都说不建议在 dllmain 中使用 loadLibrary,freeLibrary 函数。
如果不在 dllmain 加载,应该在什么地方加载呢?
1
shuax 2017-09-15 18:58:22 +08:00 via Android
如果有互相依赖会死锁,没有依赖就加载吧
|
2
ysc3839 2017-09-15 22:02:55 +08:00 via Android
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx
Calling functions that require DLLs other than Kernel32.dll may result in problems that are difficult to diagnose. For example, calling User, Shell, and COM functions can cause access violation errors, because some functions load other system components. Conversely, calling functions such as these during termination can cause access violation errors because the corresponding component may already have been unloaded or uninitialized. |
3
andychen20121130 OP @shuax 没有相互依赖。
|
4
andychen20121130 OP @ysc3839 在几个步骤中加载吗?
A process loads the DLL (DLL_PROCESS_ATTACH). The current process creates a new thread (DLL_THREAD_ATTACH). A thread exits normally (DLL_THREAD_DETACH). A process unloads the DLL (DLL_PROCESS_DETACH). |