A tiny, educational manual mapper for Windows.
This repo is a small demo showing the basic idea of manual DLL mapping into another process on Windows. It's educational: read a DLL from disk, map its PE image into a target process, fix imports/relocations with a tiny injected stub, and call the DLL entry point.
- main.cpp — tiny driver; change the PID / DLL path here.
- ManualMapper.h/.cpp — mapper implementation (read DLL, allocate remote memory, write headers/sections, inject shellcode that fixes imports/relocs and calls DllMain).
- ShellcodeData.h — data structure passed into the injected shellcode.
- test.dll — not included. Put your own DLL beside the EXE or change main.cpp.
- Open ManualMap.vcxproj in VS (uses VCProjectVersion 17.0 / v143 toolset).
- Select platform (Win32 or x64) and configuration (Debug/Release).
IMPORTANT: the mapper, the target process, and the DLL must all be the same architecture:
- 64-bit DLL -> 64-bit target -> 64-bit mapper.
- 32-bit DLL -> 32-bit target -> 32-bit mapper.
- Build the solution. You'll get a console EXE.
- Put the DLL you want to map next to the mapper EXE and name it test.dll, OR change the DLL path in main.cpp.
- Edit main.cpp to set the target PID, e.g.: const DWORD TARGET_PID = 458; // change me
- Run the EXE with enough rights to open the target process (Administrator may be required).
- The program prints a short result
- Read the DLL file into memory and parse PE headers.
- VirtualAllocEx in the target process for the DLL SizeOfImage.
- WriteProcessMemory the PE headers and sections into the remote memory.
- Prepare a small shellcode blob + a ShellcodeData struct containing:
- remote image base
- import directory pointer
- relocation pointer + size
- pointers to LoadLibraryA, GetProcAddress, and the DLL entrypoint
- Inject the shellcode into the target and run it via CreateRemoteThread.
- The injected stub fixes imports, applies relocations, and calls DllMain(DLL_PROCESS_ATTACH).
- Replace raw function copy shellcode with a real position independent shellcode blob (handwritten ASM or compiled PIC).
- Apply proper per section memory protections instead of RWX.
- Support forwarded imports, TLS callbacks, and other PE corner cases.