MCPcopy Create free account
hub / github.com/NoMercy-ac/NoMercy / GetThreadOwnerProcessId

Method GetThreadOwnerProcessId

Source/Client/NM_Engine/ThreadFunctions.cpp:8–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "SafeThreadHandle.h"
7
8DWORD CThreadFunctions::GetThreadOwnerProcessId(DWORD dwThreadID)
9{
10 auto hSnap = g_winapiApiTable->CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, NULL);
11 if (!IS_VALID_HANDLE(hSnap))
12 {
13 DEBUG_LOG(LL_ERR, "CreateToolhelp32Snapshot fail! Error: %u", g_winapiApiTable->GetLastError());
14 return 0;
15 }
16
17 THREADENTRY32 ti = { 0 };
18 ti.dwSize = sizeof(ti);
19
20 if (g_winapiApiTable->Thread32First(hSnap, &ti))
21 {
22 do
23 {
24 if (dwThreadID == ti.th32ThreadID)
25 {
26 g_winapiApiTable->CloseHandle(hSnap);
27 return ti.th32OwnerProcessID;
28 }
29 } while (g_winapiApiTable->Thread32Next(hSnap, &ti));
30 }
31
32 g_winapiApiTable->CloseHandle(hSnap);
33 return 0;
34}
35
36bool CThreadFunctions::ThreadIsItAlive(DWORD dwThreadID)
37{

Callers

nothing calls this directly

Calls 1

CloseHandleMethod · 0.80

Tested by

no test coverage detected