Injection methods in injdrv
masterThe project implements three distinct methods for DLL injection depending on the target architecture and requirements:
1. "Thunk" method
- Target: All architectures.
- Mechanism: Injects a DLL of the same architecture as the process. It allocates memory in the user-mode address space containing the DLL path and a small shellcode (thunk) that calls
LdrLoadDll. - Implementation Detail: To avoid security concerns with
PAGE_EXECUTE_READWRITEand bypassZwProtectVirtualMemorylimitations on older Windows versions, it uses a section (ZwCreateSection) to map memory withPAGE_READWRITE, writes the data, unmaps it, and re-maps it withPAGE_EXECUTE_READ. To avoid deadlocks withAddressCreationLock, it uses a kernel-mode APC to perform the mapping.
2. "Thunkless" method
- Target: Windows x64 only.
- Mechanism: Injects an x64 DLL into both x64 (native) and x86 (Wow64) processes.
- Implementation Detail: This method bypasses Control Flow Guard (CFG) issues on Windows 10 by pointing the APC's
NormalRoutinedirectly to the address ofLdrLoadDllin the 64-bitntdll.dll. It leverages the wayKiUserApcDispatcherpasses parameters to effectively callLdrLoadDll(NULL, 0, &DllName, &ContinueContext).