TheCruZ / Simple-Manual-Map-Injector

Simple C++ DLL Manual Map Injector For x86 and x64
MIT License
378 stars 82 forks source link

Read dll from source instead of disk? #7

Closed Baseult closed 2 years ago

Baseult commented 2 years ago

Hey, I wonder if it would be possible using your project to manual map from source rather than "ifstreaming" the dll from disk.

I tried it the following way but had some issues:

  1. Imported the Dll into HxD and exported it as C.
  2. export looks like this: char rawData[2785280] = { 0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, ... };
  3. Added export as dlldata.h to the Project
  4. replaced the following code: std::ifstream File(dllPath, std::ios::binary | std::ios::ate); with std::ifstream File(rawData, std::ios::binary);

Result: got an error at if (File.fail()) "Opening the file failed:"

So I changed it from std::ifstream to std::istringstream, also had to change it to: auto FileSize = sizeof(rawData);.

This almost works but I get an error in Injector.cpp saying "Invalid platform" now.

So now I've reached a point where I don't know what to do next. Would be great if you could help me out as I'm almost finished but cant get it fully working.

Thank you very much.

TheCruZ commented 2 years ago

Just remove File stuff and use directly your raw data, why you want to make it more complex:

https://github.com/TheCruZ/Simple-Manual-Map-Injector/blob/9415b04989d16a204930b4e81633287387a6024d/Manual%20Map%20Injector/main.cpp#L122

BYTE pSrcData = (BYTE)rawData;

https://github.com/TheCruZ/Simple-Manual-Map-Injector/blob/9415b04989d16a204930b4e81633287387a6024d/Manual%20Map%20Injector/main.cpp#L115

auto FileSize = sizeof(rawData);

Delete this https://github.com/TheCruZ/Simple-Manual-Map-Injector/blob/9415b04989d16a204930b4e81633287387a6024d/Manual%20Map%20Injector/main.cpp#L107