Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Technique:DLL proxy loading

From ReverseEngineering.wiki
Technique
On this wiki Facts · Code · Notes · Topics

Getting code into a Windows process by placing a DLL with the name of a system DLL the program imports (winmm.dll, version.dll, dinput8.dll, d3d9.dll...) next to the executable. The loader finds the local copy first; it loads the real system DLL itself and forwards every export to it, then runs its own code from DllMain.

How it works

The Windows loader searches the application directory before the system directory for DLLs that are not KnownDLLs. A proxy DLL exports the same names as the original. In DllMain it loads the real DLL by full path (GetSystemDirectoryW/GetWindowsDirectoryW + \\System32\\<name>.dll), resolves each export with GetProcAddress, and its own exports jump to those pointers (often small assembly thunks or a .def file with forwarders).

Choosing the DLL

Pick a DLL the target imports statically and that is not in HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\KnownDLLs (those always load from System32). winmm.dll, version.dll, dinput8.dll, dxgi.dll and d3d9.dll are common choices for games.

Pitfalls

  • DllMain runs under the loader lock: do no heavy work there. Mod loaders usually hook an early CRT or engine function (for example _initterm) and do the real initialization from that hook.
  • Windows Smart App Control / Application Control can refuse to load an unsigned proxy or plugin DLL that carries the Mark of the Web; LoadLibrary then fails (error 4551 has been observed with EDFModLoader plugins).

Examples