The Two Functions at the Heart of It
- LoadLibraryW(path) — exported by
kernel32.dll. Maps a DLL from disk into the calling process and runs itsDllMain. Returns a module handle. - GetProcAddress(hModule, name) — returns the address of an exported function inside a loaded module.
Key insight for the classic attack:
kernel32.dllis loaded at the same base address in every process in a session (ASLR randomizes per boot, not per process).- So the address of
LoadLibraryWin the injector is also valid in the target. - That lets the injector tell the target: "run
LoadLibraryWon this path" — and the target loads the DLL itself.
Key Takeaway
If you can run one function pointer in a remote process and hand it one argument, LoadLibraryW + a path string is enough.