Essentials
Last updated
Last updated
PE stands for "Portable Executable"
It's a way to organize executable code in a file which usually have the extension ".exe"
header: Contains metadata, information about where everything is located.
sections: Contains executable code, data and imports used by executable code.
.text: Contains executable code
.rdata: Contains read only data
.data: Contains application global variables
.pdata: Information about exceptions
.rsrc: It's a section that contains different objects
.reloc: Contains relocation information which allows windows loader to safely load the DLL/exe file into memory with randomized address space
Lets click on .rsrc (resources) section as its the most interesting
Pictures
Icons
Other PE files (.exe)
Other DLLs
.text
.data
.rsrc
exe are separate programs which can be loaded into memory as independent process
DLLs are PE modules that are loaded into existing processes and cannot live independently in memory, the main purpose of DLL is to deliver some functionality a calling process needs
Source code
A compiler
How you call your code?
The main function usually contains functions that either call external functions from the DLL or do internal stuff
2.1) A loader reads DLL from disk
2.2) Reserve some space in target process (exe)
2.3) Then calls DLL function called "Dllmain" which initialize the library
2.4) Loader hands over the control back to the process (exe)
2.5) Process then can call the functions from the loaded DLL
When loader loads DLL into a process
When loader unloads DLL into a process
If DLL is being loaded for a process, the case will be DLL_PROCESS_ATTACH
, and its up to the developer to decide what happens when this event occurs