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

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKissaki <kissaki@gmx.de>2013-05-16 01:29:46 +0400
committerKissaki <kissaki@gmx.de>2013-06-17 02:02:39 +0400
commit1182fc26cb7c0c9452bd0b677ac0a34cd6d843e6 (patch)
tree20b843e0cb7bab528bdba9cc648965001447025c /overlay
parent123486b4297d5b0628e912e77500cf68241b328c (diff)
Overlay: Introduce hook for ResetEx. Hook PresentEx.
* For D3D9Ex ** Hook PresentEx ** Hook ResetEx
Diffstat (limited to 'overlay')
-rw-r--r--overlay/d3d9.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/overlay/d3d9.cpp b/overlay/d3d9.cpp
index 86a4d3c82..7d7a80373 100644
--- a/overlay/d3d9.cpp
+++ b/overlay/d3d9.cpp
@@ -308,6 +308,7 @@ void DevState::createCleanState() {
static HardHook hhCreateDevice;
static HardHook hhCreateDeviceEx;
static HardHook hhReset;
+static HardHook hhResetEx;
static HardHook hhAddRef;
static HardHook hhRelease;
static HardHook hhPresent;
@@ -434,6 +435,34 @@ static HRESULT __stdcall myReset(IDirect3DDevice9 * idd, D3DPRESENT_PARAMETERS *
return hr;
}
+typedef HRESULT(__stdcall *ResetExType)(IDirect3DDevice9Ex *, D3DPRESENT_PARAMETERS *, D3DDISPLAYMODEEX *);
+static HRESULT __stdcall myResetEx(IDirect3DDevice9Ex * idd, D3DPRESENT_PARAMETERS *param, D3DDISPLAYMODEEX * param2) {
+ ods("D3D9: Chaining ResetEx");
+
+ DevState *ds = devMap[idd];
+ if (ds) {
+ DWORD dwOldThread = ds->dwMyThread;
+ if (dwOldThread)
+ ods("D3D9: myResetEx from other thread");
+ ds->dwMyThread = GetCurrentThreadId();
+
+ ds->releaseAll();
+ ds->dwMyThread = dwOldThread;
+ }
+
+ //TODO: Move logic to HardHook.
+ // Call base without active hook in case of no trampoline.
+ ResetExType oResetEx = (ResetExType) hhResetEx.call;
+ hhResetEx.restore();
+ HRESULT hr = oResetEx(idd, param, param2);
+ hhResetEx.inject();
+
+ if (ds)
+ ds->createCleanState();
+
+ return hr;
+}
+
typedef ULONG(__stdcall *AddRefType)(IDirect3DDevice9 *);
static ULONG __stdcall myAddRef(IDirect3DDevice9 *idd) {
Mutex m;
@@ -698,6 +727,9 @@ static HRESULT __stdcall myCreateDeviceEx(IDirect3D9Ex * id3d, UINT Adapter, D3D
const unsigned int offsetRelease = 2;
const unsigned int offsetReset = 16;
const unsigned int offsetPresent = 17;
+ // On IDirect3DDevice9Ex
+ const unsigned int offsetPresentEx = 121;
+ const unsigned int offsetResetEx = 132;
if (bIsWin8) {
hhAddRef.setupInterface(idd, offsetAddref, reinterpret_cast<voidFunc>(myWin8AddRef));
hhRelease.setupInterface(idd, offsetRelease, reinterpret_cast<voidFunc>(myWin8Release));
@@ -706,7 +738,9 @@ static HRESULT __stdcall myCreateDeviceEx(IDirect3D9Ex * id3d, UINT Adapter, D3D
hhRelease.setupInterface(idd, offsetRelease, reinterpret_cast<voidFunc>(myRelease));
}
hhReset.setupInterface(idd, offsetReset, reinterpret_cast<voidFunc>(myReset));
+ hhResetEx.setupInterface(idd, offsetResetEx, reinterpret_cast<voidFunc>(myResetEx));
hhPresent.setupInterface(idd, offsetPresent, reinterpret_cast<voidFunc>(myPresent));
+ hhPresentEx.setupInterface(idd, offsetPresentEx, reinterpret_cast<voidFunc>(myPresentEx));
IDirect3DSwapChain9 *pSwap = NULL;
idd->GetSwapChain(0, &pSwap);
@@ -822,6 +856,7 @@ void freeD3D9Hook(HMODULE hModule) {
hhCreateDevice.reset();
hhCreateDeviceEx.reset();
hhReset.reset();
+ hhResetEx.reset();
hhAddRef.reset();
hhRelease.reset();
hhPresent.reset();