August 26Aug 26 ManualMap Injector – Automated Manual-Map DLL Injection Framework for WindowsManualMap Injector is a Windows C++ DLL injection framework designed to manually map a DLL into a target process instead of relying on the standard LoadLibrary-based injection approach.The project includes a process-monitoring layer that continuously searches for configured target executables and schedules DLL injection after a user-defined delay.The manual mapping engine handles the main PE loading tasks internally, including section mapping, relocations, imports, TLS callbacks, optional x64 exception support, memory protection adjustment, and post-mapping cleanup.Features🔹 Manual Map DLL InjectionInstead of loading the DLL through the normal Windows loader path, the project manually places the PE image into the target process and executes a mapping routine inside the remote process.The mapper allocates memory according to the DLL's SizeOfImage, copies the PE header and individual sections, and then performs the required initialization steps.🔹 Automatic Process DetectionThe injector continuously scans the running processes and compares their executable names against a configurable target list.Example configuration:std::vector<TargetConfig> targets = { { L"example.exe", "test.dll" }, { L"example.bin", "test.dll" } }; Multiple target executables can therefore use the same DLL configuration.🔹 Configurable Injection DelayBefore an injection is attempted, the injector waits for a user-defined number of seconds.Example:Wait time (seconds): 5 This can be useful when the target application requires additional startup time before the DLL is mapped.🔹 Multiple Process Instance SupportThe scanner does not assume that only one instance of a target process exists.Every matching PID is processed individually.The project also maintains an internal (PID + DLL) key so the same DLL is not repeatedly scheduled for the same process instance.struct InjectKey { DWORD pid; std::string dll; }; This allows multiple instances of the same executable to be handled independently.Manual Mapping EngineThe core of the project is the ManualMapDll() function.Its mapping pipeline can be summarized as:DLL File │ ▼ PE Validation │ ▼ Architecture Check │ ▼ Remote Image Allocation │ ▼ PE Header Mapping │ ▼ Section Mapping │ ▼ Mapping Data │ ▼ Remote Mapping Routine │ ├── Relocations ├── Imports ├── TLS Callbacks └── Exception Support │ ▼ DLL Entry Point │ ▼ Memory Protection │ ▼ Cleanup PE ValidationBefore mapping begins, the DLL is validated as a PE image.The mapper checks the DOS signature:if (reinterpret_cast<IMAGE_DOS_HEADER*>(pSrcData)->e_magic != 0x5A4D) { return false; } It then locates the NT headers and checks whether the DLL architecture matches the injector architecture.x86 injector → x86 DLL x64 injector → x64 DLL The source checks IMAGE_FILE_HEADER::Machine against the current build architecture before continuing.Remote Image AllocationThe mapper allocates memory inside the target process according to the PE image size:VirtualAllocEx( hProc, nullptr, pOldOptHeader->SizeOfImage, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE ); The mapped image is initially allocated as writable memory before the individual section protections are configured later.PE Header & Section MappingThe PE header is copied into the allocated image and each section containing raw data is copied to its corresponding virtual address.Conceptually:Original DLL │ ├── PE Headers ├── .text ├── .rdata ├── .data ├── .rsrc └── .reloc │ ▼ Target Process Memory │ ├── PE Headers ├── .text ├── .rdata ├── .data ├── .rsrc └── .reloc The implementation writes the initial header and then iterates through IMAGE_SECTION_HEADER entries to map the individual sections.Relocation ProcessingIf the DLL cannot be loaded at its preferred image base, the mapper processes the PE relocation directory.The shellcode calculates the difference between the preferred image base and the actual mapped address:BYTE* LocationDelta = pBase - pOpt->ImageBase; Relocation entries are then processed and adjusted according to the target architecture.The project supports:IMAGE_REL_BASED_HIGHLOW → x86 IMAGE_REL_BASED_DIR64 → x64 This allows the mapped image to operate from a different memory address than its original preferred base.Import ResolutionThe manual mapper resolves imported modules and functions manually.For each import descriptor, the mapping routine calls:LoadLibraryA() and resolves imported functions through:GetProcAddress() Both ordinal-based and name-based imports are handled.TLS Callback SupportThe mapper also checks whether the DLL contains a TLS directory.If TLS callbacks are present, they are executed with:DLL_PROCESS_ATTACH This allows DLLs that rely on TLS initialization callbacks to receive their expected initialization notification.x64 Exception SupportFor 64-bit builds, the mapper can optionally register the DLL's exception runtime function table through:RtlAddFunctionTable() The relevant exception directory is located through:IMAGE_DIRECTORY_ENTRY_EXCEPTION If registration fails, the mapper reports the failure through its mapping status structure.Exception support is architecture-dependent and is only enabled for x64 builds in the current implementation.DLL Entry PointAfter the required PE initialization steps have completed, the mapper calls the DLL's entry point:_DllMain( pBase, pData->fdwReasonParam, pData->reservedParam ); By default, the injector passes:DLL_PROCESS_ATTACH as the reason parameter.Section Protection AdjustmentAfter successful mapping, the project can restore memory permissions according to each PE section's characteristics.For example:Read-only section Writable section Executable + readable section The implementation uses VirtualProtectEx() and derives the protection from the section's IMAGE_SCN_MEM_* flags.This provides a more appropriate memory layout than leaving the entire mapped image permanently executable and writable.Optional PE CleanupThe mapper provides optional cleanup functionality.Clear PE HeaderWhen enabled, the first 0x1000 bytes of the mapped image are overwritten after initialization.ClearHeader Clear Non-Needed SectionsThe mapper can also clear selected sections such as:.reloc .rsrc .pdata depending on the enabled options and exception-support configuration.These options are configurable through the ManualMapDll() parameters.Remote Mapping RoutineThe mapping work is performed by the Shellcode() routine inside the target process.The injector prepares a MANUAL_MAPPING_DATA structure containing function pointers and mapping parameters:struct MANUAL_MAPPING_DATA { f_LoadLibraryA pLoadLibraryA; f_GetProcAddress pGetProcAddress; #ifdef _WIN64 f_RtlAddFunctionTable pRtlAddFunctionTable; #endif BYTE* pbase; HINSTANCE hMod; DWORD fdwReasonParam; LPVOID reservedParam; BOOL SEHSupport; }; The structure is written into the target process before the remote mapping routine is started.Mapping Status & Error HandlingThe mapper communicates its status through the hMod field.The implementation uses special values to indicate mapping problems:0x404040 → Invalid mapping state 0x505050 → Exception support failure The injector continuously checks the mapping structure until the mapping routine reports a result.Automatic MonitoringAfter initialization, the injector continuously scans for configured processes.The basic runtime flow is:Start Injector │ ▼ Check DLL Files │ ▼ Ask For Delay │ ▼ Start Process Scanner │ ▼ Find Target Process │ ▼ Check PID + DLL │ ├── Already handled → Skip │ ▼ Schedule Injection │ ▼ Wait │ ▼ Manual Map DLL │ ▼ Monitor Process │ └── Process exits → Remove from tracking The process-tracking set is periodically cleaned so that terminated processes can be detected again if a new instance starts.Console InterfaceThe injector creates a console window and displays its current state.Example:Wait time (seconds): 5 Scanning. | Active clients: 1 Scanning.. | Active clients: 2 Scanning... | Active clients: 2 Scanning | Active clients: 1 The console title can also be customized through:SetConsoleTitleA(); Project StructureManualMapInjector/ │ ├── injector.cpp ├── injector.h ├── ManualMap.cpp ├── Shellcode.cpp └── target DLL The exact file organization can be adjusted depending on how the project is structured in Visual Studio.How to Use1. Build the InjectorOpen the project in Visual Studio and select the appropriate architecture:x86 or:x64 The DLL must use the same architecture as the injector and target process.2. Place the DLLPlace the DLL specified in the target configuration next to the injector executable or provide the desired path.Example:{ L"example.exe", "test.dll" } 3. Configure Target ProcessesEdit the target list:std::vector<TargetConfig> targets = { { L"example.exe", "test.dll" }, { L"example.bin", "test.dll" } }; You can add additional target executable names as required.4. Start the InjectorLaunch the injector and enter the desired delay:Wait time (seconds): 5 The injector will then begin scanning for matching processes.5. Start the Target ApplicationWhen a configured process is detected, the injector creates a delayed injection task.Once the configured delay expires, the DLL is passed to the manual mapping engine.Configuration OptionsThe main mapper exposes several configuration parameters:ManualMapDll( hProc, pSrcData, FileSize, ClearHeader, ClearNonNeededSections, AdjustProtections, SEHExceptionSupport, fdwReason, lpReserved ); Available options include:OptionDescriptionClearHeaderClears the mapped PE header after initializationClearNonNeededSectionsClears selected sections after mappingAdjustProtectionsRestores section memory protectionsSEHExceptionSupportEnables x64 exception-function registrationfdwReasonDLL entry-point reasonlpReservedReserved parameter passed to the DLL entry pointThe default configuration enables header cleanup, unnecessary-section cleanup, protection adjustment, and x64 exception support.Advantages✔ No Standard DLL Loader DependencyThe mapping process does not simply rely on the standard LoadLibrary() mechanism to load the target DLL.✔ PE-Level MappingThe project works directly with the PE structures and performs the required initialization stages itself.✔ Automatic Process MonitoringTarget processes are discovered automatically.✔ Multiple Target NamesDifferent executable names can be configured.✔ Multiple InstancesEach process PID is tracked independently.✔ x86 / x64 SupportThe architecture is detected at compile time and the appropriate relocation type is selected.✔ TLS SupportTLS callbacks contained in the mapped image are processed.✔ Optional x64 Exception SupportRuntime function tables can be registered for 64-bit images.✔ Memory CleanupTemporary mapping data and shellcode memory are released after successful mapping.LimitationsThis implementation is a lightweight manual mapping framework and is not a complete replacement for the Windows PE loader.Potential compatibility limitations may include:DLLs with unusual loader requirementsComplex loader dependenciesAdvanced TLS behaviorLoader-lock-sensitive initializationUnusual exception/unwind configurationsArchitecture mismatchesProtected or restricted target processesDLLs depending on loader-specific behaviorThe project should therefore be tested against the specific DLLs and target applications it is intended to support.Technical Overview┌─────────────────────────────┐ │ Injector Process │ ├─────────────────────────────┤ │ Process Scanner │ │ Target Configuration │ │ Delay Scheduler │ │ PID Tracking │ │ DLL File Loader │ └──────────────┬──────────────┘ │ ▼ ┌─────────────────────────────┐ │ ManualMapDll() │ ├─────────────────────────────┤ │ PE Validation │ │ Architecture Validation │ │ Remote Memory Allocation │ │ Header Mapping │ │ Section Mapping │ │ Mapping Data │ │ Remote Mapping Routine │ └──────────────┬──────────────┘ │ ▼ ┌─────────────────────────────┐ │ Shellcode() │ ├─────────────────────────────┤ │ Relocations │ │ Import Resolution │ │ TLS Callbacks │ │ x64 Exception Support │ │ DLL Entry Point │ └──────────────┬──────────────┘ │ ▼ ┌─────────────────────────────┐ │ Target Process │ │ Mapped DLL │ └─────────────────────────────┘ This is the hidden content, please Sign In or Sign Up PROFESSIONAL
August 27Aug 27 Author 4 hours ago, tuser0 said:pass ? This is the hidden content, please Sign In or Sign Up or crackfrm.com PROFESSIONAL
Create an account or sign in to comment