MCPcopy Create free account
hub / github.com/AlSch092/UltimateAntiCheat / GetParentProcessId

Method GetParentProcessId

Process/Process.cpp:231–262  ·  view source on GitHub ↗

GetParentProcessId - Get the process ID of the parents process returns the pid of the current process parent process. used to check for illegal launchers (an attacker's launcher code spawned our process, for example) */

Source from the content-addressed store, hash-verified

229returns the pid of the current process parent process. used to check for illegal launchers (an attacker's launcher code spawned our process, for example)
230*/
231DWORD Process::GetParentProcessId()
232{
233 HANDLE hSnapshot = NULL;
234 PROCESSENTRY32 pe32;
235 DWORD ppid = 0, pid = GetCurrentProcessId();
236
237 hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
238 __try
239 {
240 if (hSnapshot == INVALID_HANDLE_VALUE) __leave;
241
242 ZeroMemory(&pe32, sizeof(pe32));
243 pe32.dwSize = sizeof(pe32);
244 if (!Process32First(hSnapshot, &pe32)) __leave;
245
246 do
247 {
248 if (pe32.th32ProcessID == pid)
249 {
250 ppid = pe32.th32ParentProcessID;
251 break;
252 }
253 } while (Process32Next(hSnapshot, &pe32));
254
255 }
256 __finally
257 {
258 if (hSnapshot != INVALID_HANDLE_VALUE && hSnapshot != 0)
259 CloseHandle(hSnapshot);
260 }
261 return ppid;
262}
263
264/*
265 GetProcessIdByName - Get first pid given a process name.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected