兩種方法獲取檔案OEP

2021-08-26 03:44:58 字數 752 閱讀 3672

讀取的字段都是一樣的,只是乙個直接從pe檔案中讀取,乙個對映到記憶體後再讀取

1.檔案直接訪問法

bool readoepbyfile(lpctstr szfilename) dword dwoep,cbread; image_dos_header dos_header[sizeof(image_dos_header)];//image_dos_header dos_header[1]; if (!readfile(hfile,dos_header,sizeof(image_dos_header),&cbread,null)) int nentrypos=dos_header->e_lfanew+40; setfilepointer(hfile,nentrypos,null,file_begin); if (!readfile(hfile,&dwoep,sizeof(dwoep),&cbread,null)) closehandle(hfile); cstring stroep; stroep.format(_t("oep:0x%x"),dwoep); afxmessagebox(stroep); return true; }

第二種方法要注意dos stup與pe頭不一定是緊挨著的,一定要通過(dword)pbaseaddr+dos_header->e_lfanew定位到image_nt_headers

如果還要讀入口點的**或其它東西,把page_readonly|sec_commit換成page_readonly|sec_commit|sec_image會給你帶來很大的便利

謝謝列寧。

兩種方法獲取檔案OEP

讀取的字段都是一樣的,只是乙個直接從pe檔案中讀取,乙個對映到記憶體後再讀取 1.檔案直接訪問法 cpp view plain copy boolreadoepbyfile lpctstrszfilename dworddwoep,cbread image dos header dos header...

寫入檔案的兩種方法

寫入檔案的兩種方法 方法1 file.write 方法2 file.writelines write方法是將整個字串寫入到檔案中,而writelines是將乙個字串序列寫入到檔案中 如何進行選擇 如果引數是字串,就使用write方法 如果引數是序列,就使用writelines方法。開啟檔案 file...

LCA兩種方法

lca least common ancestors 即最近公共祖先,是指在有根樹中,找出某兩個結點u和v最近的公共祖先。模板題 anc i j 表示第i個點的2 j的祖先的標號 整個過程就是兩個點往上跳到同一深度,再一起往上跳找到lca include include using namespac...