Hey everybody!
I have started writing a manual mapper for x86 modules into x86 processes (into any arbitrary process) two or three days ago. So far i got the basic functionality working:
- Imports are resolved
- Exports are loaded and can be queried
- Sections are correctly protected and initialized
- Entry point is called in the process
So a call looks like that:
Code:
ManualMap::IManualMapper* mapper = ManualMap::IManualMapper::CreateMapper(GetCurrentProcess());
ManualMap::IMappedModule* pModule = nullptr;
HRESULT hResult = mapper->LoadDll(L"MapDll.dll", ManualMap::IManualMapper::ManualMapAllDependencies | ManualMap::IManualMapper::CreateExportTable, &pModule);
BOOL success = pModule->executeEntryPoint<BOOL>();
As the flags indicate you can either let the mapper load all dependent modules again (or newly) manually into the current address space or via LoadLibrary (if not set) and if the export table for GetFunctionAddress should be created inside the IMappedModule.
Internally the mapped module is compatible within any function that wants a HMODULE at least until Windows 7, i guess they didnt change it in win8, so its also valid there.
Before i can release it i need to do at least two more important things:
- Relocations. So far the DLL is loaded at the desired base address like if it has the flag set indicating that there are no relocations. That means the next dll manually mapped which has the same desired base address it fails because there is already one loaded.
- One of my thunks seems to **** up the stack balance which causes the returning of the call from the entry point to indicate an invalid ESP value across function calls.
Im aware that this thread so far might be pretty useless as there is no download/source code available, but i just wanted to post a preview and soon there will be some source code!
Greetings
Cromon