A Simple PE Viewer.
Although someone has developed a better one, I'd like to try it myself.
I haven't package it, so just download PEFile.py and import it like a module.
First import the module.
from PEFile import PEFile
And then open a file.
file = PEFile(path_to_your_file)
If the file doesn't exist, it will raise an error.
Next, read the header.
file.readheader()
The PE Header is stored in dict, like the struct in C.
file.IMAGE_DOS_HEADER['e_lfanew']
file.IMAGE_NT_HEADERS['Signature']
Also, some headers array are in list, like:
file.IMAGE_SECTION_HEADER[0]['Name']
Note: All stored value is bytes, if you expect a human-readable format, try this.
file.IMAGE_NT_HEADERS['Signature'].hex()
I have decided to stop the development.
It is much more complicated than I expected before, so I just develop a few basic functions to understand the PE format.