def get_parent_pid(self):
"""Get the Parent Process ID."""
if not self.h_process:
self.open()
NT_SUCCESS = lambda val: val >= 0
pbi = (ULONG_PTR * 6)()
size = c_ulong()
# Set return value to signed 32bit integer.
NTDLL.NtQueryInformationProcess.restype = c_int
ret = NTDLL.NtQueryInformationProcess(self.h_process,
0,
byref(pbi),
sizeof(pbi),
byref(size))
if NT_SUCCESS(ret) and size.value == sizeof(pbi):
return pbi[5]
return None
评论列表
文章目录