Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/doitsujin/dxvk.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ashton <joshua@froggi.es>2023-05-06 12:58:12 +0300
committerJoshua Ashton <joshua@froggi.es>2023-05-06 12:58:12 +0300
commitc7388b7fc96a056a2a265896b3ddbf7cc6256448 (patch)
treef79d487de8ea8276fa7630e8ba755a19dd13dd54
parent83a294285e90c65554bc851c4d4a126aa15916a4 (diff)
[d3d9] Keep reference to D3D9 module aroundd3d9-module-ref
Some games check if d3d9.dll is loaded in their WindowProc and use that to make decisions. Some of these apps FreeLibrary after calling Direct3DCreate9 which is bad to start with... but ends up with them getting very confused and they constantly remake the device in the window proc we hooked causing a stack overflow. I wonder if D3D11/DXGI should do the same here, needs testing.
-rw-r--r--src/d3d9/d3d9_interface.cpp21
-rw-r--r--src/d3d9/d3d9_interface.h4
2 files changed, 25 insertions, 0 deletions
diff --git a/src/d3d9/d3d9_interface.cpp b/src/d3d9/d3d9_interface.cpp
index e56c8b3d..e9401448 100644
--- a/src/d3d9/d3d9_interface.cpp
+++ b/src/d3d9/d3d9_interface.cpp
@@ -12,6 +12,21 @@ namespace dxvk {
Singleton<DxvkInstance> g_dxvkInstance;
+#ifdef _WIN32
+ HMODULE GetCurrentModule() {
+ HMODULE currentModule = nullptr;
+ // Get the module for the address of this function.
+ // Increments reference count for the module,
+ // unlike GetModuleHandle.
+ GetModuleHandleEx(
+ GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (LPCTSTR)GetCurrentModule,
+ &currentModule);
+
+ return currentModule;
+ }
+#endif
+
D3D9InterfaceEx::D3D9InterfaceEx(bool bExtended)
: m_instance ( g_dxvkInstance.acquire() )
, m_extended ( bExtended )
@@ -64,12 +79,18 @@ namespace dxvk {
Logger::info("Process set as DPI aware");
SetProcessDPIAware();
}
+
+ m_d3d9Module = GetCurrentModule();
#endif
}
D3D9InterfaceEx::~D3D9InterfaceEx() {
g_dxvkInstance.release();
+
+#ifdef _WIN32
+ FreeLibrary(m_d3d9Module);
+#endif
}
diff --git a/src/d3d9/d3d9_interface.h b/src/d3d9/d3d9_interface.h
index 55c9be91..b38ab102 100644
--- a/src/d3d9/d3d9_interface.h
+++ b/src/d3d9/d3d9_interface.h
@@ -148,6 +148,10 @@ namespace dxvk {
D3D9VkInteropInterface m_d3d9Interop;
+#ifdef _WIN32
+ HMODULE m_d3d9Module;
+#endif
+
};
} \ No newline at end of file