ch0 1
ch0 1
ch0 1
EXE Files
PE Files
• Used by Windows executable files, object
code, and DLLs
• A data structure that contains the information
necessary for Windows to load the file
• Almost every file executed on Windows is in
PE format
PE Header
• Information about the code
• Type of application
• Required library functions
• Space requirements
LordPE Demo
Main Sections
There are
a lot more
sections
• But the
main ones
are enough
for now
• Link Ch 2c
Linked Libraries and Functions
Imports
• Functions used by a program that are stored in
a different program, such as library
• Connected to the main EXE by Linking
• Can be linked three ways
– Statically
– At Runtime
– Dynamically
Static Linking
• Rarely used for Windows executables
• Common in Unix and Linux
• All code from the library is copied into the
executable
• Makes executable large in size
Runtime Linking
• Unpopular in friendly programs
• Common in malware, especially packed or
obfuscated malware
• Connect to libraries only when needed, not
when the program starts
• Most commonly done with the LoadLibrary
and GetProcAddress functions
Dynamic Linking
• Most common method
• Host OS searches for necessary libraries when
the program is loaded
Clues in Libraries
• The PE header lists every library and function
that will be loaded
• Their names can reveal what the program
does
• URLDownloadToFile indicates that the
program downloads something
Dependency Walker
Shows Dynamically Linked Functions