mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
refactor: iat related
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
from typing import List
|
||||
import pefile
|
||||
|
||||
|
||||
class PeSection():
|
||||
def __init__(self, pefile_section: pefile.SectionStructure):
|
||||
self.name: str = pefile_section.Name.rstrip(b'\x00').decode("utf-8")
|
||||
self.raw_addr: int = pefile_section.PointerToRawData
|
||||
self.raw_size: int = pefile_section.SizeOfRawData
|
||||
self.virt_addr: int = pefile_section.VirtualAddress
|
||||
self.virt_size: int = pefile_section.Misc_VirtualSize
|
||||
#self.permissions = pefile_section.Characteristics
|
||||
|
||||
|
||||
class SuperPe():
|
||||
"""Interact with a PE file using pefile"""
|
||||
|
||||
def __init__(self, pe: pefile.PE):
|
||||
self.pe: pefile.PE = pe
|
||||
self.pe_sections: List[PeSection] = []
|
||||
|
||||
|
||||
def init(self):
|
||||
for section in self.pe.sections:
|
||||
self.pe_sections.append(PeSection(section))
|
||||
|
||||
|
||||
def get_section_by_name(self, name: str) -> PeSection:
|
||||
for section in self.pe_sections:
|
||||
#print("{} {}".format(section.name, name))
|
||||
if section.name == name:
|
||||
return section
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user