其实在pefile主页的Wiki上已经详细介绍了,https://code.google.com/p/pefile/wiki/UsageExamples这里给出了使用例子。同时参照着看雪http://bbs.pediy.com/showthread.php?t=89838的例子,学习了下。
下面贴上自己学习过程的代码例子,Mark备用:
# -*- coding: cp936 -*-
#import os, string, shutil,re
import pefile
import pydasm
import sys
PEfile_Path = r"G:\calc.exe"
#PEfile_Path = r"G:\msvcp110.dll"
pe = pefile.PE(PEfile_Path)
print PEfile_Path,'\n\n'
'''
pe_file = open('PE.txt', 'w')
console = sys.stdout
sys.stdout = pe_file
#PE全面解析
print pe
sys.stdout = console
pe_file.close()
'''
#入口点
#print hex(pe.OPTIONAL_HEADER.AddressOfEntryPoint)
'''
#节表
for section in pe.sections:
print section
#print hex(pe.sections[i].Characteristics)
'''
'''
#导入表
for importeddll in pe.DIRECTORY_ENTRY_IMPORT:
print importeddll.dll, ':'
#print