@@ -375,32 +375,34 @@ EXTERN_DLL_EXPORT VOID __stdcall ControlRemoteProcess(HANDLE process, ControlRem
375
375
if (action == ControlRemoteProcessAction::Suspend || action == ControlRemoteProcessAction::Resume)
376
376
{
377
377
auto processId = GetProcessId (process);
378
-
379
- auto handle = CreateToolhelp32Snapshot (TH32CS_SNAPTHREAD, 0 );
380
- if (handle != INVALID_HANDLE_VALUE)
378
+ if (processId != 0 )
381
379
{
382
- auto fn = action == ControlRemoteProcessAction::Suspend ? SuspendThread : ResumeThread;
383
-
384
- THREADENTRY32 te32 = {};
385
- te32.dwSize = sizeof (THREADENTRY32);
386
- if (Thread32First (handle, &te32))
380
+ auto handle = CreateToolhelp32Snapshot (TH32CS_SNAPTHREAD, 0 );
381
+ if (handle != INVALID_HANDLE_VALUE)
387
382
{
388
- do
383
+ auto fn = action == ControlRemoteProcessAction::Suspend ? SuspendThread : ResumeThread;
384
+
385
+ THREADENTRY32 te32 = {};
386
+ te32.dwSize = sizeof (THREADENTRY32);
387
+ if (Thread32First (handle, &te32))
389
388
{
390
- if (te32. th32OwnerProcessID == processId)
389
+ do
391
390
{
392
- auto threadHandle = OpenThread (THREAD_SUSPEND_RESUME, FALSE , te32.th32ThreadID );
393
- if (threadHandle)
391
+ if (te32.th32OwnerProcessID == processId)
394
392
{
395
- fn (threadHandle);
393
+ auto threadHandle = OpenThread (THREAD_SUSPEND_RESUME, FALSE , te32.th32ThreadID );
394
+ if (threadHandle)
395
+ {
396
+ fn (threadHandle);
396
397
397
- CloseHandle (threadHandle);
398
+ CloseHandle (threadHandle);
399
+ }
398
400
}
399
- }
400
- } while (Thread32Next (handle, &te32));
401
- }
401
+ } while (Thread32Next (handle, &te32));
402
+ }
402
403
403
- CloseHandle (handle);
404
+ CloseHandle (handle);
405
+ }
404
406
}
405
407
}
406
408
else if (action == ControlRemoteProcessAction::Terminate)
0 commit comments