Returns a handle to the process with I{at least} the access rights requested. @note: If a handle was previously opened and has the required access rights, it's reused. If not, a new handle is opened with the combination of the old and new
(self, dwDesiredAccess=win32.PROCESS_ALL_ACCESS)
| 230 | self.hProcess = None |
| 231 | |
| 232 | def get_handle(self, dwDesiredAccess=win32.PROCESS_ALL_ACCESS): |
| 233 | """ |
| 234 | Returns a handle to the process with I{at least} the access rights |
| 235 | requested. |
| 236 | |
| 237 | @note: |
| 238 | If a handle was previously opened and has the required access |
| 239 | rights, it's reused. If not, a new handle is opened with the |
| 240 | combination of the old and new access rights. |
| 241 | |
| 242 | @type dwDesiredAccess: int |
| 243 | @param dwDesiredAccess: Desired access rights. |
| 244 | Defaults to L{win32.PROCESS_ALL_ACCESS}. |
| 245 | See: U{http://msdn.microsoft.com/en-us/library/windows/desktop/ms684880(v=vs.85).aspx} |
| 246 | |
| 247 | @rtype: L{ProcessHandle} |
| 248 | @return: Handle to the process. |
| 249 | |
| 250 | @raise WindowsError: It's not possible to open a handle to the process |
| 251 | with the requested access rights. This tipically happens because |
| 252 | the target process is a system process and the debugger is not |
| 253 | runnning with administrative rights. |
| 254 | """ |
| 255 | if self.hProcess in (None, win32.INVALID_HANDLE_VALUE): |
| 256 | self.open_handle(dwDesiredAccess) |
| 257 | else: |
| 258 | dwAccess = self.hProcess.dwAccess |
| 259 | if (dwAccess | dwDesiredAccess) != dwAccess: |
| 260 | self.open_handle(dwAccess | dwDesiredAccess) |
| 261 | return self.hProcess |
| 262 | |
| 263 | # ------------------------------------------------------------------------------ |
| 264 |
no test coverage detected