Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions d3d9ex/IDirect3D9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) {
IDirect3D9Ex* pIDirect3D9Ex = nullptr;
HRESULT hr = m_pWrapped->QueryInterface(riid, reinterpret_cast<void**>(&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();
Expand Down
3 changes: 2 additions & 1 deletion d3d9ex/IDirect3D9.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T, bool ex>
Expand Down
6 changes: 5 additions & 1 deletion d3d9ex/IDirect3DDevice9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -23,7 +24,10 @@ HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj)
IDirect3DDevice9Ex* pIDirect3DDevice9Ex = nullptr;
HRESULT hr = m_pWrapped->QueryInterface(riid, reinterpret_cast<void**>(&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();
Expand Down
3 changes: 2 additions & 1 deletion d3d9ex/IDirect3DDevice9.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

38 changes: 38 additions & 0 deletions d3d9ex/Wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class D3D9DLL : public WrapperBase<D3D9DLL>
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()
Expand All @@ -102,6 +105,9 @@ class D3D9DLL : public WrapperBase<D3D9DLL>
StoreAddress(&D3DPERF_SetMarker, "D3DPERF_SetMarker");
StoreAddress(&D3DPERF_SetOptions, "D3DPERF_SetOptions");
StoreAddress(&D3DPERF_SetRegion, "D3DPERF_SetRegion");

StoreAddress(&DebugSetLevel, "DebugSetLevel");
StoreAddress(&DebugSetMute, "DebugSetMute");
}

private:
Expand Down Expand Up @@ -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<DINPUT8DLL>
{
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);
}
}
14 changes: 7 additions & 7 deletions d3d9ex/d3d9ex.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
Expand All @@ -44,7 +44,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<InterproceduralOptimization>true</InterproceduralOptimization>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<SpectreMitigation>false</SpectreMitigation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
Expand All @@ -53,7 +53,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<InterproceduralOptimization>true</InterproceduralOptimization>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -83,7 +83,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>d3d9</TargetName>
<TargetName>dinput8</TargetName>
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\Deps\MinHook\include;$(SolutionDir)\Deps\spdlog\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -93,7 +93,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;SPDLOG_DISABLE_DEFAULT_LOGGER;SPDLOG_WCHAR_TO_UTF8_SUPPORT;_DEBUG;_WINDOWS;_USRDLL;D3D9EX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -134,7 +134,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<CreateHotpatchableImage>true</CreateHotpatchableImage>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
Expand Down
3 changes: 3 additions & 0 deletions d3d9ex/exports.def
Original file line number Diff line number Diff line change
Expand Up @@ -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