@rtype: int @return: Parent process global ID. @raise WindowsError: An error occured when calling a Win32 API function. @raise RuntimeError: The parent process ID can't be found.
(self)
| 203 | process = property(get_process, set_process, doc="") |
| 204 | |
| 205 | def get_pid(self): |
| 206 | """ |
| 207 | @rtype: int |
| 208 | @return: Parent process global ID. |
| 209 | |
| 210 | @raise WindowsError: An error occured when calling a Win32 API function. |
| 211 | @raise RuntimeError: The parent process ID can't be found. |
| 212 | """ |
| 213 | if self.dwProcessId is None: |
| 214 | if self.__process is not None: |
| 215 | # Infinite loop if self.__process is None |
| 216 | self.dwProcessId = self.get_process().get_pid() |
| 217 | else: |
| 218 | try: |
| 219 | # I wish this had been implemented before Vista... |
| 220 | # XXX TODO find the real ntdll call under this api |
| 221 | hThread = self.get_handle(win32.THREAD_QUERY_LIMITED_INFORMATION) |
| 222 | self.dwProcessId = win32.GetProcessIdOfThread(hThread) |
| 223 | except AttributeError: |
| 224 | # This method is really bad :P |
| 225 | self.dwProcessId = self.__get_pid_by_scanning() |
| 226 | return self.dwProcessId |
| 227 | |
| 228 | def __get_pid_by_scanning(self): |
| 229 | "Internally used by get_pid()." |
no test coverage detected