From d6e51d0fb68db1285c44582201974645fccecc7e Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 21 Jul 2021 14:17:06 +0100 Subject: [PATCH] Check the D3D12 DLL can be loaded before using it * It looks like some versions of the D3D12 DLL can't be loaded on all versions of windows (they require entry points and/or DLLs that don't exist). --- renderdoc/driver/d3d12/d3d12_sdk_select.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/renderdoc/driver/d3d12/d3d12_sdk_select.cpp b/renderdoc/driver/d3d12/d3d12_sdk_select.cpp index f48496c7f..252a18ff9 100644 --- a/renderdoc/driver/d3d12/d3d12_sdk_select.cpp +++ b/renderdoc/driver/d3d12/d3d12_sdk_select.cpp @@ -509,6 +509,23 @@ void D3D12_PrepareReplaySDKVersion(UINT SDKVersion, bytebuf d3d12core_file, { RDCERR("Couldn't write embedded D3D12Core.dll to disk! system dll will be used"); } + else + { + UINT prevErrorMode = GetErrorMode(); + SetErrorMode(prevErrorMode | SEM_FAILCRITICALERRORS); + HMODULE ret = + LoadLibraryW(StringFormat::UTF82Wide(D3D12Core_Override_Path + "/d3d12core.dll").c_str()); + + SetErrorMode(prevErrorMode); + + if(ret == NULL) + { + RDCERR("Can't open DLL! Wrong architecture or incompatible? system dll will be used"); + D3D12Core_Override_Path.clear(); + } + + FreeLibrary(ret); + } } }