Skip to content

Commit 608f007

Browse files
committed
Fix a deadlock by never suspending the current thread
1 parent 09cfc25 commit 608f007

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

global-inject-lib/all_processes_injector.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ void AllProcessesInjector::InjectIntoNewProcess(HANDLE hProcess, DWORD dwProcess
102102
// before the parent process notified csrss.exe (KERNELBASE!CsrClientCallServer),
103103
// csrss.exe returns an access denied error and the parent's CreateProcess
104104
// call fails.
105+
//
106+
// If the process is the current process, we skip this check since it
107+
// obviously began running, and we don't want to suspend the current thread
108+
// and cause a deadlock.
105109

106110
wil::unique_process_handle suspendedThread;
107111

108-
{
112+
if (dwProcessId != GetCurrentProcessId()) {
109113
DWORD processAccess = THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | DllInject::ProcessAccess;
110114

111115
wil::unique_process_handle thread1;

0 commit comments

Comments
 (0)