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

Method resolve

pydevd_attach_to_process/winappdbg/module.py:684–723  ·  view source on GitHub ↗

Resolves a function exported by this module. @type function: str or int @param function: str: Name of the function. int: Ordinal of the function. @rtype: int @return: Memory address of the exported function in the process.

(self, function)

Source from the content-addressed store, hash-verified

682 return None
683
684 def resolve(self, function):
685 """
686 Resolves a function exported by this module.
687
688 @type function: str or int
689 @param function:
690 str: Name of the function.
691 int: Ordinal of the function.
692
693 @rtype: int
694 @return: Memory address of the exported function in the process.
695 Returns None on error.
696 """
697
698 # Unknown DLL filename, there's nothing we can do.
699 filename = self.get_filename()
700 if not filename:
701 return None
702
703 # If the DLL is already mapped locally, resolve the function.
704 try:
705 hlib = win32.GetModuleHandle(filename)
706 address = win32.GetProcAddress(hlib, function)
707 except WindowsError:
708 # Load the DLL locally, resolve the function and unload it.
709 try:
710 hlib = win32.LoadLibraryEx(filename, win32.DONT_RESOLVE_DLL_REFERENCES)
711 try:
712 address = win32.GetProcAddress(hlib, function)
713 finally:
714 win32.FreeLibrary(hlib)
715 except WindowsError:
716 return None
717
718 # A NULL pointer means the function was not found.
719 if address in (None, 0):
720 return None
721
722 # Compensate for DLL base relocations locally and remotely.
723 return address - hlib + self.lpBaseOfDll
724
725 def resolve_label(self, label):
726 """

Callers 4

resolve_labelMethod · 0.95
inject_dllMethod · 0.45

Calls 1

get_filenameMethod · 0.95

Tested by

no test coverage detected