Opens a new handle to the module. The new handle is stored in the L{hFile} property.
(self)
| 383 | # ------------------------------------------------------------------------------ |
| 384 | |
| 385 | def open_handle(self): |
| 386 | """ |
| 387 | Opens a new handle to the module. |
| 388 | |
| 389 | The new handle is stored in the L{hFile} property. |
| 390 | """ |
| 391 | |
| 392 | if not self.get_filename(): |
| 393 | msg = "Cannot retrieve filename for module at %s" |
| 394 | msg = msg % HexDump.address(self.get_base()) |
| 395 | raise Exception(msg) |
| 396 | |
| 397 | hFile = win32.CreateFile(self.get_filename(), dwShareMode=win32.FILE_SHARE_READ, dwCreationDisposition=win32.OPEN_EXISTING) |
| 398 | |
| 399 | # In case hFile was set to an actual handle value instead of a Handle |
| 400 | # object. This shouldn't happen unless the user tinkered with hFile. |
| 401 | if not hasattr(self.hFile, "__del__"): |
| 402 | self.close_handle() |
| 403 | |
| 404 | self.hFile = hFile |
| 405 | |
| 406 | def close_handle(self): |
| 407 | """ |
no test coverage detected