/** Description: Simulate the Windows reprinter to load the PE file, which makes it easier to process the PE file. Parameter: szfilename: PE file path return: if the operation succeeds, the first address of the PE file image in the memory is returned. If the operation fails, 0 */ulong mappefile (tchar * szfilename) {handle hfile; ulong numr; image_dos_header dosheader = {0} is returned }; image_nt_headers ntheader; ulong dwimagesize; ulong dwnumofsections; ulong dwheadsize; callback ction; char * pbase; ulong nindex; hfile = createfile (szfilename, generic_read | generic_write, file_assist_r EAD | file_share_write, null, open_existing, file_attribute_normal, null); If (hfile = invalid_handle_value) {outputdebugstring (_ T ("failed to open the file! "); Return 0;} readfile (hfile, & dosheader, sizeof (image_dos_header), & numr, null); setfilepointer (hfile, dosheader. e_lfanew, null, file_begin); readfile (hfile, & ntheader, sizeof (image_nt_headers), & numr, null); dwimagesize = ntheader. optionalheader. sizeofimage; dwnumofsections = ntheader. fileheader. numberofsections; dwheadsize = ntheader. optionalheader. sizeofheaders; pbase = (char *) malloc (dwimagesize); memset (pbase, 0, dwimagesize); setfilepointer (hfile, 0, null, file_begin); readfile (hfile, pbase, dwheadsize, & numr, null); Direction ction = (pimage_section_header) (dosheader. e_lfanew + sizeof (ntheader. signature) + sizeof (image_file_header) + ntheader. fileheader. sizeofoptionalheader + (ulong) pbase); For (nindex = 0, direction; nindex <dwnumofsections; nindex ++, direction ++) {setfilepointer (hfile, Direction-> pointertorawdata, null, file_begin); readfile (hfile, & pbase [ction-> virtualaddress], ction-> sizeofrawdata, & numr, null);} closehandle (hfile); Return (ulong) pbase ;}