portable executable - Which PE header fields are used by windows loader? -
i'm trying understand pe header files produced executable compressor.
i've been told header fields windows uses in case intact. other, on other hand, contain complete garbage pe header perspective. i'm trying understand ones relevant ones.
let's got image_dos_header
:
and image_file_header
:
when open executable on debugger, stops @ address:
cpu disasm address hex dump command comments 0040005c 53 push ebx
so, how debugger knows 0x0040005c location needs start debugging at? what'd formula calculate "entry point" address?
i guess main question here is, pe header files relevant windows perspective loader , ones used other purposes these type of packers?
from image_dos_header
e_magic
(for check) , e_lfanew
(offset image_nt_headersxx
(32 or 64) ) used. need image_nt_headers
fields. entry point calc easy
pimage_dos_header imagebase; if (imagebase->e_magic == image_dos_signature) { union { pvoid pv; pimage_nt_headers32 pinth32; pimage_nt_headers64 pinth64; }; pv = rtloffsettopointer(imagebase, imagebase->e_lfanew); dword addressofentrypoint = 0; switch (pinth32->optionalheader.magic) { case image_nt_optional_hdr32_magic: addressofentrypoint = pinth32->optionalheader.addressofentrypoint; break; case image_nt_optional_hdr64_magic: addressofentrypoint = pinth64->optionalheader.addressofentrypoint; break; } pvoid entrypoint = addressofentrypoint ? rtloffsettopointer(imagebase, addressofentrypoint) : 0; }
so image_optional_header.addressofentrypoint
when open executable on debugger, stops @ address:
bad debugger :) must stop @ ldrinitializethunk
Comments
Post a Comment