Skip to content

Commit 52231db

Browse files
committed
add d3d9 router for dx9/dx11 toggle mode
1 parent 24f6b1f commit 52231db

File tree

4 files changed

+259
-0
lines changed

4 files changed

+259
-0
lines changed

d3d9/d3d9.vcxproj

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<ProjectGuid>{44E8BA05-3A0B-4342-B114-E66351A8748E}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<RootNamespace>d3d9</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>DynamicLibrary</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v142</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>DynamicLibrary</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v142</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>DynamicLibrary</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v142</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>DynamicLibrary</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v142</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
74+
<LinkIncremental>false</LinkIncremental>
75+
<TargetName>bin64\$(ProjectName)</TargetName>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
78+
<LinkIncremental>true</LinkIncremental>
79+
<TargetName>bin64\$(ProjectName)</TargetName>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
82+
<LinkIncremental>true</LinkIncremental>
83+
<TargetName>bin64\$(ProjectName)</TargetName>
84+
</PropertyGroup>
85+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
86+
<LinkIncremental>false</LinkIncremental>
87+
<TargetName>bin64\$(ProjectName)</TargetName>
88+
</PropertyGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
90+
<ClCompile>
91+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
92+
<WarningLevel>Level3</WarningLevel>
93+
<FunctionLevelLinking>true</FunctionLevelLinking>
94+
<IntrinsicFunctions>true</IntrinsicFunctions>
95+
<SDLCheck>true</SDLCheck>
96+
<PreprocessorDefinitions>NDEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
97+
<ConformanceMode>true</ConformanceMode>
98+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
99+
</ClCompile>
100+
<Link>
101+
<SubSystem>Windows</SubSystem>
102+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
103+
<OptimizeReferences>true</OptimizeReferences>
104+
<GenerateDebugInformation>true</GenerateDebugInformation>
105+
<EnableUAC>false</EnableUAC>
106+
<ModuleDefinitionFile>deffile.def</ModuleDefinitionFile>
107+
</Link>
108+
</ItemDefinitionGroup>
109+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
110+
<ClCompile>
111+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
112+
<WarningLevel>Level3</WarningLevel>
113+
<SDLCheck>true</SDLCheck>
114+
<PreprocessorDefinitions>WIN32;_DEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115+
<ConformanceMode>true</ConformanceMode>
116+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
117+
</ClCompile>
118+
<Link>
119+
<SubSystem>Windows</SubSystem>
120+
<GenerateDebugInformation>true</GenerateDebugInformation>
121+
<EnableUAC>false</EnableUAC>
122+
<ModuleDefinitionFile>deffile.def</ModuleDefinitionFile>
123+
</Link>
124+
</ItemDefinitionGroup>
125+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
126+
<ClCompile>
127+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
128+
<WarningLevel>Level3</WarningLevel>
129+
<SDLCheck>true</SDLCheck>
130+
<PreprocessorDefinitions>_DEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
131+
<ConformanceMode>true</ConformanceMode>
132+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
133+
</ClCompile>
134+
<Link>
135+
<SubSystem>Windows</SubSystem>
136+
<GenerateDebugInformation>true</GenerateDebugInformation>
137+
<EnableUAC>false</EnableUAC>
138+
<ModuleDefinitionFile>deffile.def</ModuleDefinitionFile>
139+
</Link>
140+
</ItemDefinitionGroup>
141+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
142+
<ClCompile>
143+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
144+
<WarningLevel>Level3</WarningLevel>
145+
<FunctionLevelLinking>true</FunctionLevelLinking>
146+
<IntrinsicFunctions>true</IntrinsicFunctions>
147+
<SDLCheck>true</SDLCheck>
148+
<PreprocessorDefinitions>WIN32;NDEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
149+
<ConformanceMode>true</ConformanceMode>
150+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
151+
</ClCompile>
152+
<Link>
153+
<SubSystem>Windows</SubSystem>
154+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
155+
<OptimizeReferences>true</OptimizeReferences>
156+
<GenerateDebugInformation>true</GenerateDebugInformation>
157+
<EnableUAC>false</EnableUAC>
158+
<ModuleDefinitionFile>deffile.def</ModuleDefinitionFile>
159+
</Link>
160+
</ItemDefinitionGroup>
161+
<ItemGroup>
162+
<ClCompile Include="dllmain.cpp" />
163+
</ItemGroup>
164+
<ItemGroup>
165+
<None Include="deffile.def" />
166+
</ItemGroup>
167+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
168+
<ImportGroup Label="ExtensionTargets">
169+
</ImportGroup>
170+
</Project>

