How liunicky/simple-dll-injection works
Project Type and Purpose
• This is a specialized tool for DLL injection in Windows processes using native C++.
• The README and file tree reveal two main parts: an injector application (SimpleDLLInjection) and the payload DLL (located under testlib). The injector uses Windows API calls (e.g., FindWindow, OpenProcess, VirtualAllocEx, CreateRemoteThread) to inject the DLL into a target process.
File Structure
• At the top level, you have a directory “C++” containing solution files and two projects:
– "SimpleDLLInjection" – the main injector executable project.
– "testlib" – a project that builds the DLL which is injected into the target process.
• The README provides a complete code example demonstrating the injection flow.
Pinpoint the Main Components
a. Injector Application (SimpleDLLInjection):
– Inside or alongside it, annotate the key steps: locating the target window, obtaining the process ID, opening the target process, allocating memory, writing the DLL path, and initiating a remote thread.
b. DLL Payload (testlib.dll):
c. Target Process:
– Since the DLL is injected into an external process (identified by its window title “Tutorial-x86_64”), include a block representing “Target Process (Tutorial-x86_64)”.
d. Windows API/System Services:
e. Development Environment Components:
– Although not part of the runtime system, the Visual Studio solution and project files (SimpleDLLInjection.sln, .vcxproj files) provide build context and can be noted in a “Build/Development” section if desired.
Relationships and Data Flow Between Components
1. The Injector locates the target window (via FindWindowA) → retrieves the process ID.
2. The Injector opens the Target Process (using OpenProcess) → allocates memory (VirtualAllocEx), writes the DLL path (WriteProcessMemory).
3. The Injector creates a remote thread in the Target Process (CreateRemoteThread) that calls LoadLibraryA to load the DLL.
• That the flow starts with the injector and crosses over into the target process, which upon receiving the injected DLL may further execute code within its own address space.
Architectural Patterns and Design Principles
• Separation of concerns: Clearly distinguish the injector executable from the DLL payload.
• Dependency on Windows API: Indicate that critical functionality is provided via Windows API functions, which orchestrate the injection operation.
• Minimal inter-component dependencies beyond the injection control flow.
Final Assembly
• The Injector application initiating the process.
• Communication with the Windows API services for process manipulation.
• The relocation (memory allocation, thread creation) that causes the DLL to load into the Target Process.
• Being very detailed—you want to capture the injection sequence with as many relevant components and API interactions as are indicated by the project’s file structure and README.