I created a library
injection method on my machine in C++ which works very well when I try to inject a specific dll into a process. However, when I run the program on my friend's computer (where Visual Studio
's redistributables are not installed), I am warned that I need MSVCR
, etc ... (the redistributables).
So I compiled in the release
mode with the following setting in Visual Studio 2012 : Runtime Library : Multi-threaded /MT
. Now when I run it on my friend's
machine I am warned that I need only the library MSVCP110D.dll
( weird, asking for the debug version) (there is no antivirus, and UAC is disabled ).
I copied the requested library manually in the release path and still wont work.
This is the injection code i made :
int inject(string lpLibraryPath)
{
HANDLE hProc;
LPVOID paramAddr;
HINSTANCE hDll;
hDll = LoadLibrary(L"KERNEL32");
fpLoadLibrary LoadLibraryAddr = (fpLoadLibrary)GetProcAddress(hDll, "LoadLibraryA");
hProc = OpenProcess(PROCESS_ALL_ACCESS, false, id);
paramAddr = VirtualAllocEx(hProc, 0, strlen(lpLibraryPath.c_str()) + 1, MEM_COMMIT, PAGE_READWRITE);
if(WriteProcessMemory(hProc, paramAddr, lpLibraryPath.c_str(), strlen(lpLibraryPath.c_str()) + 1, NULL) == NULL)
{
return 0;
}
CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryAddr, paramAddr, 0, 0);
CloseHandle(hProc);
return 1;
}
};
I found some references on stackoverflow but they were of no help . like msvcp110.dll, how do I get around it? or Fixing the "MSVCP110D.dll is missing from your computer" issue
weird , asking for the debug version
Tells you what you did wrong, you accidentally copied the Debug build of the DLL instead of the Release build. Since you only changed the setting for the Release build, it still requires msvcp110d.dll. It is in general wise to change such a setting for all configurations and all platforms. Tedious, so it often gets skipped.
I copied the requested library manually in the release path and still wont work
Right, that cannot work since you injected the DLL. A different process. So when it is loaded, the install directory for the game is searched for the file, not the directory where your utility is installed.
Your friend needs the Visual-C++ Redistributables
in order to properly run your injector, and for the DLL to be loaded. However
After Injection, the dll is trying to LoadLibrary
(if GetModuleHandle
fails) the CRT dlls. There are a lot of them!
You have some options:
Include the required DLLs inside your Injector (Resource, Bytecode, etc) and write them to the directory where the game is run from
Download the DLLs from a server on the internet and put them in the directory where the game is run from
Statically linking the CRT (to the injected DLL) also works, but you have to make sure you get all dependencies too!
The reason you need to have the required DLLs in the folder where the game is run from is because the LoadLibrary
call will be made explicitly from the Game.exe
itself, and it will only be looking for the DLLs in that directory.
You can choose to attach a Runtime-debugger such as WinDbg to the injected DLL, set a breakpoint at the DLL entry-point (wherever it is for you). Then check what sort of LoadLibrary/GetModuleHandle calls are made when your DLL is loaded, this will give you a hint as to what DLLs are required!
The problem here is because your friend doesn't have the Visual-C++ Redistributables
installed, many of the CRT files also have dependencies of their own! Your injector will have to have a Win-Installer which in turn installs the redistributables MSI from the Microsoft website, a technique which many modern games (at install time) adapted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With