diff --git a/Dllmain/BuildNo.rc b/Dllmain/BuildNo.rc index 52991c8e..24ef40af 100644 --- a/Dllmain/BuildNo.rc +++ b/Dllmain/BuildNo.rc @@ -1 +1 @@ -#define BUILD_NUMBER 7104 +#define BUILD_NUMBER 7105 diff --git a/d3d9/AddressLookupTable.h b/d3d9/AddressLookupTable.h index ca348663..36cc83ab 100644 --- a/d3d9/AddressLookupTable.h +++ b/d3d9/AddressLookupTable.h @@ -9,18 +9,12 @@ template class AddressLookupTableD3d9 { public: - explicit AddressLookupTableD3d9(D *pDevice) : pDevice(pDevice) {} + explicit AddressLookupTableD3d9(D*) {} ~AddressLookupTableD3d9() { ConstructorFlag = true; - for (const auto& cache : g_map) - { - for (const auto& entry : cache) - { - entry.second->DeleteMe(); - } - } + ClearAllInterfaces(); } template @@ -64,57 +58,57 @@ class AddressLookupTableD3d9 { return new m_IDirect3DDevice9Ex(static_cast(Proxy), Device, riid); } - m_IDirect3DCubeTexture9* CreateInterface(m_IDirect3DCubeTexture9* Proxy, void*, REFIID) + m_IDirect3DCubeTexture9* CreateInterface(m_IDirect3DCubeTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DCubeTexture9(static_cast(Proxy), pDevice); + return new m_IDirect3DCubeTexture9(static_cast(Proxy), Device); } - m_IDirect3DIndexBuffer9* CreateInterface(m_IDirect3DIndexBuffer9* Proxy, void*, REFIID) + m_IDirect3DIndexBuffer9* CreateInterface(m_IDirect3DIndexBuffer9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DIndexBuffer9(static_cast(Proxy), pDevice); + return new m_IDirect3DIndexBuffer9(static_cast(Proxy), Device); } - m_IDirect3DPixelShader9* CreateInterface(m_IDirect3DPixelShader9* Proxy, void*, REFIID) + m_IDirect3DPixelShader9* CreateInterface(m_IDirect3DPixelShader9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DPixelShader9(static_cast(Proxy), pDevice); + return new m_IDirect3DPixelShader9(static_cast(Proxy), Device); } - m_IDirect3DQuery9* CreateInterface(m_IDirect3DQuery9* Proxy, void*, REFIID) + m_IDirect3DQuery9* CreateInterface(m_IDirect3DQuery9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DQuery9(static_cast(Proxy), pDevice); + return new m_IDirect3DQuery9(static_cast(Proxy), Device); } - m_IDirect3DStateBlock9* CreateInterface(m_IDirect3DStateBlock9* Proxy, void*, REFIID) + m_IDirect3DStateBlock9* CreateInterface(m_IDirect3DStateBlock9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DStateBlock9(static_cast(Proxy), pDevice); + return new m_IDirect3DStateBlock9(static_cast(Proxy), Device); } - m_IDirect3DSurface9* CreateInterface(m_IDirect3DSurface9* Proxy, void*, REFIID) + m_IDirect3DSurface9* CreateInterface(m_IDirect3DSurface9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DSurface9(static_cast(Proxy), pDevice); + return new m_IDirect3DSurface9(static_cast(Proxy), Device); } - m_IDirect3DSwapChain9Ex* CreateInterface(m_IDirect3DSwapChain9Ex* Proxy, void*, REFIID riid) + m_IDirect3DSwapChain9Ex* CreateInterface(m_IDirect3DSwapChain9Ex* Proxy, m_IDirect3DDevice9Ex* Device, REFIID riid) { - return new m_IDirect3DSwapChain9Ex(static_cast(Proxy), pDevice, riid); + return new m_IDirect3DSwapChain9Ex(static_cast(Proxy), Device, riid); } - m_IDirect3DTexture9* CreateInterface(m_IDirect3DTexture9* Proxy, void*, REFIID) + m_IDirect3DTexture9* CreateInterface(m_IDirect3DTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DTexture9(static_cast(Proxy), pDevice); + return new m_IDirect3DTexture9(static_cast(Proxy), Device); } - m_IDirect3DVertexBuffer9* CreateInterface(m_IDirect3DVertexBuffer9* Proxy, void*, REFIID) + m_IDirect3DVertexBuffer9* CreateInterface(m_IDirect3DVertexBuffer9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DVertexBuffer9(static_cast(Proxy), pDevice); + return new m_IDirect3DVertexBuffer9(static_cast(Proxy), Device); } - m_IDirect3DVertexDeclaration9* CreateInterface(m_IDirect3DVertexDeclaration9* Proxy, void*, REFIID) + m_IDirect3DVertexDeclaration9* CreateInterface(m_IDirect3DVertexDeclaration9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DVertexDeclaration9(static_cast(Proxy), pDevice); + return new m_IDirect3DVertexDeclaration9(static_cast(Proxy), Device); } - m_IDirect3DVertexShader9* CreateInterface(m_IDirect3DVertexShader9* Proxy, void*, REFIID) + m_IDirect3DVertexShader9* CreateInterface(m_IDirect3DVertexShader9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DVertexShader9(static_cast(Proxy), pDevice); + return new m_IDirect3DVertexShader9(static_cast(Proxy), Device); } - m_IDirect3DVolume9* CreateInterface(m_IDirect3DVolume9* Proxy, void*, REFIID) + m_IDirect3DVolume9* CreateInterface(m_IDirect3DVolume9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DVolume9(static_cast(Proxy), pDevice); + return new m_IDirect3DVolume9(static_cast(Proxy), Device); } - m_IDirect3DVolumeTexture9* CreateInterface(m_IDirect3DVolumeTexture9* Proxy, void*, REFIID) + m_IDirect3DVolumeTexture9* CreateInterface(m_IDirect3DVolumeTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID) { - return new m_IDirect3DVolumeTexture9(static_cast(Proxy), pDevice); + return new m_IDirect3DVolumeTexture9(static_cast(Proxy), Device); } template @@ -139,6 +133,10 @@ class AddressLookupTableD3d9 template void SaveAddress(T *Wrapper, void *Proxy) { + while (ClearFlag) + { + Sleep(0); + } constexpr UINT CacheIndex = AddressCacheIndex::CacheIndex; if (Wrapper && Proxy) { @@ -149,7 +147,7 @@ class AddressLookupTableD3d9 template void DeleteAddress(T *Wrapper) { - if (!Wrapper || ConstructorFlag) + if (!Wrapper || ConstructorFlag || ClearFlag) { return; } @@ -164,9 +162,28 @@ class AddressLookupTableD3d9 } } + UINT GetDeviceCount() + { + return g_map[AddressCacheIndex::CacheIndex].size(); + } + + void ClearAllInterfaces() + { + ClearFlag = true; + for (UINT x = 0; x < MaxIndex; x++) + { + for (const auto& entry : g_map[x]) + { + entry.second->DeleteMe(); + } + g_map[x].clear(); + } + ClearFlag = false; + } + private: bool ConstructorFlag = false; - D *const pDevice; + bool ClearFlag = false; std::unordered_map g_map[MaxIndex]; }; diff --git a/d3d9/IDirect3DCubeTexture9.cpp b/d3d9/IDirect3DCubeTexture9.cpp index 7bd045ab..a89a6678 100644 --- a/d3d9/IDirect3DCubeTexture9.cpp +++ b/d3d9/IDirect3DCubeTexture9.cpp @@ -175,7 +175,7 @@ HRESULT m_IDirect3DCubeTexture9::GetCubeMapSurface(THIS_ D3DCUBEMAP_FACES FaceTy if (SUCCEEDED(hr) && ppCubeMapSurface) { - *ppCubeMapSurface = m_pDeviceEx->ProxyAddressLookupTable->FindAddress(*ppCubeMapSurface, m_pDeviceEx, IID_IDirect3DTexture9); + *ppCubeMapSurface = ProxyAddressLookupTable9.FindAddress(*ppCubeMapSurface, m_pDeviceEx, IID_IDirect3DTexture9); } return hr; diff --git a/d3d9/IDirect3DCubeTexture9.h b/d3d9/IDirect3DCubeTexture9.h index 08111879..fa28a8e6 100644 --- a/d3d9/IDirect3DCubeTexture9.h +++ b/d3d9/IDirect3DCubeTexture9.h @@ -11,7 +11,7 @@ class m_IDirect3DCubeTexture9 : public IDirect3DCubeTexture9, public AddressLook { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DCubeTexture9() { diff --git a/d3d9/IDirect3DDevice9Ex.cpp b/d3d9/IDirect3DDevice9Ex.cpp index be76691a..8fcb853c 100644 --- a/d3d9/IDirect3DDevice9Ex.cpp +++ b/d3d9/IDirect3DDevice9Ex.cpp @@ -507,7 +507,7 @@ HRESULT m_IDirect3DDevice9Ex::EndStateBlock(THIS_ IDirect3DStateBlock9** ppSB) if (SUCCEEDED(hr) && ppSB) { - *ppSB = ProxyAddressLookupTable->FindAddress(*ppSB, this, IID_IDirect3DStateBlock9); + *ppSB = ProxyAddressLookupTable9.FindAddress(*ppSB, this, IID_IDirect3DStateBlock9); } return hr; @@ -542,7 +542,7 @@ HRESULT m_IDirect3DDevice9Ex::GetRenderTarget(THIS_ DWORD RenderTargetIndex, IDi if (SUCCEEDED(hr) && ppRenderTarget) { - *ppRenderTarget = ProxyAddressLookupTable->FindAddress(*ppRenderTarget, this, IID_IDirect3DSurface9); + *ppRenderTarget = ProxyAddressLookupTable9.FindAddress(*ppRenderTarget, this, IID_IDirect3DSurface9); } return hr; @@ -645,7 +645,7 @@ HRESULT m_IDirect3DDevice9Ex::GetIndices(THIS_ IDirect3DIndexBuffer9** ppIndexDa if (SUCCEEDED(hr) && ppIndexData) { - *ppIndexData = ProxyAddressLookupTable->FindAddress(*ppIndexData, this, IID_IDirect3DIndexBuffer9); + *ppIndexData = ProxyAddressLookupTable9.FindAddress(*ppIndexData, this, IID_IDirect3DIndexBuffer9); } return hr; @@ -838,7 +838,7 @@ HRESULT m_IDirect3DDevice9Ex::GetPixelShader(THIS_ IDirect3DPixelShader9** ppSha if (SUCCEEDED(hr) && ppShader) { - *ppShader = ProxyAddressLookupTable->FindAddress(*ppShader, this, IID_IDirect3DPixelShader9); + *ppShader = ProxyAddressLookupTable9.FindAddress(*ppShader, this, IID_IDirect3DPixelShader9); } return hr; @@ -994,7 +994,7 @@ HRESULT m_IDirect3DDevice9Ex::GetStreamSource(THIS_ UINT StreamNumber, IDirect3D if (SUCCEEDED(hr) && ppStreamData) { - *ppStreamData = ProxyAddressLookupTable->FindAddress(*ppStreamData, this, IID_IDirect3DVertexBuffer9); + *ppStreamData = ProxyAddressLookupTable9.FindAddress(*ppStreamData, this, IID_IDirect3DVertexBuffer9); } return hr; @@ -1020,7 +1020,7 @@ HRESULT m_IDirect3DDevice9Ex::GetBackBuffer(THIS_ UINT iSwapChain, UINT iBackBuf if (SUCCEEDED(hr) && ppBackBuffer) { - *ppBackBuffer = ProxyAddressLookupTable->FindAddress(*ppBackBuffer, this, IID_IDirect3DSurface9); + *ppBackBuffer = ProxyAddressLookupTable9.FindAddress(*ppBackBuffer, this, IID_IDirect3DSurface9); } return hr; @@ -1034,7 +1034,7 @@ HRESULT m_IDirect3DDevice9Ex::GetDepthStencilSurface(IDirect3DSurface9 **ppZSten if (SUCCEEDED(hr) && ppZStencilSurface) { - *ppZStencilSurface = ProxyAddressLookupTable->FindAddress(*ppZStencilSurface, this, IID_IDirect3DSurface9); + *ppZStencilSurface = ProxyAddressLookupTable9.FindAddress(*ppZStencilSurface, this, IID_IDirect3DSurface9); } return hr; @@ -1051,13 +1051,13 @@ HRESULT m_IDirect3DDevice9Ex::GetTexture(DWORD Stage, IDirect3DBaseTexture9 **pp switch ((*ppTexture)->GetType()) { case D3DRTYPE_TEXTURE: - *ppTexture = ProxyAddressLookupTable->FindAddress(*ppTexture, this, IID_IDirect3DTexture9); + *ppTexture = ProxyAddressLookupTable9.FindAddress(*ppTexture, this, IID_IDirect3DTexture9); break; case D3DRTYPE_VOLUMETEXTURE: - *ppTexture = ProxyAddressLookupTable->FindAddress(*ppTexture, this, IID_IDirect3DVolumeTexture9); + *ppTexture = ProxyAddressLookupTable9.FindAddress(*ppTexture, this, IID_IDirect3DVolumeTexture9); break; case D3DRTYPE_CUBETEXTURE: - *ppTexture = ProxyAddressLookupTable->FindAddress(*ppTexture, this, IID_IDirect3DCubeTexture9); + *ppTexture = ProxyAddressLookupTable9.FindAddress(*ppTexture, this, IID_IDirect3DCubeTexture9); break; default: return D3DERR_INVALIDCALL; @@ -1281,7 +1281,7 @@ HRESULT m_IDirect3DDevice9Ex::GetVertexShader(THIS_ IDirect3DVertexShader9** ppS if (SUCCEEDED(hr) && ppShader) { - *ppShader = ProxyAddressLookupTable->FindAddress(*ppShader, this, IID_IDirect3DVertexShader9); + *ppShader = ProxyAddressLookupTable9.FindAddress(*ppShader, this, IID_IDirect3DVertexShader9); } return hr; @@ -1473,7 +1473,7 @@ HRESULT m_IDirect3DDevice9Ex::GetVertexDeclaration(THIS_ IDirect3DVertexDeclarat if (SUCCEEDED(hr) && ppDecl) { - *ppDecl = ProxyAddressLookupTable->FindAddress(*ppDecl, this, IID_IDirect3DVertexDeclaration9); + *ppDecl = ProxyAddressLookupTable9.FindAddress(*ppDecl, this, IID_IDirect3DVertexDeclaration9); } return hr; @@ -2054,7 +2054,7 @@ HRESULT m_IDirect3DDevice9Ex::GetSwapChain(THIS_ UINT iSwapChain, IDirect3DSwapC if (SUCCEEDED(hr)) { - *ppSwapChain = ProxyAddressLookupTable->FindAddress(*ppSwapChain, this, IID_IDirect3DSwapChain9); + *ppSwapChain = ProxyAddressLookupTable9.FindAddress(*ppSwapChain, this, IID_IDirect3DSwapChain9); } return hr; diff --git a/d3d9/IDirect3DDevice9Ex.h b/d3d9/IDirect3DDevice9Ex.h index c5a144bc..40bdb342 100644 --- a/d3d9/IDirect3DDevice9Ex.h +++ b/d3d9/IDirect3DDevice9Ex.h @@ -62,8 +62,6 @@ class m_IDirect3DDevice9Ex : public IDirect3DDevice9Ex, public AddressLookupTabl ReInitDevice(); - ProxyAddressLookupTable = new AddressLookupTableD3d9(this); - ProxyAddressLookupTableDevice9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DDevice9Ex() @@ -76,9 +74,13 @@ class m_IDirect3DDevice9Ex : public IDirect3DDevice9Ex, public AddressLookupTabl WndProc::RemoveWndProc(DeviceDetails.DeviceWindow); } - delete ProxyAddressLookupTable; - ProxyAddressLookupTableDevice9.DeleteAddress(this); + + // Clear unused interfaces + if (ProxyAddressLookupTableDevice9.GetDeviceCount() == 0) + { + ProxyAddressLookupTable9.ClearAllInterfaces(); + } } void SetDeviceDetails(DEVICEDETAILS& NewDeviceDetails) { @@ -92,8 +94,6 @@ class m_IDirect3DDevice9Ex : public IDirect3DDevice9Ex, public AddressLookupTabl } } - AddressLookupTableD3d9 *ProxyAddressLookupTable = nullptr; - /*** IUnknown methods ***/ STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj); STDMETHOD_(ULONG, AddRef)(THIS); diff --git a/d3d9/IDirect3DIndexBuffer9.h b/d3d9/IDirect3DIndexBuffer9.h index e2c7830b..1d933d42 100644 --- a/d3d9/IDirect3DIndexBuffer9.h +++ b/d3d9/IDirect3DIndexBuffer9.h @@ -11,7 +11,7 @@ class m_IDirect3DIndexBuffer9 : public IDirect3DIndexBuffer9, public AddressLook { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DIndexBuffer9() { diff --git a/d3d9/IDirect3DPixelShader9.h b/d3d9/IDirect3DPixelShader9.h index 2ab6ea1a..7ccd4d08 100644 --- a/d3d9/IDirect3DPixelShader9.h +++ b/d3d9/IDirect3DPixelShader9.h @@ -11,7 +11,7 @@ class m_IDirect3DPixelShader9 : public IDirect3DPixelShader9, public AddressLook { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DPixelShader9() { diff --git a/d3d9/IDirect3DQuery9.h b/d3d9/IDirect3DQuery9.h index 57f7fa77..b5c5d89f 100644 --- a/d3d9/IDirect3DQuery9.h +++ b/d3d9/IDirect3DQuery9.h @@ -11,7 +11,7 @@ class m_IDirect3DQuery9 : public IDirect3DQuery9, public AddressLookupTableD3d9O { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DQuery9() { diff --git a/d3d9/IDirect3DStateBlock9.h b/d3d9/IDirect3DStateBlock9.h index 7c6c5428..7c047095 100644 --- a/d3d9/IDirect3DStateBlock9.h +++ b/d3d9/IDirect3DStateBlock9.h @@ -11,7 +11,7 @@ class m_IDirect3DStateBlock9 : public IDirect3DStateBlock9, public AddressLookup { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DStateBlock9() { diff --git a/d3d9/IDirect3DSurface9.h b/d3d9/IDirect3DSurface9.h index 34b5fef9..a2176b42 100644 --- a/d3d9/IDirect3DSurface9.h +++ b/d3d9/IDirect3DSurface9.h @@ -28,7 +28,7 @@ class m_IDirect3DSurface9 : public IDirect3DSurface9, public AddressLookupTableD LOG_LIMIT(3, __FUNCTION__ << " Failed to GetDesc()!" << this << ")"); } - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DSurface9() { diff --git a/d3d9/IDirect3DSwapChain9Ex.cpp b/d3d9/IDirect3DSwapChain9Ex.cpp index f908303c..03e90964 100644 --- a/d3d9/IDirect3DSwapChain9Ex.cpp +++ b/d3d9/IDirect3DSwapChain9Ex.cpp @@ -80,7 +80,7 @@ HRESULT m_IDirect3DSwapChain9Ex::GetBackBuffer(THIS_ UINT BackBuffer, D3DBACKBUF if (SUCCEEDED(hr) && ppBackBuffer) { - *ppBackBuffer = m_pDeviceEx->ProxyAddressLookupTable->FindAddress(*ppBackBuffer, m_pDeviceEx, IID_IDirect3DSurface9); + *ppBackBuffer = ProxyAddressLookupTable9.FindAddress(*ppBackBuffer, m_pDeviceEx, IID_IDirect3DSurface9); } return hr; diff --git a/d3d9/IDirect3DSwapChain9Ex.h b/d3d9/IDirect3DSwapChain9Ex.h index 75cd296f..f897a4de 100644 --- a/d3d9/IDirect3DSwapChain9Ex.h +++ b/d3d9/IDirect3DSwapChain9Ex.h @@ -18,7 +18,7 @@ class m_IDirect3DSwapChain9Ex : public IDirect3DSwapChain9Ex, public AddressLook ProxyInterfaceEx = pSwapChain9; } - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DSwapChain9Ex() { diff --git a/d3d9/IDirect3DTexture9.cpp b/d3d9/IDirect3DTexture9.cpp index d45b02c2..6698aae8 100644 --- a/d3d9/IDirect3DTexture9.cpp +++ b/d3d9/IDirect3DTexture9.cpp @@ -175,7 +175,7 @@ HRESULT m_IDirect3DTexture9::GetSurfaceLevel(THIS_ UINT Level, IDirect3DSurface9 if (SUCCEEDED(hr) && ppSurfaceLevel) { - *ppSurfaceLevel = m_pDeviceEx->ProxyAddressLookupTable->FindAddress(*ppSurfaceLevel, m_pDeviceEx, IID_IDirect3DSurface9); + *ppSurfaceLevel = ProxyAddressLookupTable9.FindAddress(*ppSurfaceLevel, m_pDeviceEx, IID_IDirect3DSurface9); } return hr; diff --git a/d3d9/IDirect3DTexture9.h b/d3d9/IDirect3DTexture9.h index cf997873..ff98df4e 100644 --- a/d3d9/IDirect3DTexture9.h +++ b/d3d9/IDirect3DTexture9.h @@ -11,7 +11,7 @@ class m_IDirect3DTexture9 : public IDirect3DTexture9, public AddressLookupTableD { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DTexture9() { diff --git a/d3d9/IDirect3DVertexBuffer9.h b/d3d9/IDirect3DVertexBuffer9.h index ccfc842f..58d93702 100644 --- a/d3d9/IDirect3DVertexBuffer9.h +++ b/d3d9/IDirect3DVertexBuffer9.h @@ -11,7 +11,7 @@ class m_IDirect3DVertexBuffer9 : public IDirect3DVertexBuffer9, public AddressLo { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DVertexBuffer9() { diff --git a/d3d9/IDirect3DVertexDeclaration9.h b/d3d9/IDirect3DVertexDeclaration9.h index a110d446..bbd4b8f3 100644 --- a/d3d9/IDirect3DVertexDeclaration9.h +++ b/d3d9/IDirect3DVertexDeclaration9.h @@ -11,7 +11,7 @@ class m_IDirect3DVertexDeclaration9 : public IDirect3DVertexDeclaration9, public { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DVertexDeclaration9() { diff --git a/d3d9/IDirect3DVertexShader9.h b/d3d9/IDirect3DVertexShader9.h index 50fa465e..0a9095e2 100644 --- a/d3d9/IDirect3DVertexShader9.h +++ b/d3d9/IDirect3DVertexShader9.h @@ -11,7 +11,7 @@ class m_IDirect3DVertexShader9 : public IDirect3DVertexShader9, public AddressLo { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DVertexShader9() { diff --git a/d3d9/IDirect3DVolume9.h b/d3d9/IDirect3DVolume9.h index 3e9f36fb..d9dac08d 100644 --- a/d3d9/IDirect3DVolume9.h +++ b/d3d9/IDirect3DVolume9.h @@ -11,7 +11,7 @@ class m_IDirect3DVolume9 : public IDirect3DVolume9, public AddressLookupTableD3d { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DVolume9() { diff --git a/d3d9/IDirect3DVolumeTexture9.cpp b/d3d9/IDirect3DVolumeTexture9.cpp index 296996ef..5cddeaa3 100644 --- a/d3d9/IDirect3DVolumeTexture9.cpp +++ b/d3d9/IDirect3DVolumeTexture9.cpp @@ -175,7 +175,7 @@ HRESULT m_IDirect3DVolumeTexture9::GetVolumeLevel(THIS_ UINT Level, IDirect3DVol if (SUCCEEDED(hr) && ppVolumeLevel) { - *ppVolumeLevel = m_pDeviceEx->ProxyAddressLookupTable->FindAddress(*ppVolumeLevel, m_pDeviceEx, IID_IDirect3DVolume9); + *ppVolumeLevel = ProxyAddressLookupTable9.FindAddress(*ppVolumeLevel, m_pDeviceEx, IID_IDirect3DVolume9); } return hr; diff --git a/d3d9/IDirect3DVolumeTexture9.h b/d3d9/IDirect3DVolumeTexture9.h index 6e5c0736..69e039f7 100644 --- a/d3d9/IDirect3DVolumeTexture9.h +++ b/d3d9/IDirect3DVolumeTexture9.h @@ -11,7 +11,7 @@ class m_IDirect3DVolumeTexture9 : public IDirect3DVolumeTexture9, public Address { LOG_LIMIT(3, "Creating interface " << __FUNCTION__ << " (" << this << ")"); - pDevice->ProxyAddressLookupTable->SaveAddress(this, ProxyInterface); + ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface); } ~m_IDirect3DVolumeTexture9() { diff --git a/d3d9/InterfaceQuery.cpp b/d3d9/InterfaceQuery.cpp index b7de65ef..2294783e 100644 --- a/d3d9/InterfaceQuery.cpp +++ b/d3d9/InterfaceQuery.cpp @@ -58,14 +58,14 @@ void WINAPI D3d9Wrapper::genericQueryInterface(REFIID riid, LPVOID *ppvObj, m_ID if (riid == IID_IDirect3DSwapChain9 || riid == IID_IDirect3DSwapChain9Ex) { - *ppvObj = m_pDeviceEx->ProxyAddressLookupTable->FindAddress(*ppvObj, m_pDeviceEx, riid); + *ppvObj = ProxyAddressLookupTable9.FindAddress(*ppvObj, m_pDeviceEx, riid); return; } #define QUERYINTERFACE(x) \ if (riid == IID_ ## x) \ { \ - *ppvObj = m_pDeviceEx->ProxyAddressLookupTable->FindAddress(*ppvObj, m_pDeviceEx, riid); \ + *ppvObj = ProxyAddressLookupTable9.FindAddress(*ppvObj, m_pDeviceEx, riid); \ return; \ } diff --git a/d3d9/d3d9.cpp b/d3d9/d3d9.cpp index 4a92d7c0..71d14efa 100644 --- a/d3d9/d3d9.cpp +++ b/d3d9/d3d9.cpp @@ -27,6 +27,7 @@ namespace D3d9Wrapper using namespace D3d9Wrapper; +AddressLookupTableD3d9 ProxyAddressLookupTable9(nullptr); AddressLookupTableD3d9 ProxyAddressLookupTableDevice9(nullptr); HMODULE GetSystemD3d9() diff --git a/d3d9/d3d9.h b/d3d9/d3d9.h index 85c4b0c0..2904c628 100644 --- a/d3d9/d3d9.h +++ b/d3d9/d3d9.h @@ -46,6 +46,7 @@ struct DEVICEDETAILS DWORD DeviceMultiSampleQuality = 0; }; +extern AddressLookupTableD3d9 ProxyAddressLookupTable9; extern AddressLookupTableD3d9 ProxyAddressLookupTableDevice9; DWORD UpdateBehaviorFlags(DWORD BehaviorFlags);