winapi - C++ Read PE Optional Headers to determine DEP and ASLR -
i wish parse pe file , read optional headers it, , other data enables me know if 32bit pe or 64 bit. know imagehlp , dbghlp header files give me structures such image_optional_header. not sure how parse file yield these. can use documentation , write own parser using offsets, if knows correct api parse pe?
my objective : 1) determine if file x64 or x86 executable. in header?? 2) check aslr, dep , safeseh. first 2 think in pe optional headers.
so there api parse pe , return me these structures?
you should take @ image helper library. there method mapandload
give pointer various parts of pe file (loaded_image
structure), i.e. image_nt_headers, image_section_header. image_nt_headers
structure contains pointer image_optional_header
structure.
the field dllcharacteristic contains various flags image_dllcharacteristics_nx_compat or image_dllcharacteristics_no_seh example.
to use these api include imagehlp.h , link imagehlp.lib.