Winapi DllMain和Qt-Mfc迁移

Winapi DllMain和Qt-Mfc迁移,winapi,qt,qt4,qt-mfc-migration,Winapi,Qt,Qt4,Qt Mfc Migration,我正在使用Mfc到Qt迁移解决方案,将我的Mfc插件迁移到Qt。 我的Mfc插件加载在第三方Mfc应用程序中。基本上,我使用以下示例: 我阅读了pluginInstance函数的代码,对Qt源代码进行了整编,注意到pluginInstance在内部调用了LoadLibrary和SetWindowsHook 到目前为止,一切正常。但我有以下忧虑: 禁止从user32.dll调用LoadLibrary和函数,如从DllMain调用SetWindowsHook。我在DllMain的msdn文档中读到了

我正在使用Mfc到Qt迁移解决方案,将我的Mfc插件迁移到Qt。 我的Mfc插件加载在第三方Mfc应用程序中。基本上,我使用以下示例:

我阅读了pluginInstance函数的代码,对Qt源代码进行了整编,注意到pluginInstance在内部调用了LoadLibrary和SetWindowsHook

到目前为止,一切正常。但我有以下忧虑: 禁止从user32.dll调用LoadLibrary和函数,如从DllMain调用SetWindowsHook。我在DllMain的msdn文档中读到了这一点。那么,如果这是不安全的,为什么官方Qt网站说在DllMain中调用pluginInstance?
也许我遗漏了什么

也许他们没有读到:),但是为一个不调用其他“不安全”API(如CreateThread()等)的DLL调用LoadLibrary()是安全的,这只是一个建议,只要想想当您从DLL\u进程\u附加调用LoadLibrary()时发生了什么,库被加载,IAT填充,DllMain()被调用

BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID  ) {
 static bool ownApplication = FALSE;
 if ( dwReason == DLL_PROCESS_ATTACH )
     ownApplication = QMfcApp::pluginInstance( hInstance );
 if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
     delete qApp;
 return TRUE;
}