Code Injectionadvanced
Reflective DLL Injection
Loading a DLL straight from memory by implementing the Windows loader inside the payload itself, so no DLL is ever written to disk or registered in the process module list.
Reflective DLL injection ships a DLL as a raw buffer plus a small bootstrap
function (ReflectiveLoader) that performs the work the Windows loader normally
does — so the DLL is mapped and run entirely from memory, never touching disk
and never appearing in the PEB module list.
What the loader stub does
- Walk the PEB to resolve
kernel32exports it needs (LoadLibraryA,GetProcAddress,VirtualAlloc). - Allocate memory and copy the DLL's headers and sections into place.
- Process the base relocations and resolve the import address table.
- Call the DLL's entry point (
DllMain) withDLL_PROCESS_ATTACH.
WriteProcessMemory(hProc, buf, dllBytes, len)
CreateRemoteThread(hProc, NULL, 0, buf + offsetof(ReflectiveLoader), ...)Detection & analysis
- There is no module entry for the DLL — enumerate executable private
memory instead (
pe-sieve, Moneta, Volatility'smalfind). - Look for
CreateRemoteThread/ thread start addresses pointing intoMEM_PRIVATERWXregions with a PE header but no backing file. - Dump the region and rebuild headers to analyze the hidden DLL offline.
Votes