Skip to content

Prevent recursive thread creation in DllMain#3

Open
rxznve wants to merge 1 commit intoTheEasyPeasy:masterfrom
rxznve:patch-1
Open

Prevent recursive thread creation in DllMain#3
rxznve wants to merge 1 commit intoTheEasyPeasy:masterfrom
rxznve:patch-1

Conversation

@rxznve
Copy link
Copy Markdown

@rxznve rxznve commented Mar 30, 2026

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant