MCPcopy Create free account
hub / github.com/dobin/SuperMega / write_code_section

Function write_code_section

pe/pehelper.py:66–73  ·  view source on GitHub ↗
(exe_file: FilePath, new_data: bytes)

Source from the content-addressed store, hash-verified

64
65
66def write_code_section(exe_file: FilePath, new_data: bytes):
67 pe = pefile.PE(exe_file)
68 section = get_code_section(pe)
69 file_offset = section.PointerToRawData
70 with open(exe_file, 'r+b') as f:
71 f.seek(file_offset)
72 f.write(new_data)
73 pe.close()
74
75
76def get_code_section(pe: pefile.PE) -> pefile.SectionStructure:

Callers

nothing calls this directly

Calls 2

get_code_sectionFunction · 0.85
closeMethod · 0.80

Tested by

no test coverage detected