diff --git a/DDrawCompat/Common/Hook.cpp b/DDrawCompat/Common/Hook.cpp index 6bf8f5e..48e0a82 100644 --- a/DDrawCompat/Common/Hook.cpp +++ b/DDrawCompat/Common/Hook.cpp @@ -232,10 +232,29 @@ namespace } g_isDbgEngInitialized = true; - Compat::hookIatFunction(GetModuleHandle("dbgeng"), "GetProcAddress", dbgEngGetProcAddress); + if (!GetModuleHandle("dbghelp.dll")) + { + LoadLibraryW((Compat::getSystemPath() / "dbghelp.dll").c_str()); + } + + auto dbgEng = LoadLibraryW((Compat::getSystemPath() / "dbgeng.dll").c_str()); + if (!dbgEng) + { + Compat::Log() << "ERROR: DbgEng: failed to load library"; + return false; + } + + Compat::hookIatFunction(dbgEng, "GetProcAddress", dbgEngGetProcAddress); + + auto debugCreate = reinterpret_cast(Compat::getProcAddress(dbgEng, "DebugCreate")); + if (!debugCreate) + { + Compat::Log() << "ERROR: DbgEng: DebugCreate not found"; + return false; + } HRESULT result = S_OK; - if (FAILED(result = DebugCreate(IID_IDebugClient4, reinterpret_cast(&g_debugClient))) || + if (FAILED(result = debugCreate(IID_IDebugClient4, reinterpret_cast(&g_debugClient))) || FAILED(result = g_debugClient->QueryInterface(IID_IDebugControl, reinterpret_cast(&g_debugControl))) || FAILED(result = g_debugClient->QueryInterface(IID_IDebugSymbols, reinterpret_cast(&g_debugSymbols))) || FAILED(result = g_debugClient->QueryInterface(IID_IDebugDataSpaces4, reinterpret_cast(&g_debugDataSpaces)))) diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 3249eb3..0b4dd65 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -94,7 +94,7 @@ $(ProjectDir);$(IntDir) - dbgeng.lib;dxguid.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;winmm.lib;%(AdditionalDependencies) + dxguid.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;winmm.lib;%(AdditionalDependencies) DebugFull true $(IntDir)$(TargetName).lib @@ -130,7 +130,7 @@ $(ProjectDir);$(IntDir) - dbgeng.lib;dxguid.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;winmm.lib;%(AdditionalDependencies) + dxguid.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;winmm.lib;%(AdditionalDependencies) DebugFull true $(IntDir)$(TargetName).lib @@ -167,7 +167,7 @@ $(ProjectDir);$(IntDir) - dbgeng.lib;dxguid.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;winmm.lib;%(AdditionalDependencies) + dxguid.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;winmm.lib;%(AdditionalDependencies) DebugFull true $(IntDir)$(TargetName).lib