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

Method GetProcessParentProcessId

Source/Client/NM_Engine/ProcessFunctions.cpp:8–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "SafeProcessHandle.h"
7
8DWORD CProcessFunctions::GetProcessParentProcessId(DWORD dwMainProcessId)
9{
10 auto hSnap = g_winapiApiTable->CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 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 PROCESSENTRY32 pe = { 0 };
18 pe.dwSize = sizeof(PROCESSENTRY32);
19
20 if (g_winapiApiTable->Process32First(hSnap, &pe))
21 {
22 do {
23 if (pe.th32ProcessID == dwMainProcessId)
24 {
25 g_winapiApiTable->CloseHandle(hSnap);
26 return pe.th32ParentProcessID;
27 }
28 } while (g_winapiApiTable->Process32Next(hSnap, &pe));
29 }
30
31 g_winapiApiTable->CloseHandle(hSnap);
32 return 0;
33}
34
35DWORD CProcessFunctions::GetProcessIdFromProcessName(const char* c_szProcessName)
36{

Callers

nothing calls this directly

Calls 1

CloseHandleMethod · 0.80

Tested by

no test coverage detected