I have relatively simple code here for the proxy DllMain()
function:
BOOL APIENTRY DllMain(HMODULE hDll, DWORD reason, LPVOID reserved)
{
if (reason != DLL_PROCESS_ATTACH) {
return TRUE;
}
library = LoadLibrary("vcruntime140_.dll");
if (!library) {
MessageBox(NULL, "Failed to load vcruntime140_.dll", "vcruntime140.dll proxy", MB_OK);
return FALSE;
}
if (reason == DLL_PROCESS_DETACH) {
FreeLibrary(library);
return TRUE;
}
setupVftableHooks();
return setupHooks();
}
For some reason, it doesn't load the original DLL, i.e. vcruntime140_.dll
. It loads the proxy one, aka vcruntime140.dll
. It tries to load it several times, in fact:
Loaded Binaries\Windows-x86_64\vcruntime140.dll'. Symbols loaded.
Loaded Binaries\Windows-x86_64\vcruntime140.dll'. Symbols loaded.
Unloaded Binaries\Windows-x86_64\vcruntime140.dll'
Loaded Binaries\Windows-x86_64\vcruntime140.dll'. Symbols loaded.
Unloaded Binaries\Windows-x86_64\vcruntime140.dll'
But
a) never once it actually tries to load
vcruntime140_.dll
, which is the original DLL,b) it is suspicious that last record in the debugger is Unloaded. Although it must've been loaded at the end, as the program doesn't crash (not on DLL loading anyway),
c) when the program tries to execute, it complains about
0xC0000139: Entry Point Not Found for different functions in the original DLL.
I suspect it is because the original DLL simply was not loaded (as I've checked the Dependency Walker and Entry Points look fine for all of the original functions).
Update 06.08.21: Created a x86 version of the DLL. It loads and the program starts. The difference with the above x64 version is that the program doesn't complain about Entry points for the functions. It loads the DLL from it's location within the game folder, but it also loads the equivalent dll from System32, i.e.:
Binaries\Windows-x86_64\vcruntime140.dll'.
Binaries\Windows-x86_64\vcruntime140.dll'
Binaries\Windows-x86_64\vcruntime140.dll'.
Binaries\Windows-x86_64\vcruntime140.dll'
(Win32): Loaded 'C:\Windows\System32\vcruntime140.dll'
(Win32): Loaded 'C:\Windows\System32\vcruntime140.dll'
(Win32): Unloaded 'C:\Windows\System32\vcruntime140.dll'
What is confusing about this is that it doesn't load the actual DLL from the game folder, i.e. vcruntime140_.dll. Will continue trying to debug, but since it doesn't stop at breakpoints in DllMain()
function, I don't know what's the best way to do it.
Note that the program runs in the mixed environment, as you can see from the name of the folder, from which it actually starts: Windows-x86_64