From 0cfaff85eb6cd8d41bd3487d506655b2ba74675d Mon Sep 17 00:00:00 2001 From: August Vishnevsky Date: Mon, 30 Mar 2026 19:15:01 +0300 Subject: [PATCH] Prevent recursive thread creation in DllMain The previous implementation incorrectly handled all DllMain events (DLL_PROCESS_ATTACH, DLL_THREAD_ATTACH, DLL_THREAD_DETACH, DLL_PROCESS_DETACH) by unconditionally creating a new thread that calls hookSetup. This caused an infinite loop because each new thread triggered a DLL_THREAD_ATTACH event, which in turn created another thread, leading to resource exhaustion and process instability. Fixed by limiting thread creation to the DLL_PROCESS_ATTACH event only, which is the proper place for one-time initialization. --- dllmain.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dllmain.c b/dllmain.c index 0f6e06d..509a578 100644 --- a/dllmain.c +++ b/dllmain.c @@ -9,11 +9,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)hookSetup, NULL, 0, NULL); - break; } return TRUE; }