From 5aa45a61161c4d60dd595e6aec1808014db5ffb0 Mon Sep 17 00:00:00 2001 From: Denis Maltsev Date: Sun, 12 May 2019 19:14:05 +0400 Subject: [PATCH] Initial commit --- .gitignore | 373 ++++++++++++++++++++++-- FakeDirect3D9.cpp | 106 +++++++ FakeDirect3D9.h | 33 +++ FakeDirect3DDevice9.cpp | 616 ++++++++++++++++++++++++++++++++++++++++ FakeDirect3DDevice9.h | 135 +++++++++ README.md | 21 +- d3d9.def | 18 ++ d3d9.sln | 25 ++ d3d9.vcxproj | 170 +++++++++++ d3d9.vcxproj.filters | 37 +++ main.cpp | 86 ++++++ 11 files changed, 1590 insertions(+), 30 deletions(-) create mode 100644 FakeDirect3D9.cpp create mode 100644 FakeDirect3D9.h create mode 100644 FakeDirect3DDevice9.cpp create mode 100644 FakeDirect3DDevice9.h create mode 100644 d3d9.def create mode 100644 d3d9.sln create mode 100644 d3d9.vcxproj create mode 100644 d3d9.vcxproj.filters create mode 100644 main.cpp diff --git a/.gitignore b/.gitignore index 259148f..b248083 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,349 @@ -# Prerequisites -*.d +## 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 -# Compiled Object files -*.slo -*.lo -*.o -*.obj +# 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/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# 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 -# Precompiled Headers -*.gch +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# 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 + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# 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 -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ diff --git a/FakeDirect3D9.cpp b/FakeDirect3D9.cpp new file mode 100644 index 0000000..da87a37 --- /dev/null +++ b/FakeDirect3D9.cpp @@ -0,0 +1,106 @@ +#include "FakeDirect3D9.h" +#include "FakeDirect3DDevice9.h" + +FakeDirect3D9::FakeDirect3D9(IDirect3D9 *pOriginal) : + m_pIDirect3D9(pOriginal) +{ +} + +FakeDirect3D9::~FakeDirect3D9(void) +{ +} + +HRESULT FakeDirect3D9::QueryInterface(REFIID riid, void** ppvObj) +{ + *ppvObj = NULL; + HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj); + if (SUCCEEDED(hRes)) + *ppvObj = this; + return hRes; +} + +ULONG FakeDirect3D9::AddRef(void) +{ + return(m_pIDirect3D9->AddRef()); +} + +ULONG FakeDirect3D9::Release(void) +{ + ULONG count = m_pIDirect3D9->Release(); + if (count < 1) + delete(this); + return(count); +} + +HRESULT FakeDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) +{ + return(m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction)); +} + +UINT FakeDirect3D9::GetAdapterCount(void) +{ + return(m_pIDirect3D9->GetAdapterCount()); +} + +HRESULT FakeDirect3D9::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) +{ + return(m_pIDirect3D9->GetAdapterIdentifier(Adapter,Flags,pIdentifier)); +} + +UINT FakeDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) +{ + return(m_pIDirect3D9->GetAdapterModeCount(Adapter, Format)); +} + +HRESULT FakeDirect3D9::EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) +{ + return(m_pIDirect3D9->EnumAdapterModes(Adapter,Format,Mode,pMode)); +} + +HRESULT FakeDirect3D9::GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) +{ + return(m_pIDirect3D9->GetAdapterDisplayMode(Adapter,pMode)); +} + +HRESULT FakeDirect3D9::CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) +{ + return(m_pIDirect3D9->CheckDeviceType(iAdapter,DevType,DisplayFormat,BackBufferFormat,bWindowed)); +} + +HRESULT FakeDirect3D9::CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) +{ + return(m_pIDirect3D9->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat)); +} + +HRESULT FakeDirect3D9::CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) +{ + return(m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType,pQualityLevels)); +} + +HRESULT FakeDirect3D9::CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) +{ + return(m_pIDirect3D9->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat)); +} + +HRESULT FakeDirect3D9::CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat) +{ + return(m_pIDirect3D9->CheckDeviceFormatConversion(Adapter,DeviceType,SourceFormat,TargetFormat)); +} + +HRESULT FakeDirect3D9::GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) +{ + return(m_pIDirect3D9->GetDeviceCaps(Adapter,DeviceType,pCaps)); +} + +HMONITOR FakeDirect3D9::GetAdapterMonitor(UINT Adapter) +{ + return(m_pIDirect3D9->GetAdapterMonitor(Adapter)); +} + +HRESULT FakeDirect3D9::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) +{ + pPresentationParameters->PresentationInterval = D3DPRESENT_INTERVAL_ONE; // force VSYNC + HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); + *ppReturnedDeviceInterface = new FakeDirect3DDevice9(*ppReturnedDeviceInterface); + return(hres); +} diff --git a/FakeDirect3D9.h b/FakeDirect3D9.h new file mode 100644 index 0000000..daeb56a --- /dev/null +++ b/FakeDirect3D9.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +class FakeDirect3D9 : public IDirect3D9 +{ +public: + FakeDirect3D9(IDirect3D9 *pOriginal); + virtual ~FakeDirect3D9(void); + + // The original DX9 function definitions + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObj); + virtual COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE AddRef(void); + virtual COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE Release(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE RegisterSoftwareDevice(void* pInitializeFunction); + virtual COM_DECLSPEC_NOTHROW UINT STDMETHODCALLTYPE GetAdapterCount(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) ; + virtual COM_DECLSPEC_NOTHROW UINT STDMETHODCALLTYPE GetAdapterModeCount(UINT Adapter, D3DFORMAT Format); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) ; + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) ; + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) ; + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) ; + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) ; + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) ; + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) ; + virtual COM_DECLSPEC_NOTHROW HMONITOR STDMETHODCALLTYPE GetAdapterMonitor(UINT Adapter) ; + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) ; + // The original DX9 function definitions + +private: + IDirect3D9 *m_pIDirect3D9; +}; diff --git a/FakeDirect3DDevice9.cpp b/FakeDirect3DDevice9.cpp new file mode 100644 index 0000000..5e5def3 --- /dev/null +++ b/FakeDirect3DDevice9.cpp @@ -0,0 +1,616 @@ +#include "FakeDirect3DDevice9.h" + +FakeDirect3DDevice9::FakeDirect3DDevice9(IDirect3DDevice9* pOriginal) : + m_pIDirect3DDevice9(pOriginal) +{ +} + +FakeDirect3DDevice9::~FakeDirect3DDevice9(void) +{ +} + +HRESULT FakeDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) +{ + *ppvObj = NULL; + HRESULT hRes = m_pIDirect3DDevice9->QueryInterface(riid, ppvObj); + if (SUCCEEDED(hRes)) + *ppvObj = this; + return(hRes); +} + +ULONG FakeDirect3DDevice9::AddRef(void) +{ + return(m_pIDirect3DDevice9->AddRef()); +} + +ULONG FakeDirect3DDevice9::Release(void) +{ + ULONG count = m_pIDirect3DDevice9->Release(); + if (count < 1) + delete(this); // destructor will be called automatically + return(count); +} + +HRESULT FakeDirect3DDevice9::TestCooperativeLevel(void) +{ + return(m_pIDirect3DDevice9->TestCooperativeLevel()); +} + +UINT FakeDirect3DDevice9::GetAvailableTextureMem(void) +{ + UINT ret = m_pIDirect3DDevice9->GetAvailableTextureMem(); + if (ret > (UINT)INT_MAX) + ret = (UINT)INT_MAX; + return(ret); + // return(m_pIDirect3DDevice9->GetAvailableTextureMem()); +} + +HRESULT FakeDirect3DDevice9::EvictManagedResources(void) +{ + return(m_pIDirect3DDevice9->EvictManagedResources()); +} + +HRESULT FakeDirect3DDevice9::GetDirect3D(IDirect3D9** ppD3D9) +{ + return(m_pIDirect3DDevice9->GetDirect3D(ppD3D9)); +} + +HRESULT FakeDirect3DDevice9::GetDeviceCaps(D3DCAPS9* pCaps) +{ + return(m_pIDirect3DDevice9->GetDeviceCaps(pCaps)); +} + +HRESULT FakeDirect3DDevice9::GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) +{ + return(m_pIDirect3DDevice9->GetDisplayMode(iSwapChain, pMode)); +} + +HRESULT FakeDirect3DDevice9::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters) +{ + return(m_pIDirect3DDevice9->GetCreationParameters(pParameters)); +} + +HRESULT FakeDirect3DDevice9::SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) +{ + return(m_pIDirect3DDevice9->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap)); +} + +void FakeDirect3DDevice9::SetCursorPosition(int X, int Y, DWORD Flags) +{ + return(m_pIDirect3DDevice9->SetCursorPosition(X, Y, Flags)); +} + +BOOL FakeDirect3DDevice9::ShowCursor(BOOL bShow) +{ + return(m_pIDirect3DDevice9->ShowCursor(bShow)); +} + +HRESULT FakeDirect3DDevice9::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) +{ + return(m_pIDirect3DDevice9->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain)); +} + +HRESULT FakeDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) +{ + return(m_pIDirect3DDevice9->GetSwapChain(iSwapChain, pSwapChain)); +} + +UINT FakeDirect3DDevice9::GetNumberOfSwapChains(void) +{ + return(m_pIDirect3DDevice9->GetNumberOfSwapChains()); +} + +HRESULT FakeDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) +{ + return(m_pIDirect3DDevice9->Reset(pPresentationParameters)); +} + +HRESULT FakeDirect3DDevice9::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) +{ + return (m_pIDirect3DDevice9->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion)); +} + +HRESULT FakeDirect3DDevice9::GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) +{ + return(m_pIDirect3DDevice9->GetBackBuffer(iSwapChain, iBackBuffer, Type, ppBackBuffer)); +} + +HRESULT FakeDirect3DDevice9::GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) +{ + return(m_pIDirect3DDevice9->GetRasterStatus(iSwapChain, pRasterStatus)); +} + +HRESULT FakeDirect3DDevice9::SetDialogBoxMode(BOOL bEnableDialogs) +{ + return(m_pIDirect3DDevice9->SetDialogBoxMode(bEnableDialogs)); +} + +void FakeDirect3DDevice9::SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) +{ + return(m_pIDirect3DDevice9->SetGammaRamp(iSwapChain, Flags, pRamp)); +} + +void FakeDirect3DDevice9::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) +{ + return(m_pIDirect3DDevice9->GetGammaRamp(iSwapChain, pRamp)); +} + +HRESULT FakeDirect3DDevice9::CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateVolumeTexture(Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateCubeTexture(EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateRenderTarget(Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateDepthStencilSurface(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) +{ + return(m_pIDirect3DDevice9->UpdateSurface(pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint)); +} + +HRESULT FakeDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) +{ + return(m_pIDirect3DDevice9->UpdateTexture(pSourceTexture, pDestinationTexture)); +} + +HRESULT FakeDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) +{ + return(m_pIDirect3DDevice9->GetRenderTargetData(pRenderTarget, pDestSurface)); +} + +HRESULT FakeDirect3DDevice9::GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) +{ + return(m_pIDirect3DDevice9->GetFrontBufferData(iSwapChain, pDestSurface)); +} + +HRESULT FakeDirect3DDevice9::StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) +{ + return(m_pIDirect3DDevice9->StretchRect(pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter)); +} + +HRESULT FakeDirect3DDevice9::ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) +{ + return(m_pIDirect3DDevice9->ColorFill(pSurface, pRect, color)); +} + +HRESULT FakeDirect3DDevice9::CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) +{ + return(m_pIDirect3DDevice9->CreateOffscreenPlainSurface(Width, Height, Format, Pool, ppSurface, pSharedHandle)); +} + +HRESULT FakeDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) +{ + return(m_pIDirect3DDevice9->SetRenderTarget(RenderTargetIndex, pRenderTarget)); +} + +HRESULT FakeDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) +{ + return(m_pIDirect3DDevice9->GetRenderTarget(RenderTargetIndex, ppRenderTarget)); +} + +HRESULT FakeDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) +{ + return(m_pIDirect3DDevice9->SetDepthStencilSurface(pNewZStencil)); +} + +HRESULT FakeDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) +{ + return(m_pIDirect3DDevice9->GetDepthStencilSurface(ppZStencilSurface)); +} + +HRESULT FakeDirect3DDevice9::BeginScene(void) +{ + return(m_pIDirect3DDevice9->BeginScene()); +} + +HRESULT FakeDirect3DDevice9::EndScene(void) +{ + return(m_pIDirect3DDevice9->EndScene()); +} + +HRESULT FakeDirect3DDevice9::Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) +{ + return(m_pIDirect3DDevice9->Clear(Count, pRects, Flags, Color, Z, Stencil)); +} + +HRESULT FakeDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) +{ + return(m_pIDirect3DDevice9->SetTransform(State, pMatrix)); +} + +HRESULT FakeDirect3DDevice9::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) +{ + return(m_pIDirect3DDevice9->GetTransform(State, pMatrix)); +} + +HRESULT FakeDirect3DDevice9::MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) +{ + return(m_pIDirect3DDevice9->MultiplyTransform(State, pMatrix)); +} + +HRESULT FakeDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport) +{ + return(m_pIDirect3DDevice9->SetViewport(pViewport)); +} + +HRESULT FakeDirect3DDevice9::GetViewport(D3DVIEWPORT9* pViewport) +{ + return(m_pIDirect3DDevice9->GetViewport(pViewport)); +} + +HRESULT FakeDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial) +{ + return(m_pIDirect3DDevice9->SetMaterial(pMaterial)); +} + +HRESULT FakeDirect3DDevice9::GetMaterial(D3DMATERIAL9* pMaterial) +{ + return(m_pIDirect3DDevice9->GetMaterial(pMaterial)); +} + +HRESULT FakeDirect3DDevice9::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) +{ + return(m_pIDirect3DDevice9->SetLight(Index, pLight)); +} + +HRESULT FakeDirect3DDevice9::GetLight(DWORD Index, D3DLIGHT9* pLight) +{ + return(m_pIDirect3DDevice9->GetLight(Index, pLight)); +} + +HRESULT FakeDirect3DDevice9::LightEnable(DWORD Index, BOOL Enable) +{ + return(m_pIDirect3DDevice9->LightEnable(Index, Enable)); +} + +HRESULT FakeDirect3DDevice9::GetLightEnable(DWORD Index, BOOL* pEnable) +{ + return(m_pIDirect3DDevice9->GetLightEnable(Index, pEnable)); +} + +HRESULT FakeDirect3DDevice9::SetClipPlane(DWORD Index, CONST float* pPlane) +{ + return(m_pIDirect3DDevice9->SetClipPlane(Index, pPlane)); +} + +HRESULT FakeDirect3DDevice9::GetClipPlane(DWORD Index, float* pPlane) +{ + return(m_pIDirect3DDevice9->GetClipPlane(Index, pPlane)); +} + +HRESULT FakeDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) +{ + return(m_pIDirect3DDevice9->SetRenderState(State, Value)); +} + +HRESULT FakeDirect3DDevice9::GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) +{ + return(m_pIDirect3DDevice9->GetRenderState(State, pValue)); +} + +HRESULT FakeDirect3DDevice9::CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) +{ + return(m_pIDirect3DDevice9->CreateStateBlock(Type, ppSB)); +} + +HRESULT FakeDirect3DDevice9::BeginStateBlock(void) +{ + return(m_pIDirect3DDevice9->BeginStateBlock()); +} + +HRESULT FakeDirect3DDevice9::EndStateBlock(IDirect3DStateBlock9** ppSB) +{ + return(m_pIDirect3DDevice9->EndStateBlock(ppSB)); +} + +HRESULT FakeDirect3DDevice9::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) +{ + return(m_pIDirect3DDevice9->SetClipStatus(pClipStatus)); +} + +HRESULT FakeDirect3DDevice9::GetClipStatus(D3DCLIPSTATUS9* pClipStatus) +{ + return(m_pIDirect3DDevice9->GetClipStatus(pClipStatus)); +} + +HRESULT FakeDirect3DDevice9::GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) +{ + return(m_pIDirect3DDevice9->GetTexture(Stage, ppTexture)); +} + +HRESULT FakeDirect3DDevice9::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) +{ + return(m_pIDirect3DDevice9->SetTexture(Stage, pTexture)); +} + +HRESULT FakeDirect3DDevice9::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) +{ + return(m_pIDirect3DDevice9->GetTextureStageState(Stage, Type, pValue)); +} + +HRESULT FakeDirect3DDevice9::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) +{ + return(m_pIDirect3DDevice9->SetTextureStageState(Stage, Type, Value)); +} + +HRESULT FakeDirect3DDevice9::GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) +{ + return(m_pIDirect3DDevice9->GetSamplerState(Sampler, Type, pValue)); +} + +HRESULT FakeDirect3DDevice9::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) +{ + return(m_pIDirect3DDevice9->SetSamplerState(Sampler, Type, Value)); +} + +HRESULT FakeDirect3DDevice9::ValidateDevice(DWORD* pNumPasses) +{ + return(m_pIDirect3DDevice9->ValidateDevice(pNumPasses)); +} + +HRESULT FakeDirect3DDevice9::SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) +{ + return(m_pIDirect3DDevice9->SetPaletteEntries(PaletteNumber, pEntries)); +} + +HRESULT FakeDirect3DDevice9::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) +{ + return(m_pIDirect3DDevice9->GetPaletteEntries(PaletteNumber, pEntries)); +} + +HRESULT FakeDirect3DDevice9::SetCurrentTexturePalette(UINT PaletteNumber) +{ + return(m_pIDirect3DDevice9->SetCurrentTexturePalette(PaletteNumber)); +} + +HRESULT FakeDirect3DDevice9::GetCurrentTexturePalette(UINT* PaletteNumber) +{ + return(m_pIDirect3DDevice9->GetCurrentTexturePalette(PaletteNumber)); +} + +HRESULT FakeDirect3DDevice9::SetScissorRect(CONST RECT* pRect) +{ + return(m_pIDirect3DDevice9->SetScissorRect(pRect)); +} + +HRESULT FakeDirect3DDevice9::GetScissorRect(RECT* pRect) +{ + return(m_pIDirect3DDevice9->GetScissorRect(pRect)); +} + +HRESULT FakeDirect3DDevice9::SetSoftwareVertexProcessing(BOOL bSoftware) +{ + return(m_pIDirect3DDevice9->SetSoftwareVertexProcessing(bSoftware)); +} + +BOOL FakeDirect3DDevice9::GetSoftwareVertexProcessing(void) +{ + return(m_pIDirect3DDevice9->GetSoftwareVertexProcessing()); +} + +HRESULT FakeDirect3DDevice9::SetNPatchMode(float nSegments) +{ + return(m_pIDirect3DDevice9->SetNPatchMode(nSegments)); +} + +float FakeDirect3DDevice9::GetNPatchMode(void) +{ + return(m_pIDirect3DDevice9->GetNPatchMode()); +} + +HRESULT FakeDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) +{ + return(m_pIDirect3DDevice9->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount)); +} + +HRESULT FakeDirect3DDevice9::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) +{ + return(m_pIDirect3DDevice9->DrawIndexedPrimitive(PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount)); +} + +HRESULT FakeDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) +{ + return(m_pIDirect3DDevice9->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride)); +} + +HRESULT FakeDirect3DDevice9::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) +{ + return(m_pIDirect3DDevice9->DrawIndexedPrimitiveUP(PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride)); +} + +HRESULT FakeDirect3DDevice9::ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) +{ + return(m_pIDirect3DDevice9->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags)); +} + +HRESULT FakeDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) +{ + return(m_pIDirect3DDevice9->CreateVertexDeclaration(pVertexElements, ppDecl)); +} + +HRESULT FakeDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) +{ + return(m_pIDirect3DDevice9->SetVertexDeclaration(pDecl)); +} + +HRESULT FakeDirect3DDevice9::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) +{ + return(m_pIDirect3DDevice9->GetVertexDeclaration(ppDecl)); +} + +HRESULT FakeDirect3DDevice9::SetFVF(DWORD FVF) +{ + return(m_pIDirect3DDevice9->SetFVF(FVF)); +} + +HRESULT FakeDirect3DDevice9::GetFVF(DWORD* pFVF) +{ + return(m_pIDirect3DDevice9->GetFVF(pFVF)); +} + +HRESULT FakeDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) +{ + return(m_pIDirect3DDevice9->CreateVertexShader(pFunction, ppShader)); +} + +HRESULT FakeDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader) +{ + return(m_pIDirect3DDevice9->SetVertexShader(pShader)); +} + +HRESULT FakeDirect3DDevice9::GetVertexShader(IDirect3DVertexShader9** ppShader) +{ + return(m_pIDirect3DDevice9->GetVertexShader(ppShader)); +} + +HRESULT FakeDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount)); +} + +HRESULT FakeDirect3DDevice9::GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->GetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount)); +} + +HRESULT FakeDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->SetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount)); +} + +HRESULT FakeDirect3DDevice9::GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->GetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount)); +} + +HRESULT FakeDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) +{ + return(m_pIDirect3DDevice9->SetVertexShaderConstantB(StartRegister, pConstantData, BoolCount)); +} + +HRESULT FakeDirect3DDevice9::GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) +{ + return(m_pIDirect3DDevice9->GetVertexShaderConstantB(StartRegister, pConstantData, BoolCount)); +} + +HRESULT FakeDirect3DDevice9::SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) +{ + return(m_pIDirect3DDevice9->SetStreamSource(StreamNumber, pStreamData, OffsetInBytes, Stride)); +} + +HRESULT FakeDirect3DDevice9::GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) +{ + return(m_pIDirect3DDevice9->GetStreamSource(StreamNumber, ppStreamData, OffsetInBytes, pStride)); +} + +HRESULT FakeDirect3DDevice9::SetStreamSourceFreq(UINT StreamNumber, UINT Divider) +{ + return(m_pIDirect3DDevice9->SetStreamSourceFreq(StreamNumber, Divider)); +} + +HRESULT FakeDirect3DDevice9::GetStreamSourceFreq(UINT StreamNumber, UINT* Divider) +{ + return(m_pIDirect3DDevice9->GetStreamSourceFreq(StreamNumber, Divider)); +} + +HRESULT FakeDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData) +{ + return(m_pIDirect3DDevice9->SetIndices(pIndexData)); +} + +HRESULT FakeDirect3DDevice9::GetIndices(IDirect3DIndexBuffer9** ppIndexData) +{ + return(m_pIDirect3DDevice9->GetIndices(ppIndexData)); +} + +HRESULT FakeDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) +{ + return(m_pIDirect3DDevice9->CreatePixelShader(pFunction, ppShader)); +} + +HRESULT FakeDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader) +{ + return(m_pIDirect3DDevice9->SetPixelShader(pShader)); +} + +HRESULT FakeDirect3DDevice9::GetPixelShader(IDirect3DPixelShader9** ppShader) +{ + return(m_pIDirect3DDevice9->GetPixelShader(ppShader)); +} + +HRESULT FakeDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->SetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount)); +} + +HRESULT FakeDirect3DDevice9::GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) +{ + return(m_pIDirect3DDevice9->GetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount)); +} + +HRESULT FakeDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->SetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount)); +} + +HRESULT FakeDirect3DDevice9::GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) +{ + return(m_pIDirect3DDevice9->GetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount)); +} + +HRESULT FakeDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) +{ + return(m_pIDirect3DDevice9->SetPixelShaderConstantB(StartRegister, pConstantData, BoolCount)); +} + +HRESULT FakeDirect3DDevice9::GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) +{ + return(m_pIDirect3DDevice9->GetPixelShaderConstantB(StartRegister, pConstantData, BoolCount)); +} + +HRESULT FakeDirect3DDevice9::DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) +{ + return(m_pIDirect3DDevice9->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo)); +} + +HRESULT FakeDirect3DDevice9::DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) +{ + return(m_pIDirect3DDevice9->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo)); +} + +HRESULT FakeDirect3DDevice9::DeletePatch(UINT Handle) +{ + return(m_pIDirect3DDevice9->DeletePatch(Handle)); +} + +HRESULT FakeDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) +{ + return(m_pIDirect3DDevice9->CreateQuery(Type, ppQuery)); +} diff --git a/FakeDirect3DDevice9.h b/FakeDirect3DDevice9.h new file mode 100644 index 0000000..7e25860 --- /dev/null +++ b/FakeDirect3DDevice9.h @@ -0,0 +1,135 @@ +#pragma once + +#include + +class FakeDirect3DDevice9 : public IDirect3DDevice9 +{ +public: + FakeDirect3DDevice9(IDirect3DDevice9* pOriginal); + virtual ~FakeDirect3DDevice9(void); + + // START: The original DX9 function definitions + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObj); + virtual COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE AddRef(void); + virtual COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE Release(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE TestCooperativeLevel(void); + virtual COM_DECLSPEC_NOTHROW UINT STDMETHODCALLTYPE GetAvailableTextureMem(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE EvictManagedResources(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetDirect3D(IDirect3D9** ppD3D9); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetDeviceCaps(D3DCAPS9* pCaps); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap); + virtual COM_DECLSPEC_NOTHROW void STDMETHODCALLTYPE SetCursorPosition(int X, int Y, DWORD Flags); + virtual COM_DECLSPEC_NOTHROW BOOL STDMETHODCALLTYPE ShowCursor(BOOL bShow); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain); + virtual COM_DECLSPEC_NOTHROW UINT STDMETHODCALLTYPE GetNumberOfSwapChains(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE Reset(D3DPRESENT_PARAMETERS* pPresentationParameters); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetDialogBoxMode(BOOL bEnableDialogs); + virtual COM_DECLSPEC_NOTHROW void STDMETHODCALLTYPE SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp); + virtual COM_DECLSPEC_NOTHROW void STDMETHODCALLTYPE GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE BeginScene(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE EndScene(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetViewport(CONST D3DVIEWPORT9* pViewport); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetViewport(D3DVIEWPORT9* pViewport); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetMaterial(CONST D3DMATERIAL9* pMaterial); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetMaterial(D3DMATERIAL9* pMaterial); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetLight(DWORD Index, CONST D3DLIGHT9* pLight); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetLight(DWORD Index, D3DLIGHT9* pLight); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE LightEnable(DWORD Index, BOOL Enable); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetLightEnable(DWORD Index, BOOL* pEnable); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetClipPlane(DWORD Index, CONST float* pPlane); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetClipPlane(DWORD Index, float* pPlane); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE BeginStateBlock(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE EndStateBlock(IDirect3DStateBlock9** ppSB); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetClipStatus(D3DCLIPSTATUS9* pClipStatus); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE ValidateDevice(DWORD* pNumPasses); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetCurrentTexturePalette(UINT PaletteNumber); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetCurrentTexturePalette(UINT* PaletteNumber); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetScissorRect(CONST RECT* pRect); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetScissorRect(RECT* pRect); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetSoftwareVertexProcessing(BOOL bSoftware); + virtual COM_DECLSPEC_NOTHROW BOOL STDMETHODCALLTYPE GetSoftwareVertexProcessing(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetNPatchMode(float nSegments); + virtual COM_DECLSPEC_NOTHROW float STDMETHODCALLTYPE GetNPatchMode(void); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetFVF(DWORD FVF); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetFVF(DWORD* pFVF); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetVertexShader(IDirect3DVertexShader9* pShader); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetVertexShader(IDirect3DVertexShader9** ppShader); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetStreamSourceFreq(UINT StreamNumber, UINT Divider); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetStreamSourceFreq(UINT StreamNumber, UINT* Divider); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetIndices(IDirect3DIndexBuffer9* pIndexData); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetIndices(IDirect3DIndexBuffer9** ppIndexData); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetPixelShader(IDirect3DPixelShader9* pShader); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetPixelShader(IDirect3DPixelShader9** ppShader); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE DeletePatch(UINT Handle); + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery); + // END: The original DX9 function definitions + +private: + IDirect3DDevice9* m_pIDirect3DDevice9; +}; diff --git a/README.md b/README.md index 18bf3da..fa8e951 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ -# FakeD3D9 -D3D9 proxy for Silent Storm +# d3d9.dll proxy + +D3D9 proxy for Silent Storm and other games. + +Features: +* Shadows +* Enhanced effects +* Forced VSync + +Thanks to: +* https://github.com/vikbez/pacbrcade +* https://habr.com/ru/post/133956/ +* https://steamcommunity.com/app/254980/discussions/0/846966336224167788/ + +Compile with Visual Studio 2019. + +Installation: +* Copy d3d9.dll to game folder (SteamLibrary\SteamApps\common\Silent Storm) +* Enjoy diff --git a/d3d9.def b/d3d9.def new file mode 100644 index 0000000..ee77840 --- /dev/null +++ b/d3d9.def @@ -0,0 +1,18 @@ +LIBRARY d3d9 + +EXPORTS + D3DPERF_BeginEvent = Fake_D3DPERF_BeginEvent @1 + D3DPERF_EndEvent = Fake_D3DPERF_EndEvent @2 + D3DPERF_GetStatus = Fake_D3DPERF_GetStatus @3 + D3DPERF_QueryRepeatFrame = Fake_D3DPERF_QueryRepeatFrame @4 + D3DPERF_SetMarker = Fake_D3DPERF_SetMarker @5 + D3DPERF_SetOptions = Fake_D3DPERF_SetOptions @6 + D3DPERF_SetRegion = Fake_D3DPERF_SetRegion @7 + DebugSetLevel = Fake_DebugSetLevel @8 + DebugSetMute = Fake_DebugSetMute @9 + Direct3D9EnableMaximizedWindowedModeShim = Fake_Direct3D9EnableMaximizedWindowedModeShim @10 + Direct3DCreate9 = Fake_Direct3DCreate9 @11 + Direct3DCreate9Ex = Fake_Direct3DCreate9Ex @12 + Direct3DShaderValidatorCreate9 = Fake_Direct3DShaderValidatorCreate9 @13 + PSGPError = Fake_PSGPError @14 + PSGPSampleTexture = Fake_PSGPSampleTexture @15 diff --git a/d3d9.sln b/d3d9.sln new file mode 100644 index 0000000..2f7f6f0 --- /dev/null +++ b/d3d9.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.352 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d9", "d3d9.vcxproj", "{29C574DC-0C64-4873-A777-E4ADB8DC6200}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {29C574DC-0C64-4873-A777-E4ADB8DC6200}.Debug|x86.ActiveCfg = Debug|Win32 + {29C574DC-0C64-4873-A777-E4ADB8DC6200}.Debug|x86.Build.0 = Debug|Win32 + {29C574DC-0C64-4873-A777-E4ADB8DC6200}.Release|x86.ActiveCfg = Release|Win32 + {29C574DC-0C64-4873-A777-E4ADB8DC6200}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {117AF371-1AA8-480D-AFFA-90B90CB35D5D} + EndGlobalSection +EndGlobal diff --git a/d3d9.vcxproj b/d3d9.vcxproj new file mode 100644 index 0000000..66ff021 --- /dev/null +++ b/d3d9.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {29C574DC-0C64-4873-A777-E4ADB8DC6200} + Win32Proj + d3d9 + 10.0 + + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + D3D9 + true + + + D3D9 + true + + + D3D9 + false + + + D3D9 + false + + + + Level3 + Disabled + true + WIN32;_DEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + false + d3d9.def + + + + + Level3 + Disabled + true + _DEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + false + + + + + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + false + d3d9.def + + + + + Level3 + MaxSpeed + true + true + true + NDEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + false + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/d3d9.vcxproj.filters b/d3d9.vcxproj.filters new file mode 100644 index 0000000..e7df2a4 --- /dev/null +++ b/d3d9.vcxproj.filters @@ -0,0 +1,37 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + + + Source Files + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..d5b7db9 --- /dev/null +++ b/main.cpp @@ -0,0 +1,86 @@ +#define WIN32_LEAN_AND_MEAN +#include +#include "FakeDirect3D9.h" + +struct OriginalLibrary +{ + HMODULE hDll; + FARPROC D3DPERF_BeginEvent; + FARPROC D3DPERF_EndEvent; + FARPROC D3DPERF_GetStatus; + FARPROC D3DPERF_QueryRepeatFrame; + FARPROC D3DPERF_SetMarker; + FARPROC D3DPERF_SetOptions; + FARPROC D3DPERF_SetRegion; + FARPROC DebugSetLevel; + FARPROC DebugSetMute; + FARPROC Direct3D9EnableMaximizedWindowedModeShim; + FARPROC Direct3DCreate9; + FARPROC Direct3DCreate9Ex; + FARPROC Direct3DShaderValidatorCreate9; + FARPROC PSGPError; + FARPROC PSGPSampleTexture; +} d3d9dll; + +extern "C" __declspec(naked) void Fake_D3DPERF_BeginEvent() { _asm { jmp[d3d9dll.D3DPERF_BeginEvent] } } +extern "C" __declspec(naked) void Fake_D3DPERF_EndEvent() { _asm { jmp[d3d9dll.D3DPERF_EndEvent] } } +extern "C" __declspec(naked) void Fake_D3DPERF_GetStatus() { _asm { jmp[d3d9dll.D3DPERF_GetStatus] } } +extern "C" __declspec(naked) void Fake_D3DPERF_QueryRepeatFrame() { _asm { jmp[d3d9dll.D3DPERF_QueryRepeatFrame] } } +extern "C" __declspec(naked) void Fake_D3DPERF_SetMarker() { _asm { jmp[d3d9dll.D3DPERF_SetMarker] } } +extern "C" __declspec(naked) void Fake_D3DPERF_SetOptions() { _asm { jmp[d3d9dll.D3DPERF_SetOptions] } } +extern "C" __declspec(naked) void Fake_D3DPERF_SetRegion() { _asm { jmp[d3d9dll.D3DPERF_SetRegion] } } +extern "C" __declspec(naked) void Fake_DebugSetLevel() { _asm { jmp[d3d9dll.DebugSetLevel] } } +extern "C" __declspec(naked) void Fake_DebugSetMute() { _asm { jmp[d3d9dll.DebugSetMute] } } +extern "C" __declspec(naked) void Fake_Direct3D9EnableMaximizedWindowedModeShim() { _asm { jmp[d3d9dll.Direct3D9EnableMaximizedWindowedModeShim] } } +// extern "C" __declspec(naked) void Fake_Direct3DCreate9() { _asm { jmp[d3d9dll.Direct3DCreate9] } } +extern "C" __declspec(naked) void Fake_Direct3DCreate9Ex() { _asm { jmp[d3d9dll.Direct3DCreate9Ex] } } +extern "C" __declspec(naked) void Fake_Direct3DShaderValidatorCreate9() { _asm { jmp[d3d9dll.Direct3DShaderValidatorCreate9] } } +extern "C" __declspec(naked) void Fake_PSGPError() { _asm { jmp[d3d9dll.PSGPError] } } +extern "C" __declspec(naked) void Fake_PSGPSampleTexture() { _asm { jmp[d3d9dll.PSGPSampleTexture] } } + +extern "C" IDirect3D9* WINAPI Fake_Direct3DCreate9(UINT SDKVersion) +{ + typedef IDirect3D9* (WINAPI * DIRECT3DCREATEPROC)(UINT SDKVersion); + DIRECT3DCREATEPROC Direct3DCreate9Proc = (DIRECT3DCREATEPROC)d3d9dll.Direct3DCreate9; + IDirect3D9* pFakeDirect3D9 = Direct3DCreate9Proc(SDKVersion); + return new FakeDirect3D9(pFakeDirect3D9); +} + +BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + { + WCHAR path[MAX_PATH]; + UINT length = GetSystemDirectoryW(path, MAX_PATH - 10); + CopyMemory(path + length, L"\\d3d9.dll", sizeof(WCHAR) * 11); + d3d9dll.hDll = LoadLibraryW(path); + if (!d3d9dll.hDll) + { + MessageBoxW(0, L"Cannot load original d3d9.dll library", L"d3d9.dll proxy", MB_ICONERROR); + ExitProcess(0); + } + d3d9dll.D3DPERF_BeginEvent = GetProcAddress(d3d9dll.hDll, "D3DPERF_BeginEvent"); + d3d9dll.D3DPERF_EndEvent = GetProcAddress(d3d9dll.hDll, "D3DPERF_EndEvent"); + d3d9dll.D3DPERF_GetStatus = GetProcAddress(d3d9dll.hDll, "D3DPERF_GetStatus"); + d3d9dll.D3DPERF_QueryRepeatFrame = GetProcAddress(d3d9dll.hDll, "D3DPERF_QueryRepeatFrame"); + d3d9dll.D3DPERF_SetMarker = GetProcAddress(d3d9dll.hDll, "D3DPERF_SetMarker"); + d3d9dll.D3DPERF_SetOptions = GetProcAddress(d3d9dll.hDll, "D3DPERF_SetOptions"); + d3d9dll.D3DPERF_SetRegion = GetProcAddress(d3d9dll.hDll, "D3DPERF_SetRegion"); + d3d9dll.DebugSetLevel = GetProcAddress(d3d9dll.hDll, "DebugSetLevel"); + d3d9dll.DebugSetMute = GetProcAddress(d3d9dll.hDll, "DebugSetMute"); + d3d9dll.Direct3D9EnableMaximizedWindowedModeShim = GetProcAddress(d3d9dll.hDll, "Direct3D9EnableMaximizedWindowedModeShim"); + d3d9dll.Direct3DCreate9 = GetProcAddress(d3d9dll.hDll, "Direct3DCreate9"); + d3d9dll.Direct3DCreate9Ex = GetProcAddress(d3d9dll.hDll, "Direct3DCreate9Ex"); + d3d9dll.Direct3DShaderValidatorCreate9 = GetProcAddress(d3d9dll.hDll, "Direct3DShaderValidatorCreate9"); + d3d9dll.PSGPError = GetProcAddress(d3d9dll.hDll, "PSGPError"); + d3d9dll.PSGPSampleTexture = GetProcAddress(d3d9dll.hDll, "PSGPSampleTexture"); + break; + } + case DLL_PROCESS_DETACH: + FreeLibrary(d3d9dll.hDll); + break; + } + return TRUE; +}