Skip to content

Commit

Permalink
Better check for OpenThread so it removes a duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
FransBouma committed Aug 8, 2024
1 parent acc8f7d commit df15207
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,25 +342,23 @@ static MH_STATUS Freeze(PFROZEN_THREADS pThreads, UINT pos, UINT action)
for (i = 0; i < pThreads->size; ++i)
{
HANDLE hThread = OpenThread(THREAD_ACCESS, FALSE, pThreads->pItems[i]);
if (hThread == NULL)
{
// Mark thread as not suspended, so it's not resumed later on.
pThreads->pItems[i] = 0;
}
else
BOOL suspended = FALSE;
if (hThread != NULL)
{
DWORD result = SuspendThread(hThread);
if (result == 0xFFFFFFFF)
{
// Mark thread as not suspended, so it's not resumed later on.
pThreads->pItems[i] = 0;
}
else
if (result != 0xFFFFFFFF)
{
suspended = TRUE;
ProcessThreadIPs(hThread, pos, action);
}
CloseHandle(hThread);
}

if (!suspended)
{
// Mark thread as not suspended, so it's not resumed later on.
pThreads->pItems[i] = 0;
}
}
}

Expand Down

0 comments on commit df15207

Please # to comment.