d3d9/deffile.def

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
LIBRARY addonLoader.dll
2+
EXPORTS
3+
4+
; d3d9
5+
6+
Direct3DCreate9 @30
7+
Direct3DCreate9Ex
8+
D3DPERF_BeginEvent
9+
D3DPERF_EndEvent
10+
D3DPERF_SetMarker
11+
D3DPERF_SetRegion
12+
D3DPERF_QueryRepeatFrame
13+
D3DPERF_SetOptions
14+
D3DPERF_GetStatus

d3d9/dllmain.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#define WIN32_LEAN_AND_MEAN
2+
#include <windows.h>
3+
#include <d3d9.h>
4+
5+
HMODULE target_lib = 0;
6+
const wchar_t* target_lib_name = L"addonLoader.dll";
7+
8+
typedef IDirect3D9 * (WINAPI* fnDirect3DCreate9)(UINT SDKVersion);
9+
10+
void* getTargetProc(const char* procName)
11+
{
12+
if (!target_lib)
13+
{
14+
target_lib = LoadLibrary(target_lib_name);
15+
}
16+
17+
return GetProcAddress(target_lib, procName);
18+
}
19+
20+
21+
extern "C" IDirect3D9 * WINAPI Direct3DCreate9(UINT SDKVersion) {
22+
fnDirect3DCreate9 fun = (fnDirect3DCreate9)getTargetProc("Direct3DCreate9");
23+
return fun(SDKVersion);
24+
}
25+
26+
extern "C" HRESULT WINAPI Direct3DCreate9Ex(
27+
_In_ UINT SDKVersion,
28+
_Out_ IDirect3D9Ex * *ppD3D
29+
)
30+
{
31+
return 0;
32+
}
33+
34+
35+
extern "C" int WINAPI D3DPERF_BeginEvent(D3DCOLOR col, LPCWSTR wszName)
36+
{
37+
return D3DERR_NOTAVAILABLE;
38+
}
39+
40+
extern "C" int WINAPI D3DPERF_EndEvent(void)
41+
{
42+
return D3DERR_NOTAVAILABLE;
43+
}
44+
45+
extern "C" void WINAPI D3DPERF_SetMarker(D3DCOLOR col, LPCWSTR wszName)
46+
{
47+
}
48+
49+
extern "C" void WINAPI D3DPERF_SetRegion(D3DCOLOR col, LPCWSTR wszName)
50+
{
51+
}
52+
53+
extern "C" BOOL WINAPI D3DPERF_QueryRepeatFrame(void)
54+
{
55+
return 0;
56+
}
57+
58+
extern "C" void WINAPI D3DPERF_SetOptions(DWORD dwOptions)
59+
{
60+
}
61+
62+
extern "C" DWORD WINAPI D3DPERF_GetStatus(void)
63+
{
64+
return 0;
65+
}

loader_core.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxgi", "dxgi\dxgi.vcxproj",
1818
EndProject
1919
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d11", "d3d11\d3d11.vcxproj", "{5A73591F-E0F2-400D-9C93-146CD068E18A}"
2020
EndProject
21+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d9", "d3d9\d3d9.vcxproj", "{44E8BA05-3A0B-4342-B114-E66351A8748E}"
22+
EndProject
2123
Global
2224
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2325
Debug|x64 = Debug|x64
@@ -66,6 +68,14 @@ Global
6668
{5A73591F-E0F2-400D-9C93-146CD068E18A}.Release|x64.Build.0 = Release|x64
6769
{5A73591F-E0F2-400D-9C93-146CD068E18A}.Release|x86.ActiveCfg = Release|Win32
6870
{5A73591F-E0F2-400D-9C93-146CD068E18A}.Release|x86.Build.0 = Release|Win32
71+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Debug|x64.ActiveCfg = Debug|x64
72+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Debug|x64.Build.0 = Debug|x64
73+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Debug|x86.ActiveCfg = Debug|Win32
74+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Debug|x86.Build.0 = Debug|Win32
75+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Release|x64.ActiveCfg = Release|x64
76+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Release|x64.Build.0 = Release|x64
77+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Release|x86.ActiveCfg = Release|Win32
78+
{44E8BA05-3A0B-4342-B114-E66351A8748E}.Release|x86.Build.0 = Release|Win32
6979
EndGlobalSection
7080
GlobalSection(SolutionProperties) = preSolution
7181
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)