Add temp reference for entrypoints

This commit is contained in:
disinvite 2023-12-28 15:11:03 -05:00
parent 56971a3f5e
commit ea1224db08
3 changed files with 21 additions and 6 deletions

View File

@ -30,6 +30,17 @@
// LIBRARY: LEGO1 0x1008b640
// _rand
// entry
// LIBRARY: ISLE 0x4082e0
// _WinMainCRTStartup
// entry
// LIBRARY: LEGO1 0x1008c860
// __DllMainCRTStartup@12
// LIBRARY: ISLE 0x409110
// __mtinit
// LIBRARY: ISLE 0x409190
// __getptd

View File

@ -81,6 +81,7 @@ def __init__(self, filename: str, logger=None) -> None:
self.filename = filename
self.file = None
self.imagebase = None
self.entry = None
self.sections: List[ImageSectionHeader] = []
self.last_section = None
self._relocated_addrs = set()
@ -106,6 +107,8 @@ def __enter__(self):
optional_hdr = self.file.read(pe_hdr.SizeOfOptionalHeader)
(self.imagebase,) = struct.unpack("<i", optional_hdr[0x1C:0x20])
(entry,) = struct.unpack("<i", optional_hdr[0x10:0x14])
self.entry = entry + self.imagebase
self.sections = [
ImageSectionHeader(*struct.unpack("<8s6I2HI", self.file.read(0x28)))
@ -223,6 +226,11 @@ def get_section_offset_by_name(self, name: str) -> int:
section = self._get_section_by_name(name)
return section.virtual_address
def get_abs_addr(self, section: int, offset: int) -> int:
"""Convenience function for converting section:offset pairs from cvdump
into an absolute vaddr."""
return self.get_section_offset_by_index(section) + offset
def get_raw_addr(self, vaddr: int) -> int:
"""Returns the raw offset in the PE binary for the given virtual address."""
self._set_section_for_vaddr(vaddr)

View File

@ -37,9 +37,7 @@ def __init__(self, pdb, sym_recompfile, sym_logger, base_dir):
size = contrib_dict[(pub.section, pub.offset)]
info = RecompiledInfo()
info.addr = pub.offset + sym_recompfile.get_section_offset_by_index(
pub.section
)
info.addr = sym_recompfile.get_abs_addr(pub.section, pub.offset)
info.start = 0
info.size = size
@ -52,9 +50,7 @@ def __init__(self, pdb, sym_recompfile, sym_logger, base_dir):
continue
info = RecompiledInfo()
info.addr = proc.offset + sym_recompfile.get_section_offset_by_index(
proc.section
)
info.addr = sym_recompfile.get_abs_addr(proc.section, proc.offset)
info.start = 0
info.size = proc.size