(pe: pefile.PE)
| 74 | |
| 75 | |
| 76 | def 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 |
no outgoing calls
no test coverage detected