MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / get_pid

Method get_pid

pydevd_attach_to_process/winappdbg/thread.py:205–226  ·  view source on GitHub ↗

@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)

Source from the content-addressed store, hash-verified

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()."

Callers 3

get_processMethod · 0.95
set_processMethod · 0.45
scan_threadsMethod · 0.45

Calls 3

get_processMethod · 0.95
get_handleMethod · 0.95
__get_pid_by_scanningMethod · 0.95

Tested by

no test coverage detected