From 362287eafbaa3556305e9127558e200a905bad48 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 20 Mar 2022 01:01:58 +0100 Subject: [PATCH] Add project files. --- .gitattributes | 63 ++++ .gitignore | 363 ++++++++++++++++++++ ForceD3D9On12.sln | 41 +++ ForceD3D9On12/ForceD3D9On12.cpp | 113 ++++++ ForceD3D9On12/ForceD3D9On12.h | 16 + ForceD3D9On12/ForceD3D9On12.vcxproj | 87 +++++ ForceD3D9On12/ForceD3D9On12.vcxproj.filters | 30 ++ ForceD3D9On12/Version.h | 2 + LICENSE.txt | 10 + README.md | 27 ++ d3d8/d3d8.cpp | 8 + d3d8/d3d8.rc | 33 ++ d3d8/d3d8.vcxproj | 61 ++++ d3d8/d3d8.vcxproj.filters | 27 ++ d3d9/d3d9.cpp | 20 ++ d3d9/d3d9.rc | 33 ++ d3d9/d3d9.vcxproj | 89 +++++ d3d9/d3d9.vcxproj.filters | 27 ++ ddraw/ddraw.cpp | 26 ++ ddraw/ddraw.rc | 33 ++ ddraw/ddraw.vcxproj | 61 ++++ ddraw/ddraw.vcxproj.filters | 27 ++ 22 files changed, 1197 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 ForceD3D9On12.sln create mode 100644 ForceD3D9On12/ForceD3D9On12.cpp create mode 100644 ForceD3D9On12/ForceD3D9On12.h create mode 100644 ForceD3D9On12/ForceD3D9On12.vcxproj create mode 100644 ForceD3D9On12/ForceD3D9On12.vcxproj.filters create mode 100644 ForceD3D9On12/Version.h create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 d3d8/d3d8.cpp create mode 100644 d3d8/d3d8.rc create mode 100644 d3d8/d3d8.vcxproj create mode 100644 d3d8/d3d8.vcxproj.filters create mode 100644 d3d9/d3d9.cpp create mode 100644 d3d9/d3d9.rc create mode 100644 d3d9/d3d9.vcxproj create mode 100644 d3d9/d3d9.vcxproj.filters create mode 100644 ddraw/ddraw.cpp create mode 100644 ddraw/ddraw.rc create mode 100644 ddraw/ddraw.vcxproj create mode 100644 ddraw/ddraw.vcxproj.filters diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/ForceD3D9On12.sln b/ForceD3D9On12.sln new file mode 100644 index 0000000..1be5b9c --- /dev/null +++ b/ForceD3D9On12.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ForceD3D9On12", "ForceD3D9On12\ForceD3D9On12.vcxproj", "{073AEF6C-EA51-4136-8F64-2B22416F9C7F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ddraw", "ddraw\ddraw.vcxproj", "{AF0FA384-A765-469B-873C-B751D11F1C96}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d8", "d3d8\d3d8.vcxproj", "{2C2F4C45-1AAB-4E28-B176-FC27767F55D1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d9", "d3d9\d3d9.vcxproj", "{AF3533C7-9B68-4F05-982E-41E1F03B6AB8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {073AEF6C-EA51-4136-8F64-2B22416F9C7F}.Release|x64.ActiveCfg = Release|x64 + {073AEF6C-EA51-4136-8F64-2B22416F9C7F}.Release|x64.Build.0 = Release|x64 + {073AEF6C-EA51-4136-8F64-2B22416F9C7F}.Release|x86.ActiveCfg = Release|Win32 + {073AEF6C-EA51-4136-8F64-2B22416F9C7F}.Release|x86.Build.0 = Release|Win32 + {AF0FA384-A765-469B-873C-B751D11F1C96}.Release|x64.ActiveCfg = Release|Win32 + {AF0FA384-A765-469B-873C-B751D11F1C96}.Release|x86.ActiveCfg = Release|Win32 + {AF0FA384-A765-469B-873C-B751D11F1C96}.Release|x86.Build.0 = Release|Win32 + {2C2F4C45-1AAB-4E28-B176-FC27767F55D1}.Release|x64.ActiveCfg = Release|Win32 + {2C2F4C45-1AAB-4E28-B176-FC27767F55D1}.Release|x86.ActiveCfg = Release|Win32 + {2C2F4C45-1AAB-4E28-B176-FC27767F55D1}.Release|x86.Build.0 = Release|Win32 + {AF3533C7-9B68-4F05-982E-41E1F03B6AB8}.Release|x64.ActiveCfg = Release|x64 + {AF3533C7-9B68-4F05-982E-41E1F03B6AB8}.Release|x64.Build.0 = Release|x64 + {AF3533C7-9B68-4F05-982E-41E1F03B6AB8}.Release|x86.ActiveCfg = Release|Win32 + {AF3533C7-9B68-4F05-982E-41E1F03B6AB8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {130DBB02-75F1-4B34-AFD1-1FD5A80F1087} + EndGlobalSection +EndGlobal diff --git a/ForceD3D9On12/ForceD3D9On12.cpp b/ForceD3D9On12/ForceD3D9On12.cpp new file mode 100644 index 0000000..60bc353 --- /dev/null +++ b/ForceD3D9On12/ForceD3D9On12.cpp @@ -0,0 +1,113 @@ +#include +#include +#include + +#include "ForceD3D9On12.h" + +namespace +{ + NTSTATUS APIENTRY queryAdapterInfo(const D3DKMT_QUERYADAPTERINFO* pData); + + PIMAGE_NT_HEADERS getImageNtHeaders(HMODULE module) + { + PIMAGE_DOS_HEADER dosHeader = reinterpret_cast(module); + if (IMAGE_DOS_SIGNATURE != dosHeader->e_magic) + { + return nullptr; + } + + PIMAGE_NT_HEADERS ntHeaders = reinterpret_cast( + reinterpret_cast(dosHeader) + dosHeader->e_lfanew); + if (IMAGE_NT_SIGNATURE != ntHeaders->Signature) + { + return nullptr; + } + + return ntHeaders; + } + + FARPROC* getProcAddressFromIat(HMODULE module, const char* procName) + { + PIMAGE_NT_HEADERS ntHeaders = getImageNtHeaders(module); + if (!ntHeaders) + { + return nullptr; + } + + char* moduleBase = reinterpret_cast(module); + PIMAGE_IMPORT_DESCRIPTOR importDesc = reinterpret_cast(moduleBase + + ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); + + for (PIMAGE_IMPORT_DESCRIPTOR desc = importDesc; + 0 != desc->Characteristics && 0xFFFF != desc->Name; + ++desc) + { + auto thunk = reinterpret_cast(moduleBase + desc->FirstThunk); + auto origThunk = reinterpret_cast(moduleBase + desc->OriginalFirstThunk); + while (0 != thunk->u1.AddressOfData && 0 != origThunk->u1.AddressOfData) + { + auto origImport = reinterpret_cast( + moduleBase + origThunk->u1.AddressOfData); + + if (0 == lstrcmp(origImport->Name, procName)) + { + return reinterpret_cast(&thunk->u1.Function); + } + + ++thunk; + ++origThunk; + } + } + + return nullptr; + } + + void hookIatFunction(HMODULE module, const char* funcName, void* newFunc) + { + FARPROC* func = getProcAddressFromIat(module, funcName); + if (func) + { + DWORD oldProtect = 0; + VirtualProtect(func, sizeof(func), PAGE_READWRITE, &oldProtect); + *func = static_cast(newFunc); + DWORD dummy = 0; + VirtualProtect(func, sizeof(func), oldProtect, &dummy); + } + } + + HMODULE hookOrigModule(const char* name) + { + char path[MAX_PATH]; + path[0] = 0; + GetSystemDirectory(path, sizeof(path)); + StringCbCat(path, sizeof(path), "\\"); + StringCbCat(path, sizeof(path), name); + HMODULE module = LoadLibrary(path); + if (module) + { + hookIatFunction(module, "D3DKMTQueryAdapterInfo", queryAdapterInfo); + } + return module; + } + + NTSTATUS APIENTRY queryAdapterInfo(const D3DKMT_QUERYADAPTERINFO* pData) + { + if (pData && KMTQAITYPE_UMDRIVERNAME == pData->Type && + KMTUMDVERSION_DX9 == static_cast(pData->pPrivateDriverData)->Version) + { + return STATUS_INVALID_PARAMETER; + } + return D3DKMTQueryAdapterInfo(pData); + } +} + +FARPROC getOrigFunc(const char* name) +{ + static HMODULE origModule = hookOrigModule(g_moduleName); + return GetProcAddress(origModule, name); +} + +BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD /*ul_reason_for_call*/, LPVOID /*lpReserved*/) +{ + return TRUE; +} diff --git a/ForceD3D9On12/ForceD3D9On12.h b/ForceD3D9On12/ForceD3D9On12.h new file mode 100644 index 0000000..6735244 --- /dev/null +++ b/ForceD3D9On12/ForceD3D9On12.h @@ -0,0 +1,16 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN + +#include + +extern const char* const g_moduleName; + +FARPROC getOrigFunc(const char* name); + +#define CREATE_WRAPPER_FUNC(name) \ + namespace { static FARPROC g_orig##name = getOrigFunc(#name); } \ + extern "C" __declspec(dllexport) void name() \ + { \ + g_orig##name(); \ + } diff --git a/ForceD3D9On12/ForceD3D9On12.vcxproj b/ForceD3D9On12/ForceD3D9On12.vcxproj new file mode 100644 index 0000000..05f989b --- /dev/null +++ b/ForceD3D9On12/ForceD3D9On12.vcxproj @@ -0,0 +1,87 @@ + + + + + Release + Win32 + + + Release + x64 + + + + 16.0 + Win32Proj + {073aef6c-ea51-4136-8f64-2b22416f9c7f} + ForceD3D9On12 + 10.0 + + + + StaticLibrary + v143 + + + StaticLibrary + v143 + + + + + + + + + + + + + + + false + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\Int\$(Configuration)\$(PlatformTarget)\ + + + false + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\Int\$(Configuration)\$(PlatformTarget)\ + + + + + + true + true + true + + + MultiThreaded + OldStyle + + + + + + + true + true + true + + + MultiThreaded + OldStyle + + + + + + + + + + + + + diff --git a/ForceD3D9On12/ForceD3D9On12.vcxproj.filters b/ForceD3D9On12/ForceD3D9On12.vcxproj.filters new file mode 100644 index 0000000..598ca3b --- /dev/null +++ b/ForceD3D9On12/ForceD3D9On12.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/ForceD3D9On12/Version.h b/ForceD3D9On12/Version.h new file mode 100644 index 0000000..81ab9ac --- /dev/null +++ b/ForceD3D9On12/Version.h @@ -0,0 +1,2 @@ +#define VERSION_NUMBER 1,0,0,0 +#define VERSION_STRING "1.0.0" diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..5aec258 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,10 @@ +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a13b650 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# ForceD3D9On12 + +### Introduction +This project provides DLL wrappers for the DirectX 1-9 graphics components. Its purpose is to disable the use of the Direct3D 9 user-mode display driver provided by GPU vendors. This forces the runtimes to use [D3D9On12](https://github.com/microsoft/D3D9On12) instead. + +It may fix some driver-specific issues, and it may introduce a lot of others. Don't be surprised if many games have graphics or performance issues, or just plain crash with this. + +D3D9On12 is a completely independent project. No support will be provided for it here. + +### Requirements +- Windows 10 or 11 +- DirectX 12 compatible GPU (feature level 11_0 or better) + +### Installation + +Download the latest binary release from the [releases](https://github.com/narzoul/ForceD3D9On12/releases) page. Unzip the file and copy the extracted DLLs from either the x86 folder (for 32-bit applications) or the x64 folder (for 64-bit applications) to the target application's install directory, next to where the main executable (.exe) file is located. + +[D3D9On12](https://github.com/microsoft/D3D9On12) should be preinstalled on Windows 10/11. Alternatively, it could be built from source following the instructions on its page. + +### Uninstallation +Delete the previously copied DLLs from the application's directory. + +### Development +ForceD3D9On12 is developed in C++ using Microsoft Visual Studio Community 2022. + +### License +Licensed under the [BSD Zero Clause License](LICENSE.txt). diff --git a/d3d8/d3d8.cpp b/d3d8/d3d8.cpp new file mode 100644 index 0000000..b07d4b7 --- /dev/null +++ b/d3d8/d3d8.cpp @@ -0,0 +1,8 @@ +#include "../ForceD3D9On12/ForceD3D9On12.h" + +const char* const g_moduleName = "d3d8.dll"; + +CREATE_WRAPPER_FUNC(DebugSetMute) +CREATE_WRAPPER_FUNC(Direct3DCreate8) +CREATE_WRAPPER_FUNC(ValidatePixelShader) +CREATE_WRAPPER_FUNC(ValidateVertexShader) diff --git a/d3d8/d3d8.rc b/d3d8/d3d8.rc new file mode 100644 index 0000000..d3244df --- /dev/null +++ b/d3d8/d3d8.rc @@ -0,0 +1,33 @@ +#include "../ForceD3D9On12/Version.h" + +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VERSION_NUMBER +PRODUCTVERSION VERSION_NUMBER +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +{ + BLOCK "StringFileInfo" + { + BLOCK "04090000" + { + VALUE "CompanyName", "" + VALUE "FileDescription", "https://github.com/narzoul/ForceD3D9On12" + VALUE "FileVersion", VERSION_STRING + VALUE "InternalName", "d3d8.dll" + VALUE "LegalCopyright", "BSD Zero Clause License" + VALUE "OriginalFilename", "d3d8.dll" + VALUE "ProductName", "ForceD3D9On12 Direct3D 8 wrapper" + VALUE "ProductVersion", VERSION_STRING + } + } + + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 0 + } +} diff --git a/d3d8/d3d8.vcxproj b/d3d8/d3d8.vcxproj new file mode 100644 index 0000000..dcd82d5 --- /dev/null +++ b/d3d8/d3d8.vcxproj @@ -0,0 +1,61 @@ + + + + + Release + Win32 + + + + 16.0 + Win32Proj + {2c2f4c45-1aab-4e28-b176-fc27767f55d1} + d3d8 + 10.0 + + + + DynamicLibrary + v143 + + + + + + + + + + + + $(SolutionDir)$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\$(ProjectName)\ + false + + + + Windows + true + true + $(IntDir)$(TargetName).lib + $(IntDir)$(TargetName).pdb + + + MultiThreaded + + + + + + + + {073aef6c-ea51-4136-8f64-2b22416f9c7f} + + + + + + + + + diff --git a/d3d8/d3d8.vcxproj.filters b/d3d8/d3d8.vcxproj.filters new file mode 100644 index 0000000..831108e --- /dev/null +++ b/d3d8/d3d8.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/d3d9/d3d9.cpp b/d3d9/d3d9.cpp new file mode 100644 index 0000000..35dbc8a --- /dev/null +++ b/d3d9/d3d9.cpp @@ -0,0 +1,20 @@ +#include "../ForceD3D9On12/ForceD3D9On12.h" + +const char* const g_moduleName = "d3d9.dll"; + +CREATE_WRAPPER_FUNC(D3DPERF_BeginEvent) +CREATE_WRAPPER_FUNC(D3DPERF_EndEvent) +CREATE_WRAPPER_FUNC(D3DPERF_GetStatus) +CREATE_WRAPPER_FUNC(D3DPERF_QueryRepeatFrame) +CREATE_WRAPPER_FUNC(D3DPERF_SetMarker) +CREATE_WRAPPER_FUNC(D3DPERF_SetOptions) +CREATE_WRAPPER_FUNC(D3DPERF_SetRegion) +CREATE_WRAPPER_FUNC(DebugSetLevel) +CREATE_WRAPPER_FUNC(DebugSetMute) +CREATE_WRAPPER_FUNC(Direct3DCreate9) +CREATE_WRAPPER_FUNC(Direct3DCreate9Ex) +CREATE_WRAPPER_FUNC(Direct3DCreate9On12) +CREATE_WRAPPER_FUNC(Direct3DCreate9On12Ex) +CREATE_WRAPPER_FUNC(Direct3DShaderValidatorCreate9) +CREATE_WRAPPER_FUNC(PSGPError) +CREATE_WRAPPER_FUNC(PSGPSampleTexture) diff --git a/d3d9/d3d9.rc b/d3d9/d3d9.rc new file mode 100644 index 0000000..90d3519 --- /dev/null +++ b/d3d9/d3d9.rc @@ -0,0 +1,33 @@ +#include "../ForceD3D9On12/Version.h" + +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VERSION_NUMBER +PRODUCTVERSION VERSION_NUMBER +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +{ + BLOCK "StringFileInfo" + { + BLOCK "04090000" + { + VALUE "CompanyName", "" + VALUE "FileDescription", "https://github.com/narzoul/ForceD3D9On12" + VALUE "FileVersion", VERSION_STRING + VALUE "InternalName", "d3d9.dll" + VALUE "LegalCopyright", "BSD Zero Clause License" + VALUE "OriginalFilename", "d3d9.dll" + VALUE "ProductName", "ForceD3D9On12 Direct3D 9 wrapper" + VALUE "ProductVersion", VERSION_STRING + } + } + + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 0 + } +} diff --git a/d3d9/d3d9.vcxproj b/d3d9/d3d9.vcxproj new file mode 100644 index 0000000..7268b5a --- /dev/null +++ b/d3d9/d3d9.vcxproj @@ -0,0 +1,89 @@ + + + + + Release + Win32 + + + Release + x64 + + + + 16.0 + Win32Proj + {af3533c7-9b68-4f05-982e-41e1f03b6ab8} + d3d9 + 10.0 + + + + DynamicLibrary + v143 + + + DynamicLibrary + v143 + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\$(ProjectName)\ + false + + + $(SolutionDir)$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\$(ProjectName)\ + false + + + + Windows + true + true + $(IntDir)$(TargetName).lib + $(IntDir)$(TargetName).pdb + + + MultiThreaded + + + + + Windows + true + true + $(IntDir)$(TargetName).lib + $(IntDir)$(TargetName).pdb + + + MultiThreaded + + + + + + + + {073aef6c-ea51-4136-8f64-2b22416f9c7f} + + + + + + + + + diff --git a/d3d9/d3d9.vcxproj.filters b/d3d9/d3d9.vcxproj.filters new file mode 100644 index 0000000..eb2dbf7 --- /dev/null +++ b/d3d9/d3d9.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/ddraw/ddraw.cpp b/ddraw/ddraw.cpp new file mode 100644 index 0000000..c292cbc --- /dev/null +++ b/ddraw/ddraw.cpp @@ -0,0 +1,26 @@ +#include "../ForceD3D9On12/ForceD3D9On12.h" + +const char* const g_moduleName = "ddraw.dll"; + +CREATE_WRAPPER_FUNC(AcquireDDThreadLock) +CREATE_WRAPPER_FUNC(CompleteCreateSysmemSurface) +CREATE_WRAPPER_FUNC(D3DParseUnknownCommand) +CREATE_WRAPPER_FUNC(DDGetAttachedSurfaceLcl) +CREATE_WRAPPER_FUNC(DDInternalLock) +CREATE_WRAPPER_FUNC(DDInternalUnlock) +CREATE_WRAPPER_FUNC(DSoundHelp) +CREATE_WRAPPER_FUNC(DirectDrawCreate) +CREATE_WRAPPER_FUNC(DirectDrawCreateClipper) +CREATE_WRAPPER_FUNC(DirectDrawCreateEx) +CREATE_WRAPPER_FUNC(DirectDrawEnumerateA) +CREATE_WRAPPER_FUNC(DirectDrawEnumerateExA) +CREATE_WRAPPER_FUNC(DirectDrawEnumerateExW) +CREATE_WRAPPER_FUNC(DirectDrawEnumerateW) +CREATE_WRAPPER_FUNC(DllCanUnloadNow) +CREATE_WRAPPER_FUNC(DllGetClassObject) +CREATE_WRAPPER_FUNC(GetDDSurfaceLocal) +CREATE_WRAPPER_FUNC(GetOLEThunkData) +CREATE_WRAPPER_FUNC(GetSurfaceFromDC) +CREATE_WRAPPER_FUNC(RegisterSpecialCase) +CREATE_WRAPPER_FUNC(ReleaseDDThreadLock) +CREATE_WRAPPER_FUNC(SetAppCompatData) diff --git a/ddraw/ddraw.rc b/ddraw/ddraw.rc new file mode 100644 index 0000000..7761a6b --- /dev/null +++ b/ddraw/ddraw.rc @@ -0,0 +1,33 @@ +#include "../ForceD3D9On12/Version.h" + +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VERSION_NUMBER +PRODUCTVERSION VERSION_NUMBER +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +{ + BLOCK "StringFileInfo" + { + BLOCK "04090000" + { + VALUE "CompanyName", "" + VALUE "FileDescription", "https://github.com/narzoul/ForceD3D9On12" + VALUE "FileVersion", VERSION_STRING + VALUE "InternalName", "ddraw.dll" + VALUE "LegalCopyright", "BSD Zero Clause License" + VALUE "OriginalFilename", "ddraw.dll" + VALUE "ProductName", "ForceD3D9On12 DirectDraw wrapper" + VALUE "ProductVersion", VERSION_STRING + } + } + + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 0 + } +} diff --git a/ddraw/ddraw.vcxproj b/ddraw/ddraw.vcxproj new file mode 100644 index 0000000..f4921f3 --- /dev/null +++ b/ddraw/ddraw.vcxproj @@ -0,0 +1,61 @@ + + + + + Release + Win32 + + + + 16.0 + Win32Proj + {af0fa384-a765-469b-873c-b751d11f1c96} + ddraw + 10.0 + + + + DynamicLibrary + v143 + + + + + + + + + + + + $(SolutionDir)$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\$(ProjectName)\ + false + + + + Windows + true + true + $(IntDir)$(TargetName).lib + $(IntDir)$(TargetName).pdb + + + MultiThreaded + + + + + + + + {073aef6c-ea51-4136-8f64-2b22416f9c7f} + + + + + + + + + diff --git a/ddraw/ddraw.vcxproj.filters b/ddraw/ddraw.vcxproj.filters new file mode 100644 index 0000000..c54d7d8 --- /dev/null +++ b/ddraw/ddraw.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Resource Files + + + \ No newline at end of file