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

Function get_code_section

pe/pehelper.py:76–82  ·  view source on GitHub ↗
(pe: pefile.PE)

Source from the content-addressed store, hash-verified

74
75
76def get_code_section(pe: pefile.PE) -> pefile.SectionStructure:
77 entrypoint = pe.OPTIONAL_HEADER.AddressOfEntryPoint
78 for sect in pe.sections:
79 if sect.Characteristics & pefile.SECTION_CHARACTERISTICS['IMAGE_SCN_MEM_EXECUTE']:
80 if entrypoint >= sect.VirtualAddress and entrypoint <= sect.VirtualAddress + sect.Misc_VirtualSize:
81 return sect
82 raise Exception("pehelper::get_code_section(): Code section not found")
83
84
85## Utils

Callers 3

write_code_sectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected