mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: calculate offset into .rdata (tmp)
This commit is contained in:
@@ -8,6 +8,7 @@ from helper import hexdump
|
||||
|
||||
logger = logging.getLogger("superpe")
|
||||
|
||||
|
||||
class PeSection():
|
||||
def __init__(self, pefile_section: pefile.SectionStructure):
|
||||
self.name: str = pefile_section.Name.rstrip(b'\x00').decode("utf-8")
|
||||
@@ -16,6 +17,7 @@ class PeSection():
|
||||
self.virt_addr: int = pefile_section.VirtualAddress
|
||||
self.virt_size: int = pefile_section.Misc_VirtualSize
|
||||
|
||||
|
||||
class SuperPe():
|
||||
IMAGE_DIRECTORY_ENTRY_SECURITY = 4
|
||||
IMAGE_DIRECTORY_ENTRY_BASERELOC = 5
|
||||
@@ -88,6 +90,18 @@ class SuperPe():
|
||||
return bytes(sect.get_data())
|
||||
|
||||
|
||||
def get_section_data(self, sect_name) -> bytes:
|
||||
sect = self.get_section_by_name_b(sect_name)
|
||||
return bytes(sect.get_data())
|
||||
|
||||
|
||||
def get_section_by_name_b(self, name):
|
||||
for sect in self.pe.sections:
|
||||
if sect.Name.decode().lower().startswith(name.lower()):
|
||||
return sect
|
||||
return None
|
||||
|
||||
|
||||
def write_code_section_data(self, data: bytes):
|
||||
sect = self.get_code_section()
|
||||
self.pe.set_bytes_at_offset(sect.PointerToRawData, data)
|
||||
|
||||
Reference in New Issue
Block a user