我有一个的DllMain定义为这样:的DllMain不被调用
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
int i=0, DoHijack=0;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
hMod = hModule;
hProcessCenter = ::FindWindow(NULL, _T("Form1"));
ExtractPaths(hModule, ExePath, &kNTIExeName, kNTIDllPath, &kNTIDllName);
//Only hook target processses
for(i=0; i < NB_TARGETS; i++)
{
if(strstr(kNTIExeName, Targets[i]))
DoHijack=1;
}
if(DoHijack)
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)Real_DrawText, Mine_DrawText); // <- magic
DetourAttach(&(PVOID&)Real_ExtTextOut, Mine_ExtTextOut);
DetourTransactionCommit();
break;
}
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)Real_DrawText, Mine_DrawText);
DetourDetach(&(PVOID&)Real_ExtTextOut, Mine_ExtTextOut); // <- magic
DetourTransactionCommit();
break;
}
return TRUE;
}
这是一个项目,我下班买回家后,我编译并运行它的DllMain永远不会被调用,所以我的问题这是process_attach开关永远不会被击中。什么可能导致这种情况发生?编译器中的一些东西,链接选项之一?
该dll功能在工作中完美...
谢谢。
你是如何“运行”的DLL? – wj32 2010-10-24 05:14:27
您为那些隐藏DLL的产品工作的是什么样的公司?这是恶意的,投票结束。 – 2010-10-24 07:18:04
你在'DllMain'里面做了什么?你可以发布一些代码吗? – nakiya 2010-10-24 04:43:28