mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
fix: close PE's
This commit is contained in:
+2
-1
@@ -18,6 +18,7 @@ def extract_code_from_exe(exe_file: FilePath) -> bytes:
|
|||||||
logger.info(" > 0x{:X} Code Size: {} (raw code section size: {})".format(
|
logger.info(" > 0x{:X} Code Size: {} (raw code section size: {})".format(
|
||||||
section.VirtualAddress,
|
section.VirtualAddress,
|
||||||
len(data), section.SizeOfRawData))
|
len(data), section.SizeOfRawData))
|
||||||
|
pe.close()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ def write_code_section(exe_file: FilePath, new_data: bytes):
|
|||||||
with open(exe_file, 'r+b') as f:
|
with open(exe_file, 'r+b') as f:
|
||||||
f.seek(file_offset)
|
f.seek(file_offset)
|
||||||
f.write(new_data)
|
f.write(new_data)
|
||||||
|
pe.close()
|
||||||
|
|
||||||
def get_code_section(pe: pefile.PE) -> pefile.SectionStructure:
|
def get_code_section(pe: pefile.PE) -> pefile.SectionStructure:
|
||||||
entrypoint = pe.OPTIONAL_HEADER.AddressOfEntryPoint
|
entrypoint = pe.OPTIONAL_HEADER.AddressOfEntryPoint
|
||||||
|
|||||||
Reference in New Issue
Block a user