7

The game Red Alert 2 runs on Windows 8, but as soon as I inject a DLL (via ddraw.dll or an extra DLL) it stops drawing buttons on the main menu. With the DLL it still work fine in windowed mode and it still works fine on Windows 7. The DLL is basically just

typedef HRESULT(WINAPI* LPDIRECTDRAWCREATE)(GUID*, LPDIRECTDRAW*, IUnknown*);
HMODULE dd_dll = LoadLibrary("system32/ddraw.dll");
LPDIRECTDRAWCREATE dd_create = reinterpret_cast<LPDIRECTDRAWCREATE>(GetProcAddress(dd_dll, "DirectDrawCreate"));
return dd_create(lpGUID, lplpDD, pUnkOuter);

I'm guessing some kind of automatic compatibility mode is activated for the original game that gets disabled by the DLL, but how do I find out what's causing this? It's important as the DLL provides improvements for gamers that should also be available on Windows 8 (and beyond).

  • 1
    Do you always inject the same DLL? Does the same thing happen if you inject a completely different DLL? – DCoder Sep 21 '14 at 5:20
  • Possibly system32/ddraw.dll is different location on windows 8? it might be the way you inject the dll that causes this problem. – SSpoke Sep 22 '14 at 2:58
  • 1
    It also might be the way you inject the dll that causes this problem. I found when injecting dll files its always best to set debug privileges with AdjustTokenPrivileges before using OpenProcess. Also sometimes allocating the dll into heap of target doesn't work at all because WriteProcessMemory is protected but then again just allocating path of the dll works just fine. Also in the end try using CreateRemoteThread method. Check to see if your hooked kernel32.dll LoadLibraryA actually works right when it Loads your dll file. – SSpoke Sep 22 '14 at 3:07
  • 1
    Perhaps use another method to inject your DLL that does not require DLL Hijacking? Also, executing the direct draw code in your DLL's main function could also cause troubles. perhaps create a thread and do that there? – NirIzr Aug 16 '16 at 11:26
  • 1
    If a shim is used for the game to work properly, it stands to reason that some other version of said DLL from SxS is picked or that some patching happens unbeknownst to you. There are tools to investigate the shims applied and this should give you a clue where to look ... – 0xC0000022L Jun 15 '18 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.