mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: data reuse (tmp, to fix)
This commit is contained in:
@@ -21,6 +21,18 @@ class IatResolve():
|
||||
self.id
|
||||
)
|
||||
|
||||
def get_physical_address(pe, virtual_address):
|
||||
# Iterate through the section headers to find which section contains the VA
|
||||
for section in pe.sections:
|
||||
# Check if the VA is within the range of this section
|
||||
if section.VirtualAddress <= virtual_address < section.VirtualAddress + section.Misc_VirtualSize:
|
||||
# Calculate the difference between the VA and the section's virtual address
|
||||
virtual_offset = virtual_address - section.VirtualAddress
|
||||
# Add the difference to the section's pointer to raw data
|
||||
return virtual_offset
|
||||
#physical_address = section.PointerToRawData + virtual_offset
|
||||
#return physical_address
|
||||
return None
|
||||
|
||||
class ExeInfo():
|
||||
def __init__(self):
|
||||
@@ -36,6 +48,9 @@ class ExeInfo():
|
||||
self.base_relocs = []
|
||||
self.rwx_section = None
|
||||
|
||||
self.ep = None
|
||||
self.ep_raw = None
|
||||
|
||||
|
||||
def add_iat_resolve(self, func_name, placeholder):
|
||||
self.iat_resolves[func_name] = IatResolve(
|
||||
@@ -49,6 +64,9 @@ class ExeInfo():
|
||||
if pe.FILE_HEADER.Machine != 0x8664:
|
||||
raise Exception("Binary is not 64bit: {}".format(filepath))
|
||||
|
||||
self.ep = pe.OPTIONAL_HEADER.AddressOfEntryPoint
|
||||
self.ep_raw = get_physical_address(pe, self.ep)
|
||||
|
||||
# image base
|
||||
self.image_base = pe.OPTIONAL_HEADER.ImageBase
|
||||
|
||||
|
||||
Reference in New Issue
Block a user