diff --git a/d3d9ex/IDirect3D9.cpp b/d3d9ex/IDirect3D9.cpp index 19a8d3a..c7eb940 100644 --- a/d3d9ex/IDirect3D9.cpp +++ b/d3d9ex/IDirect3D9.cpp @@ -22,7 +22,10 @@ HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) { IDirect3D9Ex* pIDirect3D9Ex = nullptr; HRESULT hr = m_pWrapped->QueryInterface(riid, reinterpret_cast(&pIDirect3D9Ex)); if (FAILED(hr)) + { + spdlog::trace("Error creating IDirect3D9Ex: {:#X}", (unsigned long)hr); return hr; + } // release one reference from old one and take new IDirect3DDevice9Ex pointer m_pWrapped->Release(); diff --git a/d3d9ex/IDirect3D9.h b/d3d9ex/IDirect3D9.h index 0b64bbc..9faf2f8 100644 --- a/d3d9ex/IDirect3D9.h +++ b/d3d9ex/IDirect3D9.h @@ -35,13 +35,14 @@ interface DECLSPEC_UUID("16760376-B89E-4CD9-9CE1-5B1C7AFC2E16") hkIDirect3D9 fin hkIDirect3D9(IDirect3D9Ex* pIDirect3D9) : m_pWrapped(pIDirect3D9) { + AddRef(); } virtual ~hkIDirect3D9() { } private: IDirect3D9Ex* m_pWrapped; - ULONG m_ref = 1; + ULONG m_ref; bool m_is_ex = false; template diff --git a/d3d9ex/IDirect3DDevice9.cpp b/d3d9ex/IDirect3DDevice9.cpp index ee42d3d..eff866f 100644 --- a/d3d9ex/IDirect3DDevice9.cpp +++ b/d3d9ex/IDirect3DDevice9.cpp @@ -14,7 +14,8 @@ HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) if (riid == __uuidof(this) || riid == __uuidof(IUnknown) || riid == __uuidof(IDirect3DDevice9) || - riid == __uuidof(IDirect3DDevice9Ex)) + riid == __uuidof(IDirect3DDevice9Ex) + ) { if (!m_is_ex && riid == __uuidof(IDirect3DDevice9Ex)) { @@ -23,7 +24,10 @@ HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) IDirect3DDevice9Ex* pIDirect3DDevice9Ex = nullptr; HRESULT hr = m_pWrapped->QueryInterface(riid, reinterpret_cast(&pIDirect3DDevice9Ex)); if (FAILED(hr)) + { + spdlog::trace("Error creating IDirect3DDevice9Ex: {:#X}", (unsigned long)hr); return hr; + } // release one reference from old one and take new IDirect3DDevice9Ex pointer m_pWrapped->Release(); diff --git a/d3d9ex/IDirect3DDevice9.h b/d3d9ex/IDirect3DDevice9.h index 02d1247..0ea90de 100644 --- a/d3d9ex/IDirect3DDevice9.h +++ b/d3d9ex/IDirect3DDevice9.h @@ -147,13 +147,14 @@ interface DECLSPEC_UUID("DD98C5F4-40E6-43D9-A0EA-0C32ABDFDF9C") hkIDirect3DDevic hkIDirect3DDevice9(IDirect3DDevice9Ex* pIDirect3DDevice9, bool is_ex) : m_pWrapped(pIDirect3DDevice9), m_is_ex(is_ex) { + AddRef(); } virtual ~hkIDirect3DDevice9() { } private: IDirect3DDevice9Ex* m_pWrapped; - ULONG m_ref = 1; + ULONG m_ref; bool m_is_ex = false; }; diff --git a/d3d9ex/Wrapper.h b/d3d9ex/Wrapper.h index d05211b..ae286b7 100644 --- a/d3d9ex/Wrapper.h +++ b/d3d9ex/Wrapper.h @@ -78,6 +78,9 @@ class D3D9DLL : public WrapperBase void (WINAPI* D3DPERF_SetOptions)(DWORD dwOptions); void (WINAPI* D3DPERF_SetRegion)(D3DCOLOR col, LPCWSTR wszName); + HRESULT(WINAPI* DebugSetLevel)(DWORD level); + void (WINAPI* DebugSetMute)(void); + bool IsDXVK() { return m_isdxvk; } D3D9DLL() @@ -102,6 +105,9 @@ class D3D9DLL : public WrapperBase StoreAddress(&D3DPERF_SetMarker, "D3DPERF_SetMarker"); StoreAddress(&D3DPERF_SetOptions, "D3DPERF_SetOptions"); StoreAddress(&D3DPERF_SetRegion, "D3DPERF_SetRegion"); + + StoreAddress(&DebugSetLevel, "DebugSetLevel"); + StoreAddress(&DebugSetMute, "DebugSetMute"); } private: @@ -155,4 +161,36 @@ extern "C" { return D3D9DLL::Get().D3DPERF_SetRegion(col, wszName); } + + HRESULT WINAPI _DebugSetLevel(DWORD level) + { + return D3D9DLL::Get().DebugSetLevel(level); + } + + void WINAPI _DebugSetMute() + { + D3D9DLL::Get().DebugSetMute(); + } } + +class DINPUT8DLL : public WrapperBase +{ +public: + + HRESULT(WINAPI* DirectInput8Create)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter); + + DINPUT8DLL() + { + WrapperLoad("dinput8.dll"); + + StoreAddress(&DirectInput8Create, "DirectInput8Create"); + } +}; + +extern "C" +{ + HRESULT WINAPI _DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter) + { + return DINPUT8DLL::Get().DirectInput8Create(hinst, dwVersion, riidltf, ppvOut, punkOuter); + } +} \ No newline at end of file diff --git a/d3d9ex/d3d9ex.vcxproj b/d3d9ex/d3d9ex.vcxproj index 09bf727..6879360 100644 --- a/d3d9ex/d3d9ex.vcxproj +++ b/d3d9ex/d3d9ex.vcxproj @@ -29,13 +29,13 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode @@ -44,7 +44,7 @@ true MultiByte true - v142 + v143 false @@ -53,7 +53,7 @@ true MultiByte true - v142 + v143 @@ -83,7 +83,7 @@ false - d3d9 + dinput8 $(SolutionDir)\Common;$(SolutionDir)\Deps\MinHook\include;$(SolutionDir)\Deps\spdlog\include;$(IncludePath) @@ -93,7 +93,7 @@ - Use + NotUsing Level3 Disabled WIN32;SPDLOG_DISABLE_DEFAULT_LOGGER;SPDLOG_WCHAR_TO_UTF8_SUPPORT;_DEBUG;_WINDOWS;_USRDLL;D3D9EX_EXPORTS;%(PreprocessorDefinitions) @@ -134,7 +134,7 @@ MaxSpeed true MultiThreaded - stdcpplatest + stdcpp20 true /Zc:__cplusplus %(AdditionalOptions) diff --git a/d3d9ex/exports.def b/d3d9ex/exports.def index 3266e59..927a5ba 100644 --- a/d3d9ex/exports.def +++ b/d3d9ex/exports.def @@ -11,4 +11,7 @@ D3DPERF_SetMarker=_D3DPERF_SetMarker @24 D3DPERF_SetOptions=_D3DPERF_SetOptions @25 D3DPERF_SetRegion=_D3DPERF_SetRegion @26 +DebugSetLevel=_DebugSetLevel @27 +DebugSetMute=_DebugSetMute @28 +DirectInput8Create=_DirectInput8Create