MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / get_proc_addr

Method get_proc_addr

pythonmemorymodule/__init__.py:937–959  ·  view source on GitHub ↗
(self, name_or_ordinal)

Source from the content-addressed store, hash-verified

935 return self._proc_addr_by_ordinal(ordinal)
936
937 def get_proc_addr(self, name_or_ordinal):
938 codebase = self._codebaseaddr
939 if not hasattr(self, '_exports_'):
940 directory = self.OPTIONAL_HEADER.DATA_DIRECTORY[IMAGE_DIRECTORY_ENTRY_EXPORT]
941 # No export table found
942 if directory.Size <= 0: raise WindowsError('No export table found.')
943 self._exports_ = IMAGE_EXPORT_DIRECTORY.from_address(codebase + directory.VirtualAddress)
944 if self._exports_.NumberOfFunctions == 0:
945 # DLL doesn't export anything
946 raise WindowsError('DLL doesn\'t export anything.&#x27;)
947 targ = type(name_or_ordinal)
948 if targ in [ str, str, str ]:
949 name_or_ordinal = str(name_or_ordinal)
950 procaddr_func = self._proc_addr_by_name
951 elif targ in [ int, int ]:
952 name_or_ordinal = int(name_or_ordinal)
953 procaddr_func = self._proc_addr_by_ordinal
954 else:
955 raise TypeError('Don\'t know what to do with name/ordinal of type: %s!&#x27; % targ)
956
957 if not name_or_ordinal in self._foffsets_:
958 self._foffsets_[name_or_ordinal] = procaddr_func(name_or_ordinal)
959 return FARPROC(codebase + self._foffsets_[name_or_ordinal])
960

Callers 1

pymemory.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected