(self)
Get the Parent Process ID.
Get the Parent Process ID.
Get the Parent Process ID .
def get_parent_pid(self):
        """Get the Parent Process ID."""
        class PROCESS_BASIC_INFORMATION(Structure):
            _fields_ = [
                ("ExitStatus", c_void_p),
                ("PebBaseAddress", c_void_p),
                ("AffinityMask", c_void_p),
                ("BasePriority", c_void_p),
                ("UniqueProcessId", c_void_p),
                ("InheritedFromUniqueProcessId", c_void_p),
            ]

        NT_SUCCESS = lambda val: val >= 0

        pbi = PROCESS_BASIC_INFORMATION()
        size = c_int()

        # Set return value to signed 32bit integer.
        NTDLL.NtQueryInformationProcess.restype = c_int

        process_handle = self.open_process()
        ret = NTDLL.NtQueryInformationProcess(
            process_handle, 0, byref(pbi), sizeof(pbi), byref(size)
        )
        KERNEL32.CloseHandle(process_handle)

        if NT_SUCCESS(ret) and size.value == sizeof(pbi):
            return pbi.InheritedFromUniqueProcessId
def get_parent_pid ( self ) : class PROCESS_BASIC_INFORMATION ( Structure ) : _fields_ = [ ( "ExitStatus" , c_void_p ) , ( "PebBaseAddress" , c_void_p ) , ( "AffinityMask" , c_void_p ) , ( "BasePriority" , c_void_p ) , ( "UniqueProcessId" , c_void_p ) , ( "InheritedFromUniqueProcessId" , c_void_p ) , ] NT_SUCCESS = lambda val : val >= 0 pbi = PROCESS_BASIC_INFORMATION ( ) size = c_int ( ) # Set return value to signed 32bit integer. NTDLL . NtQueryInformationProcess . restype = c_int process_handle = self . open_process ( ) ret = NTDLL . NtQueryInformationProcess ( process_handle , 0 , byref ( pbi ) , sizeof ( pbi ) , byref ( size ) ) KERNEL32 . CloseHandle ( process_handle ) if NT_SUCCESS ( ret ) and size . value == sizeof ( pbi ) : return pbi . InheritedFromUniqueProcessId