PE files
Files lie about their names
Section titled “Files lie about their names”A file extension is just part of the name. Anyone can rename invoice.pdf.exe to invoice.pdf. The real type is in the first few bytes, the magic bytes:
- Every PE file starts with
MZ(hex4D 5A), the initials of Mark Zbikowski, who designed the original DOS format. - On a Mac or Linux,
file FILEreads those bytes and tells you what the file really is. More on this in Magic numbers and Confirming a file type.
What’s inside
Section titled “What’s inside”- DOS header: starts with
MZ. At offset0x3Cit holds the location of the real PE header. - DOS stub: a tiny program that prints “This program cannot be run in DOS mode.”
- PE signature:
PEfollowed by two zero bytes. - File header: the CPU it targets, the number of sections and a compile timestamp (which can be faked).
- Optional header: despite the name, always there. It holds the entry point (where execution starts) and whether it’s a console or a windowed program.
- Section table and sections: the actual contents.
Common sections
Section titled “Common sections”| Section | What’s usually in it |
|---|---|
.text |
The program’s code |
.rdata |
Read-only data, often including the import table |
.data |
Global variables |
.rsrc |
Resources: icons, version info, and sometimes a hidden payload |
.reloc |
Fix-ups used when Windows loads the file at a different address |
Strange section names (such as UPX0 and UPX1), very high entropy and only a handful of imports usually mean the file is packed: compressed or encrypted so the real code appears only when it runs. See Vocabulary.
Imports are clues
Section titled “Imports are clues”The import table lists the Windows functions the program asks for. They hint at what it can do:
| Imports | Suggests |
|---|---|
VirtualAllocEx, WriteProcessMemory, CreateRemoteThread |
Injecting code into another process |
URLDownloadToFileA, InternetOpenUrlA |
Downloading something |
RegSetValueExA, CreateServiceA |
Staying on the machine after a reboot |
These are hints, not proof. Plenty of legitimate software imports the same functions.
.NET files
Section titled “.NET files”A .NET program is still a PE file, but its code is .NET bytecode rather than machine code. Open it in a .NET decompiler such as dnSpyEx or ILSpy instead of a disassembler.
Try it safely
Section titled “Try it safely”You don’t need malware to learn this. Inside your lab VM, open a normal Windows file such as C:\Windows\System32\notepad.exe in one of these:
- PE-bear: headers, sections and imports
- PeStudio: flags suspicious imports and strings
- Detect It Easy: compiler and packer detection
Then calculate its hash and compare.
That’s File Types 101. Back to the series overview.
References
Section titled “References”
One Reverse Look
"A little learning is a dangerous thing." ~ A. Pope
One Reverse Look · Made with ❤ · Your friendly knowledge seeker

