我有一個的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