Skip to content

Commit

Permalink
Fix a deadlock by never suspending the current thread
Browse files Browse the repository at this point in the history
  • Loading branch information
m417z committed Jan 16, 2023
1 parent 09cfc25 commit 608f007
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion global-inject-lib/all_processes_injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ void AllProcessesInjector::InjectIntoNewProcess(HANDLE hProcess, DWORD dwProcess
// before the parent process notified csrss.exe (KERNELBASE!CsrClientCallServer),
// csrss.exe returns an access denied error and the parent's CreateProcess
// call fails.
//
// If the process is the current process, we skip this check since it
// obviously began running, and we don't want to suspend the current thread
// and cause a deadlock.

wil::unique_process_handle suspendedThread;

{
if (dwProcessId != GetCurrentProcessId()) {
DWORD processAccess = THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | DllInject::ProcessAccess;

wil::unique_process_handle thread1;
Expand Down

0 comments on commit 608f007

Please sign in to comment.