【发布时间】:2018-10-03 13:35:19
【问题描述】:
喂!
我制作了一个简单的附加/分离脚本,但如果我按 F11,DLL 会被杀死,但不是以“正常方式”,DLL_PROCES_DETACH 不会被调用
可能是什么问题?
#include <Windows.h>
#include <thread>
HMODULE hMod = nullptr;
bool bDebugMode = true;
bool bLeave = false;
void Setup(void);
void Setup()
{
while (true)
{
if (GetAsyncKeyState(VK_F11) & 1)
{
std::this_thread::sleep_for(std::chrono::milliseconds(200));
FreeLibraryAndExitThread(hMod, 1);
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
hMod = hModule;
DisableThreadLibraryCalls(hModule);
if(bDebugMode)
MessageBox(NULL, "Attach", "Attached", MB_OK);
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Setup, 0, 0, 0); break;
case DLL_THREAD_DETACH:
Beep(500, 100);
if(bDebugMode)
MessageBox(NULL, "Detach", "Detach called!", MB_OK); break;
}
return true;
}
任何帮助将不胜感激!
【问题讨论】:
标签: dll-injection detach