Loads the debugging symbols for a module. Automatically called by L{get_symbols}.
(self)
| 445 | # handle redirected exports (for example ws2_32!recv). |
| 446 | # I haven't been able to reproduce the bug yet. |
| 447 | def load_symbols(self): |
| 448 | """ |
| 449 | Loads the debugging symbols for a module. |
| 450 | Automatically called by L{get_symbols}. |
| 451 | """ |
| 452 | if win32.PROCESS_ALL_ACCESS == win32.PROCESS_ALL_ACCESS_VISTA: |
| 453 | dwAccess = win32.PROCESS_QUERY_LIMITED_INFORMATION |
| 454 | else: |
| 455 | dwAccess = win32.PROCESS_QUERY_INFORMATION |
| 456 | hProcess = self.get_process().get_handle(dwAccess) |
| 457 | hFile = self.hFile |
| 458 | BaseOfDll = self.get_base() |
| 459 | SizeOfDll = self.get_size() |
| 460 | Enumerator = self._SymbolEnumerator() |
| 461 | try: |
| 462 | win32.SymInitialize(hProcess) |
| 463 | SymOptions = win32.SymGetOptions() |
| 464 | SymOptions |= ( |
| 465 | win32.SYMOPT_ALLOW_ZERO_ADDRESS |
| 466 | | win32.SYMOPT_CASE_INSENSITIVE |
| 467 | | win32.SYMOPT_FAVOR_COMPRESSED |
| 468 | | win32.SYMOPT_INCLUDE_32BIT_MODULES |
| 469 | | win32.SYMOPT_UNDNAME |
| 470 | ) |
| 471 | SymOptions &= ~(win32.SYMOPT_LOAD_LINES | win32.SYMOPT_NO_IMAGE_SEARCH | win32.SYMOPT_NO_CPP | win32.SYMOPT_IGNORE_NT_SYMPATH) |
| 472 | win32.SymSetOptions(SymOptions) |
| 473 | try: |
| 474 | win32.SymSetOptions(SymOptions | win32.SYMOPT_ALLOW_ABSOLUTE_SYMBOLS) |
| 475 | except WindowsError: |
| 476 | pass |
| 477 | try: |
| 478 | try: |
| 479 | success = win32.SymLoadModule64(hProcess, hFile, None, None, BaseOfDll, SizeOfDll) |
| 480 | except WindowsError: |
| 481 | success = 0 |
| 482 | if not success: |
| 483 | ImageName = self.get_filename() |
| 484 | success = win32.SymLoadModule64(hProcess, None, ImageName, None, BaseOfDll, SizeOfDll) |
| 485 | if success: |
| 486 | try: |
| 487 | win32.SymEnumerateSymbols64(hProcess, BaseOfDll, Enumerator) |
| 488 | finally: |
| 489 | win32.SymUnloadModule64(hProcess, BaseOfDll) |
| 490 | finally: |
| 491 | win32.SymCleanup(hProcess) |
| 492 | except WindowsError: |
| 493 | e = sys.exc_info()[1] |
| 494 | msg = "Cannot load debug symbols for process ID %d, reason:\n%s" |
| 495 | msg = msg % (self.get_pid(), traceback.format_exc(e)) |
| 496 | warnings.warn(msg, DebugSymbolsWarning) |
| 497 | self.__symbols = Enumerator.symbols |
| 498 | |
| 499 | def unload_symbols(self): |
| 500 | """ |
no test coverage detected