mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-16 15:39:31 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c23eda8db1 | |||
| 601c8c1504 | |||
| 2593729634 | |||
| 24769aad67 | |||
| b100018d5a | |||
| 071ac3ece5 | |||
| 0bc7eebede | |||
| d99107a919 | |||
| 56844968e4 | |||
| 0c11963a9c |
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="uMod" buildProperties="" description="" id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207" name="Debug" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207.1198697062" name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.msvc.toolchain.dll.debug.819029430" name="org.eclipse.cdt.msvc.toolchain.dll.debug" superClass="org.eclipse.cdt.msvc.toolchain.dll.debug">
|
||||
<targetPlatform id="org.eclipse.cdt.msvc.targetPlatform.dll.debug.988168225" superClass="org.eclipse.cdt.msvc.targetPlatform.dll.debug"/>
|
||||
<builder buildPath="${workspace_loc:/uMod/Debug}" id="org.eclipse.cdt.msvc.builder.611532519" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="CDT Internal Builder" superClass="org.eclipse.cdt.msvc.builder"/>
|
||||
<tool id="org.eclipse.cdt.msvc.cl.dll.debug.971252395" name="C/C++ Compiler (cl)" superClass="org.eclipse.cdt.msvc.cl.dll.debug">
|
||||
<option id="org.eclipse.cdt.msvc.cl.option.includes.1468714055" name="Include Path (/I)" superClass="org.eclipse.cdt.msvc.cl.option.includes" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include""/>
|
||||
<listOptionValue builtIn="false" value=""D:\Programme\wxWidgets-2.9.4\include""/>
|
||||
<listOptionValue builtIn="false" value=""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include""/>
|
||||
</option>
|
||||
<inputType id="org.eclipse.cdt.msvc.cl.inputType.370712665" superClass="org.eclipse.cdt.msvc.cl.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.msvc.rc.dll.debug.1079503691" name="Resource Compiler (rc)" superClass="org.eclipse.cdt.msvc.rc.dll.debug">
|
||||
<inputType id="org.eclipse.cdt.msvc.rc.inputType.1577630195" superClass="org.eclipse.cdt.msvc.rc.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.msvc.link.dll.debug.617161498" name="Linker (link)" superClass="org.eclipse.cdt.msvc.link.dll.debug">
|
||||
<inputType id="org.eclipse.cdt.msvc.link.inputType.1391138218" superClass="org.eclipse.cdt.msvc.link.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.msvc.lib.1963448406" name="Library Manager (lib)" superClass="org.eclipse.cdt.msvc.lib"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="uMod.null.2056766171" name="uMod"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="1">
|
||||
<resource resourceType="PROJECT" workspacePath="/uMod"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207;org.eclipse.cdt.msvc.toolchain.dll.debug.1265470207.1198697062;org.eclipse.cdt.msvc.cl.dll.debug.971252395;org.eclipse.cdt.msvc.cl.inputType.370712665">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.msw.build.clScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
|
||||
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
|
||||
<path value=""/>
|
||||
</doc-comment-owner>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
@@ -1,7 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
* text=auto !eol
|
||||
/.cproject -text
|
||||
/.project -text
|
||||
.settings/org.eclipse.cdt.codan.core.prefs -text
|
||||
/README.txt -text
|
||||
uMod_DX10/uMod_DX10_dll.cpp -text
|
||||
uMod_DX10/uMod_DX10_dll.h -text
|
||||
uMod_DX10/uMod_ID3D10Device.cpp -text
|
||||
uMod_DX10/uMod_ID3D10Device.h -text
|
||||
uMod_DX10/uMod_ID3D10Device1.cpp -text
|
||||
uMod_DX10/uMod_ID3D10Device1.h -text
|
||||
uMod_DX10/uMod_ID3D10Texture1D.cpp -text
|
||||
uMod_DX10/uMod_ID3D10Texture1D.h -text
|
||||
uMod_DX10/uMod_ID3D10Texture2D.cpp -text
|
||||
uMod_DX10/uMod_ID3D10Texture2D.h -text
|
||||
uMod_DX10/uMod_ID3D10Texture3D.cpp -text
|
||||
uMod_DX10/uMod_ID3D10Texture3D.h -text
|
||||
uMod_DX10/uMod_IDXGISwapChain.cpp -text
|
||||
uMod_DX10/uMod_IDXGISwapChain.h -text
|
||||
uMod_DX10/uMod_TextureClient_DX10.h -text
|
||||
uMod_DX9/uMod_DX9_dll.cpp -text
|
||||
uMod_DX9/uMod_DX9_dll.h -text
|
||||
uMod_DX9/uMod_IDirect3D9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3D9.h -text
|
||||
uMod_DX9/uMod_IDirect3D9Ex.cpp -text
|
||||
uMod_DX9/uMod_IDirect3D9Ex.h -text
|
||||
uMod_DX9/uMod_IDirect3DCubeTexture9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DCubeTexture9.h -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9.h -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9Ex.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DDevice9Ex.h -text
|
||||
uMod_DX9/uMod_IDirect3DSurface9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DSurface9.h -text
|
||||
uMod_DX9/uMod_IDirect3DTexture9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DTexture9.h -text
|
||||
uMod_DX9/uMod_IDirect3DVolumeTexture9.cpp -text
|
||||
uMod_DX9/uMod_IDirect3DVolumeTexture9.h -text
|
||||
uMod_DX9/uMod_TextureClient_DX9.cpp -text
|
||||
uMod_DX9/uMod_TextureClient_DX9.h -text
|
||||
uMod_DXMain/makefile.gcc -text
|
||||
uMod_DXMain/makefile.vc -text
|
||||
uMod_DXMain/uMod_ArrayHandler.cpp -text
|
||||
uMod_DXMain/uMod_ArrayHandler.h -text
|
||||
uMod_DXMain/uMod_DX10_dll_DIRECT_INJECTION.def -text
|
||||
uMod_DXMain/uMod_DX10_dll_HOOK_INJECTION.def -text
|
||||
uMod_DXMain/uMod_DX9_10_dll_DIRECT_INJECTION.def -text
|
||||
uMod_DXMain/uMod_DX9_dll_DIRECT_INJECTION.def -text
|
||||
uMod_DXMain/uMod_DX9_dll_HOOK_INJECTION.def -text
|
||||
uMod_DXMain/uMod_DX9_dll_NO_INJECTION.def -text
|
||||
uMod_DXMain/uMod_DXMain_dll.cpp -text
|
||||
uMod_DXMain/uMod_DXMain_dll.h -text
|
||||
uMod_DXMain/uMod_Defines.h -text
|
||||
uMod_DXMain/uMod_Detour.cpp -text
|
||||
uMod_DXMain/uMod_Detour.h -text
|
||||
uMod_DXMain/uMod_DetourEntry.h -text
|
||||
uMod_DXMain/uMod_Main.h -text
|
||||
uMod_DXMain/uMod_TextureClient.cpp -text
|
||||
uMod_DXMain/uMod_TextureClient.h -text
|
||||
uMod_DXMain/uMod_TextureFunction.cpp -text
|
||||
uMod_DXMain/uMod_TextureFunction.h -text
|
||||
uMod_DXMain/uMod_TextureServer.cpp -text
|
||||
uMod_DXMain/uMod_TextureServer.h -text
|
||||
/uMod_Error.h -text
|
||||
uMod_GUI/bin/README_Deutsch.txt -text
|
||||
uMod_GUI/bin/README_English.txt -text
|
||||
uMod_GUI/bin/README_French.txt -text
|
||||
uMod_GUI/bin/languages/Example_uMod_LanguagePack_English.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePackU_Deutsch.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePackU_French.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePackU_Russian.txt -text
|
||||
uMod_GUI/bin/languages/uMod_LanguagePack_Italian.txt -text
|
||||
uMod_GUI/config.vc -text
|
||||
uMod_GUI/makefile.vc -text
|
||||
uMod_GUI/uMod.ico -text
|
||||
uMod_GUI/uMod.rc -text
|
||||
uMod_GUI/uMod_AddTexture.cpp -text
|
||||
uMod_GUI/uMod_AddTexture.h -text
|
||||
uMod_GUI/uMod_Client.cpp -text
|
||||
uMod_GUI/uMod_Client.h -text
|
||||
uMod_GUI/uMod_Dialogs.cpp -text
|
||||
uMod_GUI/uMod_Dialogs.h -text
|
||||
uMod_GUI/uMod_DirectInjection.cpp -text
|
||||
uMod_GUI/uMod_DirectInjection.h -text
|
||||
uMod_GUI/uMod_Event.cpp -text
|
||||
uMod_GUI/uMod_Event.h -text
|
||||
uMod_GUI/uMod_File.cpp -text
|
||||
uMod_GUI/uMod_File.h -text
|
||||
uMod_GUI/uMod_GUI.cpp -text
|
||||
uMod_GUI/uMod_GUI.h -text
|
||||
uMod_GUI/uMod_GameInfo.cpp -text
|
||||
uMod_GUI/uMod_GameInfo.h -text
|
||||
uMod_GUI/uMod_GamePage.cpp -text
|
||||
uMod_GUI/uMod_GamePage.h -text
|
||||
uMod_GUI/uMod_Language.cpp -text
|
||||
uMod_GUI/uMod_Language.h -text
|
||||
uMod_GUI/uMod_Main.h -text
|
||||
uMod_GUI/uMod_MiniPanels.cpp -text
|
||||
uMod_GUI/uMod_MiniPanels.h -text
|
||||
uMod_GUI/uMod_ModElement.cpp -text
|
||||
uMod_GUI/uMod_ModElement.h -text
|
||||
uMod_GUI/uMod_Sender.cpp -text
|
||||
uMod_GUI/uMod_Sender.h -text
|
||||
uMod_GUI/uMod_Server.cpp -text
|
||||
uMod_GUI/uMod_Server.h -text
|
||||
uMod_GUI/uMod_Settings.cpp -text
|
||||
uMod_GUI/uMod_Settings.h -text
|
||||
uMod_GUI/uMod_TreeView.cpp -text
|
||||
uMod_GUI/uMod_TreeView.h -text
|
||||
uMod_GUI/unzip.cpp -text
|
||||
uMod_GUI/unzip.h -text
|
||||
uMod_GUI/zip.cpp -text
|
||||
uMod_GUI/zip.h -text
|
||||
/uMod_GlobalDefines.h -text
|
||||
/uMod_Utils.h -text
|
||||
@@ -1,62 +0,0 @@
|
||||
name: gMod CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
targetplatform: [x86]
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
env:
|
||||
Configuration: Release
|
||||
Actions_Allow_Unsecure_Commands: true
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSBuild.exe
|
||||
uses: microsoft/setup-msbuild@v1.3.1
|
||||
|
||||
- name: Build CMake Files
|
||||
run: cmake -S . -B build -A Win32
|
||||
|
||||
- name: Build binaries
|
||||
run: cmake --build build --config Release
|
||||
|
||||
- name: Retrieve version
|
||||
id: set_version
|
||||
run: |
|
||||
$fileVersionInfo = (Get-Item -Path .\bin\Release\gMod.dll).VersionInfo.FileVersion
|
||||
if ([string]::IsNullOrEmpty($fileVersionInfo)) {
|
||||
Write-Host "The DLL file version information could not be retrieved."
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "FileVersionInfo: $fileVersionInfo"
|
||||
echo "::set-output name=version::$fileVersionInfo"
|
||||
}
|
||||
shell: pwsh
|
||||
|
||||
- name: Publish release
|
||||
uses: Xotl/cool-github-releases@v1.1.8
|
||||
with:
|
||||
mode: update
|
||||
tag_name: v${{ steps.set_version.outputs.version }}
|
||||
release_name: gMod v${{ steps.set_version.outputs.version }}
|
||||
assets: .\bin\Release\gMod.dll
|
||||
github_token: ${{ env.GITHUB_TOKEN }}
|
||||
replace_assets: true
|
||||
body_mrkdwn: ${{ env.Changelog }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,39 +0,0 @@
|
||||
name: gMod CI Pipeline
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
targetplatform: [x86]
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
env:
|
||||
Configuration: Release
|
||||
Actions_Allow_Unsecure_Commands: true
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSBuild.exe
|
||||
uses: microsoft/setup-msbuild@v1.3.1
|
||||
|
||||
- name: Build CMake Files
|
||||
run: cmake -S . -B build -A Win32
|
||||
|
||||
- name: Build binaries
|
||||
run: cmake --build build --config Release
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
# IDE
|
||||
*.vs
|
||||
*.user
|
||||
*.settings
|
||||
*.vscode
|
||||
*.project
|
||||
*.cproject
|
||||
*.vcproj
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
**/CMakeFiles/**
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
*.sln
|
||||
*.rc
|
||||
/*.dir
|
||||
|
||||
# Build directories
|
||||
Release
|
||||
Debug
|
||||
bin/
|
||||
*/Debug
|
||||
*/Release
|
||||
*/bin
|
||||
*/obj
|
||||
|
||||
# Bloated Windows Databases
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.suo
|
||||
*.exp
|
||||
*.db
|
||||
*.pdb
|
||||
*.idb
|
||||
*.ilk
|
||||
*.opendb
|
||||
*.log
|
||||
*.lastbuildstate
|
||||
|
||||
# Compiled files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
*.exe
|
||||
*.wxs
|
||||
*.wixobj
|
||||
*.msi
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
*.idb
|
||||
*.pdb
|
||||
*.opendb
|
||||
*.wixpdb
|
||||
|
||||
**/RelWithDebInfo/
|
||||
**/Debug/
|
||||
/bin
|
||||
/win32
|
||||
/out
|
||||
/build
|
||||
/_deps
|
||||
|
||||
.idea
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>uMod 2</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/uMod/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,66 @@
|
||||
#Sun Mar 11 21:51:23 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false}
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue.params={}
|
||||
org.eclipse.cdt.codan.checkers.noreturn=Error
|
||||
org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={exceptions\=>("@(\#)","$Id")}
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
@@ -1,77 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(CMAKE_GENERATOR_PLATFORM win32)
|
||||
|
||||
project(gMod)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
if(NOT(CMAKE_SIZEOF_VOID_P EQUAL 4))
|
||||
message(FATAL_ERROR "You are configuring a non 32-bit build, this is not supported. Run cmake with `-A Win32`")
|
||||
endif()
|
||||
|
||||
option(CLEAN "Cleans third party libraries and recompiles them" OFF)
|
||||
if(${CLEAN} MATCHES "ON")
|
||||
message("Removing directory: ${PROJECT_SOURCE_DIR}/bin/install")
|
||||
file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/bin/install)
|
||||
endif()
|
||||
|
||||
set(VERSION_MAJOR 1)
|
||||
set(VERSION_MINOR 6)
|
||||
set(VERSION_PATCH 1)
|
||||
set(VERSION_TWEAK 0)
|
||||
|
||||
set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/bin/install)
|
||||
|
||||
add_compile_options(/MP /permissive-)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
include(libzippp)
|
||||
include(minhook)
|
||||
include(dxtk)
|
||||
include(msgsl)
|
||||
|
||||
add_library(gMod SHARED)
|
||||
|
||||
file(GLOB SOURCES
|
||||
"header/*.h"
|
||||
"source/*.cpp"
|
||||
"modules/*.ixx"
|
||||
${VERSION_RC}
|
||||
)
|
||||
|
||||
target_include_directories(gMod PRIVATE
|
||||
"header"
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
)
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
|
||||
target_sources(gMod PRIVATE ${SOURCES})
|
||||
|
||||
target_link_libraries(gMod PRIVATE
|
||||
dxguid
|
||||
libzippp
|
||||
psapi
|
||||
minhook
|
||||
directxtex
|
||||
Microsoft.GSL::GSL
|
||||
)
|
||||
target_link_options(gMod PRIVATE
|
||||
"$<$<CONFIG:DEBUG>:/NODEFAULTLIB:LIBCMT>"
|
||||
"/LARGEADDRESSAWARE"
|
||||
)
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
|
||||
target_sources(gMod PRIVATE ${SOURCES})
|
||||
target_compile_definitions(gMod PRIVATE
|
||||
"NOMINMAX"
|
||||
"_WIN32_WINNT=_WIN32_WINNT_WIN7"
|
||||
"WIN32_LEAN_AND_MEAN"
|
||||
"VC_EXTRALEAN"
|
||||
DIRECT_INJECTION
|
||||
LOG_MESSAGE
|
||||
)
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "x86-Debug",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [ "msvc_x86" ],
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": ""
|
||||
},
|
||||
{
|
||||
"name": "x86-Release",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"configurationType": "Release",
|
||||
"inheritEnvironments": [ "msvc_x86" ],
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,27 +0,0 @@
|
||||
Requirements:
|
||||
- DirectX SDK (June 2010)
|
||||
- Visual Studio 2022
|
||||
- CMake 3.16+, integrated into the Developer Powershell for VS 2022
|
||||
|
||||
Compile:
|
||||
- cmake -B build
|
||||
- cmake --open build
|
||||
- compile
|
||||
|
||||
*Usage is primarily intended with GW Launcher or Daybreak, but it can be used without.*
|
||||
|
||||
**Usage with manual gMod.dll injection:**
|
||||
- Create a file called modlist.txt in either the Guild Wars (Gw.exe) folder, or the gMod.dll folder.
|
||||
- Inject gMod.dll before d3d9.dll is loaded.
|
||||
|
||||
**Usage without dll injection:**
|
||||
- Create a file called modlist.txt in the Guild Wars (Gw.exe) folder.
|
||||
- Place gMod.dll in the Guild Wars folder
|
||||
- Rename gMod.dll to d3d9.dll
|
||||
- Launch Guild Wars
|
||||
|
||||
**Format of the modlist.txt file:**
|
||||
|
||||
|
||||
Each line in the modlist.txt is the full path to a mod you want to load (eg. `D:\uMod\Borderless Cartography Made Easy 2015 1.3.tpf`)
|
||||
gMod will load all these files on startup
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
The licence is set for each file separately.
|
||||
|
||||
|
||||
1) How to compile the GUI:
|
||||
|
||||
1.1) You need:
|
||||
- wxWidgets 2.9. (an earlier version won't work, cause I use wxString functions only available in 2.9., I use atm 2.9.2)
|
||||
|
||||
In the package a makefile for the gcc (makefile.gcc) and a makefile for the MS Visual C Compiler (makefile.vc) is included, but you can generate your own makefile for the compiler of your choice.
|
||||
|
||||
Compiling wxWidgets:
|
||||
- Compile it with BUILD=release otherwise the executable will be very large.
|
||||
- The vc compiler somehow generates a smaller executable.
|
||||
- Set the linkage to static (in the config.gcc or config.vc) before you compile the wxWidgets, to ensure, that also on other PC's your executable will run.
|
||||
|
||||
If you use my makefiles, you have to change the WX_DIR Variable to your wxWidgets directory. This Variable is nearly at the beginning of the makefiles.
|
||||
note: I have set the linkage to static in the corresponding config.* files, if you have not compiled you wxWidgets with static linkage the compiler will fail, when linking the GUI.
|
||||
|
||||
1.2) Using gcc: <-- not provide any more
|
||||
change in the uMod_GUI Directory and type:
|
||||
mingw32-make -f makefile.gcc BUILD=release
|
||||
(note: with the options -j 4 you compile simultaneously with 4 threads)
|
||||
|
||||
1.3) Using vc:
|
||||
change in the uMod_GUI Directory and type:
|
||||
nmake -f makefile.vc BUILD=release
|
||||
(note: you need to use the special MS Visual prompt)
|
||||
|
||||
|
||||
2) How to compile the dll:
|
||||
|
||||
2.1) You need:
|
||||
- The DirectX SDK (I use June 2010)
|
||||
- MS Visual C Compiler (I use the free Express 2010 version)
|
||||
- maybe the Microsoft Windows SDK
|
||||
|
||||
There exist two makefiles, one for the mingw32-make.exe (makefile.gcc) which call the vc compiler and one for the nmake.exe (makefile.vc) which also calls the vc compiler. I have created the makefile.gcc only to use the -j 4 option of the gnu make.
|
||||
|
||||
You have to compile the 3 dll's separately (one for each injection method). The dll will be copied after successful compilation in the uMod_GUI/bin directory.
|
||||
|
||||
If you want to use the logging mode of the dll you have to parse LOG_MESSAGE=1
|
||||
|
||||
|
||||
2.2) Using gcc (BUT you need the vc compiler!):
|
||||
change in the uMod_DXMain Directory and type:
|
||||
mingw32-make -f makefile.gcc HI=1
|
||||
mingw32-make -f makefile.gcc DI=1
|
||||
mingw32-make -f makefile.gcc NI=1
|
||||
(note: you need to use the special MS Visual prompt)
|
||||
|
||||
|
||||
2.3) Using vc:
|
||||
change in the uMod_DXMain Directory and type:
|
||||
nmake -f makefile.vc HI=1
|
||||
nmake -f makefile.vc DI=1
|
||||
nmake -f makefile.vc NI=1
|
||||
(note: you need to use the special MS Visual prompt)
|
||||
@@ -1,31 +0,0 @@
|
||||
include_guard()
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
DirectXTex
|
||||
GIT_REPOSITORY https://github.com/microsoft/DirectXTex
|
||||
GIT_TAG oct2023)
|
||||
FetchContent_GetProperties(directxtex)
|
||||
if (directxtex_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
FetchContent_Populate(directxtex)
|
||||
|
||||
add_library(directxtex)
|
||||
file(GLOB SOURCES
|
||||
"${directxtex_SOURCE_DIR}/DDSTextureLoader/DDSTextureLoader9.h"
|
||||
"${directxtex_SOURCE_DIR}/DDSTextureLoader/DDSTextureLoader9.cpp"
|
||||
"${directxtex_SOURCE_DIR}/WICTextureLoader/WICTextureLoader9.h"
|
||||
"${directxtex_SOURCE_DIR}/WICTextureLoader/WICTextureLoader9.cpp"
|
||||
"${directxtex_SOURCE_DIR}/DirectXTex/*.h"
|
||||
"${directxtex_SOURCE_DIR}/DirectXTex/*.cpp"
|
||||
)
|
||||
list(REMOVE_ITEM SOURCES
|
||||
"${directxtex_SOURCE_DIR}/DirectXTex/BCDirectCompute.cpp"
|
||||
)
|
||||
source_group(TREE ${directxtex_SOURCE_DIR} FILES ${SOURCES})
|
||||
target_sources(directxtex PRIVATE ${SOURCES})
|
||||
target_include_directories(directxtex PUBLIC "${directxtex_SOURCE_DIR}")
|
||||
|
||||
set_target_properties(directxtex PROPERTIES FOLDER "Dependencies/")
|
||||
@@ -1,65 +0,0 @@
|
||||
include_guard()
|
||||
include(FetchContent)
|
||||
include(zlib)
|
||||
|
||||
FetchContent_Declare(
|
||||
libzip
|
||||
GIT_REPOSITORY https://github.com/nih-at/libzip
|
||||
GIT_TAG v1.10.1)
|
||||
FetchContent_GetProperties(libzip)
|
||||
|
||||
if (libzip_POPULATED)
|
||||
message(STATUS "Skipping libzip download")
|
||||
return()
|
||||
endif()
|
||||
|
||||
FetchContent_Populate(libzip)
|
||||
if(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/zip.lib)
|
||||
message(STATUS "Skipping libzip build")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(OPTIONS
|
||||
"-A" "Win32"
|
||||
"-DZLIB_LIBRARY:PATH=${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib"
|
||||
"-DZLIB_INCLUDE_DIR:PATH=${CMAKE_INSTALL_PREFIX}/include"
|
||||
"-DENABLE_COMMONCRYPTO=OFF"
|
||||
"-DENABLE_GNUTLS=OFF"
|
||||
"-DENABLE_MBEDTLS=OFF"
|
||||
"-DENABLE_OPENSSL=OFF"
|
||||
"-DENABLE_WINDOWS_CRYPTO=ON"
|
||||
"-DENABLE_FDOPEN=OFF"
|
||||
"-DENABLE_BZIP2=OFF"
|
||||
"-DENABLE_LZMA=OFF"
|
||||
"-DENABLE_ZSTD=OFF"
|
||||
"-DBUILD_TOOLS=OFF"
|
||||
"-DBUILD_REGRESS=OFF"
|
||||
"-DBUILD_EXAMPLES=OFF"
|
||||
"-DBUILD_DOC=OFF"
|
||||
"-DLIBZIP_DO_INSTALL=ON"
|
||||
"-DBUILD_SHARED_LIBS=OFF"
|
||||
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
|
||||
"-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}"
|
||||
)
|
||||
|
||||
message("Building libzip with OPTIONS:\n${OPTIONS}")
|
||||
|
||||
# Patch CMakeLists.txt to require version 3.15 - otherwise cmake ignores MSVC_RUNTIME_LIBRARY
|
||||
file(READ ${libzip_SOURCE_DIR}/CMakeLists.txt FILE_CONTENT)
|
||||
string(REPLACE "VERSION 3.5.0" "VERSION 3.15.0" UPDATED_CONTENT "${FILE_CONTENT}")
|
||||
file(WRITE ${libzip_SOURCE_DIR}/CMakeLists.txt "${UPDATED_CONTENT}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} ${OPTIONS} .
|
||||
WORKING_DIRECTORY ${libzip_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Release
|
||||
WORKING_DIRECTORY ${libzip_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --install . --config Release
|
||||
WORKING_DIRECTORY ${libzip_SOURCE_DIR}
|
||||
)
|
||||
|
||||
message(STATUS "Finished libzip build")
|
||||
@@ -1,42 +0,0 @@
|
||||
include_guard()
|
||||
include(FetchContent)
|
||||
include(libzip)
|
||||
|
||||
find_library(ZLIB_LIBRARY REQUIRED
|
||||
NAMES zlibstatic
|
||||
PATHS ${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
find_library(LIBZIP_LIBRARY REQUIRED
|
||||
NAMES zip
|
||||
PATHS ${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
|
||||
FetchContent_Declare(
|
||||
libzippp
|
||||
GIT_REPOSITORY https://github.com/ctabin/libzippp
|
||||
GIT_TAG libzippp-v7.0-1.10.1)
|
||||
FetchContent_GetProperties(libzippp)
|
||||
|
||||
if (NOT libzippp_POPULATED)
|
||||
FetchContent_Populate(libzippp)
|
||||
endif()
|
||||
|
||||
add_library(libzippp STATIC)
|
||||
|
||||
set(SOURCES
|
||||
"${libzippp_SOURCE_DIR}/src/libzippp.h"
|
||||
"${libzippp_SOURCE_DIR}/src/libzippp.cpp"
|
||||
)
|
||||
source_group(TREE ${libzippp_SOURCE_DIR} FILES ${SOURCES})
|
||||
target_sources(libzippp PRIVATE ${SOURCES})
|
||||
target_include_directories(libzippp PUBLIC "${libzippp_SOURCE_DIR}/src")
|
||||
target_include_directories(libzippp PRIVATE "${CMAKE_INSTALL_PREFIX}/include")
|
||||
target_compile_definitions(libzippp PUBLIC
|
||||
LIBZIPPP_WITH_ENCRYPTION
|
||||
)
|
||||
target_link_libraries(libzippp PRIVATE
|
||||
${LIBZIP_LIBRARY}
|
||||
${ZLIB_LIBRARY}
|
||||
)
|
||||
|
||||
set_target_properties(libzippp PROPERTIES FOLDER "Dependencies/")
|
||||
@@ -1,16 +0,0 @@
|
||||
include_guard()
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
minhook
|
||||
GIT_REPOSITORY https://github.com/TsudaKageyu/minhook
|
||||
GIT_TAG master)
|
||||
FetchContent_GetProperties(minhook)
|
||||
|
||||
if (NOT minhook_POPULATED)
|
||||
FetchContent_Populate(minhook)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${minhook_SOURCE_DIR} EXCLUDE_FROM_ALL)
|
||||
|
||||
set_target_properties(minhook PROPERTIES FOLDER "Dependencies/")
|
||||
@@ -1,11 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(GSL
|
||||
GIT_REPOSITORY "https://github.com/microsoft/GSL"
|
||||
GIT_TAG "v4.0.0"
|
||||
GIT_SHALLOW ON
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(GSL)
|
||||
@@ -1,47 +0,0 @@
|
||||
include_guard()
|
||||
include(FetchContent)
|
||||
|
||||
# Fetch zlib using FetchContent
|
||||
FetchContent_Declare(
|
||||
zlib
|
||||
GIT_REPOSITORY https://github.com/madler/zlib
|
||||
GIT_TAG v1.3
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(zlib)
|
||||
|
||||
if(zlib_POPULATED)
|
||||
message(STATUS "Skipping zlib download")
|
||||
return()
|
||||
endif()
|
||||
|
||||
FetchContent_Populate(zlib)
|
||||
|
||||
if(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib)
|
||||
message(STATUS "Skipping zlib build")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(OPTIONS
|
||||
"-A" "Win32"
|
||||
"-DBUILD_SHARED_LIBS=OFF"
|
||||
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
|
||||
"-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}"
|
||||
)
|
||||
|
||||
message("Building zlib with OPTIONS:\n${OPTIONS}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} ${OPTIONS} .
|
||||
WORKING_DIRECTORY ${zlib_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build . --config Release
|
||||
WORKING_DIRECTORY ${zlib_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --install . --config Release
|
||||
WORKING_DIRECTORY ${zlib_SOURCE_DIR}
|
||||
)
|
||||
|
||||
message(STATUS "Finished zlib build")
|
||||
@@ -1,50 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
//#define HashType DWORD64
|
||||
using HashType = DWORD32;
|
||||
|
||||
struct TexEntry {
|
||||
std::vector<BYTE> data{};
|
||||
HashType crc_hash = 0; // hash value
|
||||
std::string ext{};
|
||||
};
|
||||
|
||||
struct TextureFileStruct {
|
||||
std::vector<BYTE> data{};
|
||||
HashType crc_hash = 0; // hash value
|
||||
};
|
||||
|
||||
inline void Message(const char* format, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#if 0
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void Info(const char* format, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void Warning(const char* format, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
static HANDLE hConsole = GetStdHandle(STD_ERROR_HANDLE);
|
||||
[[maybe_unused]] static auto success = SetConsoleTextAttribute(hConsole, 6);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <future>
|
||||
#include <map>
|
||||
#include <ranges>
|
||||
#include "Utils.h"
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "Defines.h"
|
||||
#include "Error.h"
|
||||
#include "Defines.h"
|
||||
|
||||
#include "uMod_IDirect3D9.h"
|
||||
#include "uMod_IDirect3D9Ex.h"
|
||||
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DDevice9Ex.h"
|
||||
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
|
||||
#pragma warning(disable : 4477)
|
||||
|
||||
extern unsigned int gl_ErrorState;
|
||||
extern HINSTANCE gl_hThisInstance;
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
template<typename T>
|
||||
void erase_first(std::vector<T>& vec, const T& elem)
|
||||
{
|
||||
const auto found = std::ranges::find(vec, elem);
|
||||
if (found != std::ranges::end(vec)) {
|
||||
vec.erase(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
class uMod_IDirect3D9 : public IDirect3D9 {
|
||||
public:
|
||||
uMod_IDirect3D9(IDirect3D9* pOriginal);
|
||||
virtual ~uMod_IDirect3D9();
|
||||
|
||||
// The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj) override;
|
||||
ULONG __stdcall AddRef() override;
|
||||
ULONG __stdcall Release() override;
|
||||
HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction) override;
|
||||
UINT __stdcall GetAdapterCount() override;
|
||||
HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) override;
|
||||
UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) override;
|
||||
HRESULT __stdcall EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) override;
|
||||
HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) override;
|
||||
HRESULT __stdcall CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) override;
|
||||
HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) override;
|
||||
HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) override;
|
||||
HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) override;
|
||||
HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) override;
|
||||
HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) override;
|
||||
HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) override;
|
||||
HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) override;
|
||||
|
||||
private:
|
||||
IDirect3D9* m_pIDirect3D9;
|
||||
};
|
||||
@@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
class uMod_IDirect3D9Ex : public IDirect3D9Ex {
|
||||
public:
|
||||
uMod_IDirect3D9Ex(IDirect3D9Ex* pOriginal);
|
||||
virtual ~uMod_IDirect3D9Ex();
|
||||
|
||||
// The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj) override;
|
||||
ULONG __stdcall AddRef() override;
|
||||
ULONG __stdcall Release() override;
|
||||
HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction) override;
|
||||
UINT __stdcall GetAdapterCount() override;
|
||||
HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) override;
|
||||
UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) override;
|
||||
HRESULT __stdcall EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) override;
|
||||
HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) override;
|
||||
HRESULT __stdcall CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) override;
|
||||
HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) override;
|
||||
HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) override;
|
||||
HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) override;
|
||||
HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) override;
|
||||
HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) override;
|
||||
HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) override;
|
||||
HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) override;
|
||||
|
||||
HRESULT __stdcall CreateDeviceEx(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode,
|
||||
IDirect3DDevice9Ex** ppReturnedDeviceInterface) override;
|
||||
HRESULT __stdcall EnumAdapterModesEx(UINT Adapter, const D3DDISPLAYMODEFILTER* pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode) override;
|
||||
HRESULT __stdcall GetAdapterDisplayModeEx(UINT Adapter, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation) override;
|
||||
HRESULT __stdcall GetAdapterLUID(UINT Adapter, LUID* pLUID) override;
|
||||
UINT __stdcall GetAdapterModeCountEx(UINT Adapter, const D3DDISPLAYMODEFILTER* pFilter) override;
|
||||
|
||||
private:
|
||||
IDirect3D9Ex* m_pIDirect3D9Ex;
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
interface uMod_IDirect3DCubeTexture9 : IDirect3DCubeTexture9 {
|
||||
uMod_IDirect3DCubeTexture9(IDirect3DCubeTexture9** ppTex, IDirect3DDevice9* pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = nullptr; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DCubeTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
}
|
||||
|
||||
// callback interface
|
||||
IDirect3DCubeTexture9* m_D3Dtex = nullptr;
|
||||
uMod_IDirect3DCubeTexture9* CrossRef_D3Dtex = nullptr;
|
||||
IDirect3DDevice9* m_D3Ddev = nullptr;
|
||||
TextureFileStruct* Reference = nullptr;
|
||||
HashType Hash = 0u;
|
||||
bool FAKE = false;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj) override;
|
||||
STDMETHOD_(ULONG, AddRef)() override;
|
||||
STDMETHOD_(ULONG, Release)() override;
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice) override;
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData, DWORD SizeOfData, DWORD Flags) override;
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid, void* pData, DWORD* pSizeOfData) override;
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid) override;
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew) override;
|
||||
STDMETHOD_(DWORD, GetPriority)() override;
|
||||
STDMETHOD_(void, PreLoad)() override;
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)() override;
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew) override;
|
||||
STDMETHOD_(DWORD, GetLOD)() override;
|
||||
STDMETHOD_(DWORD, GetLevelCount)() override;
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType) override;
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)() override;
|
||||
STDMETHOD_(void, GenerateMipSubLevels)() override;
|
||||
|
||||
STDMETHOD(AddDirtyRect)(D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) override;
|
||||
STDMETHOD(GetLevelDesc)(UINT Level, D3DSURFACE_DESC* pDesc) override;
|
||||
STDMETHOD(GetCubeMapSurface)(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) override;
|
||||
STDMETHOD(LockRect)(D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect, DWORD Flags) override;
|
||||
STDMETHOD(UnlockRect)(D3DCUBEMAP_FACES FaceType, UINT Level) override;
|
||||
|
||||
|
||||
[[nodiscard]] HashType GetHash() const;
|
||||
};
|
||||
@@ -1,173 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
|
||||
class TextureClient;
|
||||
|
||||
class uMod_IDirect3DDevice9 : public IDirect3DDevice9 {
|
||||
public:
|
||||
uMod_IDirect3DDevice9(IDirect3DDevice9* pOriginal, int back_buffer_count);
|
||||
virtual ~uMod_IDirect3DDevice9();
|
||||
|
||||
// START: The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj) override;
|
||||
ULONG __stdcall AddRef() override;
|
||||
ULONG __stdcall Release() override;
|
||||
HRESULT __stdcall TestCooperativeLevel() override;
|
||||
UINT __stdcall GetAvailableTextureMem() override;
|
||||
HRESULT __stdcall EvictManagedResources() override;
|
||||
HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9) override;
|
||||
HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps) override;
|
||||
HRESULT __stdcall GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) override;
|
||||
HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters) override;
|
||||
HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) override;
|
||||
void __stdcall SetCursorPosition(int X, int Y, DWORD Flags) override;
|
||||
BOOL __stdcall ShowCursor(BOOL bShow) override;
|
||||
HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) override;
|
||||
HRESULT __stdcall GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) override;
|
||||
UINT __stdcall GetNumberOfSwapChains() override;
|
||||
HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) override;
|
||||
HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) override;
|
||||
HRESULT __stdcall GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) override;
|
||||
HRESULT __stdcall GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) override;
|
||||
HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs) override;
|
||||
void __stdcall SetGammaRamp(UINT iSwapChain, DWORD Flags,CONST D3DGAMMARAMP* pRamp) override;
|
||||
void __stdcall GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) override;
|
||||
HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint) override;
|
||||
HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) override;
|
||||
HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) override;
|
||||
HRESULT __stdcall GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) override;
|
||||
HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) override;
|
||||
HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect, D3DCOLOR color) override;
|
||||
HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) override;
|
||||
HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) override;
|
||||
HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) override;
|
||||
HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) override;
|
||||
HRESULT __stdcall BeginScene() override;
|
||||
HRESULT __stdcall EndScene() override;
|
||||
HRESULT __stdcall Clear(DWORD Count,CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) override;
|
||||
HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) override;
|
||||
HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) override;
|
||||
HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) override;
|
||||
HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport) override;
|
||||
HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport) override;
|
||||
HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial) override;
|
||||
HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial) override;
|
||||
HRESULT __stdcall SetLight(DWORD Index,CONST D3DLIGHT9* pLight) override;
|
||||
HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT9* pLight) override;
|
||||
HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable) override;
|
||||
HRESULT __stdcall GetLightEnable(DWORD Index, BOOL* pEnable) override;
|
||||
HRESULT __stdcall SetClipPlane(DWORD Index,CONST float* pPlane) override;
|
||||
HRESULT __stdcall GetClipPlane(DWORD Index, float* pPlane) override;
|
||||
HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) override;
|
||||
HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) override;
|
||||
HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) override;
|
||||
HRESULT __stdcall BeginStateBlock() override;
|
||||
HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB) override;
|
||||
HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) override;
|
||||
HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus) override;
|
||||
HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) override;
|
||||
HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) override;
|
||||
HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) override;
|
||||
HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) override;
|
||||
HRESULT __stdcall GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) override;
|
||||
HRESULT __stdcall SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) override;
|
||||
HRESULT __stdcall ValidateDevice(DWORD* pNumPasses) override;
|
||||
HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries) override;
|
||||
HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) override;
|
||||
HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber) override;
|
||||
HRESULT __stdcall GetCurrentTexturePalette(UINT* PaletteNumber) override;
|
||||
HRESULT __stdcall SetScissorRect(CONST RECT* pRect) override;
|
||||
HRESULT __stdcall GetScissorRect(RECT* pRect) override;
|
||||
HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware) override;
|
||||
BOOL __stdcall GetSoftwareVertexProcessing() override;
|
||||
HRESULT __stdcall SetNPatchMode(float nSegments) override;
|
||||
float __stdcall GetNPatchMode() override;
|
||||
HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) override;
|
||||
HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) override;
|
||||
HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override;
|
||||
HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount,CONST void* pIndexData, D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
|
||||
UINT VertexStreamZeroStride) override;
|
||||
HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) override;
|
||||
HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) override;
|
||||
HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) override;
|
||||
HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) override;
|
||||
HRESULT __stdcall SetFVF(DWORD FVF) override;
|
||||
HRESULT __stdcall GetFVF(DWORD* pFVF) override;
|
||||
HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) override;
|
||||
HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader) override;
|
||||
HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader) override;
|
||||
HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) override;
|
||||
HRESULT __stdcall GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) override;
|
||||
HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber, UINT Divider) override;
|
||||
HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber, UINT* Divider) override;
|
||||
HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData) override;
|
||||
HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData) override;
|
||||
HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) override;
|
||||
HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader) override;
|
||||
HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader) override;
|
||||
HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) override;
|
||||
HRESULT __stdcall DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) override;
|
||||
HRESULT __stdcall DeletePatch(UINT Handle) override;
|
||||
HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) override;
|
||||
// END: The original DX9 function definitions
|
||||
|
||||
TextureClient* GetuMod_Client() { return uMod_Client; }
|
||||
|
||||
uMod_IDirect3DTexture9* GetLastCreatedTexture() { return LastCreatedTexture; }
|
||||
|
||||
void SetLastCreatedTexture(uMod_IDirect3DTexture9* pTexture)
|
||||
{
|
||||
LastCreatedTexture = pTexture;
|
||||
}
|
||||
|
||||
uMod_IDirect3DVolumeTexture9* GetLastCreatedVolumeTexture() { return LastCreatedVolumeTexture; }
|
||||
|
||||
void SetLastCreatedVolumeTexture(uMod_IDirect3DVolumeTexture9* pTexture)
|
||||
{
|
||||
LastCreatedVolumeTexture = pTexture;
|
||||
}
|
||||
|
||||
uMod_IDirect3DCubeTexture9* GetLastCreatedCubeTexture() { return LastCreatedCubeTexture; }
|
||||
|
||||
void SetLastCreatedCubeTexture(uMod_IDirect3DCubeTexture9* pTexture)
|
||||
{
|
||||
LastCreatedCubeTexture = pTexture;
|
||||
}
|
||||
|
||||
private:
|
||||
IDirect3DDevice9* m_pIDirect3DDevice9 = nullptr;
|
||||
|
||||
int BackBufferCount;
|
||||
bool NormalRendering = true;
|
||||
int uMod_Reference = 1;
|
||||
|
||||
uMod_IDirect3DTexture9* LastCreatedTexture = nullptr;
|
||||
uMod_IDirect3DVolumeTexture9* LastCreatedVolumeTexture = nullptr;
|
||||
uMod_IDirect3DCubeTexture9* LastCreatedCubeTexture = nullptr;
|
||||
|
||||
TextureClient* uMod_Client;
|
||||
};
|
||||
@@ -1,196 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
|
||||
class TextureClient;
|
||||
|
||||
class uMod_IDirect3DDevice9Ex : public IDirect3DDevice9Ex {
|
||||
public:
|
||||
uMod_IDirect3DDevice9Ex(IDirect3DDevice9Ex* pOriginal, int back_buffer_count);
|
||||
virtual ~uMod_IDirect3DDevice9Ex();
|
||||
|
||||
// START: The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj) override;
|
||||
ULONG __stdcall AddRef() override;
|
||||
ULONG __stdcall Release() override;
|
||||
HRESULT __stdcall TestCooperativeLevel() override;
|
||||
UINT __stdcall GetAvailableTextureMem() override;
|
||||
HRESULT __stdcall EvictManagedResources() override;
|
||||
HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9) override;
|
||||
HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps) override;
|
||||
HRESULT __stdcall GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) override;
|
||||
HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters) override;
|
||||
HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) override;
|
||||
void __stdcall SetCursorPosition(int X, int Y, DWORD Flags) override;
|
||||
BOOL __stdcall ShowCursor(BOOL bShow) override;
|
||||
HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) override;
|
||||
HRESULT __stdcall GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) override;
|
||||
UINT __stdcall GetNumberOfSwapChains() override;
|
||||
HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) override;
|
||||
HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) override;
|
||||
HRESULT __stdcall GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) override;
|
||||
HRESULT __stdcall GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) override;
|
||||
HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs) override;
|
||||
void __stdcall SetGammaRamp(UINT iSwapChain, DWORD Flags,CONST D3DGAMMARAMP* pRamp) override;
|
||||
void __stdcall GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) override;
|
||||
HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint) override;
|
||||
HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) override;
|
||||
HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) override;
|
||||
HRESULT __stdcall GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) override;
|
||||
HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) override;
|
||||
HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect, D3DCOLOR color) override;
|
||||
HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
|
||||
HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) override;
|
||||
HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) override;
|
||||
HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) override;
|
||||
HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) override;
|
||||
HRESULT __stdcall BeginScene() override;
|
||||
HRESULT __stdcall EndScene() override;
|
||||
HRESULT __stdcall Clear(DWORD Count,CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) override;
|
||||
HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) override;
|
||||
HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) override;
|
||||
HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) override;
|
||||
HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport) override;
|
||||
HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport) override;
|
||||
HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial) override;
|
||||
HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial) override;
|
||||
HRESULT __stdcall SetLight(DWORD Index,CONST D3DLIGHT9* pLight) override;
|
||||
HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT9* pLight) override;
|
||||
HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable) override;
|
||||
HRESULT __stdcall GetLightEnable(DWORD Index, BOOL* pEnable) override;
|
||||
HRESULT __stdcall SetClipPlane(DWORD Index,CONST float* pPlane) override;
|
||||
HRESULT __stdcall GetClipPlane(DWORD Index, float* pPlane) override;
|
||||
HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) override;
|
||||
HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) override;
|
||||
HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) override;
|
||||
HRESULT __stdcall BeginStateBlock() override;
|
||||
HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB) override;
|
||||
HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) override;
|
||||
HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus) override;
|
||||
HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) override;
|
||||
HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) override;
|
||||
HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) override;
|
||||
HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) override;
|
||||
HRESULT __stdcall GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) override;
|
||||
HRESULT __stdcall SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) override;
|
||||
HRESULT __stdcall ValidateDevice(DWORD* pNumPasses) override;
|
||||
HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries) override;
|
||||
HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) override;
|
||||
HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber) override;
|
||||
HRESULT __stdcall GetCurrentTexturePalette(UINT* PaletteNumber) override;
|
||||
HRESULT __stdcall SetScissorRect(CONST RECT* pRect) override;
|
||||
HRESULT __stdcall GetScissorRect(RECT* pRect) override;
|
||||
HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware) override;
|
||||
BOOL __stdcall GetSoftwareVertexProcessing() override;
|
||||
HRESULT __stdcall SetNPatchMode(float nSegments) override;
|
||||
float __stdcall GetNPatchMode() override;
|
||||
HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) override;
|
||||
HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) override;
|
||||
HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override;
|
||||
HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount,CONST void* pIndexData, D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
|
||||
UINT VertexStreamZeroStride) override;
|
||||
HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) override;
|
||||
HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) override;
|
||||
HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) override;
|
||||
HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) override;
|
||||
HRESULT __stdcall SetFVF(DWORD FVF) override;
|
||||
HRESULT __stdcall GetFVF(DWORD* pFVF) override;
|
||||
HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) override;
|
||||
HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader) override;
|
||||
HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader) override;
|
||||
HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) override;
|
||||
HRESULT __stdcall GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) override;
|
||||
HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber, UINT Divider) override;
|
||||
HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber, UINT* Divider) override;
|
||||
HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData) override;
|
||||
HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData) override;
|
||||
HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) override;
|
||||
HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader) override;
|
||||
HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader) override;
|
||||
HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override;
|
||||
HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override;
|
||||
HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override;
|
||||
HRESULT __stdcall DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) override;
|
||||
HRESULT __stdcall DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) override;
|
||||
HRESULT __stdcall DeletePatch(UINT Handle) override;
|
||||
HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) override;
|
||||
|
||||
|
||||
|
||||
HRESULT __stdcall CheckDeviceState(HWND hWindow) override;
|
||||
HRESULT __stdcall CheckResourceResidency(IDirect3DResource9** pResourceArray, UINT32 NumResources) override;
|
||||
HRESULT __stdcall ComposeRects(IDirect3DSurface9* pSource, IDirect3DSurface9* pDestination, IDirect3DVertexBuffer9* pSrcRectDescriptors, UINT NumRects, IDirect3DVertexBuffer9* pDstRectDescriptors, D3DCOMPOSERECTSOP Operation, INT XOffset,
|
||||
INT YOffset) override;
|
||||
HRESULT __stdcall CreateDepthStencilSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage) override;
|
||||
HRESULT __stdcall CreateOffscreenPlainSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage) override;
|
||||
HRESULT __stdcall CreateRenderTargetEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage) override;
|
||||
HRESULT __stdcall GetDisplayModeEx(UINT iSwapChain, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation) override;
|
||||
HRESULT __stdcall GetGPUThreadPriority(INT* pPriority) override;
|
||||
HRESULT __stdcall GetMaximumFrameLatency(UINT* pMaxLatency) override;
|
||||
HRESULT __stdcall PresentEx(const RECT* pSourceRect, const RECT* pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion, DWORD dwFlags) override;
|
||||
HRESULT __stdcall ResetEx(D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode) override;
|
||||
HRESULT __stdcall SetConvolutionMonoKernel(UINT Width, UINT Height, float* RowWeights, float* ColumnWeights) override;
|
||||
HRESULT __stdcall SetGPUThreadPriority(INT pPriority) override;
|
||||
HRESULT __stdcall SetMaximumFrameLatency(UINT pMaxLatency) override;
|
||||
//HRESULT __stdcall TestCooperativeLevel();
|
||||
HRESULT __stdcall WaitForVBlank(UINT SwapChainIndex) override;
|
||||
|
||||
|
||||
// END: The original DX9 function definitions
|
||||
|
||||
TextureClient* GetuMod_Client() { return uMod_Client; }
|
||||
|
||||
uMod_IDirect3DTexture9* GetLastCreatedTexture() { return LastCreatedTexture; }
|
||||
|
||||
void SetLastCreatedTexture(uMod_IDirect3DTexture9* pTexture)
|
||||
{
|
||||
LastCreatedTexture = pTexture;
|
||||
}
|
||||
|
||||
uMod_IDirect3DVolumeTexture9* GetLastCreatedVolumeTexture() { return LastCreatedVolumeTexture; }
|
||||
|
||||
void SetLastCreatedVolumeTexture(uMod_IDirect3DVolumeTexture9* pTexture)
|
||||
{
|
||||
LastCreatedVolumeTexture = pTexture;
|
||||
}
|
||||
|
||||
uMod_IDirect3DCubeTexture9* GetLastCreatedCubeTexture() { return LastCreatedCubeTexture; }
|
||||
|
||||
void SetLastCreatedCubeTexture(uMod_IDirect3DCubeTexture9* pTexture)
|
||||
{
|
||||
LastCreatedCubeTexture = pTexture;
|
||||
}
|
||||
|
||||
private:
|
||||
IDirect3DDevice9Ex* m_pIDirect3DDevice9Ex;
|
||||
|
||||
int BackBufferCount;
|
||||
bool NormalRendering = true;
|
||||
|
||||
int uMod_Reference = 1;
|
||||
|
||||
uMod_IDirect3DTexture9* LastCreatedTexture = nullptr;
|
||||
uMod_IDirect3DVolumeTexture9* LastCreatedVolumeTexture = nullptr;
|
||||
uMod_IDirect3DCubeTexture9* LastCreatedCubeTexture = nullptr;
|
||||
|
||||
TextureClient* uMod_Client = nullptr;
|
||||
};
|
||||
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
struct TextureFileStruct;
|
||||
interface uMod_IDirect3DTexture9 : public IDirect3DTexture9 {
|
||||
uMod_IDirect3DTexture9(IDirect3DTexture9** ppTex, IDirect3DDevice9* pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
}
|
||||
virtual ~uMod_IDirect3DTexture9()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// callback interface
|
||||
IDirect3DTexture9* m_D3Dtex = nullptr;
|
||||
uMod_IDirect3DTexture9* CrossRef_D3Dtex = nullptr;
|
||||
IDirect3DDevice9* m_D3Ddev = nullptr;
|
||||
TextureFileStruct* Reference = nullptr;
|
||||
HashType Hash = 0u;
|
||||
bool FAKE = false;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj) override;
|
||||
STDMETHOD_(ULONG, AddRef)() override;
|
||||
STDMETHOD_(ULONG, Release)() override;
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice) override;
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData, DWORD SizeOfData, DWORD Flags) override;
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid, void* pData, DWORD* pSizeOfData) override;
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid) override;
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew) override;
|
||||
STDMETHOD_(DWORD, GetPriority)() override;
|
||||
STDMETHOD_(void, PreLoad)() override;
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)() override;
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew) override;
|
||||
STDMETHOD_(DWORD, GetLOD)() override;
|
||||
STDMETHOD_(DWORD, GetLevelCount)() override;
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType) override;
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)() override;
|
||||
STDMETHOD_(void, GenerateMipSubLevels)() override;
|
||||
STDMETHOD(GetLevelDesc)(UINT Level, D3DSURFACE_DESC* pDesc) override;
|
||||
STDMETHOD(GetSurfaceLevel)(UINT Level, IDirect3DSurface9** ppSurfaceLevel) override;
|
||||
STDMETHOD(LockRect)(UINT Level, D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect, DWORD Flags) override;
|
||||
STDMETHOD(UnlockRect)(UINT Level) override;
|
||||
STDMETHOD(AddDirtyRect)(CONST RECT* pDirtyRect) override;
|
||||
|
||||
[[nodiscard]] HashType GetHash() const;
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
interface uMod_IDirect3DVolumeTexture9 : IDirect3DVolumeTexture9 {
|
||||
uMod_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9** ppTex, IDirect3DDevice9* pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = nullptr; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DVolumeTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
}
|
||||
|
||||
// callback interface
|
||||
IDirect3DVolumeTexture9* m_D3Dtex = nullptr;
|
||||
uMod_IDirect3DVolumeTexture9* CrossRef_D3Dtex = nullptr;
|
||||
IDirect3DDevice9* m_D3Ddev = nullptr;
|
||||
TextureFileStruct* Reference = nullptr;
|
||||
HashType Hash = 0u;
|
||||
bool FAKE = false;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj) override;
|
||||
STDMETHOD_(ULONG, AddRef)() override;
|
||||
STDMETHOD_(ULONG, Release)() override;
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice) override;
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData, DWORD SizeOfData, DWORD Flags) override;
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid, void* pData, DWORD* pSizeOfData) override;
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid) override;
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew) override;
|
||||
STDMETHOD_(DWORD, GetPriority)() override;
|
||||
STDMETHOD_(void, PreLoad)() override;
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)() override;
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew) override;
|
||||
STDMETHOD_(DWORD, GetLOD)() override;
|
||||
STDMETHOD_(DWORD, GetLevelCount)() override;
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType) override;
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)() override;
|
||||
STDMETHOD_(void, GenerateMipSubLevels)() override;
|
||||
STDMETHOD(AddDirtyBox)(CONST D3DBOX* pDirtyBox) override;
|
||||
STDMETHOD(GetLevelDesc)(UINT Level, D3DVOLUME_DESC* pDesc) override;
|
||||
STDMETHOD(GetVolumeLevel)(UINT Level, IDirect3DVolume9** ppVolumeLevel) override;
|
||||
STDMETHOD(LockBox)(UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) override;
|
||||
STDMETHOD(UnlockBox)(UINT Level) override;
|
||||
|
||||
|
||||
[[nodiscard]] HashType GetHash() const;
|
||||
};
|
||||
@@ -1,186 +0,0 @@
|
||||
module;
|
||||
|
||||
#include "Main.h"
|
||||
#include "Defines.h"
|
||||
|
||||
export module ModfileLoader;
|
||||
|
||||
import <intsafe.h>;
|
||||
import <vector>;
|
||||
import <string>;
|
||||
import <libzippp.h>;
|
||||
import <regex>;
|
||||
import <algorithm>;
|
||||
import <filesystem>;
|
||||
import ModfileLoader.TpfReader;
|
||||
|
||||
export class ModfileLoader {
|
||||
std::string file_name;
|
||||
const std::string TPF_PASSWORD{
|
||||
0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, static_cast<char>(0xA6), static_cast<char>(0xBD),
|
||||
0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F,
|
||||
0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74,
|
||||
0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41,
|
||||
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
|
||||
0x46, 0x6F
|
||||
};
|
||||
|
||||
public:
|
||||
ModfileLoader(const std::string& fileName);
|
||||
|
||||
std::vector<TexEntry> GetContents();
|
||||
|
||||
private:
|
||||
|
||||
std::vector<TexEntry> GetTpfContents();
|
||||
|
||||
std::vector<TexEntry> GetFileContents();
|
||||
|
||||
void LoadEntries(libzippp::ZipArchive& archive, std::vector<TexEntry>& entries);
|
||||
};
|
||||
|
||||
ModfileLoader::ModfileLoader(const std::string& fileName)
|
||||
{
|
||||
file_name = std::filesystem::absolute(fileName).string();
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetContents()
|
||||
{
|
||||
try {
|
||||
return file_name.ends_with(".tpf") ? GetTpfContents() : GetFileContents();
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
Warning("Failed to open mod file: %s\n", file_name.c_str());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetTpfContents()
|
||||
{
|
||||
std::vector<TexEntry> entries;
|
||||
auto tpf_reader = TpfReader(file_name);
|
||||
const auto buffer = tpf_reader.ReadToEnd();
|
||||
const auto zip_archive = libzippp::ZipArchive::fromBuffer(buffer.data(), buffer.size(), false, TPF_PASSWORD);
|
||||
if (!zip_archive) {
|
||||
Warning("Failed to open tpf file: %s - %u bytes!", file_name.c_str(), buffer.size());
|
||||
return {};
|
||||
}
|
||||
zip_archive->setErrorHandlerCallback(
|
||||
[](const std::string& message, const std::string& strerror, int zip_error_code, int system_error_code) -> void {
|
||||
Message("GetTpfContents: %s %s %d %d\n", message.c_str(), strerror.c_str(), zip_error_code, system_error_code);
|
||||
});
|
||||
zip_archive->open();
|
||||
LoadEntries(*zip_archive, entries);
|
||||
zip_archive->close();
|
||||
libzippp::ZipArchive::free(zip_archive);
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
std::vector<TexEntry> ModfileLoader::GetFileContents()
|
||||
{
|
||||
std::vector<TexEntry> entries;
|
||||
|
||||
libzippp::ZipArchive zip_archive(file_name);
|
||||
zip_archive.open();
|
||||
LoadEntries(zip_archive, entries);
|
||||
zip_archive.close();
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
void ParseSimpleArchive(const libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
for (const auto& entry : archive.getEntries()) {
|
||||
if (entry.isFile()) {
|
||||
//TODO: #6 - Implement regex search
|
||||
auto name = entry.getName();
|
||||
|
||||
const static std::regex re(R"(0x[0-9a-f]{8})", std::regex::optimize | std::regex::icase);
|
||||
std::smatch match;
|
||||
if (!std::regex_search(name, match, re)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t crc_hash;
|
||||
try {
|
||||
crc_hash = std::stoul(match.str(), nullptr, 16);
|
||||
}
|
||||
catch (const std::invalid_argument& e) {
|
||||
Warning("Failed to parse %s as a hash", name.c_str());
|
||||
continue;
|
||||
}
|
||||
catch (const std::out_of_range& e) {
|
||||
Message("Out of range while parsing %s as a hash", name.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto data_ptr = static_cast<BYTE*>(entry.readAsBinary());
|
||||
const auto size = entry.getSize();
|
||||
std::vector vec(data_ptr, data_ptr + size);
|
||||
std::filesystem::path tex_name(entry.getName());
|
||||
entries.emplace_back(std::move(vec), crc_hash, tex_name.extension().string());
|
||||
delete[] data_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParseTexmodArchive(std::vector<std::string>& lines, libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
for (const auto& line : lines) {
|
||||
// 0xC57D73F7|GW.EXE_0xC57D73F7.tga\r\n
|
||||
// match[1] | match[2]
|
||||
const static auto address_file_regex = std::regex(R"(^[\\/.]*([^|]+)\|([^\r\n]+))", std::regex::optimize);
|
||||
std::smatch match;
|
||||
std::regex_search(line, match, address_file_regex);
|
||||
if (match.size() != 3u)
|
||||
continue;
|
||||
const auto address_string = match[1].str();
|
||||
const auto file_path = match[2].str();
|
||||
|
||||
const auto entry = archive.getEntry(file_path);
|
||||
if (entry.isNull() || !entry.isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t crc_hash{};
|
||||
try {
|
||||
crc_hash = std::stoul(address_string, nullptr, 16);
|
||||
}
|
||||
catch (const std::invalid_argument& e) {
|
||||
Warning("Failed to parse %s as a hash", address_string.c_str());
|
||||
continue;
|
||||
}
|
||||
catch (const std::out_of_range& e) {
|
||||
Warning("Out of range while parsing %s as a hash", address_string.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto data_ptr = static_cast<BYTE*>(entry.readAsBinary());
|
||||
const auto size = static_cast<size_t>(entry.getSize());
|
||||
std::vector vec(data_ptr, data_ptr + size);
|
||||
const auto tex_name = std::filesystem::path(entry.getName());
|
||||
entries.emplace_back(std::move(vec), crc_hash, tex_name.extension().string());
|
||||
delete[] data_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ModfileLoader::LoadEntries(libzippp::ZipArchive& archive, std::vector<TexEntry>& entries)
|
||||
{
|
||||
const auto def_file = archive.getEntry("texmod.def");
|
||||
if (def_file.isNull() || !def_file.isFile()) {
|
||||
ParseSimpleArchive(archive, entries);
|
||||
}
|
||||
else {
|
||||
const auto def = def_file.readAsText();
|
||||
std::istringstream iss(def);
|
||||
std::vector<std::string> lines;
|
||||
std::string line;
|
||||
|
||||
while (std::getline(iss, line)) {
|
||||
lines.push_back(line);
|
||||
}
|
||||
|
||||
ParseTexmodArchive(lines, archive, entries);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
export module ModfileLoader.TpfReader;
|
||||
|
||||
import <string>;
|
||||
import <fstream>;
|
||||
import <vector>;
|
||||
|
||||
export class TpfReader {
|
||||
public:
|
||||
TpfReader(const std::string& path)
|
||||
{
|
||||
file_stream = std::ifstream(path, std::ios::binary);
|
||||
if (!file_stream.seekg(0, std::ios::end).good() || !file_stream.seekg(0, std::ios::beg).good()) {
|
||||
throw std::invalid_argument("Provided stream needs to have SEEK set to True");
|
||||
}
|
||||
}
|
||||
|
||||
~TpfReader()
|
||||
{
|
||||
file_stream.close();
|
||||
}
|
||||
|
||||
std::vector<char> ReadToEnd()
|
||||
{
|
||||
file_stream.seekg(0, std::ios::end);
|
||||
line_length = file_stream.tellg();
|
||||
file_stream.seekg(0, std::ios::beg); // Go to the beginning of the stream
|
||||
|
||||
std::vector<char> data(line_length);
|
||||
file_stream.read(data.data(), line_length);
|
||||
for (auto i = 0; i < data.size(); i++) {
|
||||
data[i] = XOR(data[i], i);
|
||||
}
|
||||
|
||||
for (int i = data.size() - 1; i > 0 && data[i] != 0; i--) {
|
||||
data[i] = 0;
|
||||
}
|
||||
|
||||
// in the other zip libraries, these had to be cut off, with libzip we need to zero them out
|
||||
// cutting them off makes the archive invalid
|
||||
//data.resize(last_zero);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ifstream file_stream;
|
||||
long line_length;
|
||||
|
||||
[[nodiscard]] char XOR(const char b, const long position) const
|
||||
{
|
||||
if (position > line_length - 4) {
|
||||
return b ^ TPF_XOREven;
|
||||
}
|
||||
|
||||
return position % 2 == 0 ? b ^ TPF_XOREven : b ^ TPF_XOROdd;
|
||||
}
|
||||
|
||||
static constexpr char TPF_XOROdd = 0x3F;
|
||||
static constexpr char TPF_XOREven = static_cast<char>(0xA4);
|
||||
};
|
||||
@@ -1,386 +0,0 @@
|
||||
module;
|
||||
|
||||
#include "Main.h"
|
||||
#include "Error.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include <DDSTextureLoader/DDSTextureLoader9.h>
|
||||
#include <DirectXTex/DirectXTex.h>
|
||||
|
||||
export module TextureClient;
|
||||
import TextureFunction;
|
||||
import ModfileLoader;
|
||||
|
||||
/*
|
||||
* An object of this class is owned by each d3d9 device.
|
||||
* All other functions are called from the render thread instance of the game itself.
|
||||
*/
|
||||
export class TextureClient {
|
||||
public:
|
||||
TextureClient(IDirect3DDevice9* device);
|
||||
~TextureClient();
|
||||
|
||||
int AddTexture(uModTexturePtr auto pTexture);
|
||||
int RemoveTexture(uModTexturePtr auto pTexture); //called from uMod_IDirect3DTexture9::Release()
|
||||
int LookUpToMod(uModTexturePtr auto pTexture);
|
||||
// called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
int MergeUpdate(); //called from uMod_IDirect3DDevice9::BeginScene()
|
||||
void Initialize();
|
||||
|
||||
std::vector<uMod_IDirect3DTexture9*> OriginalTextures;
|
||||
// stores the pointer to the uMod_IDirect3DTexture9 objects created by the game
|
||||
std::vector<uMod_IDirect3DVolumeTexture9*> OriginalVolumeTextures;
|
||||
// stores the pointer to the uMod_IDirect3DVolumeTexture9 objects created by the game
|
||||
std::vector<uMod_IDirect3DCubeTexture9*> OriginalCubeTextures;
|
||||
// stores the pointer to the uMod_IDirect3DCubeTexture9 objects created by the game
|
||||
|
||||
|
||||
private:
|
||||
IDirect3DDevice9* D3D9Device;
|
||||
// Cached info about whether this id a dx9ex device or not; used for proxy functions
|
||||
bool isDirectXExDevice = false;
|
||||
|
||||
// DX9 proxy functions
|
||||
void SetLastCreatedTexture(uMod_IDirect3DTexture9*);
|
||||
void SetLastCreatedVolumeTexture(uMod_IDirect3DVolumeTexture9*);
|
||||
void SetLastCreatedCubeTexture(uMod_IDirect3DCubeTexture9*);
|
||||
|
||||
bool should_update = false;
|
||||
|
||||
int LockMutex();
|
||||
int UnlockMutex();
|
||||
HANDLE hMutex;
|
||||
|
||||
std::unordered_map<HashType, gsl::owner<TextureFileStruct*>> modded_textures;
|
||||
// array which stores the file in memory and the hash of each texture to be modded
|
||||
|
||||
// called if a target texture is found
|
||||
int LoadTexture(TextureFileStruct* file_in_memory, uModTexturePtrPtr auto ppTexture);
|
||||
|
||||
void LoadModsFromFile(const char* source);
|
||||
std::filesystem::path exe_path; // path to gw.exe
|
||||
std::filesystem::path dll_path; // path to gmod dll
|
||||
};
|
||||
|
||||
TextureClient::TextureClient(IDirect3DDevice9* device)
|
||||
{
|
||||
Message("TextureClient::TextureClient(): %p\n", this);
|
||||
D3D9Device = device;
|
||||
|
||||
void* cpy;
|
||||
isDirectXExDevice = D3D9Device->QueryInterface(IID_IDirect3DTexture9, &cpy) == 0x01000001L;
|
||||
|
||||
hMutex = CreateMutex(nullptr, false, nullptr);
|
||||
}
|
||||
|
||||
TextureClient::~TextureClient()
|
||||
{
|
||||
Message("TextureClient::~TextureClient(): %p\n", this);
|
||||
if (hMutex != nullptr) {
|
||||
CloseHandle(hMutex);
|
||||
}
|
||||
for (const auto texture_file_struct : modded_textures | std::views::values) {
|
||||
delete texture_file_struct;
|
||||
}
|
||||
modded_textures.clear();
|
||||
}
|
||||
|
||||
int TextureClient::MergeUpdate()
|
||||
{
|
||||
if (!should_update) return RETURN_OK;
|
||||
should_update = false;
|
||||
if (const int ret = LockMutex()) {
|
||||
gl_ErrorState |= uMod_ERROR_TEXTURE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Message("MergeUpdate(): %p\n", this);
|
||||
|
||||
for (const auto pTexture : OriginalTextures) {
|
||||
if (pTexture->CrossRef_D3Dtex == nullptr) {
|
||||
LookUpToMod(pTexture);
|
||||
}
|
||||
}
|
||||
for (const auto pTexture : OriginalVolumeTextures) {
|
||||
if (pTexture->CrossRef_D3Dtex == nullptr) {
|
||||
LookUpToMod(pTexture);
|
||||
}
|
||||
}
|
||||
for (const auto pTexture : OriginalCubeTextures) {
|
||||
if (pTexture->CrossRef_D3Dtex == nullptr) {
|
||||
LookUpToMod(pTexture);
|
||||
}
|
||||
}
|
||||
|
||||
return UnlockMutex();
|
||||
}
|
||||
|
||||
void TextureClient::SetLastCreatedTexture(uMod_IDirect3DTexture9* texture)
|
||||
{
|
||||
if (isDirectXExDevice)
|
||||
return static_cast<uMod_IDirect3DDevice9Ex*>(D3D9Device)->SetLastCreatedTexture(texture);
|
||||
return static_cast<uMod_IDirect3DDevice9*>(D3D9Device)->SetLastCreatedTexture(texture);
|
||||
}
|
||||
|
||||
void TextureClient::SetLastCreatedVolumeTexture(uMod_IDirect3DVolumeTexture9* texture)
|
||||
{
|
||||
if (isDirectXExDevice)
|
||||
return static_cast<uMod_IDirect3DDevice9Ex*>(D3D9Device)->SetLastCreatedVolumeTexture(texture);
|
||||
return static_cast<uMod_IDirect3DDevice9*>(D3D9Device)->SetLastCreatedVolumeTexture(texture);
|
||||
}
|
||||
|
||||
void TextureClient::SetLastCreatedCubeTexture(uMod_IDirect3DCubeTexture9* texture)
|
||||
{
|
||||
if (isDirectXExDevice)
|
||||
return static_cast<uMod_IDirect3DDevice9Ex*>(D3D9Device)->SetLastCreatedCubeTexture(texture);
|
||||
return static_cast<uMod_IDirect3DDevice9*>(D3D9Device)->SetLastCreatedCubeTexture(texture);
|
||||
}
|
||||
|
||||
int TextureClient::LockMutex()
|
||||
{
|
||||
if ((gl_ErrorState & (uMod_ERROR_FATAL | uMod_ERROR_MUTEX))) {
|
||||
return RETURN_NO_MUTEX;
|
||||
}
|
||||
if (WAIT_OBJECT_0 != WaitForSingleObject(hMutex, 100)) {
|
||||
return RETURN_MUTEX_LOCK; //waiting 100ms, to wait infinite pass INFINITE
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
int TextureClient::UnlockMutex()
|
||||
{
|
||||
if (ReleaseMutex(hMutex) == 0) {
|
||||
return RETURN_MUTEX_UNLOCK;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
gsl::owner<TextureFileStruct*> AddFile(TexEntry& entry, const bool compress, const std::filesystem::path& dll_path)
|
||||
{
|
||||
const auto texture_file_struct = new TextureFileStruct();
|
||||
texture_file_struct->crc_hash = entry.crc_hash;
|
||||
const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress, dll_path);
|
||||
texture_file_struct->data.assign(static_cast<BYTE*>(dds_blob.GetBufferPointer()), static_cast<BYTE*>(dds_blob.GetBufferPointer()) + dds_blob.GetBufferSize());
|
||||
return texture_file_struct;
|
||||
}
|
||||
|
||||
std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::string& modfile, const std::filesystem::path& dll_path, const bool compress)
|
||||
{
|
||||
const auto hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
if (FAILED(hr)) return {};
|
||||
Message("Initialize: loading file %s... ", modfile.c_str());
|
||||
auto file_loader = ModfileLoader(modfile);
|
||||
auto entries = file_loader.GetContents();
|
||||
if (entries.empty()) {
|
||||
Message("No entries found.\n");
|
||||
return {};
|
||||
}
|
||||
Message("%zu textures... ", entries.size());
|
||||
std::vector<gsl::owner<TextureFileStruct*>> texture_file_structs;
|
||||
texture_file_structs.reserve(entries.size());
|
||||
unsigned file_bytes_loaded = 0;
|
||||
for (auto& tpf_entry : entries) {
|
||||
const auto tex_file_struct = AddFile(tpf_entry, compress, dll_path);
|
||||
texture_file_structs.push_back(tex_file_struct);
|
||||
file_bytes_loaded += texture_file_structs.back()->data.size();
|
||||
}
|
||||
entries.clear();
|
||||
Message("%d bytes loaded.\n", file_bytes_loaded);
|
||||
CoUninitialize();
|
||||
return texture_file_structs;
|
||||
}
|
||||
|
||||
void TextureClient::LoadModsFromFile(const char* source)
|
||||
{
|
||||
static std::vector<std::string> loaded_modfiles{};
|
||||
Message("Initialize: searching in %s\n", source);
|
||||
|
||||
std::ifstream file(source);
|
||||
if (!file.is_open()) {
|
||||
Warning("LoadModsFromFile: failed to open modlist.txt for reading; aborting!!!");
|
||||
return;
|
||||
}
|
||||
Message("Initialize: found modlist.txt. Reading\n");
|
||||
std::string line;
|
||||
std::vector<std::string> modfiles;
|
||||
while (std::getline(file, line)) {
|
||||
// Remove newline character
|
||||
line.erase(std::ranges::remove(line, '\r').begin(), line.end());
|
||||
line.erase(std::ranges::remove(line, '\n').begin(), line.end());
|
||||
|
||||
if (!std::ranges::contains(loaded_modfiles, line)) {
|
||||
modfiles.push_back(line);
|
||||
loaded_modfiles.push_back(line);
|
||||
}
|
||||
}
|
||||
auto files_size = 0u;
|
||||
for (const auto modfile : modfiles) {
|
||||
if (std::filesystem::exists(modfile)) {
|
||||
files_size += std::filesystem::file_size(modfile);
|
||||
}
|
||||
}
|
||||
std::vector<std::future<std::vector<gsl::owner<TextureFileStruct*>>>> futures;
|
||||
for (const auto modfile : modfiles) {
|
||||
futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, dll_path, files_size > 400'000'000));
|
||||
}
|
||||
auto loaded_size = 0u;
|
||||
for (auto& future : futures) {
|
||||
const auto texture_file_structs = future.get();
|
||||
for (const auto texture_file_struct : texture_file_structs) {
|
||||
if (!texture_file_struct->crc_hash) continue;
|
||||
if (!modded_textures.contains(texture_file_struct->crc_hash)) {
|
||||
modded_textures.emplace(texture_file_struct->crc_hash, texture_file_struct);
|
||||
loaded_size += texture_file_struct->data.size();
|
||||
}
|
||||
else {
|
||||
delete texture_file_struct;
|
||||
}
|
||||
}
|
||||
should_update = true;
|
||||
}
|
||||
Message("Finished loading mods from %s: Loaded %u bytes (%u mb)", source, loaded_size, loaded_size / 1024 / 1024);
|
||||
}
|
||||
|
||||
void TextureClient::Initialize()
|
||||
{
|
||||
const auto t1 = std::chrono::high_resolution_clock::now();
|
||||
Info("Initialize: begin\n");
|
||||
Message("Initialize: searching for modlist.txt\n");
|
||||
char gwpath[MAX_PATH]{};
|
||||
GetModuleFileName(GetModuleHandle(nullptr), gwpath, MAX_PATH); //ask for name and path of this executable
|
||||
char dllpath[MAX_PATH]{};
|
||||
GetModuleFileName(gl_hThisInstance, dllpath, MAX_PATH); //ask for name and path of this dll
|
||||
exe_path = std::filesystem::path(gwpath).parent_path();
|
||||
dll_path = std::filesystem::path(dllpath).parent_path();
|
||||
for (const auto& path : {exe_path, dll_path}) {
|
||||
const auto modlist = path / "modlist.txt";
|
||||
if (std::filesystem::exists(modlist)) {
|
||||
Message("Initialize: found %s\n", modlist.string().c_str());
|
||||
LoadModsFromFile(modlist.string().c_str());
|
||||
}
|
||||
}
|
||||
const auto t2 = std::chrono::high_resolution_clock::now();
|
||||
const auto ms = duration_cast<std::chrono::milliseconds>(t2 - t1);
|
||||
Info("Initialize: end, took %d ms\n", ms);
|
||||
}
|
||||
|
||||
int TextureClient::AddTexture(uModTexturePtr auto pTexture)
|
||||
{
|
||||
if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DTexture9*>) {
|
||||
SetLastCreatedTexture(nullptr);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DVolumeTexture9*>) {
|
||||
SetLastCreatedVolumeTexture(nullptr);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DCubeTexture9*>) {
|
||||
SetLastCreatedCubeTexture(nullptr);
|
||||
}
|
||||
|
||||
if (pTexture->FAKE) {
|
||||
return RETURN_OK; // this is a fake texture
|
||||
}
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
Message("TextureClient::AddTexture( Cube: %p): %p (thread: %u)\n", pTexture, this, GetCurrentThreadId());
|
||||
|
||||
pTexture->Hash = pTexture->GetHash();
|
||||
if (!pTexture->Hash) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DTexture9*>) {
|
||||
OriginalTextures.push_back(pTexture);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DVolumeTexture9*>) {
|
||||
OriginalVolumeTextures.push_back(pTexture);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DCubeTexture9*>) {
|
||||
OriginalCubeTextures.push_back(pTexture);
|
||||
}
|
||||
|
||||
return LookUpToMod(pTexture); // check if this texture should be modded
|
||||
}
|
||||
|
||||
int TextureClient::RemoveTexture(uModTexturePtr auto pTexture)
|
||||
{
|
||||
Message("TextureClient::RemoveTexture( %p, %#lX): %p\n", pTexture, pTexture->Hash, this);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) {
|
||||
return RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if (!pTexture->FAKE) {
|
||||
if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DTexture9*>) {
|
||||
utils::erase_first(OriginalTextures, pTexture);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DVolumeTexture9*>) {
|
||||
utils::erase_first(OriginalVolumeTextures, pTexture);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(pTexture), uMod_IDirect3DCubeTexture9*>) {
|
||||
utils::erase_first(OriginalCubeTextures, pTexture);
|
||||
}
|
||||
}
|
||||
if (!pTexture->Reference)
|
||||
return RETURN_OK; // Should this ever happen?
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
int TextureClient::LookUpToMod(uModTexturePtr auto pTexture)
|
||||
{
|
||||
Message("TextureClient::LookUpToMod( %p): hash: %#lX, %p\n", pTexture, pTexture->Hash, this);
|
||||
int ret = RETURN_OK;
|
||||
|
||||
if (pTexture->CrossRef_D3Dtex != nullptr)
|
||||
return ret; // bug, this texture is already switched
|
||||
|
||||
const auto found = modded_textures.find(pTexture->Hash);
|
||||
if (found == modded_textures.end())
|
||||
return ret;
|
||||
|
||||
const auto textureFileStruct = found->second;
|
||||
|
||||
decltype(pTexture) fake_Texture;
|
||||
ret = LoadTexture(textureFileStruct, &fake_Texture);
|
||||
if (ret != RETURN_OK)
|
||||
return ret;
|
||||
|
||||
ret = SwitchTextures(fake_Texture, pTexture);
|
||||
if (ret != RETURN_OK) {
|
||||
Message("TextureClient::LookUpToMod(): textures not switched %#lX\n", textureFileStruct->crc_hash);
|
||||
fake_Texture->Release();
|
||||
return ret;
|
||||
}
|
||||
fake_Texture->Reference = textureFileStruct;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TextureClient::LoadTexture(TextureFileStruct* file_in_memory, uModTexturePtrPtr auto ppTexture)
|
||||
{
|
||||
Message("LoadTexture( %p, %p, %#lX): %p\n", file_in_memory, ppTexture, file_in_memory->crc_hash, this);
|
||||
if (const auto ret = DirectX::CreateDDSTextureFromMemoryEx(
|
||||
D3D9Device,
|
||||
file_in_memory->data.data(),
|
||||
file_in_memory->data.size(),
|
||||
0, D3DPOOL_MANAGED, false,
|
||||
reinterpret_cast<LPDIRECT3DTEXTURE9*>(ppTexture)); ret != D3D_OK) {
|
||||
*ppTexture = nullptr;
|
||||
Warning("LoadDDSTexture (%p, %#lX): FAILED ret: \n", file_in_memory->data.data(), file_in_memory->crc_hash, ret);
|
||||
return RETURN_TEXTURE_NOT_LOADED;
|
||||
}
|
||||
if constexpr (std::same_as<decltype(ppTexture), uMod_IDirect3DTexture9**>) {
|
||||
SetLastCreatedTexture(nullptr);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(ppTexture), uMod_IDirect3DVolumeTexture9**>) {
|
||||
SetLastCreatedVolumeTexture(nullptr);
|
||||
}
|
||||
else if constexpr (std::same_as<decltype(ppTexture), uMod_IDirect3DCubeTexture9**>) {
|
||||
SetLastCreatedCubeTexture(nullptr);
|
||||
}
|
||||
(*ppTexture)->FAKE = true;
|
||||
|
||||
Message("LoadTexture (%p, %#lX): DONE\n", *ppTexture, file_in_memory->crc_hash);
|
||||
return RETURN_OK;
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
module;
|
||||
|
||||
#include "Main.h"
|
||||
#include <d3d9types.h>
|
||||
#include <DirectXTex/DirectXTex.h>
|
||||
|
||||
export module TextureFunction;
|
||||
|
||||
export template <typename T>
|
||||
concept uModTexturePtr = requires(T a)
|
||||
{
|
||||
std::same_as<uMod_IDirect3DTexture9*, T> ||
|
||||
std::same_as<uMod_IDirect3DVolumeTexture9*, T> ||
|
||||
std::same_as<uMod_IDirect3DCubeTexture9*, T>;
|
||||
};
|
||||
|
||||
export template <typename T>
|
||||
concept uModTexturePtrPtr = uModTexturePtr<std::remove_pointer_t<T>>;
|
||||
|
||||
export template <typename T> requires uModTexturePtr<T>
|
||||
void UnswitchTextures(T pTexture)
|
||||
{
|
||||
decltype(pTexture) CrossRef = pTexture->CrossRef_D3Dtex;
|
||||
if (CrossRef != nullptr) {
|
||||
std::swap(pTexture->m_D3Dtex, CrossRef->m_D3Dtex);
|
||||
|
||||
// cancel the link
|
||||
CrossRef->CrossRef_D3Dtex = nullptr;
|
||||
pTexture->CrossRef_D3Dtex = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
export template <typename T> requires uModTexturePtr<T>
|
||||
int SwitchTextures(T pTexture1, T pTexture2)
|
||||
{
|
||||
if (pTexture1->m_D3Ddev == pTexture2->m_D3Ddev && pTexture1->CrossRef_D3Dtex == nullptr && pTexture2->CrossRef_D3Dtex == nullptr) {
|
||||
// make cross reference
|
||||
pTexture1->CrossRef_D3Dtex = pTexture2;
|
||||
pTexture2->CrossRef_D3Dtex = pTexture1;
|
||||
|
||||
// switch textures
|
||||
std::swap(pTexture1->m_D3Dtex, pTexture2->m_D3Dtex);
|
||||
return RETURN_OK;
|
||||
}
|
||||
return RETURN_TEXTURE_NOT_SWITCHED;
|
||||
}
|
||||
|
||||
export namespace TextureFunction {
|
||||
|
||||
unsigned int GetCRC32(char* pcDatabuf, unsigned int ulDatalen)
|
||||
{
|
||||
constexpr static auto crc32_poly = 0xEDB88320u;
|
||||
constexpr static auto ul_crc_in = 0xffffffff;
|
||||
unsigned int crc = ul_crc_in;
|
||||
for (unsigned int idx = 0u; idx < ulDatalen; idx++) {
|
||||
unsigned int data = *pcDatabuf++;
|
||||
for (unsigned int bit = 0u; bit < 8u; bit++, data >>= 1) {
|
||||
crc = crc >> 1 ^ ((crc ^ data) & 1 ? crc32_poly : 0);
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
int GetBitsFromFormat(D3DFORMAT format)
|
||||
{
|
||||
switch (format) //switch trough the formats to calculate the size of the raw data
|
||||
{
|
||||
case D3DFMT_A1: // 1-bit monochrome.
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
case D3DFMT_R3G3B2: // 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
|
||||
case D3DFMT_A8: // 8-bit alpha only.
|
||||
case D3DFMT_A8P8: // 8-bit color indexed with 8 bits of alpha.
|
||||
case D3DFMT_P8: // 8-bit color indexed.
|
||||
case D3DFMT_L8: // 8-bit luminance only.
|
||||
case D3DFMT_A4L4: // 8-bit using 4 bits each for alpha and luminance.
|
||||
case D3DFMT_FORCE_DWORD:
|
||||
case D3DFMT_S8_LOCKABLE: // A lockable 8-bit stencil buffer.
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
case D3DFMT_D16_LOCKABLE: //16-bit z-buffer bit depth.
|
||||
case D3DFMT_D15S1: // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
|
||||
case D3DFMT_L6V5U5: // 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
|
||||
case D3DFMT_V8U8: // 16-bit bump-map format using 8 bits each for u and v data.
|
||||
case D3DFMT_CxV8U8: // 16-bit normal compression format. The texture sampler computes the C channel from: C = sqrt(1 - U2 - V2).
|
||||
case D3DFMT_R5G6B5: // 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
|
||||
case D3DFMT_X1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color.
|
||||
case D3DFMT_A1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
|
||||
case D3DFMT_A4R4G4B4: // 16-bit ARGB pixel format with 4 bits for each channel.
|
||||
case D3DFMT_A8R3G3B2: // 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
|
||||
case D3DFMT_X4R4G4B4: // 16-bit RGB pixel format using 4 bits for each color.
|
||||
case D3DFMT_L16: // 16-bit luminance only.
|
||||
case D3DFMT_R16F: // 16-bit float format using 16 bits for the red channel.
|
||||
case D3DFMT_A8L8: // 16-bit using 8 bits each for alpha and luminance.
|
||||
case D3DFMT_D16: // 16-bit z-buffer bit depth.
|
||||
case D3DFMT_INDEX16: // 16-bit index buffer bit depth.
|
||||
case D3DFMT_G8R8_G8B8: // ??
|
||||
case D3DFMT_R8G8_B8G8: // ??
|
||||
case D3DFMT_UYVY: // ??
|
||||
case D3DFMT_YUY2: // ??
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
|
||||
case D3DFMT_R8G8B8: //24-bit RGB pixel format with 8 bits per channel.
|
||||
{
|
||||
return 24;
|
||||
}
|
||||
|
||||
case D3DFMT_R32F: // 32-bit float format using 32 bits for the red channel.
|
||||
case D3DFMT_X8L8V8U8: // 32-bit bump-map format with luminance using 8 bits for each channel.
|
||||
case D3DFMT_A2W10V10U10: // 32-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.
|
||||
case D3DFMT_Q8W8V8U8: // 32-bit bump-map format using 8 bits for each channel.
|
||||
case D3DFMT_V16U16: // 32-bit bump-map format using 16 bits for each channel.
|
||||
case D3DFMT_A8R8G8B8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8R8G8B8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_A2B10G10R10: // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
|
||||
case D3DFMT_A8B8G8R8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8B8G8R8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_G16R16: // 32-bit pixel format using 16 bits each for green and red.
|
||||
case D3DFMT_G16R16F: // 32-bit float format using 16 bits for the red channel and 16 bits for the green channel.
|
||||
case D3DFMT_A2R10G10B10: // 32-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
|
||||
case D3DFMT_D32: // 32-bit z-buffer bit depth.
|
||||
case D3DFMT_D24S8: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
|
||||
case D3DFMT_D24X8: //32-bit z-buffer bit depth using 24 bits for the depth channel.
|
||||
case D3DFMT_D24X4S4: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
|
||||
case D3DFMT_D32F_LOCKABLE: // A lockable format where the depth value is represented as a standard IEEE floating-point number.
|
||||
case D3DFMT_D24FS8: // A non-lockable format that contains 24 bits of depth (in a 24-bit floating point format - 20e4) and 8 bits of stencil.
|
||||
case D3DFMT_D32_LOCKABLE: // A lockable 32-bit depth buffer.
|
||||
case D3DFMT_INDEX32: // 32-bit index buffer bit depth.
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
case D3DFMT_G32R32F: // 64-bit float format using 32 bits for the red channel and 32 bits for the green channel.
|
||||
case D3DFMT_Q16W16V16U16: // 64-bit bump-map format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16: // 64-bit pixel format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16F: // 64-bit float format using 16 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
case D3DFMT_A32B32G32R32F: // 128-bit float format using 32 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return 128;
|
||||
}
|
||||
case D3DFMT_DXT2:
|
||||
case D3DFMT_DXT3:
|
||||
case D3DFMT_DXT4:
|
||||
case D3DFMT_DXT5: {
|
||||
return 8;
|
||||
}
|
||||
case D3DFMT_DXT1: {
|
||||
return 4;
|
||||
}
|
||||
default: //compressed formats
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DirectX::ScratchImage ImageConvertToBGRA(DirectX::ScratchImage& image, const TexEntry& entry)
|
||||
{
|
||||
if (image.GetMetadata().format == DXGI_FORMAT_B8G8R8A8_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC1_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC2_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC3_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC4_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC5_UNORM) {
|
||||
return std::move(image);
|
||||
}
|
||||
DirectX::ScratchImage bgra_image;
|
||||
const HRESULT hr = DirectX::Convert(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
DirectX::TEX_FILTER_DEFAULT,
|
||||
DirectX::TEX_THRESHOLD_DEFAULT,
|
||||
bgra_image);
|
||||
if (FAILED(hr)) {
|
||||
Warning("ImageConvertToBGRA (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
bgra_image = std::move(image);
|
||||
}
|
||||
image.Release();
|
||||
return bgra_image;
|
||||
}
|
||||
|
||||
DirectX::ScratchImage ImageGenerateMipMaps(DirectX::ScratchImage& image, const TexEntry& entry)
|
||||
{
|
||||
if (entry.ext == ".dds") {
|
||||
return std::move(image);
|
||||
}
|
||||
DirectX::ScratchImage mipmapped_image;
|
||||
const auto hr = DirectX::GenerateMipMaps(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DirectX::TEX_FILTER_DEFAULT,
|
||||
0,
|
||||
mipmapped_image);
|
||||
if (FAILED(hr)) {
|
||||
Warning("GenerateMipMaps (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
mipmapped_image = std::move(image);
|
||||
}
|
||||
image.Release();
|
||||
return mipmapped_image;
|
||||
}
|
||||
|
||||
DirectX::ScratchImage ImageCompress(DirectX::ScratchImage& image, const TexEntry& entry)
|
||||
{
|
||||
if (image.GetMetadata().format == DXGI_FORMAT_BC1_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC2_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC3_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC4_UNORM ||
|
||||
image.GetMetadata().format == DXGI_FORMAT_BC5_UNORM) {
|
||||
return std::move(image);
|
||||
}
|
||||
DirectX::ScratchImage compressed_image;
|
||||
const auto hr = DirectX::Compress(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DXGI_FORMAT_BC3_UNORM,
|
||||
DirectX::TEX_COMPRESS_DEFAULT,
|
||||
DirectX::TEX_THRESHOLD_DEFAULT,
|
||||
compressed_image);
|
||||
if (FAILED(hr)) {
|
||||
Warning("ImageCompress (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
compressed_image = std::move(image);
|
||||
}
|
||||
image.Release();
|
||||
return compressed_image;
|
||||
}
|
||||
|
||||
void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry, const std::filesystem::path& dll_path)
|
||||
{
|
||||
const auto file_name = std::format("0x{:x}.dds", entry.crc_hash);
|
||||
const auto file_out = dll_path / "textures" / file_name;
|
||||
try {
|
||||
if (std::filesystem::exists(file_out)) {
|
||||
return;
|
||||
}
|
||||
if (!std::filesystem::exists(file_out.parent_path())) {
|
||||
std::filesystem::create_directory(file_out.parent_path());
|
||||
}
|
||||
const auto hr = DirectX::SaveToDDSFile(
|
||||
image.GetImages(),
|
||||
image.GetImageCount(),
|
||||
image.GetMetadata(),
|
||||
DirectX::DDS_FLAGS_NONE,
|
||||
file_out.c_str());
|
||||
if (FAILED(hr)) {
|
||||
Warning("SaveDDSImageToDisk (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
Warning("SaveDDSImageToDisk (%#lX%s): %s\n", entry.crc_hash, entry.ext.c_str(), e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress, const std::filesystem::path& dll_path)
|
||||
{
|
||||
DirectX::ScratchImage image;
|
||||
HRESULT hr = 0;
|
||||
|
||||
if (entry.ext == ".dds") {
|
||||
hr = DirectX::LoadFromDDSMemory(entry.data.data(), entry.data.size(), DirectX::DDS_FLAGS_NONE, nullptr, image);
|
||||
}
|
||||
else if (entry.ext == ".tga") {
|
||||
hr = DirectX::LoadFromTGAMemory(entry.data.data(), entry.data.size(), DirectX::TGA_FLAGS_BGR, nullptr, image);
|
||||
}
|
||||
else if (entry.ext == ".hdr") {
|
||||
hr = DirectX::LoadFromHDRMemory(entry.data.data(), entry.data.size(), nullptr, image);
|
||||
}
|
||||
else {
|
||||
hr = DirectX::LoadFromWICMemory(entry.data.data(), entry.data.size(), DirectX::WIC_FLAGS_NONE, nullptr, image);
|
||||
if (image.GetMetadata().format == DXGI_FORMAT_B8G8R8X8_UNORM) {
|
||||
// todo: this is undefined behaviour, but we must force them to be interpreted as BGRA instead of BGRX
|
||||
const_cast<DXGI_FORMAT&>(image.GetMetadata().format) = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
const auto images = image.GetImages();
|
||||
for (int i = 0; i < image.GetImageCount(); ++i) {
|
||||
const_cast<DXGI_FORMAT&>(images[i].format) = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
}
|
||||
}
|
||||
}
|
||||
entry.data.clear();
|
||||
if (FAILED(hr)) {
|
||||
Warning("LoadImageFromMemory (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto bgra_image = ImageConvertToBGRA(image, entry);
|
||||
auto mipmapped_image = ImageGenerateMipMaps(bgra_image, entry);
|
||||
const auto compressed_image = compress ? ImageCompress(mipmapped_image, entry) : std::move(mipmapped_image);
|
||||
|
||||
DirectX::Blob dds_blob;
|
||||
hr = DirectX::SaveToDDSMemory(
|
||||
compressed_image.GetImages(),
|
||||
compressed_image.GetImageCount(),
|
||||
compressed_image.GetMetadata(),
|
||||
DirectX::DDS_FLAGS_NONE,
|
||||
dds_blob);
|
||||
if (FAILED(hr)) {
|
||||
Warning("SaveDDSImageToMemory (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
ImageSave(compressed_image, entry, dll_path);
|
||||
#endif
|
||||
return dds_blob;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "Error.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <cstdio>
|
||||
#include <process.h>
|
||||
#include <Main.h>
|
||||
|
||||
__declspec(noreturn) void FatalAssert(
|
||||
const char *expr,
|
||||
const char *file,
|
||||
unsigned int line,
|
||||
const char *function)
|
||||
{
|
||||
char module_path[MAX_PATH]{};
|
||||
if (gl_hThisInstance) {
|
||||
GetModuleFileName(gl_hThisInstance, module_path, _countof(module_path));
|
||||
}
|
||||
if (!*module_path) {
|
||||
strcpy(module_path, "Unknown");
|
||||
}
|
||||
const char* fmt = "Module: %s\n\nExpr: %s\n\nFile: %s\n\nFunction: %s, line %d";
|
||||
int len = snprintf(NULL, 0, fmt, module_path, expr, file, function, line);
|
||||
char* buf = new char[len + 1];
|
||||
snprintf(buf,len + 1, fmt, module_path, expr, file, function, line);
|
||||
|
||||
|
||||
MessageBox(0, buf, "uMod Assertion Failure", MB_OK | MB_ICONERROR);
|
||||
|
||||
delete[] buf;
|
||||
abort();
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
#include "Main.h"
|
||||
#include <Psapi.h>
|
||||
#include "MinHook.h"
|
||||
|
||||
void ExitInstance();
|
||||
void InitInstance(HINSTANCE hModule);
|
||||
|
||||
namespace {
|
||||
|
||||
#define DISABLE_HOOK(var) if(var) { MH_DisableHook(var);}
|
||||
|
||||
using Direct3DCreate9_type = IDirect3D9* (APIENTRY*)(UINT);
|
||||
using Direct3DCreate9Ex_type = HRESULT(APIENTRY*)(UINT SDKVersion, IDirect3D9Ex** ppD3D);
|
||||
using GetProcAddress_type = FARPROC(APIENTRY*)(HMODULE, LPCSTR);
|
||||
|
||||
// Pointer to original address of Direct3DCreate9
|
||||
Direct3DCreate9_type Direct3DCreate9_ret = nullptr;
|
||||
|
||||
// Pointer to original address of Direct3DCreate9
|
||||
Direct3DCreate9Ex_type Direct3DCreate9Ex_ret = nullptr;
|
||||
|
||||
GetProcAddress_type GetProcAddress_fn = nullptr;
|
||||
GetProcAddress_type GetProcAddress_ret = nullptr;
|
||||
|
||||
FILE* stdout_proxy;
|
||||
FILE* stderr_proxy;
|
||||
|
||||
HMODULE gMod_Loaded_d3d9_Module_Handle = nullptr;
|
||||
|
||||
HMODULE FindLoadedModuleByName(const char* name, bool include_this_module = false)
|
||||
{
|
||||
HMODULE hModules[1024];
|
||||
HANDLE hProcess;
|
||||
DWORD cbNeeded;
|
||||
unsigned int i;
|
||||
|
||||
// Get a handle to the current process.
|
||||
hProcess = GetCurrentProcess();
|
||||
if (!EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded))
|
||||
return nullptr;
|
||||
for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
||||
if (hModules[i] == gl_hThisInstance && !include_this_module)
|
||||
continue;
|
||||
TCHAR szModuleName[MAX_PATH];
|
||||
ASSERT(GetModuleFileName(hModules[i], szModuleName, _countof(szModuleName)) > 0);
|
||||
const auto basename = strrchr(szModuleName, '\\');
|
||||
if (basename && stricmp(basename + 1, name) == 0)
|
||||
return hModules[i];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HMODULE LoadD3d9Dll()
|
||||
{
|
||||
HMODULE found = FindLoadedModuleByName("d3d9.dll");
|
||||
if (!found) {
|
||||
char executable_path[MAX_PATH]{};
|
||||
ASSERT(GetModuleFileName(GetModuleHandle(nullptr), executable_path, _countof(executable_path)) > 0);
|
||||
|
||||
char dll_path[MAX_PATH]{};
|
||||
ASSERT(GetModuleFileName(gl_hThisInstance, dll_path, _countof(dll_path)) > 0);
|
||||
|
||||
const auto exe_path = std::filesystem::path(executable_path);
|
||||
const auto gmod_path = std::filesystem::path(dll_path);
|
||||
|
||||
if (exe_path.parent_path() != gmod_path.parent_path()
|
||||
|| gmod_path.filename() != "d3d9.dll") {
|
||||
// Call basic LoadLibrary function; we're not in the same directory as the exe.
|
||||
gMod_Loaded_d3d9_Module_Handle = LoadLibrary("d3d9.dll");
|
||||
}
|
||||
if (!gMod_Loaded_d3d9_Module_Handle) {
|
||||
// Tried resolving d3d9.dll locally, didn't work. Try system directory
|
||||
char buffer[MAX_PATH];
|
||||
ASSERT(GetSystemDirectory(buffer, _countof(buffer)) > 0); //get the system directory, we need to open the original d3d9.dll
|
||||
|
||||
// Append dll name
|
||||
strcat_s(buffer, _countof(buffer), "\\d3d9.dll");
|
||||
gMod_Loaded_d3d9_Module_Handle = LoadLibrary(buffer);
|
||||
}
|
||||
|
||||
ASSERT(gMod_Loaded_d3d9_Module_Handle);
|
||||
|
||||
found = FindLoadedModuleByName("d3d9.dll");
|
||||
ASSERT(found && found == gMod_Loaded_d3d9_Module_Handle);
|
||||
}
|
||||
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
// GetProcAddress, hooked via OnGetProcAddress
|
||||
Direct3DCreate9_ret = reinterpret_cast<Direct3DCreate9_type>(GetProcAddress(found, "Direct3DCreate9"));
|
||||
Direct3DCreate9Ex_ret = reinterpret_cast<Direct3DCreate9Ex_type>(GetProcAddress(found, "Direct3DCreate9Ex"));
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
FARPROC APIENTRY OnGetProcAddress(HMODULE hModule, LPCSTR lpProcName)
|
||||
{
|
||||
ASSERT(GetProcAddress_ret);
|
||||
if ((int)lpProcName < 0xffff)
|
||||
return GetProcAddress_ret(hModule, lpProcName); // lpProcName is ordinal offset, not string
|
||||
|
||||
if (strcmp(lpProcName, "Direct3DCreate9") == 0) {
|
||||
Direct3DCreate9_ret = reinterpret_cast<Direct3DCreate9_type>(GetProcAddress_ret(hModule, lpProcName));
|
||||
return reinterpret_cast<FARPROC>(Direct3DCreate9);
|
||||
}
|
||||
if (strcmp(lpProcName, "Direct3DCreate9Ex") == 0) {
|
||||
Direct3DCreate9Ex_ret = reinterpret_cast<Direct3DCreate9Ex_type>(GetProcAddress_ret(hModule, lpProcName));
|
||||
return reinterpret_cast<FARPROC>(Direct3DCreate9Ex);
|
||||
}
|
||||
return GetProcAddress_ret(hModule, lpProcName);
|
||||
}
|
||||
|
||||
// If the original d3d9 function is nullptr or points to gMod, load the actual d3d9 dll and redirect the addresses
|
||||
void CheckLoadD3d9Dll()
|
||||
{
|
||||
if (!(Direct3DCreate9_ret && Direct3DCreate9_ret != Direct3DCreate9)) {
|
||||
ASSERT(LoadD3d9Dll());
|
||||
ASSERT(Direct3DCreate9_ret && Direct3DCreate9_ret != Direct3DCreate9);
|
||||
}
|
||||
if (!(Direct3DCreate9Ex_ret && Direct3DCreate9Ex_ret != Direct3DCreate9Ex)) {
|
||||
ASSERT(LoadD3d9Dll());
|
||||
ASSERT(Direct3DCreate9Ex_ret && Direct3DCreate9Ex_ret != Direct3DCreate9Ex);
|
||||
}
|
||||
}
|
||||
|
||||
// There may be a sitation where more than 1 gmod is loaded; avoid recursions!
|
||||
bool creating_d3d9 = false;
|
||||
}
|
||||
|
||||
unsigned int gl_ErrorState = 0;
|
||||
HINSTANCE gl_hThisInstance = nullptr;
|
||||
|
||||
IDirect3D9* APIENTRY Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
Message("uMod_Direct3DCreate9: uMod %p\n", Direct3DCreate9);
|
||||
|
||||
ASSERT(!creating_d3d9);
|
||||
creating_d3d9 = true;
|
||||
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
CheckLoadD3d9Dll();
|
||||
|
||||
IDirect3D9* pIDirect3D9_orig = Direct3DCreate9_ret(SDKVersion); //creating the original IDirect3D9 object
|
||||
ASSERT(pIDirect3D9_orig);
|
||||
|
||||
creating_d3d9 = false;
|
||||
|
||||
return new uMod_IDirect3D9(pIDirect3D9_orig); //return our object instead of the "real one"
|
||||
}
|
||||
|
||||
HRESULT APIENTRY Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex** ppD3D)
|
||||
{
|
||||
Message("uMod_Direct3DCreate9Ex: uMod %p\n", Direct3DCreate9Ex);
|
||||
|
||||
ASSERT(!creating_d3d9);
|
||||
creating_d3d9 = true;
|
||||
|
||||
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
CheckLoadD3d9Dll();
|
||||
|
||||
IDirect3D9Ex* pIDirect3D9Ex_orig = nullptr;
|
||||
HRESULT ret = Direct3DCreate9Ex_ret(SDKVersion, &pIDirect3D9Ex_orig); //creating the original IDirect3D9 object
|
||||
|
||||
creating_d3d9 = false;
|
||||
|
||||
if (ret != S_OK)
|
||||
return ret;
|
||||
|
||||
// @Cleanup: should be we freeing pIDirect3D9Ex at the end of our own lifecycle?
|
||||
const auto pIDirect3D9Ex = new uMod_IDirect3D9Ex(pIDirect3D9Ex_orig);
|
||||
// original umod does not do this for some reason
|
||||
*ppD3D = static_cast<IDirect3D9Ex*>(pIDirect3D9Ex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* dll entry routine, here we initialize or clean up
|
||||
*/
|
||||
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH: {
|
||||
#ifdef _DEBUG
|
||||
AllocConsole();
|
||||
SetConsoleTitleA("gMod Console");
|
||||
freopen_s(&stdout_proxy, "CONOUT$", "w", stdout);
|
||||
freopen_s(&stderr_proxy, "CONOUT$", "w", stderr);
|
||||
#endif
|
||||
InitInstance(hModule);
|
||||
break;
|
||||
}
|
||||
case DLL_PROCESS_DETACH: {
|
||||
ExitInstance();
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InitInstance(HINSTANCE hModule)
|
||||
{
|
||||
Message("InitInstance: %p\n", hModule);
|
||||
DisableThreadLibraryCalls(hModule); //reduce overhead
|
||||
|
||||
// Store the handle to this module
|
||||
gl_hThisInstance = hModule;
|
||||
|
||||
// d3d9.dll shouldn't be loaded at this point.
|
||||
const auto d3d9_loaded = FindLoadedModuleByName("d3d9.dll");
|
||||
ASSERT(!d3d9_loaded);
|
||||
|
||||
MH_Initialize();
|
||||
|
||||
// Hook into LoadLibraryA - we'll do our hooks on the flip side
|
||||
GetProcAddress_fn = reinterpret_cast<GetProcAddress_type>(GetProcAddress);
|
||||
ASSERT(GetProcAddress_fn);
|
||||
if (GetProcAddress_fn) {
|
||||
MH_CreateHook(GetProcAddress_fn, OnGetProcAddress, (void**)&GetProcAddress_ret);
|
||||
MH_EnableHook(GetProcAddress_fn);
|
||||
}
|
||||
}
|
||||
|
||||
void ExitInstance()
|
||||
{
|
||||
DISABLE_HOOK(GetProcAddress_fn);
|
||||
|
||||
MH_Uninitialize();
|
||||
|
||||
if (gMod_Loaded_d3d9_Module_Handle)
|
||||
FreeLibrary(gMod_Loaded_d3d9_Module_Handle);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (stdout_proxy)
|
||||
fclose(stdout_proxy);
|
||||
if (stderr_proxy)
|
||||
fclose(stderr_proxy);
|
||||
__try {
|
||||
FreeConsole();
|
||||
}
|
||||
__except (EXCEPTION_CONTINUE_EXECUTION) { }
|
||||
#endif
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
#include "Main.h"
|
||||
|
||||
#ifndef PRE_MESSAGE
|
||||
#define PRE_MESSAGE "uMod_IDirect3D9"
|
||||
#endif
|
||||
|
||||
uMod_IDirect3D9::uMod_IDirect3D9(IDirect3D9* pOriginal)
|
||||
{
|
||||
Message(PRE_MESSAGE "::" PRE_MESSAGE " (%p): %p\n", pOriginal, this);
|
||||
m_pIDirect3D9 = pOriginal;
|
||||
}
|
||||
|
||||
uMod_IDirect3D9::~uMod_IDirect3D9()
|
||||
{
|
||||
Message(PRE_MESSAGE "::~" PRE_MESSAGE "(): %p\n", this);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
*ppvObj = nullptr;
|
||||
|
||||
// call this to increase AddRef at original object
|
||||
// and to check if such an interface is there
|
||||
|
||||
const HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj);
|
||||
|
||||
if (hRes == NOERROR) // if OK, send our "fake" address
|
||||
{
|
||||
*ppvObj = this;
|
||||
}
|
||||
|
||||
return hRes;
|
||||
}
|
||||
|
||||
ULONG __stdcall uMod_IDirect3D9::AddRef()
|
||||
{
|
||||
return m_pIDirect3D9->AddRef();
|
||||
}
|
||||
|
||||
ULONG __stdcall uMod_IDirect3D9::Release()
|
||||
{
|
||||
// call original routine
|
||||
const ULONG count = m_pIDirect3D9->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction)
|
||||
{
|
||||
return m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction);
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9::GetAdapterCount()
|
||||
{
|
||||
return m_pIDirect3D9->GetAdapterCount();
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier)
|
||||
{
|
||||
return m_pIDirect3D9->GetAdapterIdentifier(Adapter, Flags, pIdentifier);
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format)
|
||||
{
|
||||
return m_pIDirect3D9->GetAdapterModeCount(Adapter, Format);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode)
|
||||
{
|
||||
return m_pIDirect3D9->EnumAdapterModes(Adapter, Format, Mode, pMode);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode)
|
||||
{
|
||||
return m_pIDirect3D9->GetAdapterDisplayMode(Adapter, pMode);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
|
||||
{
|
||||
return m_pIDirect3D9->CheckDeviceType(iAdapter, DevType, DisplayFormat, BackBufferFormat, bWindowed);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
|
||||
{
|
||||
return m_pIDirect3D9->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::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 __stdcall uMod_IDirect3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
|
||||
{
|
||||
return m_pIDirect3D9->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
|
||||
{
|
||||
return m_pIDirect3D9->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps)
|
||||
{
|
||||
return m_pIDirect3D9->GetDeviceCaps(Adapter, DeviceType, pCaps);
|
||||
}
|
||||
|
||||
HMONITOR __stdcall uMod_IDirect3D9::GetAdapterMonitor(UINT Adapter)
|
||||
{
|
||||
return m_pIDirect3D9->GetAdapterMonitor(Adapter);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface)
|
||||
{
|
||||
Message(PRE_MESSAGE "::CreateDevice(): %p\n", this);
|
||||
// we intercept this call and provide our own "fake" Device Object
|
||||
const HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
|
||||
|
||||
int count = 1;
|
||||
if (pPresentationParameters != nullptr) {
|
||||
count = pPresentationParameters->BackBufferCount;
|
||||
}
|
||||
const auto pIDirect3DDevice9 = new uMod_IDirect3DDevice9(*ppReturnedDeviceInterface, count);
|
||||
|
||||
// store our pointer (the fake one) for returning it to the calling program
|
||||
*ppReturnedDeviceInterface = pIDirect3DDevice9;
|
||||
|
||||
return hres;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#include "Main.h"
|
||||
|
||||
#define IDirect3D9 IDirect3D9Ex
|
||||
#define uMod_IDirect3D9 uMod_IDirect3D9Ex
|
||||
#define m_pIDirect3D9 m_pIDirect3D9Ex
|
||||
#define PRE_MESSAGE "uMod_IDirect3D9Ex"
|
||||
|
||||
// ReSharper disable once CppUnusedIncludeDirective
|
||||
#include "uMod_IDirect3D9.cpp"
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::CreateDeviceEx(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode,
|
||||
IDirect3DDevice9Ex** ppReturnedDeviceInterface)
|
||||
{
|
||||
Message("uMod_IDirect3D9Ex::CreateDeviceEx: %p\n", this);
|
||||
// we intercept this call and provide our own "fake" Device Object
|
||||
const HRESULT hres = m_pIDirect3D9Ex->CreateDeviceEx(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
|
||||
|
||||
int count = 1;
|
||||
if (pPresentationParameters != nullptr) {
|
||||
count = pPresentationParameters->BackBufferCount;
|
||||
}
|
||||
const auto pIDirect3DDevice9Ex = new uMod_IDirect3DDevice9Ex(*ppReturnedDeviceInterface, count);
|
||||
|
||||
// store our pointer (the fake one) for returning it to the calling program
|
||||
*ppReturnedDeviceInterface = pIDirect3DDevice9Ex;
|
||||
|
||||
return hres;
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::EnumAdapterModesEx(UINT Adapter, const D3DDISPLAYMODEFILTER* pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode)
|
||||
{
|
||||
return m_pIDirect3D9Ex->EnumAdapterModesEx(Adapter, pFilter, Mode, pMode);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::GetAdapterDisplayModeEx(UINT Adapter, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation)
|
||||
{
|
||||
return m_pIDirect3D9Ex->GetAdapterDisplayModeEx(Adapter, pMode, pRotation);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::GetAdapterLUID(UINT Adapter, LUID* pLUID)
|
||||
{
|
||||
return m_pIDirect3D9Ex->GetAdapterLUID(Adapter, pLUID);
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9Ex::GetAdapterModeCountEx(UINT Adapter, const D3DDISPLAYMODEFILTER* pFilter)
|
||||
{
|
||||
return m_pIDirect3D9Ex->GetAdapterModeCountEx(Adapter, pFilter);
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
#include "Main.h"
|
||||
|
||||
import TextureFunction;
|
||||
import TextureClient;
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid == IID_IDirect3D9) {
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return 0x01000002L;
|
||||
}
|
||||
HRESULT hRes;
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
hRes = CrossRef_D3Dtex->m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj == CrossRef_D3Dtex->m_D3Dtex) {
|
||||
*ppvObj = this;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj == m_D3Dtex) {
|
||||
*ppvObj = this;
|
||||
}
|
||||
}
|
||||
return hRes;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DCubeTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) {
|
||||
return 1; //bug, this case should never happen
|
||||
}
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->AddRef();
|
||||
}
|
||||
return m_D3Dtex->AddRef();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DCubeTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::Release(): %p\n", this);
|
||||
|
||||
void* cpy;
|
||||
const long ret = m_D3Ddev->QueryInterface(IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE) {
|
||||
UnswitchTextures(this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else {
|
||||
if (CrossRef_D3Dtex != nullptr) //if this texture is switched with a fake texture
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9* fake_texture = CrossRef_D3Dtex;
|
||||
count = fake_texture->m_D3Dtex->Release(); //release the original texture
|
||||
if (count == 0) //if texture is released we switch the textures back
|
||||
{
|
||||
UnswitchTextures(this);
|
||||
fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
}
|
||||
else {
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) //if this texture is released, we clean up
|
||||
{
|
||||
// if this texture is the LastCreatedTexture, the next time LastCreatedTexture would be added,
|
||||
// the hash of a non existing texture would be calculated
|
||||
if (ret == 0x01000000L) {
|
||||
if (static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->GetLastCreatedCubeTexture() == this) {
|
||||
static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->SetLastCreatedCubeTexture(nullptr);
|
||||
}
|
||||
else {
|
||||
static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->GetLastCreatedCubeTexture() == this) {
|
||||
static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->SetLastCreatedCubeTexture(nullptr);
|
||||
}
|
||||
else {
|
||||
static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::SetPrivateData(REFGUID refguid,CONST void* pData, DWORD SizeOfData, DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
return m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData);
|
||||
}
|
||||
return m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->FreePrivateData(refguid);
|
||||
}
|
||||
return m_D3Dtex->FreePrivateData(refguid);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return m_D3Dtex->SetPriority(PriorityNew);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetPriority()
|
||||
{
|
||||
return m_D3Dtex->GetPriority();
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DCubeTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DCubeTexture9::GetType()
|
||||
{
|
||||
return m_D3Dtex->GetType();
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return m_D3Dtex->SetLOD(LODNew);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetLOD()
|
||||
{
|
||||
return m_D3Dtex->GetLOD();
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetLevelCount()
|
||||
{
|
||||
return m_D3Dtex->GetLevelCount();
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return m_D3Dtex->SetAutoGenFilterType(FilterType);
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DCubeTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return m_D3Dtex->GetAutoGenFilterType();
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DCubeTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::AddDirtyRect(D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->AddDirtyRect(FaceType, pDirtyRect);
|
||||
}
|
||||
return m_D3Dtex->AddDirtyRect(FaceType, pDirtyRect);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetLevelDesc(UINT Level, D3DSURFACE_DESC* pDesc)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetLevelDesc(Level, pDesc);
|
||||
}
|
||||
return m_D3Dtex->GetLevelDesc(Level, pDesc);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetCubeMapSurface(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetCubeMapSurface(FaceType, Level, ppCubeMapSurface);
|
||||
}
|
||||
return m_D3Dtex->GetCubeMapSurface(FaceType, Level, ppCubeMapSurface);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::LockRect(D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect, DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->LockRect(FaceType, Level, pLockedRect, pRect, Flags);
|
||||
}
|
||||
return m_D3Dtex->LockRect(FaceType, Level, pLockedRect, pRect, Flags);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::UnlockRect(D3DCUBEMAP_FACES FaceType, UINT Level)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->UnlockRect(FaceType, Level);
|
||||
}
|
||||
return m_D3Dtex->UnlockRect(FaceType, Level);
|
||||
}
|
||||
|
||||
HashType uMod_IDirect3DCubeTexture9::GetHash() const
|
||||
{
|
||||
if (FAKE) {
|
||||
return 0;
|
||||
}
|
||||
IDirect3DCubeTexture9* pTexture = m_D3Dtex;
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
pTexture = CrossRef_D3Dtex->m_D3Dtex;
|
||||
}
|
||||
|
||||
IDirect3DSurface9* pResolvedSurface = nullptr;
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DSURFACE_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc) != D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Warning("uMod_IDirect3DCubeTexture9::GetHash() Failed: GetLevelDesc \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() (%d %d) %d\n", desc.Width, desc.Height, desc.Format);
|
||||
|
||||
if (pTexture->LockRect(D3DCUBEMAP_FACE_POSITIVE_X, 0, &d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK)
|
||||
{
|
||||
Warning("uMod_IDirect3DCubeTexture9::GetHash() Failed: LockRect 1\n");
|
||||
if (pTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_POSITIVE_X, 0, &pResolvedSurface) != D3D_OK) {
|
||||
Warning("uMod_IDirect3DCubeTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return 0;
|
||||
}
|
||||
if (pResolvedSurface->LockRect(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
pResolvedSurface->Release();
|
||||
Warning("uMod_IDirect3DCubeTexture9::GetHash() Failed: LockRect 2\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const int size = (TextureFunction::GetBitsFromFormat(desc.Format) * desc.Width * desc.Height) / 8;
|
||||
const auto hash = TextureFunction::GetCRC32(static_cast<char*>(d3dlr.pBits), size); //calculate the crc32 of the texture
|
||||
|
||||
// Only release surfaces after we're finished with d3dlr
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->UnlockRect();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else {
|
||||
pTexture->UnlockRect(D3DCUBEMAP_FACE_POSITIVE_X, 0); //unlock the raw data
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() %#lX (%d %d) %d = %d\n", hash, desc.Width, desc.Height, desc.Format, size);
|
||||
return hash;
|
||||
}
|
||||
@@ -1,913 +0,0 @@
|
||||
#include "Main.h"
|
||||
import TextureClient;
|
||||
|
||||
#ifndef RETURN_QueryInterface
|
||||
#define RETURN_QueryInterface 0x01000000L
|
||||
#endif
|
||||
|
||||
#ifndef PRE_MESSAGE
|
||||
#define PRE_MESSAGE "uMod_IDirect3DDevice9"
|
||||
#endif
|
||||
|
||||
uMod_IDirect3DDevice9::uMod_IDirect3DDevice9(IDirect3DDevice9* pOriginal, int back_buffer_count)
|
||||
{
|
||||
Message(PRE_MESSAGE "::" PRE_MESSAGE " (%p): %p\n", pOriginal, this);
|
||||
|
||||
BackBufferCount = back_buffer_count;
|
||||
|
||||
uMod_Client = new TextureClient(this); //get a new texture client for this device
|
||||
uMod_Client->Initialize();
|
||||
m_pIDirect3DDevice9 = pOriginal; // store the pointer to original object
|
||||
}
|
||||
|
||||
uMod_IDirect3DDevice9::~uMod_IDirect3DDevice9()
|
||||
{
|
||||
Message(PRE_MESSAGE "::~" PRE_MESSAGE "(): %p\n", this);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
// check if original dll can provide interface. then send *our* address
|
||||
if (riid == IID_IDirect3DTexture9) {
|
||||
// This function should never be called with IDirect3DTexture9 by the game
|
||||
*ppvObj = this;
|
||||
return RETURN_QueryInterface;
|
||||
}
|
||||
|
||||
*ppvObj = nullptr;
|
||||
Message(PRE_MESSAGE "::QueryInterface(): %p\n", this);
|
||||
const HRESULT hRes = m_pIDirect3DDevice9->QueryInterface(riid, ppvObj);
|
||||
|
||||
if (*ppvObj == m_pIDirect3DDevice9) {
|
||||
uMod_Reference++; //increasing our counter
|
||||
*ppvObj = this;
|
||||
}
|
||||
|
||||
return hRes;
|
||||
}
|
||||
|
||||
ULONG uMod_IDirect3DDevice9::AddRef()
|
||||
{
|
||||
uMod_Reference++; //increasing our counter
|
||||
Message("%p = " PRE_MESSAGE "::AddRef(): %p\n", uMod_Reference, this);
|
||||
return m_pIDirect3DDevice9->AddRef();
|
||||
}
|
||||
|
||||
ULONG uMod_IDirect3DDevice9::Release()
|
||||
{
|
||||
if (--uMod_Reference == 0) //if our counter drops to zero, the real device will be deleted, so we clean up before
|
||||
{
|
||||
// we must not release the fake textures, cause they are released if the target textures are released
|
||||
// and the target textures are released by the game.
|
||||
|
||||
delete uMod_Client; //must be deleted at the end, because other releases might call a function of this object
|
||||
uMod_Client = nullptr;
|
||||
}
|
||||
|
||||
const ULONG count = m_pIDirect3DDevice9->Release();
|
||||
Message("%p = " PRE_MESSAGE "::Release(): %p\n", count, this);
|
||||
if (uMod_Reference != count) //bug
|
||||
{
|
||||
Message("Error in " PRE_MESSAGE "::Release(): %p!=%p\n", uMod_Reference, count);
|
||||
}
|
||||
|
||||
if (count == 0u) {
|
||||
delete this;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::TestCooperativeLevel()
|
||||
{
|
||||
return m_pIDirect3DDevice9->TestCooperativeLevel();
|
||||
}
|
||||
|
||||
UINT uMod_IDirect3DDevice9::GetAvailableTextureMem()
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetAvailableTextureMem();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::EvictManagedResources()
|
||||
{
|
||||
return m_pIDirect3DDevice9->EvictManagedResources();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetDirect3D(IDirect3D9** ppD3D9)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetDirect3D(ppD3D9);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetDeviceCaps(D3DCAPS9* pCaps)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetDeviceCaps(pCaps);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetDisplayMode(iSwapChain, pMode);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetCreationParameters(pParameters);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap);
|
||||
}
|
||||
|
||||
void uMod_IDirect3DDevice9::SetCursorPosition(int X, int Y, DWORD Flags)
|
||||
{
|
||||
m_pIDirect3DDevice9->SetCursorPosition(X, Y, Flags);
|
||||
}
|
||||
|
||||
BOOL uMod_IDirect3DDevice9::ShowCursor(BOOL bShow)
|
||||
{
|
||||
return m_pIDirect3DDevice9->ShowCursor(bShow);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetSwapChain(iSwapChain, pSwapChain);
|
||||
}
|
||||
|
||||
UINT uMod_IDirect3DDevice9::GetNumberOfSwapChains()
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetNumberOfSwapChains();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters)
|
||||
{
|
||||
return m_pIDirect3DDevice9->Reset(pPresentationParameters);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)
|
||||
{
|
||||
return m_pIDirect3DDevice9->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetBackBuffer(iSwapChain, iBackBuffer, Type, ppBackBuffer);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetRasterStatus(iSwapChain, pRasterStatus);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetDialogBoxMode(BOOL bEnableDialogs)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetDialogBoxMode(bEnableDialogs);
|
||||
}
|
||||
|
||||
void uMod_IDirect3DDevice9::SetGammaRamp(UINT iSwapChain, DWORD Flags,CONST D3DGAMMARAMP* pRamp)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetGammaRamp(iSwapChain, Flags, pRamp);
|
||||
}
|
||||
|
||||
void uMod_IDirect3DDevice9::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetGammaRamp(iSwapChain, pRamp);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle)
|
||||
{
|
||||
//create real texture
|
||||
Message("uMod_IDirect3DDevice9::CreateTexture()\n");
|
||||
const HRESULT ret = m_pIDirect3DDevice9->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle);
|
||||
if (ret != D3D_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
const auto texture = new uMod_IDirect3DTexture9(ppTexture, this);
|
||||
*ppTexture = texture;
|
||||
|
||||
if (LastCreatedTexture != nullptr && uMod_Client != nullptr) //if a texture was loaded before, hopefully this texture contains now the data, so we can add it
|
||||
{
|
||||
uMod_Client->AddTexture(LastCreatedTexture);
|
||||
}
|
||||
LastCreatedTexture = texture;
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle)
|
||||
{
|
||||
//create real texture
|
||||
Message("uMod_IDirect3DDevice9::CreateVolumeTexture()\n");
|
||||
const HRESULT ret = m_pIDirect3DDevice9->CreateVolumeTexture(Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle);
|
||||
if (ret != D3D_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//create fake texture
|
||||
const auto texture = new uMod_IDirect3DVolumeTexture9(ppVolumeTexture, this);
|
||||
*ppVolumeTexture = texture;
|
||||
|
||||
if (LastCreatedVolumeTexture != nullptr && uMod_Client != nullptr) //if a texture was loaded before, hopefully this texture contains now the data, so we can add it
|
||||
{
|
||||
uMod_Client->AddTexture(LastCreatedVolumeTexture);
|
||||
}
|
||||
LastCreatedVolumeTexture = texture;
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle)
|
||||
{
|
||||
//create real texture
|
||||
Message("uMod_IDirect3DDevice9::CreateCubeTexture()\n");
|
||||
const HRESULT ret = m_pIDirect3DDevice9->CreateCubeTexture(EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle);
|
||||
if (ret != D3D_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//create fake texture
|
||||
const auto texture = new uMod_IDirect3DCubeTexture9(ppCubeTexture, this);
|
||||
*ppCubeTexture = texture;
|
||||
|
||||
if (LastCreatedCubeTexture != nullptr && uMod_Client != nullptr) //if a texture was loaded before, hopefully this texture contains now the data, so we can add it
|
||||
{
|
||||
uMod_Client->AddTexture(LastCreatedCubeTexture);
|
||||
}
|
||||
LastCreatedCubeTexture = texture;
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::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 uMod_IDirect3DDevice9::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 uMod_IDirect3DDevice9::UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint)
|
||||
{
|
||||
return m_pIDirect3DDevice9->UpdateSurface(pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture)
|
||||
{
|
||||
Message(PRE_MESSAGE "::UpdateTexture( %p, %p): %p\n", pSourceTexture, pDestinationTexture, this);
|
||||
// we must pass the real texture objects
|
||||
|
||||
|
||||
uMod_IDirect3DTexture9* pSource = nullptr;
|
||||
uMod_IDirect3DVolumeTexture9* pSourceVolume = nullptr;
|
||||
uMod_IDirect3DCubeTexture9* pSourceCube = nullptr;
|
||||
IDirect3DBaseTexture9* cpy;
|
||||
if (pSourceTexture != nullptr) {
|
||||
switch (pSourceTexture->QueryInterface(IID_IDirect3D9, (void**)&cpy)) {
|
||||
case 0x01000000L: {
|
||||
pSource = static_cast<uMod_IDirect3DTexture9*>(pSourceTexture);
|
||||
if (const auto hash = pSource->GetHash()) {
|
||||
if (hash != pSource->Hash) // this hash has changed !!
|
||||
{
|
||||
pSource->Hash = hash;
|
||||
if (pSource->CrossRef_D3Dtex != nullptr) {
|
||||
UnswitchTextures(pSource);
|
||||
}
|
||||
uMod_Client->LookUpToMod(pSource);
|
||||
}
|
||||
}
|
||||
else if (pSource->CrossRef_D3Dtex != nullptr) {
|
||||
UnswitchTextures(pSource); // we better unswitch
|
||||
}
|
||||
|
||||
// the source must be the original texture if not switched and the fake texture if it is switched
|
||||
if (pSource->CrossRef_D3Dtex != nullptr) {
|
||||
pSourceTexture = pSource->CrossRef_D3Dtex->m_D3Dtex;
|
||||
}
|
||||
else {
|
||||
pSourceTexture = pSource->m_D3Dtex;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x01000001L: {
|
||||
pSourceVolume = static_cast<uMod_IDirect3DVolumeTexture9*>(pSourceTexture);
|
||||
if (const auto hash = pSource->GetHash()) {
|
||||
if (hash != pSourceVolume->Hash) // this hash has changed !!
|
||||
{
|
||||
pSourceVolume->Hash = hash;
|
||||
if (pSourceVolume->CrossRef_D3Dtex != nullptr) {
|
||||
UnswitchTextures(pSourceVolume);
|
||||
}
|
||||
uMod_Client->LookUpToMod(pSourceVolume);
|
||||
}
|
||||
}
|
||||
else if (pSourceVolume->CrossRef_D3Dtex != nullptr) {
|
||||
UnswitchTextures(pSourceVolume); // we better unswitch
|
||||
}
|
||||
|
||||
// the source must be the original texture if not switched and the fake texture if it is switched
|
||||
if (pSourceVolume->CrossRef_D3Dtex != nullptr) {
|
||||
pSourceTexture = pSourceVolume->CrossRef_D3Dtex->m_D3Dtex;
|
||||
}
|
||||
else {
|
||||
pSourceTexture = pSourceVolume->m_D3Dtex;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x01000002L: {
|
||||
pSourceCube = static_cast<uMod_IDirect3DCubeTexture9*>(pSourceTexture);
|
||||
if (const auto hash = pSourceCube->GetHash()) {
|
||||
if (hash != pSourceCube->Hash) // this hash has changed !!
|
||||
{
|
||||
pSourceCube->Hash = hash;
|
||||
if (pSourceCube->CrossRef_D3Dtex != nullptr) {
|
||||
UnswitchTextures(pSourceCube);
|
||||
}
|
||||
uMod_Client->LookUpToMod(pSourceCube);
|
||||
}
|
||||
}
|
||||
else if (pSourceCube->CrossRef_D3Dtex != nullptr) {
|
||||
UnswitchTextures(pSourceCube); // we better unswitch
|
||||
}
|
||||
|
||||
// the source must be the original texture if not switched and the fake texture if it is switched
|
||||
if (pSourceCube->CrossRef_D3Dtex != nullptr) {
|
||||
pSourceTexture = pSourceCube->CrossRef_D3Dtex->m_D3Dtex;
|
||||
}
|
||||
else {
|
||||
pSourceTexture = pSourceCube->m_D3Dtex;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break; // this is no fake texture and QueryInterface failed, because IDirect3DBaseTexture9 object cannot be a IDirect3D9 object ;)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pDestinationTexture != nullptr) {
|
||||
switch (pSourceTexture->QueryInterface(IID_IDirect3D9, (void**)&cpy)) {
|
||||
case 0x01000000L: {
|
||||
const auto pDest = static_cast<uMod_IDirect3DTexture9*>(pDestinationTexture);
|
||||
|
||||
if (pSource != nullptr && pDest->Hash != pSource->Hash) {
|
||||
pDest->Hash = pSource->Hash; // take over the hash
|
||||
UnswitchTextures(pDest);
|
||||
if (pSource->CrossRef_D3Dtex != nullptr) {
|
||||
uMod_IDirect3DTexture9* cpy = pSource->CrossRef_D3Dtex;
|
||||
UnswitchTextures(pSource);
|
||||
SwitchTextures(cpy, pDest);
|
||||
}
|
||||
}
|
||||
if (pDest->CrossRef_D3Dtex != nullptr) {
|
||||
pDestinationTexture = pDest->CrossRef_D3Dtex->m_D3Dtex; // make sure to copy into the original texture
|
||||
}
|
||||
else {
|
||||
pDestinationTexture = pDest->m_D3Dtex;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x01000001L: {
|
||||
const auto pDest = static_cast<uMod_IDirect3DVolumeTexture9*>(pDestinationTexture);
|
||||
|
||||
if (pSourceVolume != nullptr && pDest->Hash != pSourceVolume->Hash) {
|
||||
pDest->Hash = pSourceVolume->Hash; // take over the hash
|
||||
UnswitchTextures(pDest);
|
||||
if (pSourceVolume->CrossRef_D3Dtex != nullptr) {
|
||||
uMod_IDirect3DVolumeTexture9* cpy = pSourceVolume->CrossRef_D3Dtex;
|
||||
UnswitchTextures(pSourceVolume);
|
||||
SwitchTextures(cpy, pDest);
|
||||
}
|
||||
}
|
||||
if (pDest->CrossRef_D3Dtex != nullptr) {
|
||||
pDestinationTexture = pDest->CrossRef_D3Dtex->m_D3Dtex; // make sure to copy into the original texture
|
||||
}
|
||||
else {
|
||||
pDestinationTexture = pDest->m_D3Dtex;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x01000002L: {
|
||||
auto pDest = static_cast<uMod_IDirect3DCubeTexture9*>(pDestinationTexture);
|
||||
|
||||
if (pSourceCube != nullptr && pDest->Hash != pSourceCube->Hash) {
|
||||
pDest->Hash = pSourceCube->Hash; // take over the hash
|
||||
UnswitchTextures(pDest);
|
||||
if (pSourceCube->CrossRef_D3Dtex != nullptr) {
|
||||
uMod_IDirect3DCubeTexture9* cpy = pSourceCube->CrossRef_D3Dtex;
|
||||
UnswitchTextures(pSourceCube);
|
||||
SwitchTextures(cpy, pDest);
|
||||
}
|
||||
}
|
||||
if (pDest->CrossRef_D3Dtex != nullptr) {
|
||||
pDestinationTexture = pDest->CrossRef_D3Dtex->m_D3Dtex; // make sure to copy into the original texture
|
||||
}
|
||||
else {
|
||||
pDestinationTexture = pDest->m_D3Dtex;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_pIDirect3DDevice9->UpdateTexture(pSourceTexture, pDestinationTexture);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetRenderTargetData(pRenderTarget, pDestSurface);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetFrontBufferData(iSwapChain, pDestSurface);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter)
|
||||
{
|
||||
return m_pIDirect3DDevice9->StretchRect(pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect, D3DCOLOR color)
|
||||
{
|
||||
return m_pIDirect3DDevice9->ColorFill(pSurface, pRect, color);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateOffscreenPlainSurface(Width, Height, Format, Pool, ppSurface, pSharedHandle);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget)
|
||||
{
|
||||
{
|
||||
IDirect3DSurface9* back_buffer;
|
||||
NormalRendering = false;
|
||||
for (int i = 0; !NormalRendering && i < BackBufferCount; i++) {
|
||||
m_pIDirect3DDevice9->GetBackBuffer(0, i, D3DBACKBUFFER_TYPE_MONO, &back_buffer);
|
||||
if (back_buffer == pRenderTarget) {
|
||||
NormalRendering = true;
|
||||
}
|
||||
back_buffer->Release();
|
||||
}
|
||||
}
|
||||
return m_pIDirect3DDevice9->SetRenderTarget(RenderTargetIndex, pRenderTarget);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetRenderTarget(RenderTargetIndex, ppRenderTarget);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetDepthStencilSurface(pNewZStencil);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetDepthStencilSurface(ppZStencilSurface);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::BeginScene()
|
||||
{
|
||||
if (LastCreatedTexture != nullptr) // add the last created texture
|
||||
{
|
||||
uMod_Client->AddTexture(LastCreatedTexture);
|
||||
}
|
||||
if (LastCreatedVolumeTexture != nullptr) // add the last created texture
|
||||
{
|
||||
uMod_Client->AddTexture(LastCreatedVolumeTexture);
|
||||
}
|
||||
if (LastCreatedCubeTexture != nullptr) // add the last created texture
|
||||
{
|
||||
uMod_Client->AddTexture(LastCreatedCubeTexture);
|
||||
}
|
||||
uMod_Client->MergeUpdate(); // merge an update, if present
|
||||
|
||||
return m_pIDirect3DDevice9->BeginScene();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::EndScene()
|
||||
{
|
||||
return m_pIDirect3DDevice9->EndScene();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::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 uMod_IDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetTransform(State, pMatrix);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetTransform(State, pMatrix);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix)
|
||||
{
|
||||
return m_pIDirect3DDevice9->MultiplyTransform(State, pMatrix);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetViewport(pViewport);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetViewport(D3DVIEWPORT9* pViewport)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetViewport(pViewport);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetMaterial(pMaterial);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetMaterial(D3DMATERIAL9* pMaterial)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetMaterial(pMaterial);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetLight(DWORD Index,CONST D3DLIGHT9* pLight)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetLight(Index, pLight);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetLight(DWORD Index, D3DLIGHT9* pLight)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetLight(Index, pLight);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::LightEnable(DWORD Index, BOOL Enable)
|
||||
{
|
||||
return m_pIDirect3DDevice9->LightEnable(Index, Enable);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetLightEnable(DWORD Index, BOOL* pEnable)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetLightEnable(Index, pEnable);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetClipPlane(DWORD Index,CONST float* pPlane)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetClipPlane(Index, pPlane);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetClipPlane(DWORD Index, float* pPlane)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetClipPlane(Index, pPlane);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetRenderState(State, Value);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetRenderState(State, pValue);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateStateBlock(Type, ppSB);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::BeginStateBlock()
|
||||
{
|
||||
return m_pIDirect3DDevice9->BeginStateBlock();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::EndStateBlock(IDirect3DStateBlock9** ppSB)
|
||||
{
|
||||
return m_pIDirect3DDevice9->EndStateBlock(ppSB);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetClipStatus(pClipStatus);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetClipStatus(D3DCLIPSTATUS9* pClipStatus)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetClipStatus(pClipStatus);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetTexture(Stage, ppTexture);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture)
|
||||
{
|
||||
// we must pass the real texture objects
|
||||
// if (dev != this) this texture was not initialized through our device and is thus no fake texture object
|
||||
|
||||
//IDirect3DDevice9 *dev = NULL;
|
||||
IDirect3DBaseTexture9* cpy;
|
||||
if (pTexture != nullptr) {
|
||||
long int ret = pTexture->QueryInterface(IID_IDirect3D9, (void**)&cpy);
|
||||
switch (ret) {
|
||||
case 0x01000000L:
|
||||
pTexture = static_cast<uMod_IDirect3DTexture9*>(pTexture)->m_D3Dtex;
|
||||
break;
|
||||
case 0x01000001L:
|
||||
pTexture = static_cast<uMod_IDirect3DVolumeTexture9*>(pTexture)->m_D3Dtex;
|
||||
break;
|
||||
case 0x01000002L:
|
||||
pTexture = static_cast<uMod_IDirect3DCubeTexture9*>(pTexture)->m_D3Dtex;
|
||||
break;
|
||||
default:
|
||||
break; // this is no fake texture and QueryInterface failed, because IDirect3DBaseTexture9 object cannot be a IDirect3D9 object ;)
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (pTexture != NULL && ((uMod_IDirect3DTexture9*)(pTexture))->GetDevice(&dev) == D3D_OK)
|
||||
{
|
||||
if(dev == this) pTexture = ((uMod_IDirect3DTexture9*)(pTexture))->m_D3Dtex;
|
||||
}
|
||||
*/
|
||||
return m_pIDirect3DDevice9->SetTexture(Stage, pTexture);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetTextureStageState(Stage, Type, pValue);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetTextureStageState(Stage, Type, Value);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetSamplerState(Sampler, Type, pValue);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetSamplerState(Sampler, Type, Value);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::ValidateDevice(DWORD* pNumPasses)
|
||||
{
|
||||
return m_pIDirect3DDevice9->ValidateDevice(pNumPasses);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetPaletteEntries(PaletteNumber, pEntries);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetPaletteEntries(PaletteNumber, pEntries);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetCurrentTexturePalette(UINT PaletteNumber)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetCurrentTexturePalette(PaletteNumber);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetCurrentTexturePalette(UINT* PaletteNumber)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetCurrentTexturePalette(PaletteNumber);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetScissorRect(CONST RECT* pRect)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetScissorRect(pRect);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetScissorRect(RECT* pRect)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetScissorRect(pRect);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetSoftwareVertexProcessing(BOOL bSoftware)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetSoftwareVertexProcessing(bSoftware);
|
||||
}
|
||||
|
||||
BOOL uMod_IDirect3DDevice9::GetSoftwareVertexProcessing()
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetSoftwareVertexProcessing();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetNPatchMode(float nSegments)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetNPatchMode(nSegments);
|
||||
}
|
||||
|
||||
float uMod_IDirect3DDevice9::GetNPatchMode()
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetNPatchMode();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->DrawIndexedPrimitive(PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride)
|
||||
{
|
||||
return m_pIDirect3DDevice9->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::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 uMod_IDirect3DDevice9::ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags)
|
||||
{
|
||||
return m_pIDirect3DDevice9->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateVertexDeclaration(pVertexElements, ppDecl);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetVertexDeclaration(pDecl);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetVertexDeclaration(ppDecl);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetFVF(DWORD FVF)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetFVF(FVF);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetFVF(DWORD* pFVF)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetFVF(pFVF);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateVertexShader(pFunction, ppShader);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetVertexShader(pShader);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetVertexShader(IDirect3DVertexShader9** ppShader)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetVertexShader(ppShader);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData, UINT Vector4fCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData, UINT Vector4iCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData, UINT BoolCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetVertexShaderConstantB(StartRegister, pConstantData, BoolCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetVertexShaderConstantB(StartRegister, pConstantData, BoolCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetStreamSource(StreamNumber, pStreamData, OffsetInBytes, Stride);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetStreamSource(StreamNumber, ppStreamData, OffsetInBytes, pStride);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetStreamSourceFreq(UINT StreamNumber, UINT Divider)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetStreamSourceFreq(StreamNumber, Divider);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetStreamSourceFreq(UINT StreamNumber, UINT* Divider)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetStreamSourceFreq(StreamNumber, Divider);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetIndices(pIndexData);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetIndices(IDirect3DIndexBuffer9** ppIndexData)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetIndices(ppIndexData);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreatePixelShader(pFunction, ppShader);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetPixelShader(pShader);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetPixelShader(IDirect3DPixelShader9** ppShader)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetPixelShader(ppShader);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData, UINT Vector4fCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData, UINT Vector4iCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData, UINT BoolCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->SetPixelShaderConstantB(StartRegister, pConstantData, BoolCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount)
|
||||
{
|
||||
return m_pIDirect3DDevice9->GetPixelShaderConstantB(StartRegister, pConstantData, BoolCount);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo)
|
||||
{
|
||||
return m_pIDirect3DDevice9->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo)
|
||||
{
|
||||
return m_pIDirect3DDevice9->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::DeletePatch(UINT Handle)
|
||||
{
|
||||
return m_pIDirect3DDevice9->DeletePatch(Handle);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery)
|
||||
{
|
||||
return m_pIDirect3DDevice9->CreateQuery(Type, ppQuery);
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
#include "Main.h"
|
||||
|
||||
#define uMod_IDirect3DDevice9 uMod_IDirect3DDevice9Ex
|
||||
#define IDirect3DDevice9 IDirect3DDevice9Ex
|
||||
#define m_pIDirect3DDevice9 m_pIDirect3DDevice9Ex
|
||||
|
||||
#define RETURN_QueryInterface 0x01000001L
|
||||
#define PRE_MESSAGE "uMod_IDirect3DDevice9Ex"
|
||||
|
||||
// ReSharper disable once CppUnusedIncludeDirective
|
||||
#include "uMod_IDirect3DDevice9.cpp"
|
||||
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CheckDeviceState(HWND hWindow)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->CheckDeviceState(hWindow);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CheckResourceResidency(IDirect3DResource9** ppResourceArray, UINT32 NumResources)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->CheckResourceResidency(ppResourceArray, NumResources);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::ComposeRects(IDirect3DSurface9* pSource, IDirect3DSurface9* pDestination, IDirect3DVertexBuffer9* pSrcRectDescriptors, UINT NumRects, IDirect3DVertexBuffer9* pDstRectDescriptors, D3DCOMPOSERECTSOP Operation,
|
||||
INT XOffset, INT YOffset)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->ComposeRects(pSource, pDestination, pSrcRectDescriptors, NumRects, pDstRectDescriptors, Operation, XOffset, YOffset);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateDepthStencilSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->CreateDepthStencilSurfaceEx(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle, Usage);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateOffscreenPlainSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->CreateOffscreenPlainSurfaceEx(Width, Height, Format, Pool, ppSurface, pSharedHandle, Usage);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateRenderTargetEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->CreateRenderTargetEx(Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle, Usage);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetDisplayModeEx(UINT iSwapChain, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->GetDisplayModeEx(iSwapChain, pMode, pRotation);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetGPUThreadPriority(INT* pPriority)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->GetGPUThreadPriority(pPriority);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetMaximumFrameLatency(UINT* pMaxLatency)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->GetMaximumFrameLatency(pMaxLatency);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::PresentEx(const RECT* pSourceRect, const RECT* pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion, DWORD dwFlags)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->PresentEx(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::ResetEx(D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->ResetEx(pPresentationParameters, pFullscreenDisplayMode);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetConvolutionMonoKernel(UINT Width, UINT Height, float* RowWeights, float* ColumnWeights)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->SetConvolutionMonoKernel(Width, Height, RowWeights, ColumnWeights);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetGPUThreadPriority(INT pPriority)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->SetGPUThreadPriority(pPriority);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetMaximumFrameLatency(UINT pMaxLatency)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->SetMaximumFrameLatency(pMaxLatency);
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::TestCooperativeLevel()
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->TestCooperativeLevel();
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::WaitForVBlank(UINT SwapChainIndex)
|
||||
{
|
||||
return m_pIDirect3DDevice9Ex->WaitForVBlank(SwapChainIndex);
|
||||
}
|
||||
@@ -1,344 +0,0 @@
|
||||
#include "Main.h"
|
||||
|
||||
import TextureFunction;
|
||||
import TextureClient;
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid == IID_IDirect3D9) {
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return 0x01000000L;
|
||||
}
|
||||
HRESULT hRes;
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
hRes = CrossRef_D3Dtex->m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj == CrossRef_D3Dtex->m_D3Dtex) {
|
||||
*ppvObj = this;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj == m_D3Dtex) {
|
||||
*ppvObj = this;
|
||||
}
|
||||
}
|
||||
return hRes;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) {
|
||||
return 1; //bug, this case should never happen
|
||||
}
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->AddRef();
|
||||
}
|
||||
return m_D3Dtex->AddRef();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DTexture9::Release(): %p\n", this);
|
||||
|
||||
void* cpy;
|
||||
const long ret = m_D3Ddev->QueryInterface(IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE) {
|
||||
UnswitchTextures(this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else {
|
||||
if (CrossRef_D3Dtex != nullptr) //if this texture is switched with a fake texture
|
||||
{
|
||||
uMod_IDirect3DTexture9* fake_texture = CrossRef_D3Dtex;
|
||||
count = fake_texture->m_D3Dtex->Release(); //release the original texture
|
||||
if (count == 0) //if texture is released we switch the textures back
|
||||
{
|
||||
UnswitchTextures(this);
|
||||
fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
}
|
||||
else {
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) //if this texture is released, we clean up
|
||||
{
|
||||
// if this texture is the LastCreatedTexture, the next time LastCreatedTexture would be added,
|
||||
// the hash of a non existing texture would be calculated
|
||||
if (ret == 0x01000000L) {
|
||||
if (static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->GetLastCreatedTexture() == this) {
|
||||
static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->SetLastCreatedTexture(nullptr);
|
||||
}
|
||||
else {
|
||||
static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->GetLastCreatedTexture() == this) {
|
||||
static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->SetLastCreatedTexture(nullptr);
|
||||
}
|
||||
else {
|
||||
static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DTexture9::Release() end: %p\n", this);
|
||||
return count;
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::SetPrivateData(REFGUID refguid,CONST void* pData, DWORD SizeOfData, DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
return m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData);
|
||||
}
|
||||
return m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->FreePrivateData(refguid);
|
||||
}
|
||||
return m_D3Dtex->FreePrivateData(refguid);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return m_D3Dtex->SetPriority(PriorityNew);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetPriority()
|
||||
{
|
||||
return m_D3Dtex->GetPriority();
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DTexture9::GetType()
|
||||
{
|
||||
return m_D3Dtex->GetType();
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return m_D3Dtex->SetLOD(LODNew);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetLOD()
|
||||
{
|
||||
return m_D3Dtex->GetLOD();
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetLevelCount()
|
||||
{
|
||||
return m_D3Dtex->GetLevelCount();
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return m_D3Dtex->SetAutoGenFilterType(FilterType);
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return m_D3Dtex->GetAutoGenFilterType();
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetLevelDesc(UINT Level, D3DSURFACE_DESC* pDesc)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetLevelDesc(Level, pDesc);
|
||||
}
|
||||
return m_D3Dtex->GetLevelDesc(Level, pDesc);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetSurfaceLevel(UINT Level, IDirect3DSurface9** ppSurfaceLevel)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetSurfaceLevel(Level, ppSurfaceLevel);
|
||||
}
|
||||
return m_D3Dtex->GetSurfaceLevel(Level, ppSurfaceLevel);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::LockRect(UINT Level, D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect, DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->LockRect(Level, pLockedRect, pRect, Flags);
|
||||
}
|
||||
return m_D3Dtex->LockRect(Level, pLockedRect, pRect, Flags);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::UnlockRect(UINT Level)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->UnlockRect(Level);
|
||||
}
|
||||
return m_D3Dtex->UnlockRect(Level);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::AddDirtyRect(CONST RECT* pDirtyRect)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->AddDirtyRect(pDirtyRect);
|
||||
}
|
||||
return m_D3Dtex->AddDirtyRect(pDirtyRect);
|
||||
}
|
||||
|
||||
|
||||
HashType uMod_IDirect3DTexture9::GetHash() const
|
||||
{
|
||||
ASSERT(!FAKE);
|
||||
IDirect3DTexture9* pTexture = m_D3Dtex;
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
pTexture = CrossRef_D3Dtex->m_D3Dtex;
|
||||
}
|
||||
|
||||
IDirect3DSurface9* pOffscreenSurface = nullptr;
|
||||
//IDirect3DTexture9 *pOffscreenTexture = NULL;
|
||||
IDirect3DSurface9* pResolvedSurface = nullptr;
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DSURFACE_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc) != D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: GetLevelDesc \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DTexture9::GetHash() (%d %d) %d\n", desc.Width, desc.Height, desc.Format);
|
||||
|
||||
|
||||
if (desc.Pool == D3DPOOL_DEFAULT) //get the raw data of the texture
|
||||
{
|
||||
//Message("uMod_IDirect3DTexture9::GetHash() (D3DPOOL_DEFAULT)\n");
|
||||
|
||||
IDirect3DSurface9* pSurfaceLevel_orig = nullptr;
|
||||
if (pTexture->GetSurfaceLevel(0, &pSurfaceLevel_orig) != D3D_OK) {
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: GetSurfaceLevel 1 (D3DPOOL_DEFAULT)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (desc.MultiSampleType != D3DMULTISAMPLE_NONE) {
|
||||
//Message("uMod_IDirect3DTexture9::GetHash() MultiSampleType\n");
|
||||
if (D3D_OK != m_D3Ddev->CreateRenderTarget(desc.Width, desc.Height, desc.Format, D3DMULTISAMPLE_NONE, 0, FALSE, &pResolvedSurface, nullptr)) {
|
||||
pSurfaceLevel_orig->Release();
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: CreateRenderTarget (D3DPOOL_DEFAULT)\n");
|
||||
return 0;
|
||||
}
|
||||
if (D3D_OK != m_D3Ddev->StretchRect(pSurfaceLevel_orig, nullptr, pResolvedSurface, nullptr, D3DTEXF_NONE)) {
|
||||
pSurfaceLevel_orig->Release();
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: StretchRect (D3DPOOL_DEFAULT)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pSurfaceLevel_orig = pResolvedSurface;
|
||||
}
|
||||
|
||||
if (D3D_OK != m_D3Ddev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pOffscreenSurface, nullptr)) {
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: CreateOffscreenPlainSurface (D3DPOOL_DEFAULT)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (D3D_OK != m_D3Ddev->GetRenderTargetData(pSurfaceLevel_orig, pOffscreenSurface)) {
|
||||
pSurfaceLevel_orig->Release();
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
pOffscreenSurface->Release();
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: GetRenderTargetData (D3DPOOL_DEFAULT)\n");
|
||||
return 0;
|
||||
}
|
||||
pSurfaceLevel_orig->Release();
|
||||
|
||||
if (pOffscreenSurface->LockRect(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
pOffscreenSurface->Release();
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: LockRect (D3DPOOL_DEFAULT)\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (pTexture->LockRect(0, &d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: LockRect 1\n");
|
||||
if (pTexture->GetSurfaceLevel(0, &pResolvedSurface) != D3D_OK) {
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return 0;
|
||||
}
|
||||
if (pResolvedSurface->LockRect(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
pResolvedSurface->Release();
|
||||
Warning("uMod_IDirect3DTexture9::GetHash() Failed: LockRect 2\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const int size = (TextureFunction::GetBitsFromFormat(desc.Format) * desc.Width * desc.Height) / 8;
|
||||
const auto hash = TextureFunction::GetCRC32(static_cast<char*>(d3dlr.pBits), size); //calculate the crc32 of the texture
|
||||
|
||||
// Only release surfaces after we're finished with d3dlr
|
||||
if (pOffscreenSurface != nullptr) {
|
||||
pOffscreenSurface->UnlockRect();
|
||||
pOffscreenSurface->Release();
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
}
|
||||
else if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->UnlockRect();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else {
|
||||
pTexture->UnlockRect(0);
|
||||
}
|
||||
Message("uMod_IDirect3DTexture9::GetHash() %#lX (%d %d) %d = %d\n", hash, desc.Width, desc.Height, desc.Format, size);
|
||||
return hash;
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
#include "Main.h"
|
||||
import TextureFunction;
|
||||
import TextureClient;
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid == IID_IDirect3D9) {
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return 0x01000001L;
|
||||
}
|
||||
HRESULT hRes;
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
hRes = CrossRef_D3Dtex->m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj == CrossRef_D3Dtex->m_D3Dtex) {
|
||||
*ppvObj = this;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj == m_D3Dtex) {
|
||||
*ppvObj = this;
|
||||
}
|
||||
}
|
||||
return hRes;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DVolumeTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) {
|
||||
return 1; //bug, this case should never happen
|
||||
}
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->AddRef();
|
||||
}
|
||||
return m_D3Dtex->AddRef();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DVolumeTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::Release(): %p\n", this);
|
||||
|
||||
void* cpy;
|
||||
const long ret = m_D3Ddev->QueryInterface(IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE) {
|
||||
UnswitchTextures(this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else {
|
||||
if (CrossRef_D3Dtex != nullptr) //if this texture is switched with a fake texture
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9* fake_texture = CrossRef_D3Dtex;
|
||||
count = fake_texture->m_D3Dtex->Release(); //release the original texture
|
||||
if (count == 0) //if texture is released we switch the textures back
|
||||
{
|
||||
UnswitchTextures(this);
|
||||
fake_texture->Release(); // we release the fake texture
|
||||
}
|
||||
}
|
||||
else {
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) //if this texture is released, we clean up
|
||||
{
|
||||
// if this texture is the LastCreatedTexture, the next time LastCreatedTexture would be added,
|
||||
// the hash of a non existing texture would be calculated
|
||||
if (ret == 0x01000000L) {
|
||||
if (static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->GetLastCreatedVolumeTexture() == this) {
|
||||
static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->SetLastCreatedVolumeTexture(nullptr);
|
||||
}
|
||||
else {
|
||||
static_cast<uMod_IDirect3DDevice9*>(m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->GetLastCreatedVolumeTexture() == this) {
|
||||
static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->SetLastCreatedVolumeTexture(nullptr);
|
||||
}
|
||||
else {
|
||||
static_cast<uMod_IDirect3DDevice9Ex*>(m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::SetPrivateData(REFGUID refguid,CONST void* pData, DWORD SizeOfData, DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
return m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData);
|
||||
}
|
||||
return m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->FreePrivateData(refguid);
|
||||
}
|
||||
return m_D3Dtex->FreePrivateData(refguid);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return m_D3Dtex->SetPriority(PriorityNew);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetPriority()
|
||||
{
|
||||
return m_D3Dtex->GetPriority();
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DVolumeTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DVolumeTexture9::GetType()
|
||||
{
|
||||
return m_D3Dtex->GetType();
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return m_D3Dtex->SetLOD(LODNew);
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetLOD()
|
||||
{
|
||||
return m_D3Dtex->GetLOD();
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetLevelCount()
|
||||
{
|
||||
return m_D3Dtex->GetLevelCount();
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return m_D3Dtex->SetAutoGenFilterType(FilterType);
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DVolumeTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return m_D3Dtex->GetAutoGenFilterType();
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DVolumeTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::AddDirtyBox(CONST D3DBOX* pDirtyBox)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->AddDirtyBox(pDirtyBox);
|
||||
}
|
||||
return m_D3Dtex->AddDirtyBox(pDirtyBox);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetLevelDesc(UINT Level, D3DVOLUME_DESC* pDesc)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetLevelDesc(Level, pDesc);
|
||||
}
|
||||
return m_D3Dtex->GetLevelDesc(Level, pDesc);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetVolumeLevel(UINT Level, IDirect3DVolume9** ppVolumeLevel)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->GetVolumeLevel(Level, ppVolumeLevel);
|
||||
}
|
||||
return m_D3Dtex->GetVolumeLevel(Level, ppVolumeLevel);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::LockBox(UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->LockBox(Level, pLockedVolume, pBox, Flags);
|
||||
}
|
||||
return m_D3Dtex->LockBox(Level, pLockedVolume, pBox, Flags);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::UnlockBox(UINT Level)
|
||||
{
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
return CrossRef_D3Dtex->m_D3Dtex->UnlockBox(Level);
|
||||
}
|
||||
return m_D3Dtex->UnlockBox(Level);
|
||||
}
|
||||
|
||||
HashType uMod_IDirect3DVolumeTexture9::GetHash() const
|
||||
{
|
||||
if (FAKE) {
|
||||
return 0;
|
||||
}
|
||||
IDirect3DVolumeTexture9* pTexture = m_D3Dtex;
|
||||
if (CrossRef_D3Dtex != nullptr) {
|
||||
pTexture = CrossRef_D3Dtex->m_D3Dtex;
|
||||
}
|
||||
|
||||
IDirect3DVolume9* pResolvedSurface = nullptr;
|
||||
D3DLOCKED_BOX d3dlr;
|
||||
D3DVOLUME_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc) != D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Warning("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetLevelDesc \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() (%d %d %d) %d\n", desc.Width, desc.Height, desc.Depth, desc.Format);
|
||||
if (pTexture->LockBox(0, &d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
Warning("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect 1\n");
|
||||
if (pTexture->GetVolumeLevel(0, &pResolvedSurface) != D3D_OK) {
|
||||
Warning("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return 0;
|
||||
}
|
||||
if (pResolvedSurface->LockBox(&d3dlr, nullptr, D3DLOCK_READONLY) != D3D_OK) {
|
||||
pResolvedSurface->Release();
|
||||
Warning("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect 2\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const int size = (TextureFunction::GetBitsFromFormat(desc.Format) * desc.Width * desc.Height * desc.Depth) / 8;
|
||||
const auto hash = TextureFunction::GetCRC32(static_cast<char*>(d3dlr.pBits), size); //calculate the crc32 of the texture
|
||||
|
||||
// Only release surfaces after we're finished with d3dlr
|
||||
if (pResolvedSurface != nullptr) {
|
||||
pResolvedSurface->UnlockBox();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else {
|
||||
pTexture->UnlockBox(0);
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() %#lX (%d %d) %d = %d\n", hash, desc.Width, desc.Height, desc.Format, size);
|
||||
return hash;
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
NEVER USE THIS CODE FOR ILLEGAL PURPOSE
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#define number_of_byte 5
|
||||
|
||||
#include "uMod_DX10_dll.h"
|
||||
#include "uMod_ID3D10Device.h"
|
||||
#include "uMod_ID3D10Device1.h"
|
||||
#include "uMod_IDXGISwapChain.h"
|
||||
|
||||
/*
|
||||
* global variable which are not linked external
|
||||
*/
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
HINSTANCE gl_hOriginal_DX10_Dll = NULL;
|
||||
HINSTANCE gl_hOriginal_DX101_Dll = NULL;
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
typedef HRESULT (APIENTRY *D3D10CreateDeviceAndSwapChain_type)( IDXGIAdapter*, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, DXGI_SWAP_CHAIN_DESC*, IDXGISwapChain**, ID3D10Device**);
|
||||
typedef HRESULT (APIENTRY *D3D10CreateDeviceAndSwapChain1_type)( IDXGIAdapter*, D3D10_DRIVER_TYPE, HMODULE, UINT, D3D10_FEATURE_LEVEL1, UINT, DXGI_SWAP_CHAIN_DESC*, IDXGISwapChain**, ID3D10Device1**);
|
||||
|
||||
uMod_Detour_Entry<D3D10CreateDeviceAndSwapChain_type> Detour_D3D10CreateDeviceAndSwapChain(5);
|
||||
uMod_Detour_Entry<D3D10CreateDeviceAndSwapChain1_type> Detour_D3D10CreateDeviceAndSwapChain1(5);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* global variable which are linked external
|
||||
*/
|
||||
|
||||
void InitDX10(void)
|
||||
{
|
||||
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
LoadOriginal_DX10_Dll();
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
char buffer[MAX_PATH];
|
||||
wchar_t buffer_w[MAX_PATH];
|
||||
GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d9.dll
|
||||
swprintf_s( buffer_w, MAX_PATH, L"%s\\d3d10.dll", buffer);
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d10.dll");
|
||||
|
||||
Detour_D3D10CreateDeviceAndSwapChain.SetFunctionName( "D3D10CreateDeviceAndSwapChain");
|
||||
Detour_D3D10CreateDeviceAndSwapChain.SetTargetFunction( uMod_D3D10CreateDeviceAndSwapChain);
|
||||
Detour_D3D10CreateDeviceAndSwapChain.SetLibName( "d3d10.dll");
|
||||
Detour_D3D10CreateDeviceAndSwapChain.SetFullLibName( buffer);
|
||||
Detour_D3D10CreateDeviceAndSwapChain.SetLibName( L"d3d10.dll"); // set also for wide character
|
||||
Detour_D3D10CreateDeviceAndSwapChain.SetFullLibName( buffer_w); // set also for wide character
|
||||
|
||||
GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d9.dll
|
||||
swprintf_s( buffer_w, MAX_PATH, L"%s\\d3d10_1.dll", buffer);
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d10_1.dll");
|
||||
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.SetFunctionName( "D3D10CreateDeviceAndSwapChain1");
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.SetTargetFunction( uMod_D3D10CreateDeviceAndSwapChain1);
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.SetLibName( "d3d10_1.dll");
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.SetFullLibName( buffer);
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.SetLibName( L"d3d10_1.dll"); // set also for wide character
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.SetFullLibName( buffer_w); // set also for wide character
|
||||
|
||||
GlobalDetour.AddEntry(&Detour_D3D10CreateDeviceAndSwapChain);
|
||||
GlobalDetour.AddEntry(&Detour_D3D10CreateDeviceAndSwapChain1);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExitDX10(void)
|
||||
{
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
// Release the system's d3d9.dll
|
||||
if (gl_hOriginal_DX10_Dll!=NULL)
|
||||
{
|
||||
FreeLibrary(gl_hOriginal_DX10_Dll);
|
||||
gl_hOriginal_DX10_Dll = NULL;
|
||||
}
|
||||
|
||||
if (gl_hOriginal_DX101_Dll!=NULL)
|
||||
{
|
||||
FreeLibrary(gl_hOriginal_DX101_Dll);
|
||||
gl_hOriginal_DX101_Dll = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
void LoadOriginal_DX10_Dll(void)
|
||||
{
|
||||
char buffer[MAX_PATH];
|
||||
|
||||
if (gl_hOriginal_DX10_Dll==NULL)
|
||||
{
|
||||
GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d10.dll
|
||||
|
||||
// Append dll name
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d10.dll");
|
||||
|
||||
// try to load the system's d3d10.dll
|
||||
gl_hOriginal_DX10_Dll = LoadLibrary(buffer);
|
||||
}
|
||||
|
||||
if (gl_hOriginal_DX101_Dll==NULL)
|
||||
{
|
||||
GetSystemDirectory(buffer,MAX_PATH);
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d10_1.dll");
|
||||
gl_hOriginal_DX101_Dll = LoadLibrary(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* We do not inject, the game loads this dll by itself thus we must include the Direct3DCreate9 function
|
||||
*/
|
||||
/*
|
||||
IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
Message("WINAPI Direct3DCreate9\n");
|
||||
|
||||
if (!gl_hOriginal_DX9_Dll) LoadOriginal_DX9_Dll(); // looking for the "right d3d9.dll"
|
||||
|
||||
// find original function in original d3d9.dll
|
||||
Direct3DCreate9_type D3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9");
|
||||
|
||||
|
||||
if (!D3DCreate9_fn)
|
||||
{
|
||||
Message("Direct3DCreate9: original function not found in dll\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//Create originale IDirect3D9 object
|
||||
IDirect3D9 *pIDirect3D9_orig = D3DCreate9_fn(SDKVersion);
|
||||
|
||||
//create our uMod_IDirect3D9 object
|
||||
uMod_IDirect3D9 *pIDirect3D9 = new uMod_IDirect3D9( pIDirect3D9_orig, gl_TextureServer);
|
||||
|
||||
// Return pointer to our object instead of "real one"
|
||||
return (pIDirect3D9);
|
||||
}
|
||||
|
||||
HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **ppD3D)
|
||||
{
|
||||
Message("WINAPI Direct3DCreate9Ex\n");
|
||||
|
||||
if (!gl_hOriginal_DX9_Dll) LoadOriginal_DX9_Dll(); // looking for the "right d3d9.dll"
|
||||
|
||||
// find original function in original d3d9.dll
|
||||
Direct3DCreate9Ex_type D3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9Ex");
|
||||
|
||||
|
||||
if (!D3DCreate9Ex_fn)
|
||||
{
|
||||
Message("Direct3DCreate9Ex: original function not found in dll\n");
|
||||
return (D3DERR_NOTAVAILABLE);
|
||||
}
|
||||
|
||||
|
||||
//Create originale IDirect3D9 object
|
||||
IDirect3D9Ex *pIDirect3D9Ex_orig;
|
||||
HRESULT ret = D3DCreate9Ex_fn( SDKVersion, &pIDirect3D9Ex_orig);
|
||||
if (ret!=S_OK) return (ret);
|
||||
|
||||
//create our uMod_IDirect3D9 object
|
||||
uMod_IDirect3D9Ex *pIDirect3D9Ex = new uMod_IDirect3D9Ex( pIDirect3D9Ex_orig, gl_TextureServer);
|
||||
|
||||
ppD3D = &pIDirect3D9Ex_orig; // Return pointer to our object instead of "real one"
|
||||
return (ret);
|
||||
}
|
||||
|
||||
typedef IDirect3D9 *(APIENTRY *Direct3DCreate9_type)(UINT);
|
||||
typedef HRESULT (APIENTRY *Direct3DCreate9Ex_type)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
|
||||
typedef int (WINAPI *D3DPERF_BeginEvent_type)( D3DCOLOR , LPCWSTR );
|
||||
int WINAPI D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName )
|
||||
{
|
||||
D3DPERF_BeginEvent_type fn = (D3DPERF_BeginEvent_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_BeginEvent");
|
||||
return fn( col, wszName);
|
||||
}
|
||||
|
||||
typedef int (WINAPI *D3DPERF_EndEvent_type)( void );
|
||||
int WINAPI D3DPERF_EndEvent( void )
|
||||
{
|
||||
D3DPERF_EndEvent_type fn = (D3DPERF_EndEvent_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_EndEvent");
|
||||
return fn();
|
||||
}
|
||||
|
||||
typedef void (WINAPI *D3DPERF_SetMarker_type)( D3DCOLOR , LPCWSTR );
|
||||
void WINAPI D3DPERF_SetMarker( D3DCOLOR col, LPCWSTR wszName )
|
||||
{
|
||||
D3DPERF_SetMarker_type fn = (D3DPERF_SetMarker_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetMarker");
|
||||
return fn( col, wszName);
|
||||
}
|
||||
|
||||
typedef void (WINAPI *D3DPERF_SetRegion_type)( D3DCOLOR, LPCWSTR );
|
||||
void WINAPI D3DPERF_SetRegion( D3DCOLOR col, LPCWSTR wszName )
|
||||
{
|
||||
D3DPERF_SetRegion_type fn = (D3DPERF_SetRegion_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetRegion");
|
||||
return fn( col, wszName);
|
||||
}
|
||||
|
||||
typedef BOOL (WINAPI *D3DPERF_QueryRepeatFrame_type)( void );
|
||||
BOOL WINAPI D3DPERF_QueryRepeatFrame( void )
|
||||
{
|
||||
D3DPERF_QueryRepeatFrame_type fn = (D3DPERF_QueryRepeatFrame_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_QueryRepeatFrame");
|
||||
return fn( );
|
||||
}
|
||||
|
||||
typedef void (WINAPI *D3DPERF_SetOptions_type)( DWORD );
|
||||
void WINAPI D3DPERF_SetOptions( DWORD dwOptions )
|
||||
{
|
||||
D3DPERF_SetOptions_type fn = (D3DPERF_SetOptions_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetOptions");
|
||||
return fn( dwOptions);
|
||||
}
|
||||
|
||||
typedef DWORD (WINAPI *D3DPERF_GetStatus_type)( void );
|
||||
DWORD WINAPI D3DPERF_GetStatus( void )
|
||||
{
|
||||
D3DPERF_GetStatus_type fn = (D3DPERF_GetStatus_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_GetStatus");
|
||||
return fn( );
|
||||
}
|
||||
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
/*
|
||||
* We inject the dll into the game, thus we retour the original Direct3DCreate9 function to our MyDirect3DCreate9 function
|
||||
*/
|
||||
|
||||
HRESULT APIENTRY uMod_D3D10CreateDeviceAndSwapChain(
|
||||
IDXGIAdapter *pAdapter,
|
||||
D3D10_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
UINT SDKVersion,
|
||||
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
||||
IDXGISwapChain **ppSwapChain,
|
||||
ID3D10Device **ppDevice
|
||||
)
|
||||
{
|
||||
Detour_D3D10CreateDeviceAndSwapChain.Retour();
|
||||
HRESULT ret = Detour_D3D10CreateDeviceAndSwapChain.Function()(pAdapter,DriverType,Software,Flags,SDKVersion,pSwapChainDesc, ppSwapChain, ppDevice);
|
||||
if (ret==S_OK)
|
||||
{
|
||||
uMod_ID3D10Device *dev = new uMod_ID3D10Device( *ppDevice, gl_TextureServer);
|
||||
*ppDevice = (ID3D10Device*) dev;
|
||||
|
||||
if (ppSwapChain!=NULL)
|
||||
{
|
||||
uMod_IDXGISwapChain *swap = new uMod_IDXGISwapChain( *ppSwapChain, dev);
|
||||
*ppSwapChain = swap;
|
||||
}
|
||||
}
|
||||
else Message("D3D10CreateDeviceAndSwapChain: Failed\n");
|
||||
Detour_D3D10CreateDeviceAndSwapChain.Detour();
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_D3D10CreateDeviceAndSwapChain1(
|
||||
IDXGIAdapter *pAdapter,
|
||||
D3D10_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
D3D10_FEATURE_LEVEL1 HardwareLevel,
|
||||
UINT SDKVersion,
|
||||
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
||||
IDXGISwapChain **ppSwapChain,
|
||||
ID3D10Device1 **ppDevice
|
||||
)
|
||||
{
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.Retour();
|
||||
HRESULT ret = Detour_D3D10CreateDeviceAndSwapChain1.Function()(pAdapter,DriverType,Software,Flags,HardwareLevel,SDKVersion,pSwapChainDesc, ppSwapChain, ppDevice);
|
||||
if (ret==S_OK)
|
||||
{
|
||||
uMod_ID3D10Device1 *dev = new uMod_ID3D10Device1( *ppDevice, gl_TextureServer);
|
||||
*ppDevice = (ID3D10Device1*) dev;
|
||||
|
||||
if (ppSwapChain!=NULL)
|
||||
{
|
||||
uMod_IDXGISwapChain *swap = new uMod_IDXGISwapChain( *ppSwapChain, (uMod_ID3D10Device*)dev);
|
||||
*ppSwapChain = swap;
|
||||
}
|
||||
}
|
||||
else Message("D3D10CreateDeviceAndSwapChain1: Failed\n");
|
||||
Detour_D3D10CreateDeviceAndSwapChain1.Detour();
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_DX10_DLL_H_
|
||||
#define uMod_DX10_DLL_H_
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
|
||||
void InitDX10();
|
||||
void ExitDX10();
|
||||
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
/**
|
||||
* Load the official d3d10.dll from the system path.
|
||||
*/
|
||||
void LoadOriginal_DX10_Dll(void);
|
||||
#endif
|
||||
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
HRESULT APIENTRY uMod_D3D10CreateDeviceAndSwapChain(
|
||||
IDXGIAdapter *pAdapter,
|
||||
D3D10_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
UINT SDKVersion,
|
||||
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
||||
IDXGISwapChain **ppSwapChain,
|
||||
ID3D10Device **ppDevice
|
||||
);
|
||||
|
||||
HRESULT APIENTRY uMod_D3D10CreateDeviceAndSwapChain1(
|
||||
IDXGIAdapter *pAdapter,
|
||||
D3D10_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
D3D10_FEATURE_LEVEL1 HardwareLevel,
|
||||
UINT SDKVersion,
|
||||
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
||||
IDXGISwapChain **ppSwapChain,
|
||||
ID3D10Device1 **ppDevice
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,573 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine.If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "uMod_ID3D10Device.h"
|
||||
|
||||
#ifndef PRE_MESSAGE
|
||||
#define PRE_MESSAGE "uMod_ID3D10Device"
|
||||
#endif
|
||||
|
||||
|
||||
uMod_ID3D10Device::uMod_ID3D10Device( ID3D10Device* pOriginal, uMod_TextureServer* server)
|
||||
{
|
||||
Message( PRE_MESSAGE "::" PRE_MESSAGE "( %lu, %lu): %lu\n", pOriginal, server, this);
|
||||
m_ID3D10Device = pOriginal;
|
||||
uMod_Server = server;
|
||||
RefCounter = 1;
|
||||
}
|
||||
|
||||
uMod_ID3D10Device::~uMod_ID3D10Device()
|
||||
{
|
||||
Message( PRE_MESSAGE "::~" PRE_MESSAGE "(): %lu\n", this);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::QueryInterface( REFIID riid, void** ppvObject)
|
||||
{
|
||||
*ppvObject = NULL;
|
||||
Message( PRE_MESSAGE "::QueryInterface(): %lu\n", this);
|
||||
HRESULT hRes = m_ID3D10Device->QueryInterface(riid, ppvObject);
|
||||
|
||||
if (ppvObject!=NULL)
|
||||
{if (*ppvObject == m_ID3D10Device)// && (riid==IID_ID3D10Device || riid==IID_ID3D10Device1))
|
||||
{
|
||||
RefCounter++; //increasing our counter
|
||||
//*ppvObject = this;
|
||||
Message("hit: %lu, %lu, %lu, %lu %lu\n", riid, IID_ID3D10Device, IID_ID3D10Device1, *ppvObject, this)
|
||||
}}
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Device::AddRef(void)
|
||||
{
|
||||
Message( PRE_MESSAGE "::AddRef(): %lu\n", this);
|
||||
RefCounter++;
|
||||
return m_ID3D10Device->AddRef();
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Device::Release( void)
|
||||
{
|
||||
Message( PRE_MESSAGE "::Release(): (%d) %lu\n", RefCounter, this);
|
||||
if (--RefCounter==0) //if our counter drops to zero, the real device will be deleted, so we clean up before
|
||||
{
|
||||
// we must not release the fake textures, cause they are released if the target textures are released
|
||||
// and the target textures are released by the game.
|
||||
}
|
||||
|
||||
// call original routine
|
||||
ULONG count = m_ID3D10Device->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0)
|
||||
{
|
||||
delete(this);
|
||||
}
|
||||
|
||||
return(count);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers)
|
||||
{
|
||||
return m_ID3D10Device->VSSetConstantBuffers( StartSlot, NumBuffers, ppConstantBuffers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews)
|
||||
{
|
||||
return m_ID3D10Device->PSSetShaderResources( StartSlot, NumViews, ppShaderResourceViews);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSSetShader( ID3D10PixelShader *pPixelShader)
|
||||
{
|
||||
return m_ID3D10Device->PSSetShader( pPixelShader);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers)
|
||||
{
|
||||
return m_ID3D10Device->PSSetSamplers( StartSlot, NumSamplers, ppSamplers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSSetShader( ID3D10VertexShader *pVertexShader)
|
||||
{
|
||||
return m_ID3D10Device->VSSetShader( pVertexShader);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::DrawIndexed( UINT IndexCount,UINT StartIndexLocation, INT BaseVertexLocation)
|
||||
{
|
||||
return m_ID3D10Device->DrawIndexed( IndexCount, StartIndexLocation, BaseVertexLocation);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::Draw( UINT VertexCount, UINT StartVertexLocation)
|
||||
{
|
||||
return m_ID3D10Device->Draw( VertexCount, StartVertexLocation);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers)
|
||||
{
|
||||
return m_ID3D10Device->PSSetConstantBuffers( StartSlot, NumBuffers, ppConstantBuffers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IASetInputLayout( ID3D10InputLayout *pInputLayout)
|
||||
{
|
||||
return m_ID3D10Device->IASetInputLayout( pInputLayout);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IASetVertexBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppVertexBuffers, const UINT *pStrides, const UINT *pOffsets)
|
||||
{
|
||||
return m_ID3D10Device->IASetVertexBuffers( StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IASetIndexBuffer( ID3D10Buffer *pIndexBuffer, DXGI_FORMAT Format, UINT Offset)
|
||||
{
|
||||
return m_ID3D10Device->IASetIndexBuffer( pIndexBuffer, Format, Offset);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::DrawIndexedInstanced(UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, INT BaseVertexLocation, UINT StartInstanceLocation)
|
||||
{
|
||||
return m_ID3D10Device->DrawIndexedInstanced( IndexCountPerInstance, InstanceCount, StartIndexLocation, BaseVertexLocation, StartInstanceLocation);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::DrawInstanced( UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation)
|
||||
{
|
||||
return m_ID3D10Device->DrawInstanced( VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers)
|
||||
{
|
||||
return m_ID3D10Device->GSSetConstantBuffers( StartSlot, NumBuffers, ppConstantBuffers);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSSetShader( ID3D10GeometryShader *pShader)
|
||||
{
|
||||
return m_ID3D10Device->GSSetShader( pShader);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY Topology)
|
||||
{
|
||||
return m_ID3D10Device->IASetPrimitiveTopology( Topology);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSSetShaderResources(UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews)
|
||||
{
|
||||
return m_ID3D10Device->VSSetShaderResources( StartSlot, NumViews, ppShaderResourceViews);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers)
|
||||
{
|
||||
return m_ID3D10Device->VSSetSamplers( StartSlot, NumSamplers, ppSamplers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::SetPredication( ID3D10Predicate *pPredicate, BOOL PredicateValue)
|
||||
{
|
||||
return m_ID3D10Device->SetPredication( pPredicate, PredicateValue);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews)
|
||||
{
|
||||
return m_ID3D10Device->GSSetShaderResources( StartSlot, NumViews, ppShaderResourceViews);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers)
|
||||
{
|
||||
return m_ID3D10Device->GSSetSamplers( StartSlot, NumSamplers, ppSamplers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::OMSetRenderTargets( UINT NumViews, ID3D10RenderTargetView *const *ppRenderTargetViews, ID3D10DepthStencilView *pDepthStencilView)
|
||||
{
|
||||
return m_ID3D10Device->OMSetRenderTargets( NumViews, ppRenderTargetViews, pDepthStencilView);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::OMSetBlendState( ID3D10BlendState *pBlendState, const FLOAT BlendFactor[ 4 ], UINT SampleMask)
|
||||
{
|
||||
return m_ID3D10Device->OMSetBlendState( pBlendState, BlendFactor, SampleMask);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::OMSetDepthStencilState( ID3D10DepthStencilState *pDepthStencilState, UINT StencilRef)
|
||||
{
|
||||
return m_ID3D10Device->OMSetDepthStencilState( pDepthStencilState, StencilRef);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::SOSetTargets(UINT NumBuffers, ID3D10Buffer *const *ppSOTargets, const UINT *pOffsets)
|
||||
{
|
||||
return m_ID3D10Device->SOSetTargets( NumBuffers, ppSOTargets, pOffsets);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::DrawAuto(void)
|
||||
{
|
||||
return m_ID3D10Device->DrawAuto();
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::RSSetState( ID3D10RasterizerState *pRasterizerState)
|
||||
{
|
||||
return m_ID3D10Device->RSSetState( pRasterizerState);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::RSSetViewports( UINT NumViewports, const D3D10_VIEWPORT *pViewports)
|
||||
{
|
||||
return m_ID3D10Device->RSSetViewports( NumViewports, pViewports);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::RSSetScissorRects( UINT NumRects, const D3D10_RECT *pRects)
|
||||
{
|
||||
return m_ID3D10Device->RSSetScissorRects( NumRects, pRects);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::CopySubresourceRegion( ID3D10Resource *pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, ID3D10Resource *pSrcResource, UINT SrcSubresource, const D3D10_BOX *pSrcBox)
|
||||
{
|
||||
return m_ID3D10Device->CopySubresourceRegion( pDstResource, DstSubresource, DstX, DstY, DstZ, pSrcResource, SrcSubresource, pSrcBox);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::CopyResource( ID3D10Resource *pDstResource, ID3D10Resource *pSrcResource)
|
||||
{
|
||||
return m_ID3D10Device->CopyResource( pDstResource, pSrcResource);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::UpdateSubresource( ID3D10Resource *pDstResource, UINT DstSubresource, const D3D10_BOX *pDstBox, const void *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch)
|
||||
{
|
||||
return m_ID3D10Device->UpdateSubresource( pDstResource, DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::ClearRenderTargetView( ID3D10RenderTargetView *pRenderTargetView, const FLOAT ColorRGBA[ 4 ])
|
||||
{
|
||||
return m_ID3D10Device->ClearRenderTargetView( pRenderTargetView, ColorRGBA);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::ClearDepthStencilView( ID3D10DepthStencilView *pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil)
|
||||
{
|
||||
return m_ID3D10Device->ClearDepthStencilView( pDepthStencilView, ClearFlags, Depth, Stencil);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GenerateMips( ID3D10ShaderResourceView *pShaderResourceView)
|
||||
{
|
||||
return m_ID3D10Device->GenerateMips( pShaderResourceView);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::ResolveSubresource( ID3D10Resource *pDstResource, UINT DstSubresource, ID3D10Resource *pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format)
|
||||
{
|
||||
return m_ID3D10Device->ResolveSubresource( pDstResource, DstSubresource, pSrcResource, SrcSubresource, Format);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSGetConstantBuffers( UINT StartSlot,UINT NumBuffers, ID3D10Buffer **ppConstantBuffers)
|
||||
{
|
||||
return m_ID3D10Device->VSGetConstantBuffers( StartSlot, NumBuffers, ppConstantBuffers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews)
|
||||
{
|
||||
return m_ID3D10Device->PSGetShaderResources( StartSlot, NumViews, ppShaderResourceViews);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSGetShader( ID3D10PixelShader **ppPixelShader)
|
||||
{
|
||||
return m_ID3D10Device->PSGetShader( ppPixelShader);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers)
|
||||
{
|
||||
return m_ID3D10Device->PSGetSamplers( StartSlot, NumSamplers, ppSamplers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSGetShader( ID3D10VertexShader **ppVertexShader)
|
||||
{
|
||||
return m_ID3D10Device->VSGetShader( ppVertexShader);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::PSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers)
|
||||
{
|
||||
return m_ID3D10Device->PSGetConstantBuffers( StartSlot, NumBuffers, ppConstantBuffers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IAGetInputLayout( ID3D10InputLayout **ppInputLayout)
|
||||
{
|
||||
return m_ID3D10Device->IAGetInputLayout( ppInputLayout);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IAGetVertexBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppVertexBuffers, UINT *pStrides, UINT *pOffsets)
|
||||
{
|
||||
return m_ID3D10Device->IAGetVertexBuffers( StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IAGetIndexBuffer( ID3D10Buffer **pIndexBuffer, DXGI_FORMAT *Format, UINT *Offset)
|
||||
{
|
||||
return m_ID3D10Device->IAGetIndexBuffer( pIndexBuffer, Format, Offset);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers)
|
||||
{
|
||||
return m_ID3D10Device->GSGetConstantBuffers( StartSlot, NumBuffers, ppConstantBuffers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSGetShader( ID3D10GeometryShader **ppGeometryShader)
|
||||
{
|
||||
return m_ID3D10Device->GSGetShader( ppGeometryShader);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::IAGetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY *pTopology)
|
||||
{
|
||||
return m_ID3D10Device->IAGetPrimitiveTopology( pTopology);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews)
|
||||
{
|
||||
return m_ID3D10Device->VSGetShaderResources( StartSlot, NumViews, ppShaderResourceViews);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::VSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers)
|
||||
{
|
||||
return m_ID3D10Device->VSGetSamplers( StartSlot, NumSamplers, ppSamplers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GetPredication( ID3D10Predicate **ppPredicate, BOOL *pPredicateValue)
|
||||
{
|
||||
return m_ID3D10Device->GetPredication( ppPredicate, pPredicateValue);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews)
|
||||
{
|
||||
return m_ID3D10Device->GSGetShaderResources( StartSlot, NumViews, ppShaderResourceViews);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers)
|
||||
{
|
||||
return m_ID3D10Device->GSGetSamplers( StartSlot, NumSamplers, ppSamplers);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::OMGetRenderTargets( UINT NumViews, ID3D10RenderTargetView **ppRenderTargetViews, ID3D10DepthStencilView **ppDepthStencilView)
|
||||
{
|
||||
return m_ID3D10Device->OMGetRenderTargets( NumViews, ppRenderTargetViews, ppDepthStencilView);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::OMGetBlendState( ID3D10BlendState **ppBlendState, FLOAT BlendFactor[ 4 ], UINT *pSampleMask)
|
||||
{
|
||||
return m_ID3D10Device->OMGetBlendState( ppBlendState, BlendFactor, pSampleMask);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::OMGetDepthStencilState( ID3D10DepthStencilState **ppDepthStencilState, UINT *pStencilRef)
|
||||
{
|
||||
return m_ID3D10Device->OMGetDepthStencilState( ppDepthStencilState, pStencilRef);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::SOGetTargets( UINT NumBuffers, ID3D10Buffer **ppSOTargets, UINT *pOffsets)
|
||||
{
|
||||
return m_ID3D10Device->SOGetTargets( NumBuffers, ppSOTargets, pOffsets);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::RSGetState( ID3D10RasterizerState **ppRasterizerState)
|
||||
{
|
||||
return m_ID3D10Device->RSGetState( ppRasterizerState);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::RSGetViewports( UINT *NumViewports, D3D10_VIEWPORT *pViewports)
|
||||
{
|
||||
return m_ID3D10Device->RSGetViewports( NumViewports, pViewports);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::RSGetScissorRects( UINT *NumRects, D3D10_RECT *pRects)
|
||||
{
|
||||
return m_ID3D10Device->RSGetScissorRects( NumRects, pRects);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::GetDeviceRemovedReason(void)
|
||||
{
|
||||
return m_ID3D10Device->GetDeviceRemovedReason();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::SetExceptionMode( UINT RaiseFlags)
|
||||
{
|
||||
return m_ID3D10Device->SetExceptionMode( RaiseFlags);
|
||||
}
|
||||
|
||||
UINT STDMETHODCALLTYPE uMod_ID3D10Device::GetExceptionMode(void)
|
||||
{
|
||||
return m_ID3D10Device->GetExceptionMode();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::GetPrivateData( REFGUID guid, UINT *pDataSize, void *pData)
|
||||
{
|
||||
return m_ID3D10Device->GetPrivateData( guid, pDataSize, pData);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::SetPrivateData( REFGUID guid, UINT DataSize, const void *pData)
|
||||
{
|
||||
return m_ID3D10Device->SetPrivateData( guid, DataSize, pData);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::SetPrivateDataInterface( REFGUID guid, const IUnknown *pData)
|
||||
{
|
||||
return m_ID3D10Device->SetPrivateDataInterface( guid, pData);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::ClearState( void)
|
||||
{
|
||||
return m_ID3D10Device->ClearState();
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::Flush( void)
|
||||
{
|
||||
return m_ID3D10Device->Flush();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateBuffer( const D3D10_BUFFER_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Buffer **ppBuffer)
|
||||
{
|
||||
return m_ID3D10Device->CreateBuffer( pDesc, pInitialData, ppBuffer);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateTexture1D( const D3D10_TEXTURE1D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture1D **ppTexture1D)
|
||||
{
|
||||
HRESULT hRes = m_ID3D10Device->CreateTexture1D( pDesc, pInitialData, ppTexture1D);
|
||||
if( SUCCEEDED( hRes ) )
|
||||
{
|
||||
*ppTexture1D = new uMod_ID3D10Texture1D( *ppTexture1D);
|
||||
}
|
||||
return hRes;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateTexture2D( const D3D10_TEXTURE2D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture2D **ppTexture2D)
|
||||
{
|
||||
HRESULT hRes = m_ID3D10Device->CreateTexture2D( pDesc, pInitialData, ppTexture2D);
|
||||
if( SUCCEEDED( hRes ) )
|
||||
{
|
||||
*ppTexture2D = new uMod_ID3D10Texture2D( *ppTexture2D);
|
||||
}
|
||||
return hRes;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateTexture3D( const D3D10_TEXTURE3D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture3D **ppTexture3D)
|
||||
{
|
||||
HRESULT hRes = m_ID3D10Device->CreateTexture3D( pDesc, pInitialData, ppTexture3D);
|
||||
if( SUCCEEDED( hRes ) )
|
||||
{
|
||||
*ppTexture3D = new uMod_ID3D10Texture3D( *ppTexture3D);
|
||||
}
|
||||
return hRes;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateShaderResourceView( ID3D10Resource *pResource, const D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc, ID3D10ShaderResourceView **ppSRView)
|
||||
{
|
||||
return m_ID3D10Device->CreateShaderResourceView( pResource, pDesc, ppSRView);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateRenderTargetView( ID3D10Resource *pResource, const D3D10_RENDER_TARGET_VIEW_DESC *pDesc, ID3D10RenderTargetView **ppRTView)
|
||||
{
|
||||
return m_ID3D10Device->CreateRenderTargetView( pResource, pDesc, ppRTView);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateDepthStencilView( ID3D10Resource *pResource, const D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc, ID3D10DepthStencilView **ppDepthStencilView)
|
||||
{
|
||||
return m_ID3D10Device->CreateDepthStencilView( pResource, pDesc, ppDepthStencilView);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateInputLayout( const D3D10_INPUT_ELEMENT_DESC *pInputElementDescs, UINT NumElements, const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D10InputLayout **ppInputLayout)
|
||||
{
|
||||
return m_ID3D10Device->CreateInputLayout( pInputElementDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, ppInputLayout);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateVertexShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10VertexShader **ppVertexShader)
|
||||
{
|
||||
return m_ID3D10Device->CreateVertexShader( pShaderBytecode, BytecodeLength, ppVertexShader);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateGeometryShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10GeometryShader **ppGeometryShader)
|
||||
{
|
||||
return m_ID3D10Device->CreateGeometryShader( pShaderBytecode, BytecodeLength, ppGeometryShader);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateGeometryShaderWithStreamOutput( const void *pShaderBytecode, SIZE_T BytecodeLength, const D3D10_SO_DECLARATION_ENTRY *pSODeclaration, UINT NumEntries, UINT OutputStreamStride, ID3D10GeometryShader **ppGeometryShader)
|
||||
{
|
||||
return m_ID3D10Device->CreateGeometryShaderWithStreamOutput( pShaderBytecode, BytecodeLength, pSODeclaration, NumEntries, OutputStreamStride, ppGeometryShader);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreatePixelShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10PixelShader **ppPixelShader)
|
||||
{
|
||||
return m_ID3D10Device->CreatePixelShader( pShaderBytecode, BytecodeLength, ppPixelShader);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateBlendState( const D3D10_BLEND_DESC *pBlendStateDesc, ID3D10BlendState **ppBlendState)
|
||||
{
|
||||
return m_ID3D10Device->CreateBlendState( pBlendStateDesc, ppBlendState);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateDepthStencilState( const D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc, ID3D10DepthStencilState **ppDepthStencilState)
|
||||
{
|
||||
return m_ID3D10Device->CreateDepthStencilState( pDepthStencilDesc, ppDepthStencilState);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateRasterizerState( const D3D10_RASTERIZER_DESC *pRasterizerDesc, ID3D10RasterizerState **ppRasterizerState)
|
||||
{
|
||||
return m_ID3D10Device->CreateRasterizerState( pRasterizerDesc, ppRasterizerState);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateSamplerState( const D3D10_SAMPLER_DESC *pSamplerDesc, ID3D10SamplerState **ppSamplerState)
|
||||
{
|
||||
return m_ID3D10Device->CreateSamplerState( pSamplerDesc, ppSamplerState);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateQuery( const D3D10_QUERY_DESC *pQueryDesc, ID3D10Query **ppQuery)
|
||||
{
|
||||
return m_ID3D10Device->CreateQuery( pQueryDesc, ppQuery);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreatePredicate( const D3D10_QUERY_DESC *pPredicateDesc, ID3D10Predicate **ppPredicate)
|
||||
{
|
||||
return m_ID3D10Device->CreatePredicate( pPredicateDesc, ppPredicate);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CreateCounter( const D3D10_COUNTER_DESC *pCounterDesc, ID3D10Counter **ppCounter)
|
||||
{
|
||||
return m_ID3D10Device->CreateCounter( pCounterDesc, ppCounter);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CheckFormatSupport( DXGI_FORMAT Format, UINT *pFormatSupport)
|
||||
{
|
||||
return m_ID3D10Device->CheckFormatSupport( Format, pFormatSupport);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CheckMultisampleQualityLevels( DXGI_FORMAT Format, UINT SampleCount, UINT *pNumQualityLevels)
|
||||
{
|
||||
return m_ID3D10Device->CheckMultisampleQualityLevels( Format, SampleCount, pNumQualityLevels);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::CheckCounterInfo( D3D10_COUNTER_INFO *pCounterInfo)
|
||||
{
|
||||
return m_ID3D10Device->CheckCounterInfo( pCounterInfo);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::CheckCounter( const D3D10_COUNTER_DESC *pDesc, D3D10_COUNTER_TYPE *pType, UINT *pActiveCounters, LPSTR szName, UINT *pNameLength, LPSTR szUnits, UINT *pUnitsLength, LPSTR szDescription, UINT *pDescriptionLength)
|
||||
{
|
||||
return m_ID3D10Device->CheckCounter( pDesc, pType, pActiveCounters, szName, pNameLength, szUnits, pUnitsLength, szDescription, pDescriptionLength);
|
||||
}
|
||||
|
||||
UINT STDMETHODCALLTYPE uMod_ID3D10Device::GetCreationFlags( void)
|
||||
{
|
||||
return m_ID3D10Device->GetCreationFlags();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device::OpenSharedResource( HANDLE hResource, REFIID ReturnedInterface, void **ppResource)
|
||||
{
|
||||
return m_ID3D10Device->OpenSharedResource( hResource, ReturnedInterface, ppResource);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::SetTextFilterSize( UINT Width, UINT Height)
|
||||
{
|
||||
return m_ID3D10Device->SetTextFilterSize( Width, Height);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Device::GetTextFilterSize( UINT *pWidth, UINT *pHeight)
|
||||
{
|
||||
return m_ID3D10Device->GetTextFilterSize( pWidth, pHeight);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __CDT_PARSER__
|
||||
#undef UMOD_ID3D10DEVICE_H_
|
||||
#endif
|
||||
|
||||
#ifndef UMOD_ID3D10DEVICE_H_
|
||||
#define UMOD_ID3D10DEVICE_H_
|
||||
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#include <D3D10Misc.h>
|
||||
#include <d3dx10.h>
|
||||
#include "..\uMod_DXMain\uMod_TextureServer.h"
|
||||
#include "uMod_TextureClient_DX10.h"
|
||||
#include "uMod_ID3D10Texture1D.h"
|
||||
#include "uMod_ID3D10Texture2D.h"
|
||||
#include "uMod_ID3D10Texture3D.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class uMod_ID3D10Device : public ID3D10Device
|
||||
{
|
||||
public:
|
||||
uMod_ID3D10Device(ID3D10Device* pOriginal, uMod_TextureServer* server);
|
||||
virtual ~uMod_ID3D10Device();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppvObject);
|
||||
ULONG STDMETHODCALLTYPE AddRef(void);
|
||||
ULONG STDMETHODCALLTYPE Release( void);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetShader( ID3D10PixelShader *pPixelShader);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetShader( ID3D10VertexShader *pVertexShader);
|
||||
|
||||
void STDMETHODCALLTYPE DrawIndexed( UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation);
|
||||
|
||||
void STDMETHODCALLTYPE Draw( UINT VertexCount, UINT StartVertexLocation);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE IASetInputLayout( ID3D10InputLayout *pInputLayout);
|
||||
|
||||
void STDMETHODCALLTYPE IASetVertexBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppVertexBuffers, const UINT *pStrides, const UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE IASetIndexBuffer( ID3D10Buffer *pIndexBuffer, DXGI_FORMAT Format, UINT Offset);
|
||||
|
||||
void STDMETHODCALLTYPE DrawIndexedInstanced( UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, INT BaseVertexLocation, UINT StartInstanceLocation);
|
||||
|
||||
void STDMETHODCALLTYPE DrawInstanced( UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetShader( ID3D10GeometryShader *pShader);
|
||||
|
||||
void STDMETHODCALLTYPE IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY Topology);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE SetPredication( ID3D10Predicate *pPredicate, BOOL PredicateValue);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE OMSetRenderTargets( UINT NumViews, ID3D10RenderTargetView *const *ppRenderTargetViews, ID3D10DepthStencilView *pDepthStencilView);
|
||||
|
||||
void STDMETHODCALLTYPE OMSetBlendState( ID3D10BlendState *pBlendState, const FLOAT BlendFactor[ 4 ], UINT SampleMask);
|
||||
|
||||
void STDMETHODCALLTYPE OMSetDepthStencilState( ID3D10DepthStencilState *pDepthStencilState, UINT StencilRef);
|
||||
|
||||
void STDMETHODCALLTYPE SOSetTargets( UINT NumBuffers, ID3D10Buffer *const *ppSOTargets, const UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE DrawAuto(void);
|
||||
|
||||
void STDMETHODCALLTYPE RSSetState( ID3D10RasterizerState *pRasterizerState);
|
||||
|
||||
void STDMETHODCALLTYPE RSSetViewports( UINT NumViewports, const D3D10_VIEWPORT *pViewports);
|
||||
|
||||
void STDMETHODCALLTYPE RSSetScissorRects( UINT NumRects, const D3D10_RECT *pRects);
|
||||
|
||||
void STDMETHODCALLTYPE CopySubresourceRegion( ID3D10Resource *pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, ID3D10Resource *pSrcResource, UINT SrcSubresource, const D3D10_BOX *pSrcBox);
|
||||
|
||||
void STDMETHODCALLTYPE CopyResource( ID3D10Resource *pDstResource, ID3D10Resource *pSrcResource);
|
||||
|
||||
void STDMETHODCALLTYPE UpdateSubresource( ID3D10Resource *pDstResource, UINT DstSubresource, const D3D10_BOX *pDstBox, const void *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch);
|
||||
|
||||
void STDMETHODCALLTYPE ClearRenderTargetView( ID3D10RenderTargetView *pRenderTargetView, const FLOAT ColorRGBA[ 4 ]);
|
||||
|
||||
void STDMETHODCALLTYPE ClearDepthStencilView( ID3D10DepthStencilView *pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil);
|
||||
|
||||
void STDMETHODCALLTYPE GenerateMips( ID3D10ShaderResourceView *pShaderResourceView);
|
||||
|
||||
void STDMETHODCALLTYPE ResolveSubresource( ID3D10Resource *pDstResource, UINT DstSubresource, ID3D10Resource *pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetShader( ID3D10PixelShader **ppPixelShader);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetShader( ID3D10VertexShader **ppVertexShader);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetInputLayout( ID3D10InputLayout **ppInputLayout);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetVertexBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppVertexBuffers, UINT *pStrides, UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetIndexBuffer( ID3D10Buffer **pIndexBuffer, DXGI_FORMAT *Format, UINT *Offset);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetShader( ID3D10GeometryShader **ppGeometryShader);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY *pTopology);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE GetPredication( ID3D10Predicate **ppPredicate, BOOL *pPredicateValue);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE OMGetRenderTargets( UINT NumViews, ID3D10RenderTargetView **ppRenderTargetViews, ID3D10DepthStencilView **ppDepthStencilView);
|
||||
|
||||
void STDMETHODCALLTYPE OMGetBlendState( ID3D10BlendState **ppBlendState, FLOAT BlendFactor[ 4 ], UINT *pSampleMask);
|
||||
|
||||
void STDMETHODCALLTYPE OMGetDepthStencilState( ID3D10DepthStencilState **ppDepthStencilState, UINT *pStencilRef);
|
||||
|
||||
void STDMETHODCALLTYPE SOGetTargets( UINT NumBuffers, ID3D10Buffer **ppSOTargets, UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE RSGetState( ID3D10RasterizerState **ppRasterizerState);
|
||||
|
||||
void STDMETHODCALLTYPE RSGetViewports( UINT *NumViewports, D3D10_VIEWPORT *pViewports);
|
||||
|
||||
void STDMETHODCALLTYPE RSGetScissorRects( UINT *NumRects, D3D10_RECT *pRects);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetDeviceRemovedReason(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetExceptionMode( UINT RaiseFlags);
|
||||
|
||||
UINT STDMETHODCALLTYPE GetExceptionMode(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData( REFGUID guid,UINT *pDataSize, void *pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData( REFGUID guid, UINT DataSize, const void *pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( REFGUID guid, const IUnknown *pData);
|
||||
|
||||
void STDMETHODCALLTYPE ClearState( void);
|
||||
|
||||
void STDMETHODCALLTYPE Flush( void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateBuffer( const D3D10_BUFFER_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Buffer **ppBuffer);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateTexture1D( const D3D10_TEXTURE1D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture1D **ppTexture1D);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateTexture2D( const D3D10_TEXTURE2D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture2D **ppTexture2D);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateTexture3D( const D3D10_TEXTURE3D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture3D **ppTexture3D);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateShaderResourceView( ID3D10Resource *pResource, const D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc, ID3D10ShaderResourceView **ppSRView);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateRenderTargetView( ID3D10Resource *pResource, const D3D10_RENDER_TARGET_VIEW_DESC *pDesc, ID3D10RenderTargetView **ppRTView);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateDepthStencilView( ID3D10Resource *pResource, const D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc, ID3D10DepthStencilView **ppDepthStencilView);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateInputLayout( const D3D10_INPUT_ELEMENT_DESC *pInputElementDescs, UINT NumElements, const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D10InputLayout **ppInputLayout);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateVertexShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10VertexShader **ppVertexShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateGeometryShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10GeometryShader **ppGeometryShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateGeometryShaderWithStreamOutput( const void *pShaderBytecode, SIZE_T BytecodeLength, const D3D10_SO_DECLARATION_ENTRY *pSODeclaration, UINT NumEntries, UINT OutputStreamStride, ID3D10GeometryShader **ppGeometryShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreatePixelShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10PixelShader **ppPixelShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateBlendState( const D3D10_BLEND_DESC *pBlendStateDesc, ID3D10BlendState **ppBlendState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateDepthStencilState( const D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc, ID3D10DepthStencilState **ppDepthStencilState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateRasterizerState( const D3D10_RASTERIZER_DESC *pRasterizerDesc, ID3D10RasterizerState **ppRasterizerState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateSamplerState( const D3D10_SAMPLER_DESC *pSamplerDesc, ID3D10SamplerState **ppSamplerState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateQuery( const D3D10_QUERY_DESC *pQueryDesc, ID3D10Query **ppQuery);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreatePredicate( const D3D10_QUERY_DESC *pPredicateDesc, ID3D10Predicate **ppPredicate);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateCounter( const D3D10_COUNTER_DESC *pCounterDesc, ID3D10Counter **ppCounter);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CheckFormatSupport( DXGI_FORMAT Format, UINT *pFormatSupport);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels( DXGI_FORMAT Format, UINT SampleCount, UINT *pNumQualityLevels);
|
||||
|
||||
void STDMETHODCALLTYPE CheckCounterInfo( D3D10_COUNTER_INFO *pCounterInfo);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CheckCounter( const D3D10_COUNTER_DESC *pDesc, D3D10_COUNTER_TYPE *pType, UINT *pActiveCounters, LPSTR szName, UINT *pNameLength, LPSTR szUnits, UINT *pUnitsLength, LPSTR szDescription, UINT *pDescriptionLength);
|
||||
|
||||
UINT STDMETHODCALLTYPE GetCreationFlags( void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE OpenSharedResource( HANDLE hResource, REFIID ReturnedInterface, void **ppResource);
|
||||
|
||||
void STDMETHODCALLTYPE SetTextFilterSize( UINT Width, UINT Height);
|
||||
|
||||
void STDMETHODCALLTYPE GetTextFilterSize( UINT *pWidth, UINT *pHeight);
|
||||
|
||||
|
||||
ID3D10Device* m_ID3D10Device;
|
||||
uMod_TextureServer* uMod_Server;
|
||||
uMod_TextureClient_DX10* uMod_Client;
|
||||
|
||||
private:
|
||||
unsigned int RefCounter;
|
||||
};
|
||||
|
||||
|
||||
#endif /* UMOD_ID3D10DEVICE_H_ */
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define UMOD_ID3D10DEVICE_H_
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Main.h"
|
||||
#include "uMod_ID3D10Device1.h"
|
||||
|
||||
#define uMod_ID3D10Device uMod_ID3D10Device1
|
||||
#define ID3D10Device ID3D10Device1
|
||||
#define m_ID3D10Device m_ID3D10Device1
|
||||
|
||||
//#define RETURN_QueryInterface 0x01000001L
|
||||
#define PRE_MESSAGE "uMod_ID3D10Device1"
|
||||
#define DEF_DX_VERSION VERSION_DX101
|
||||
|
||||
|
||||
#include "uMod_ID3D10Device.cpp"
|
||||
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device1::CreateShaderResourceView1( ID3D10Resource *pResource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *pDesc, ID3D10ShaderResourceView1 **ppSRView)
|
||||
{
|
||||
return m_ID3D10Device1->CreateShaderResourceView1( pResource, pDesc, ppSRView);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Device1::CreateBlendState1( const D3D10_BLEND_DESC1 *pBlendStateDesc, ID3D10BlendState1 **ppBlendState)
|
||||
{
|
||||
return m_ID3D10Device1->CreateBlendState1( pBlendStateDesc, ppBlendState);
|
||||
}
|
||||
|
||||
D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE uMod_ID3D10Device1::GetFeatureLevel(void)
|
||||
{
|
||||
return m_ID3D10Device1->GetFeatureLevel();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef UMOD_ID3D10DEVICE1_H_
|
||||
#define UMOD_ID3D10DEVICE1_H_
|
||||
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#include <D3D10Misc.h>
|
||||
#include <d3dx10.h>
|
||||
#include "..\uMod_DXMain\uMod_TextureServer.h"
|
||||
#include "uMod_TextureClient_DX10.h"
|
||||
#include "uMod_ID3D10Texture1D.h"
|
||||
#include "uMod_ID3D10Texture2D.h"
|
||||
#include "uMod_ID3D10Texture3D.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class uMod_ID3D10Device1 : public ID3D10Device1
|
||||
{
|
||||
public:
|
||||
uMod_ID3D10Device1(ID3D10Device1* pOriginal, uMod_TextureServer* server);
|
||||
virtual ~uMod_ID3D10Device1();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppvObject);
|
||||
ULONG STDMETHODCALLTYPE AddRef(void);
|
||||
ULONG STDMETHODCALLTYPE Release( void);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetShader( ID3D10PixelShader *pPixelShader);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetShader( ID3D10VertexShader *pVertexShader);
|
||||
|
||||
void STDMETHODCALLTYPE DrawIndexed( UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation);
|
||||
|
||||
void STDMETHODCALLTYPE Draw( UINT VertexCount, UINT StartVertexLocation);
|
||||
|
||||
void STDMETHODCALLTYPE PSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE IASetInputLayout( ID3D10InputLayout *pInputLayout);
|
||||
|
||||
void STDMETHODCALLTYPE IASetVertexBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppVertexBuffers, const UINT *pStrides, const UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE IASetIndexBuffer( ID3D10Buffer *pIndexBuffer, DXGI_FORMAT Format, UINT Offset);
|
||||
|
||||
void STDMETHODCALLTYPE DrawIndexedInstanced( UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, INT BaseVertexLocation, UINT StartInstanceLocation);
|
||||
|
||||
void STDMETHODCALLTYPE DrawInstanced( UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer *const *ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetShader( ID3D10GeometryShader *pShader);
|
||||
|
||||
void STDMETHODCALLTYPE IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY Topology);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE VSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE SetPredication( ID3D10Predicate *pPredicate, BOOL PredicateValue);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView *const *ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE GSSetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState *const *ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE OMSetRenderTargets( UINT NumViews, ID3D10RenderTargetView *const *ppRenderTargetViews, ID3D10DepthStencilView *pDepthStencilView);
|
||||
|
||||
void STDMETHODCALLTYPE OMSetBlendState( ID3D10BlendState *pBlendState, const FLOAT BlendFactor[ 4 ], UINT SampleMask);
|
||||
|
||||
void STDMETHODCALLTYPE OMSetDepthStencilState( ID3D10DepthStencilState *pDepthStencilState, UINT StencilRef);
|
||||
|
||||
void STDMETHODCALLTYPE SOSetTargets( UINT NumBuffers, ID3D10Buffer *const *ppSOTargets, const UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE DrawAuto(void);
|
||||
|
||||
void STDMETHODCALLTYPE RSSetState( ID3D10RasterizerState *pRasterizerState);
|
||||
|
||||
void STDMETHODCALLTYPE RSSetViewports( UINT NumViewports, const D3D10_VIEWPORT *pViewports);
|
||||
|
||||
void STDMETHODCALLTYPE RSSetScissorRects( UINT NumRects, const D3D10_RECT *pRects);
|
||||
|
||||
void STDMETHODCALLTYPE CopySubresourceRegion( ID3D10Resource *pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, ID3D10Resource *pSrcResource, UINT SrcSubresource, const D3D10_BOX *pSrcBox);
|
||||
|
||||
void STDMETHODCALLTYPE CopyResource( ID3D10Resource *pDstResource, ID3D10Resource *pSrcResource);
|
||||
|
||||
void STDMETHODCALLTYPE UpdateSubresource( ID3D10Resource *pDstResource, UINT DstSubresource, const D3D10_BOX *pDstBox, const void *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch);
|
||||
|
||||
void STDMETHODCALLTYPE ClearRenderTargetView( ID3D10RenderTargetView *pRenderTargetView, const FLOAT ColorRGBA[ 4 ]);
|
||||
|
||||
void STDMETHODCALLTYPE ClearDepthStencilView( ID3D10DepthStencilView *pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil);
|
||||
|
||||
void STDMETHODCALLTYPE GenerateMips( ID3D10ShaderResourceView *pShaderResourceView);
|
||||
|
||||
void STDMETHODCALLTYPE ResolveSubresource( ID3D10Resource *pDstResource, UINT DstSubresource, ID3D10Resource *pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetShader( ID3D10PixelShader **ppPixelShader);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetShader( ID3D10VertexShader **ppVertexShader);
|
||||
|
||||
void STDMETHODCALLTYPE PSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetInputLayout( ID3D10InputLayout **ppInputLayout);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetVertexBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppVertexBuffers, UINT *pStrides, UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetIndexBuffer( ID3D10Buffer **pIndexBuffer, DXGI_FORMAT *Format, UINT *Offset);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetConstantBuffers( UINT StartSlot, UINT NumBuffers, ID3D10Buffer **ppConstantBuffers);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetShader( ID3D10GeometryShader **ppGeometryShader);
|
||||
|
||||
void STDMETHODCALLTYPE IAGetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY *pTopology);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE VSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE GetPredication( ID3D10Predicate **ppPredicate, BOOL *pPredicateValue);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetShaderResources( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView **ppShaderResourceViews);
|
||||
|
||||
void STDMETHODCALLTYPE GSGetSamplers( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState **ppSamplers);
|
||||
|
||||
void STDMETHODCALLTYPE OMGetRenderTargets( UINT NumViews, ID3D10RenderTargetView **ppRenderTargetViews, ID3D10DepthStencilView **ppDepthStencilView);
|
||||
|
||||
void STDMETHODCALLTYPE OMGetBlendState( ID3D10BlendState **ppBlendState, FLOAT BlendFactor[ 4 ], UINT *pSampleMask);
|
||||
|
||||
void STDMETHODCALLTYPE OMGetDepthStencilState( ID3D10DepthStencilState **ppDepthStencilState, UINT *pStencilRef);
|
||||
|
||||
void STDMETHODCALLTYPE SOGetTargets( UINT NumBuffers, ID3D10Buffer **ppSOTargets, UINT *pOffsets);
|
||||
|
||||
void STDMETHODCALLTYPE RSGetState( ID3D10RasterizerState **ppRasterizerState);
|
||||
|
||||
void STDMETHODCALLTYPE RSGetViewports( UINT *NumViewports, D3D10_VIEWPORT *pViewports);
|
||||
|
||||
void STDMETHODCALLTYPE RSGetScissorRects( UINT *NumRects, D3D10_RECT *pRects);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetDeviceRemovedReason(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetExceptionMode( UINT RaiseFlags);
|
||||
|
||||
UINT STDMETHODCALLTYPE GetExceptionMode(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData( REFGUID guid,UINT *pDataSize, void *pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData( REFGUID guid, UINT DataSize, const void *pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( REFGUID guid, const IUnknown *pData);
|
||||
|
||||
void STDMETHODCALLTYPE ClearState( void);
|
||||
|
||||
void STDMETHODCALLTYPE Flush( void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateBuffer( const D3D10_BUFFER_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Buffer **ppBuffer);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateTexture1D( const D3D10_TEXTURE1D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture1D **ppTexture1D);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateTexture2D( const D3D10_TEXTURE2D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture2D **ppTexture2D);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateTexture3D( const D3D10_TEXTURE3D_DESC *pDesc, const D3D10_SUBRESOURCE_DATA *pInitialData, ID3D10Texture3D **ppTexture3D);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateShaderResourceView( ID3D10Resource *pResource, const D3D10_SHADER_RESOURCE_VIEW_DESC *pDesc, ID3D10ShaderResourceView **ppSRView);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateRenderTargetView( ID3D10Resource *pResource, const D3D10_RENDER_TARGET_VIEW_DESC *pDesc, ID3D10RenderTargetView **ppRTView);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateDepthStencilView( ID3D10Resource *pResource, const D3D10_DEPTH_STENCIL_VIEW_DESC *pDesc, ID3D10DepthStencilView **ppDepthStencilView);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateInputLayout( const D3D10_INPUT_ELEMENT_DESC *pInputElementDescs, UINT NumElements, const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D10InputLayout **ppInputLayout);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateVertexShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10VertexShader **ppVertexShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateGeometryShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10GeometryShader **ppGeometryShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateGeometryShaderWithStreamOutput( const void *pShaderBytecode, SIZE_T BytecodeLength, const D3D10_SO_DECLARATION_ENTRY *pSODeclaration, UINT NumEntries, UINT OutputStreamStride, ID3D10GeometryShader **ppGeometryShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreatePixelShader( const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10PixelShader **ppPixelShader);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateBlendState( const D3D10_BLEND_DESC *pBlendStateDesc, ID3D10BlendState **ppBlendState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateDepthStencilState( const D3D10_DEPTH_STENCIL_DESC *pDepthStencilDesc, ID3D10DepthStencilState **ppDepthStencilState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateRasterizerState( const D3D10_RASTERIZER_DESC *pRasterizerDesc, ID3D10RasterizerState **ppRasterizerState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateSamplerState( const D3D10_SAMPLER_DESC *pSamplerDesc, ID3D10SamplerState **ppSamplerState);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateQuery( const D3D10_QUERY_DESC *pQueryDesc, ID3D10Query **ppQuery);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreatePredicate( const D3D10_QUERY_DESC *pPredicateDesc, ID3D10Predicate **ppPredicate);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateCounter( const D3D10_COUNTER_DESC *pCounterDesc, ID3D10Counter **ppCounter);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CheckFormatSupport( DXGI_FORMAT Format, UINT *pFormatSupport);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels( DXGI_FORMAT Format, UINT SampleCount, UINT *pNumQualityLevels);
|
||||
|
||||
void STDMETHODCALLTYPE CheckCounterInfo( D3D10_COUNTER_INFO *pCounterInfo);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CheckCounter( const D3D10_COUNTER_DESC *pDesc, D3D10_COUNTER_TYPE *pType, UINT *pActiveCounters, LPSTR szName, UINT *pNameLength, LPSTR szUnits, UINT *pUnitsLength, LPSTR szDescription, UINT *pDescriptionLength);
|
||||
|
||||
UINT STDMETHODCALLTYPE GetCreationFlags( void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE OpenSharedResource( HANDLE hResource, REFIID ReturnedInterface, void **ppResource);
|
||||
|
||||
void STDMETHODCALLTYPE SetTextFilterSize( UINT Width, UINT Height);
|
||||
|
||||
void STDMETHODCALLTYPE GetTextFilterSize( UINT *pWidth, UINT *pHeight);
|
||||
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateShaderResourceView1( ID3D10Resource *pResource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *pDesc, ID3D10ShaderResourceView1 **ppSRView);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateBlendState1( const D3D10_BLEND_DESC1 *pBlendStateDesc, ID3D10BlendState1 **ppBlendState);
|
||||
|
||||
D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE GetFeatureLevel(void);
|
||||
|
||||
|
||||
|
||||
ID3D10Device1* m_ID3D10Device1;
|
||||
uMod_TextureServer* uMod_Server;
|
||||
uMod_TextureClient_DX10* uMod_Client;
|
||||
|
||||
private:
|
||||
unsigned int RefCounter;
|
||||
};
|
||||
|
||||
|
||||
#endif /* UMOD_ID3D10DEVICE1_H_ */
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "uMod_ID3D10Texture1D.h"
|
||||
|
||||
|
||||
uMod_ID3D10Texture1D::uMod_ID3D10Texture1D(ID3D10Texture1D *pOriginal)
|
||||
{
|
||||
Message( "uMod_ID3D10Texture1D::uMod_ID3D10Texture1D( %lu): %lu\n", pOriginal, this);
|
||||
m_ID3D10Texture1D = pOriginal;
|
||||
}
|
||||
uMod_ID3D10Texture1D::~uMod_ID3D10Texture1D()
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture1D::QueryInterface( REFIID riid, void** ppvObject)
|
||||
{
|
||||
return m_ID3D10Texture1D->QueryInterface( riid, ppvObject);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Texture1D::AddRef(void)
|
||||
{
|
||||
return m_ID3D10Texture1D->AddRef();
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Texture1D::Release( void)
|
||||
{
|
||||
ULONG count = m_ID3D10Texture1D->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0)
|
||||
{
|
||||
delete(this);
|
||||
}
|
||||
return(count);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture1D::GetDevice( ID3D10Device **ppDevice)
|
||||
{
|
||||
return m_ID3D10Texture1D->GetDevice( ppDevice);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture1D::GetPrivateData( REFGUID guid, UINT *pDataSize, void *pData)
|
||||
{
|
||||
return m_ID3D10Texture1D->GetPrivateData( guid, pDataSize, pData);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture1D::SetPrivateData( REFGUID guid, UINT DataSize, const void *pData)
|
||||
{
|
||||
return m_ID3D10Texture1D->SetPrivateData( guid, DataSize, pData);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture1D::SetPrivateDataInterface( REFGUID guid, const IUnknown *pData)
|
||||
{
|
||||
return m_ID3D10Texture1D->SetPrivateDataInterface( guid, pData);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture1D::GetType( D3D10_RESOURCE_DIMENSION *rType)
|
||||
{
|
||||
return m_ID3D10Texture1D->GetType( rType);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture1D::SetEvictionPriority( UINT EvictionPriority)
|
||||
{
|
||||
return m_ID3D10Texture1D->SetEvictionPriority( EvictionPriority);
|
||||
}
|
||||
UINT STDMETHODCALLTYPE uMod_ID3D10Texture1D::GetEvictionPriority(void)
|
||||
{
|
||||
return m_ID3D10Texture1D->GetEvictionPriority();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture1D::Map( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, void **ppData)
|
||||
{
|
||||
return m_ID3D10Texture1D->Map( Subresource, MapType, MapFlags, ppData);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture1D::Unmap( UINT Subresource)
|
||||
{
|
||||
return m_ID3D10Texture1D->Unmap( Subresource);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture1D::GetDesc( D3D10_TEXTURE1D_DESC *pDesc)
|
||||
{
|
||||
return m_ID3D10Texture1D->GetDesc( pDesc);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UMOD_ID3D10TEXTURE1D_H_
|
||||
#define UMOD_ID3D10TEXTURE1D_H_
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#include <D3D10Misc.h>
|
||||
#include <d3dx10.h>
|
||||
|
||||
class uMod_ID3D10Texture1D : public ID3D10Texture1D
|
||||
{
|
||||
public:
|
||||
uMod_ID3D10Texture1D(ID3D10Texture1D *pOriginal);
|
||||
virtual ~uMod_ID3D10Texture1D();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppvObject);
|
||||
ULONG STDMETHODCALLTYPE AddRef(void);
|
||||
ULONG STDMETHODCALLTYPE Release( void);
|
||||
|
||||
void STDMETHODCALLTYPE GetDevice( ID3D10Device **ppDevice);
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData( REFGUID guid, UINT *pDataSize, void *pData);
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData( REFGUID guid, UINT DataSize, const void *pData);
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( REFGUID guid, const IUnknown *pData);
|
||||
|
||||
void STDMETHODCALLTYPE GetType( D3D10_RESOURCE_DIMENSION *rType);
|
||||
void STDMETHODCALLTYPE SetEvictionPriority( UINT EvictionPriority);
|
||||
UINT STDMETHODCALLTYPE GetEvictionPriority(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Map( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, void **ppData);
|
||||
void STDMETHODCALLTYPE Unmap( UINT Subresource);
|
||||
void STDMETHODCALLTYPE GetDesc( D3D10_TEXTURE1D_DESC *pDesc);
|
||||
|
||||
ID3D10Texture1D *m_ID3D10Texture1D;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* UMOD_ID3D10TEXTURE1D_H_ */
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "uMod_ID3D10Texture2D.h"
|
||||
|
||||
|
||||
uMod_ID3D10Texture2D::uMod_ID3D10Texture2D(ID3D10Texture2D *pOriginal)
|
||||
{
|
||||
Message( "uMod_ID3D10Texture1D::uMod_ID3D10Texture1D( %lu): %lu\n", pOriginal, this);
|
||||
m_ID3D10Texture2D = pOriginal;
|
||||
}
|
||||
uMod_ID3D10Texture2D::~uMod_ID3D10Texture2D()
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture2D::QueryInterface( REFIID riid, void** ppvObject)
|
||||
{
|
||||
return m_ID3D10Texture2D->QueryInterface( riid, ppvObject);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Texture2D::AddRef(void)
|
||||
{
|
||||
return m_ID3D10Texture2D->AddRef();
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Texture2D::Release( void)
|
||||
{
|
||||
ULONG count = m_ID3D10Texture2D->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0)
|
||||
{
|
||||
delete(this);
|
||||
}
|
||||
return(count);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture2D::GetDevice( ID3D10Device **ppDevice)
|
||||
{
|
||||
return m_ID3D10Texture2D->GetDevice( ppDevice);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture2D::GetPrivateData( REFGUID guid, UINT *pDataSize, void *pData)
|
||||
{
|
||||
return m_ID3D10Texture2D->GetPrivateData( guid, pDataSize, pData);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture2D::SetPrivateData( REFGUID guid, UINT DataSize, const void *pData)
|
||||
{
|
||||
return m_ID3D10Texture2D->SetPrivateData( guid, DataSize, pData);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture2D::SetPrivateDataInterface( REFGUID guid, const IUnknown *pData)
|
||||
{
|
||||
return m_ID3D10Texture2D->SetPrivateDataInterface( guid, pData);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture2D::GetType( D3D10_RESOURCE_DIMENSION *rType)
|
||||
{
|
||||
return m_ID3D10Texture2D->GetType( rType);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture2D::SetEvictionPriority( UINT EvictionPriority)
|
||||
{
|
||||
return m_ID3D10Texture2D->SetEvictionPriority( EvictionPriority);
|
||||
}
|
||||
UINT STDMETHODCALLTYPE uMod_ID3D10Texture2D::GetEvictionPriority(void)
|
||||
{
|
||||
return m_ID3D10Texture2D->GetEvictionPriority();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture2D::Map( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE2D *pMappedTex2D)
|
||||
{
|
||||
return m_ID3D10Texture2D->Map( Subresource, MapType, MapFlags, pMappedTex2D);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture2D::Unmap( UINT Subresource)
|
||||
{
|
||||
return m_ID3D10Texture2D->Unmap( Subresource);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture2D::GetDesc( D3D10_TEXTURE2D_DESC *pDesc)
|
||||
{
|
||||
return m_ID3D10Texture2D->GetDesc( pDesc);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UMOD_ID3D10TEXTURE2D_H_
|
||||
#define UMOD_ID3D10TEXTURE2D_H_
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#include <D3D10Misc.h>
|
||||
#include <d3dx10.h>
|
||||
|
||||
class uMod_ID3D10Texture2D : public ID3D10Texture2D
|
||||
{
|
||||
public:
|
||||
uMod_ID3D10Texture2D(ID3D10Texture2D *pOriginal);
|
||||
virtual ~uMod_ID3D10Texture2D();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppvObject);
|
||||
ULONG STDMETHODCALLTYPE AddRef(void);
|
||||
ULONG STDMETHODCALLTYPE Release( void);
|
||||
|
||||
void STDMETHODCALLTYPE GetDevice( ID3D10Device **ppDevice);
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData( REFGUID guid, UINT *pDataSize, void *pData);
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData( REFGUID guid, UINT DataSize, const void *pData);
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( REFGUID guid, const IUnknown *pData);
|
||||
|
||||
void STDMETHODCALLTYPE GetType( D3D10_RESOURCE_DIMENSION *rType);
|
||||
void STDMETHODCALLTYPE SetEvictionPriority( UINT EvictionPriority);
|
||||
UINT STDMETHODCALLTYPE GetEvictionPriority(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Map( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE2D *ppData);
|
||||
void STDMETHODCALLTYPE Unmap( UINT Subresource);
|
||||
void STDMETHODCALLTYPE GetDesc( D3D10_TEXTURE2D_DESC *pDesc);
|
||||
|
||||
ID3D10Texture2D *m_ID3D10Texture2D;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* UMOD_ID3D10TEXTURE2D_H_ */
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "uMod_ID3D10Texture3D.h"
|
||||
|
||||
|
||||
uMod_ID3D10Texture3D::uMod_ID3D10Texture3D(ID3D10Texture3D *pOriginal)
|
||||
{
|
||||
Message( "uMod_ID3D10Texture1D::uMod_ID3D10Texture1D( %lu): %lu\n", pOriginal, this);
|
||||
m_ID3D10Texture3D = pOriginal;
|
||||
}
|
||||
uMod_ID3D10Texture3D::~uMod_ID3D10Texture3D()
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture3D::QueryInterface( REFIID riid, void** ppvObject)
|
||||
{
|
||||
return m_ID3D10Texture3D->QueryInterface( riid, ppvObject);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Texture3D::AddRef(void)
|
||||
{
|
||||
return m_ID3D10Texture3D->AddRef();
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE uMod_ID3D10Texture3D::Release( void)
|
||||
{
|
||||
ULONG count = m_ID3D10Texture3D->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0)
|
||||
{
|
||||
delete(this);
|
||||
}
|
||||
return(count);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture3D::GetDevice( ID3D10Device **ppDevice)
|
||||
{
|
||||
return m_ID3D10Texture3D->GetDevice( ppDevice);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture3D::GetPrivateData( REFGUID guid, UINT *pDataSize, void *pData)
|
||||
{
|
||||
return m_ID3D10Texture3D->GetPrivateData( guid, pDataSize, pData);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture3D::SetPrivateData( REFGUID guid, UINT DataSize, const void *pData)
|
||||
{
|
||||
return m_ID3D10Texture3D->SetPrivateData( guid, DataSize, pData);
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture3D::SetPrivateDataInterface( REFGUID guid, const IUnknown *pData)
|
||||
{
|
||||
return m_ID3D10Texture3D->SetPrivateDataInterface( guid, pData);
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture3D::GetType( D3D10_RESOURCE_DIMENSION *rType)
|
||||
{
|
||||
return m_ID3D10Texture3D->GetType( rType);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture3D::SetEvictionPriority( UINT EvictionPriority)
|
||||
{
|
||||
return m_ID3D10Texture3D->SetEvictionPriority( EvictionPriority);
|
||||
}
|
||||
UINT STDMETHODCALLTYPE uMod_ID3D10Texture3D::GetEvictionPriority(void)
|
||||
{
|
||||
return m_ID3D10Texture3D->GetEvictionPriority();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_ID3D10Texture3D::Map( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE3D *pMappedTex3D)
|
||||
{
|
||||
return m_ID3D10Texture3D->Map( Subresource, MapType, MapFlags, pMappedTex3D);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture3D::Unmap( UINT Subresource)
|
||||
{
|
||||
return m_ID3D10Texture3D->Unmap( Subresource);
|
||||
}
|
||||
void STDMETHODCALLTYPE uMod_ID3D10Texture3D::GetDesc( D3D10_TEXTURE3D_DESC *pDesc)
|
||||
{
|
||||
return m_ID3D10Texture3D->GetDesc( pDesc);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UMOD_ID3D10TEXTURE3D_H_
|
||||
#define UMOD_ID3D10TEXTURE3D_H_
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#include <D3D10Misc.h>
|
||||
#include <d3dx10.h>
|
||||
|
||||
class uMod_ID3D10Texture3D : public ID3D10Texture3D
|
||||
{
|
||||
public:
|
||||
uMod_ID3D10Texture3D(ID3D10Texture3D *pOriginal);
|
||||
virtual ~uMod_ID3D10Texture3D();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppvObject);
|
||||
ULONG STDMETHODCALLTYPE AddRef(void);
|
||||
ULONG STDMETHODCALLTYPE Release( void);
|
||||
|
||||
void STDMETHODCALLTYPE GetDevice( ID3D10Device **ppDevice);
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData( REFGUID guid, UINT *pDataSize, void *pData);
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData( REFGUID guid, UINT DataSize, const void *pData);
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( REFGUID guid, const IUnknown *pData);
|
||||
|
||||
void STDMETHODCALLTYPE GetType( D3D10_RESOURCE_DIMENSION *rType);
|
||||
void STDMETHODCALLTYPE SetEvictionPriority( UINT EvictionPriority);
|
||||
UINT STDMETHODCALLTYPE GetEvictionPriority(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Map( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE3D *ppData);
|
||||
void STDMETHODCALLTYPE Unmap( UINT Subresource);
|
||||
void STDMETHODCALLTYPE GetDesc( D3D10_TEXTURE3D_DESC *pDesc);
|
||||
|
||||
ID3D10Texture3D *m_ID3D10Texture3D;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* UMOD_ID3D10TEXTURE3D_H_ */
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine.If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "uMod_IDXGISwapChain.h"
|
||||
#include "uMod_ID3D10Device.h"
|
||||
|
||||
|
||||
uMod_IDXGISwapChain::uMod_IDXGISwapChain(IDXGISwapChain *pOriginal, uMod_ID3D10Device *dev)
|
||||
{
|
||||
Message( "uMod_IDXGISwapChain::uMod_IDXGISwapChain( %lu, %lu): %lu\n", pOriginal, dev, this);
|
||||
m_IDXGISwapChain = pOriginal;
|
||||
u_ID3D10Device = dev;
|
||||
RefCounter = 1;
|
||||
}
|
||||
|
||||
uMod_IDXGISwapChain::~uMod_IDXGISwapChain()
|
||||
{
|
||||
Message( "IDXGISwapChain::~IDXGISwapChain(): %lu\n", this);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::QueryInterface( REFIID riid, void** ppvObject)
|
||||
{
|
||||
*ppvObject = NULL;
|
||||
Message( "uMod_IDXGISwapChain::QueryInterface(): %lu\n", this);
|
||||
HRESULT hRes = m_IDXGISwapChain->QueryInterface(riid, ppvObject);
|
||||
|
||||
if (*ppvObject == m_IDXGISwapChain)
|
||||
{
|
||||
RefCounter++; //increasing our counter
|
||||
*ppvObject = this;
|
||||
}
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE uMod_IDXGISwapChain::AddRef(void)
|
||||
{
|
||||
Message( "uMod_IDXGISwapChain::AddRef(): %lu\n", this);
|
||||
RefCounter++;
|
||||
return m_IDXGISwapChain->AddRef();
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE uMod_IDXGISwapChain::Release( void)
|
||||
{
|
||||
Message( "uMod_IDXGISwapChain::Release(): %lu\n", this);
|
||||
if (--RefCounter==0) //if our counter drops to zero, the real device will be deleted, so we clean up before
|
||||
{
|
||||
// we must not release the fake textures, cause they are released if the target textures are released
|
||||
// and the target textures are released by the game.
|
||||
}
|
||||
|
||||
// call original routine
|
||||
ULONG count = m_IDXGISwapChain->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0)
|
||||
{
|
||||
delete(this);
|
||||
}
|
||||
|
||||
return(count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::SetPrivateData(REFGUID Name, UINT DataSize, const void *pData)
|
||||
{
|
||||
return m_IDXGISwapChain->SetPrivateData( Name, DataSize, pData);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown)
|
||||
{
|
||||
return m_IDXGISwapChain->SetPrivateDataInterface( Name, pUnknown);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetPrivateData( REFGUID Name, UINT *pDataSize, void *pData)
|
||||
{
|
||||
return m_IDXGISwapChain->GetPrivateData( Name, pDataSize, pData);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetParent( REFIID riid, void **ppParent)
|
||||
{
|
||||
return m_IDXGISwapChain->GetParent( riid, ppParent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetDevice( REFIID riid, void **ppDevice)
|
||||
{
|
||||
// ToDO:
|
||||
// Increas RefCounter from u_ID3D10Device but not from u_ID3D10Device->m_ID3D10Device ? ? ? ? ?
|
||||
HRESULT hRes = m_IDXGISwapChain->GetDevice( riid, ppDevice);
|
||||
if (*ppDevice == u_ID3D10Device->m_ID3D10Device) *ppDevice = u_ID3D10Device;
|
||||
return hRes;
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::Present( UINT SyncInterval, UINT Flags)
|
||||
{
|
||||
Message( "uMod_IDXGISwapChain::Present(): %lu\n", this);
|
||||
return m_IDXGISwapChain->Present( SyncInterval, Flags);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetBuffer( UINT Buffer, REFIID riid, void **ppSurface)
|
||||
{
|
||||
Message( "uMod_IDXGISwapChain::GetBuffer(): %lu\n", this);
|
||||
return m_IDXGISwapChain->GetBuffer( Buffer, riid, ppSurface);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::SetFullscreenState( BOOL Fullscreen, IDXGIOutput *pTarget)
|
||||
{
|
||||
return m_IDXGISwapChain->SetFullscreenState( Fullscreen, pTarget);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetFullscreenState( BOOL *pFullscreen, IDXGIOutput **ppTarget)
|
||||
{
|
||||
return m_IDXGISwapChain->GetFullscreenState( pFullscreen, ppTarget);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetDesc( DXGI_SWAP_CHAIN_DESC *pDesc)
|
||||
{
|
||||
return m_IDXGISwapChain->GetDesc( pDesc);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::ResizeBuffers( UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
|
||||
{
|
||||
return m_IDXGISwapChain->ResizeBuffers( BufferCount, Width, Height, NewFormat, SwapChainFlags);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::ResizeTarget( const DXGI_MODE_DESC *pNewTargetParameters)
|
||||
{
|
||||
return m_IDXGISwapChain->ResizeTarget( pNewTargetParameters);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetContainingOutput( IDXGIOutput **ppOutput)
|
||||
{
|
||||
return m_IDXGISwapChain->GetContainingOutput( ppOutput);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetFrameStatistics( DXGI_FRAME_STATISTICS *pStats)
|
||||
{
|
||||
return m_IDXGISwapChain->GetFrameStatistics( pStats);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE uMod_IDXGISwapChain::GetLastPresentCount( UINT *pLastPresentCount)
|
||||
{
|
||||
return m_IDXGISwapChain->GetLastPresentCount( pLastPresentCount);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UMOD_IDXGISWAPCHAIN_H_
|
||||
#define UMOD_IDXGISWAPCHAIN_H_
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#include <D3D10Misc.h>
|
||||
#include <d3dx10.h>
|
||||
|
||||
class uMod_ID3D10Device;
|
||||
|
||||
class uMod_IDXGISwapChain : public IDXGISwapChain
|
||||
{
|
||||
public:
|
||||
uMod_IDXGISwapChain(IDXGISwapChain *pOriginal, uMod_ID3D10Device *dev);
|
||||
virtual ~uMod_IDXGISwapChain();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppvObject);
|
||||
ULONG STDMETHODCALLTYPE AddRef(void);
|
||||
ULONG STDMETHODCALLTYPE Release( void);
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData( REFGUID Name, UINT DataSize, const void *pData);
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown);
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData( REFGUID Name, UINT *pDataSize, void *pData);
|
||||
HRESULT STDMETHODCALLTYPE GetParent( REFIID riid, void **ppParent);
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetDevice( REFIID riid, void **ppDevice);
|
||||
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Present( UINT SyncInterval, UINT Flags);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetBuffer( UINT Buffer, REFIID riid, void **ppSurface);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetFullscreenState( BOOL Fullscreen, IDXGIOutput *pTarget);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetFullscreenState( BOOL *pFullscreen, IDXGIOutput **ppTarget);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetDesc( DXGI_SWAP_CHAIN_DESC *pDesc);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ResizeBuffers( UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ResizeTarget( const DXGI_MODE_DESC *pNewTargetParameters);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetContainingOutput( IDXGIOutput **ppOutput);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetFrameStatistics( DXGI_FRAME_STATISTICS *pStats);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetLastPresentCount( UINT *pLastPresentCount);
|
||||
|
||||
|
||||
IDXGISwapChain *m_IDXGISwapChain;
|
||||
uMod_ID3D10Device *u_ID3D10Device;
|
||||
|
||||
private:
|
||||
unsigned int RefCounter;
|
||||
};
|
||||
|
||||
|
||||
#endif /* UMOD_IDXGISWAPCHAIN_H_ */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_TEXTURECLIENT_DX10_HPP
|
||||
#define uMod_TEXTURECLIENT_DX10_HPP
|
||||
|
||||
#include "..\uMod_Error.h"
|
||||
#include "..\uMod_DXMain\uMod_TextureClient.h"
|
||||
|
||||
class uMod_TextureServer;
|
||||
class uMod_ID3D10Device;
|
||||
|
||||
/*
|
||||
* An object of this class is owned by each d3d10 device.
|
||||
* functions called by the Server are called from the server thread instance.
|
||||
* All other functions are called from the render thread instance of the game itself.
|
||||
*/
|
||||
|
||||
class uMod_TextureClient_DX10 : public uMod_TextureClient
|
||||
{
|
||||
public:
|
||||
uMod_TextureClient_DX10( uMod_ID3D10Device* device, const int version);
|
||||
virtual ~uMod_TextureClient_DX10(void);
|
||||
/*
|
||||
int AddTexture( uMod_IDirect3DTexture9* tex); //called from uMod_IDirect3DDevice9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
int AddTexture( uMod_IDirect3DVolumeTexture9* tex); //called from uMod_IDirect3DVolumeTexture9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
int AddTexture( uMod_IDirect3DCubeTexture9* tex); //called from uMod_IDirect3DCubeTexture9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
|
||||
int RemoveTexture( uMod_IDirect3DTexture9* tex); //called from uMod_IDirect3DTexture9::Release()
|
||||
int RemoveTexture( uMod_IDirect3DVolumeTexture9* tex); //called from uMod_IDirect3DVolumeTexture9::Release()
|
||||
int RemoveTexture( uMod_IDirect3DCubeTexture9* tex); //called from uMod_IDirect3DCubeTexture9::Release()
|
||||
|
||||
int SaveAllTextures(bool val); //called from the Server
|
||||
int SaveSingleTexture(bool val); //called from the Server
|
||||
|
||||
int SaveTexture(uMod_IDirect3DTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
int SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
int SaveTexture(uMod_IDirect3DCubeTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
|
||||
int MergeUpdate(void); //called from uMod_IDirect3DDevice9::BeginScene()
|
||||
|
||||
|
||||
|
||||
int LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
int LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
int LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
uMod_TextureHandler<uMod_IDirect3DTexture9> OriginalTextures; // stores the pointer to the uMod_IDirect3DTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DVolumeTexture9> OriginalVolumeTextures; // stores the pointer to the uMod_IDirect3DVolumeTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DCubeTexture9> OriginalCubeTextures; // stores the pointer to the uMod_IDirect3DCubeTexture9 objects created by the game
|
||||
|
||||
|
||||
// if the has could not be calculated for a texture it is not considered in the original texture list,
|
||||
// but it is now added into the following lists and we try to calculate the hash once again later
|
||||
int CheckAgainNonAdded(void);
|
||||
bool Bool_CheckAgainNonAdded;
|
||||
uMod_TextureHandler<uMod_IDirect3DTexture9> NonAdded_OriginalTextures; // stores the pointer to the uMod_IDirect3DTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DVolumeTexture9> NonAdded_OriginalVolumeTextures; // stores the pointer to the uMod_IDirect3DVolumeTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DCubeTexture9> NonAdded_OriginalCubeTextures; // stores the pointer to the uMod_IDirect3DCubeTexture9 objects created by the game
|
||||
|
||||
private:
|
||||
IDirect3DDevice9* D3D9Device;
|
||||
|
||||
int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture); // called if a target texture is found
|
||||
int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture); // called if a target texture is found
|
||||
int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture); // called if a target texture is found
|
||||
|
||||
// and the corresponding fake texture should be loaded
|
||||
|
||||
//MyTypeHash GetHash(unsigned char *str, int len);
|
||||
//unsigned int GetCRC32(char *pcDatabuf, unsigned int ulDatalen);
|
||||
*
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* uMod_TEXTUREHANDLER_HPP_ */
|
||||
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
NEVER USE THIS CODE FOR ILLEGAL PURPOSE
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "uMod_DX9_dll.h"
|
||||
#include "uMod_IDirect3D9.h"
|
||||
#include "uMod_IDirect3D9Ex.h"
|
||||
|
||||
|
||||
/*
|
||||
* global variable which are not linked external
|
||||
*/
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
HINSTANCE gl_hOriginal_DX9_Dll = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
typedef IDirect3D9 *(APIENTRY *Direct3DCreate9_type)(UINT);
|
||||
typedef HRESULT (APIENTRY *Direct3DCreate9Ex_type)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
|
||||
uMod_Detour_Entry<Direct3DCreate9_type> Detour_Direct3DCreate9(5);
|
||||
uMod_Detour_Entry<Direct3DCreate9Ex_type> Detour_Direct3DCreate9Ex(5);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void InitDX9(void)
|
||||
{
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
char buffer[MAX_PATH];
|
||||
wchar_t buffer_w[MAX_PATH];
|
||||
GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d9.dll
|
||||
|
||||
swprintf_s( buffer_w, MAX_PATH, L"%s\\d3d9.dll", buffer);
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d9.dll");
|
||||
|
||||
Detour_Direct3DCreate9.SetFunctionName( "Direct3DCreate9");
|
||||
Detour_Direct3DCreate9.SetTargetFunction( uMod_Direct3DCreate9);
|
||||
Detour_Direct3DCreate9.SetLibName( "d3d9.dll");
|
||||
Detour_Direct3DCreate9.SetFullLibName( buffer);
|
||||
Detour_Direct3DCreate9.SetLibName( L"d3d9.dll"); // set also for wide character
|
||||
Detour_Direct3DCreate9.SetFullLibName( buffer_w); // set also for wide character
|
||||
|
||||
Detour_Direct3DCreate9Ex.SetFunctionName( "Direct3DCreate9Ex");
|
||||
Detour_Direct3DCreate9Ex.SetTargetFunction( uMod_Direct3DCreate9Ex);
|
||||
Detour_Direct3DCreate9Ex.SetLibName( "d3d9.dll");
|
||||
Detour_Direct3DCreate9Ex.SetFullLibName( buffer);
|
||||
Detour_Direct3DCreate9Ex.SetLibName( L"d3d9.dll"); // set also for wide character
|
||||
Detour_Direct3DCreate9Ex.SetFullLibName( buffer_w); // set also for wide character
|
||||
|
||||
GlobalDetour.AddEntry(&Detour_Direct3DCreate9);
|
||||
GlobalDetour.AddEntry(&Detour_Direct3DCreate9Ex);
|
||||
//char buffer[MAX_PATH];
|
||||
//if (gl_hOriginal_DX9_Dll==NULL)
|
||||
{
|
||||
GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d9.dll
|
||||
|
||||
// Append dll name
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d9.dll");
|
||||
|
||||
// try to load the system's d3d9.dll
|
||||
HANDLE gl_hOriginal_DX9_Dll = LoadLibrary(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
LoadOriginal_DX9_Dll();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExitDX9(void)
|
||||
{
|
||||
// Release the system's d3d9.dll
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
if (gl_hOriginal_DX9_Dll!=NULL)
|
||||
{
|
||||
FreeLibrary(gl_hOriginal_DX9_Dll);
|
||||
gl_hOriginal_DX9_Dll = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
/*
|
||||
* We do not inject, the game loads this dll by itself thus we must include the Direct3DCreate9 function
|
||||
*/
|
||||
void LoadOriginal_DX9_Dll(void)
|
||||
{
|
||||
char buffer[MAX_PATH];
|
||||
if (gl_hOriginal_DX9_Dll==NULL)
|
||||
{
|
||||
GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d9.dll
|
||||
|
||||
// Append dll name
|
||||
strcat_s( buffer, MAX_PATH,"\\d3d9.dll");
|
||||
|
||||
// try to load the system's d3d9.dll
|
||||
gl_hOriginal_DX9_Dll = LoadLibrary(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
Message("WINAPI Direct3DCreate9\n");
|
||||
|
||||
if (gl_hOriginal_DX9_Dll==NULL) LoadOriginal_DX9_Dll(); // looking for the "original d3d9.dll"
|
||||
if (gl_hOriginal_DX9_Dll==NULL) return (NULL);
|
||||
|
||||
// find original function in original d3d9.dll
|
||||
Direct3DCreate9_type D3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9");
|
||||
|
||||
|
||||
if (!D3DCreate9_fn)
|
||||
{
|
||||
Message("Direct3DCreate9: original function not found in dll\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//Create originale IDirect3D9 object
|
||||
IDirect3D9 *pIDirect3D9_orig = D3DCreate9_fn(SDKVersion);
|
||||
|
||||
//create our uMod_IDirect3D9 object
|
||||
uMod_IDirect3D9 *pIDirect3D9 = new uMod_IDirect3D9( pIDirect3D9_orig, gl_TextureServer);
|
||||
|
||||
// Return pointer to our object instead of "real one"
|
||||
return (pIDirect3D9);
|
||||
}
|
||||
|
||||
HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **ppD3D)
|
||||
{
|
||||
Message("WINAPI Direct3DCreate9Ex\n");
|
||||
|
||||
if (gl_hOriginal_DX9_Dll==NULL) LoadOriginal_DX9_Dll(); // looking for the "original d3d9.dll"
|
||||
if (gl_hOriginal_DX9_Dll==NULL) return (NULL);
|
||||
|
||||
// find original function in original d3d9.dll
|
||||
Direct3DCreate9Ex_type D3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9Ex");
|
||||
|
||||
|
||||
if (!D3DCreate9Ex_fn)
|
||||
{
|
||||
Message("Direct3DCreate9Ex: original function not found in dll\n");
|
||||
return (D3DERR_NOTAVAILABLE);
|
||||
}
|
||||
|
||||
|
||||
//Create originale IDirect3D9 object
|
||||
IDirect3D9Ex *pIDirect3D9Ex_orig;
|
||||
HRESULT ret = D3DCreate9Ex_fn( SDKVersion, &pIDirect3D9Ex_orig);
|
||||
if (ret!=S_OK) return (ret);
|
||||
|
||||
//create our uMod_IDirect3D9 object
|
||||
uMod_IDirect3D9Ex *pIDirect3D9Ex = new uMod_IDirect3D9Ex( pIDirect3D9Ex_orig, gl_TextureServer);
|
||||
|
||||
ppD3D = &pIDirect3D9Ex_orig; // Return pointer to our object instead of "real one"
|
||||
return (ret);
|
||||
}
|
||||
|
||||
typedef IDirect3D9 *(APIENTRY *Direct3DCreate9_type)(UINT);
|
||||
typedef HRESULT (APIENTRY *Direct3DCreate9Ex_type)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
|
||||
typedef int (WINAPI *D3DPERF_BeginEvent_type)( D3DCOLOR , LPCWSTR );
|
||||
int WINAPI D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName )
|
||||
{
|
||||
D3DPERF_BeginEvent_type fn = (D3DPERF_BeginEvent_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_BeginEvent");
|
||||
return fn( col, wszName);
|
||||
}
|
||||
|
||||
typedef int (WINAPI *D3DPERF_EndEvent_type)( void );
|
||||
int WINAPI D3DPERF_EndEvent( void )
|
||||
{
|
||||
D3DPERF_EndEvent_type fn = (D3DPERF_EndEvent_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_EndEvent");
|
||||
return fn();
|
||||
}
|
||||
|
||||
typedef void (WINAPI *D3DPERF_SetMarker_type)( D3DCOLOR , LPCWSTR );
|
||||
void WINAPI D3DPERF_SetMarker( D3DCOLOR col, LPCWSTR wszName )
|
||||
{
|
||||
D3DPERF_SetMarker_type fn = (D3DPERF_SetMarker_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetMarker");
|
||||
return fn( col, wszName);
|
||||
}
|
||||
|
||||
typedef void (WINAPI *D3DPERF_SetRegion_type)( D3DCOLOR, LPCWSTR );
|
||||
void WINAPI D3DPERF_SetRegion( D3DCOLOR col, LPCWSTR wszName )
|
||||
{
|
||||
D3DPERF_SetRegion_type fn = (D3DPERF_SetRegion_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetRegion");
|
||||
return fn( col, wszName);
|
||||
}
|
||||
|
||||
typedef BOOL (WINAPI *D3DPERF_QueryRepeatFrame_type)( void );
|
||||
BOOL WINAPI D3DPERF_QueryRepeatFrame( void )
|
||||
{
|
||||
D3DPERF_QueryRepeatFrame_type fn = (D3DPERF_QueryRepeatFrame_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_QueryRepeatFrame");
|
||||
return fn( );
|
||||
}
|
||||
|
||||
typedef void (WINAPI *D3DPERF_SetOptions_type)( DWORD );
|
||||
void WINAPI D3DPERF_SetOptions( DWORD dwOptions )
|
||||
{
|
||||
D3DPERF_SetOptions_type fn = (D3DPERF_SetOptions_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetOptions");
|
||||
return fn( dwOptions);
|
||||
}
|
||||
|
||||
typedef DWORD (WINAPI *D3DPERF_GetStatus_type)( void );
|
||||
DWORD WINAPI D3DPERF_GetStatus( void )
|
||||
{
|
||||
D3DPERF_GetStatus_type fn = (D3DPERF_GetStatus_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_GetStatus");
|
||||
return fn( );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
/*
|
||||
* We inject the dll into the game, thus we retour the original Direct3DCreate9 function to our MyDirect3DCreate9 function
|
||||
*/
|
||||
|
||||
IDirect3D9 *APIENTRY uMod_Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
Message("uMod_Direct3DCreate9: original %p, uMod %p\n", Detour_Direct3DCreate9.Function(), uMod_Direct3DCreate9);
|
||||
|
||||
IDirect3D9 *pIDirect3D9_orig = NULL;
|
||||
uMod_IDirect3D9 *pIDirect3D9 = NULL;
|
||||
|
||||
Detour_Direct3DCreate9.Retour();
|
||||
|
||||
pIDirect3D9_orig = Detour_Direct3DCreate9.Function()(SDKVersion); //creating the original IDirect3D9 object
|
||||
|
||||
if (pIDirect3D9_orig)
|
||||
{
|
||||
pIDirect3D9 = new uMod_IDirect3D9( pIDirect3D9_orig, gl_TextureServer); //creating our uMod_IDirect3D9 object
|
||||
}
|
||||
Detour_Direct3DCreate9.Detour();
|
||||
|
||||
return (pIDirect3D9); //return our object instead of the "real one"
|
||||
}
|
||||
|
||||
|
||||
HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D)
|
||||
{
|
||||
Message( "uMod_Direct3DCreate9Ex: original %p, uMod %p\n", Detour_Direct3DCreate9Ex.Function(), uMod_Direct3DCreate9Ex);
|
||||
|
||||
IDirect3D9Ex *pIDirect3D9Ex_orig = NULL;
|
||||
uMod_IDirect3D9Ex *pIDirect3D9Ex = NULL;
|
||||
HRESULT ret = D3DERR_NOTAVAILABLE;
|
||||
|
||||
Detour_Direct3DCreate9Ex.Retour();
|
||||
ret = Detour_Direct3DCreate9Ex.Function()(SDKVersion, &pIDirect3D9Ex_orig); //creating the original IDirect3D9 object
|
||||
|
||||
if (ret!=S_OK) return (ret);
|
||||
|
||||
if (pIDirect3D9Ex_orig)
|
||||
{
|
||||
pIDirect3D9Ex = new uMod_IDirect3D9Ex( pIDirect3D9Ex_orig, gl_TextureServer); //creating our uMod_IDirect3D9 object
|
||||
}
|
||||
Detour_Direct3DCreate9Ex.Detour();
|
||||
|
||||
ppD3D = (IDirect3D9Ex**) &pIDirect3D9Ex; //return our object instead of the "real one"
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_DX9_DLL_H_
|
||||
#define uMod_DX9_DLL_H_
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
void InitDX9();
|
||||
void ExitDX9();
|
||||
|
||||
#if INJECTION_METHOD==NO_INJECTION
|
||||
/**
|
||||
* Load the official d3d9.dll from the system path.
|
||||
*/
|
||||
void LoadOriginal_DX9_Dll(void);
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
/**
|
||||
* Direct3DCreate9 function must be exported if compiled for "No Injection"
|
||||
*/
|
||||
IDirect3D9 *APIENTRY uMod_Direct3DCreate9(UINT SDKVersion);
|
||||
|
||||
/**
|
||||
* Direct3DCreate9Ex function must be exported if compiled for "No Injection"
|
||||
*/
|
||||
HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Main.h"
|
||||
#include "uMod_IDirect3D9.h"
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
|
||||
#ifndef PRE_MESSAGE
|
||||
#define PRE_MESSAGE "uMod_IDirect3D9"
|
||||
#endif
|
||||
|
||||
uMod_IDirect3D9::uMod_IDirect3D9( IDirect3D9 *pOriginal, uMod_TextureServer* server)
|
||||
{
|
||||
Message( PRE_MESSAGE "::" PRE_MESSAGE "( %p, %p): %p\n", pOriginal, server, this);
|
||||
m_pIDirect3D9 = pOriginal;
|
||||
uMod_Server = server;
|
||||
}
|
||||
|
||||
uMod_IDirect3D9::~uMod_IDirect3D9(void)
|
||||
{
|
||||
Message( PRE_MESSAGE "::~" PRE_MESSAGE "(): %p\n", this);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
*ppvObj = NULL;
|
||||
|
||||
// call this to increase AddRef at original object
|
||||
// and to check if such an interface is there
|
||||
|
||||
HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj);
|
||||
|
||||
if (hRes == NOERROR) // if OK, send our "fake" address
|
||||
{
|
||||
*ppvObj = this;
|
||||
}
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
ULONG __stdcall uMod_IDirect3D9::AddRef(void)
|
||||
{
|
||||
return(m_pIDirect3D9->AddRef());
|
||||
}
|
||||
|
||||
ULONG __stdcall uMod_IDirect3D9::Release(void)
|
||||
{
|
||||
// call original routine
|
||||
ULONG count = m_pIDirect3D9->Release();
|
||||
|
||||
// in case no further Ref is there, the Original Object has deleted itself
|
||||
if (count == 0)
|
||||
{
|
||||
delete(this);
|
||||
}
|
||||
|
||||
return(count);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction)
|
||||
{
|
||||
return(m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction));
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9::GetAdapterCount(void)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterCount());
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterIdentifier(Adapter,Flags,pIdentifier));
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterModeCount(Adapter, Format));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode)
|
||||
{
|
||||
return(m_pIDirect3D9->EnumAdapterModes(Adapter,Format,Mode,pMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterDisplayMode(Adapter,pMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDeviceType(iAdapter,DevType,DisplayFormat,BackBufferFormat,bWindowed));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::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 __stdcall uMod_IDirect3D9::CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat)
|
||||
{
|
||||
return(m_pIDirect3D9->CheckDeviceFormatConversion(Adapter,DeviceType,SourceFormat,TargetFormat));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps)
|
||||
{
|
||||
return(m_pIDirect3D9->GetDeviceCaps(Adapter,DeviceType,pCaps));
|
||||
}
|
||||
|
||||
HMONITOR __stdcall uMod_IDirect3D9::GetAdapterMonitor(UINT Adapter)
|
||||
{
|
||||
return(m_pIDirect3D9->GetAdapterMonitor(Adapter));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface)
|
||||
{
|
||||
Message( PRE_MESSAGE "::CreateDevice(): %p\n", this);
|
||||
// we intercept this call and provide our own "fake" Device Object
|
||||
HRESULT hres = m_pIDirect3D9->CreateDevice( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
|
||||
|
||||
int count = 1;
|
||||
if (pPresentationParameters!=NULL) count = pPresentationParameters->BackBufferCount;
|
||||
uMod_IDirect3DDevice9 *pIDirect3DDevice9 = new uMod_IDirect3DDevice9(*ppReturnedDeviceInterface, uMod_Server, count);
|
||||
|
||||
// store our pointer (the fake one) for returning it to the calling program
|
||||
*ppReturnedDeviceInterface = pIDirect3DDevice9;
|
||||
|
||||
return(hres);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Michael Koch
|
||||
* (proxydll_9.zip)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3D9_H_
|
||||
#define uMod_IDirect3D9_H_
|
||||
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include "..\uMod_DXMain\uMod_TextureServer.h"
|
||||
|
||||
class uMod_IDirect3D9 : public IDirect3D9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3D9(IDirect3D9 *pOriginal, uMod_TextureServer *server);
|
||||
virtual ~uMod_IDirect3D9(void);
|
||||
|
||||
// The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction);
|
||||
UINT __stdcall GetAdapterCount(void);
|
||||
HRESULT __stdcall GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) ;
|
||||
UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format);
|
||||
HRESULT __stdcall EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) ;
|
||||
HRESULT __stdcall CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) ;
|
||||
HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) ;
|
||||
HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) ;
|
||||
HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat);
|
||||
HRESULT __stdcall GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) ;
|
||||
HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) ;
|
||||
HRESULT __stdcall CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) ;
|
||||
|
||||
private:
|
||||
IDirect3D9 *m_pIDirect3D9;
|
||||
uMod_TextureServer* uMod_Server;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "uMod_IDirect3D9Ex.h"
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DDevice9Ex.h"
|
||||
|
||||
|
||||
|
||||
#define IDirect3D9 IDirect3D9Ex
|
||||
#define uMod_IDirect3D9 uMod_IDirect3D9Ex
|
||||
#define m_pIDirect3D9 m_pIDirect3D9Ex
|
||||
#define PRE_MESSAGE "uMod_IDirect3D9Ex"
|
||||
|
||||
#define uMod_IDirect3D9_H_
|
||||
|
||||
#include "uMod_IDirect3D9.cpp"
|
||||
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::CreateDeviceEx( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface)
|
||||
{
|
||||
Message( "uMod_IDirect3D9Ex::CreateDeviceEx: %p\n", this);
|
||||
// we intercept this call and provide our own "fake" Device Object
|
||||
HRESULT hres = m_pIDirect3D9Ex->CreateDeviceEx( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
|
||||
|
||||
int count = 1;
|
||||
if (pPresentationParameters!=NULL) count = pPresentationParameters->BackBufferCount;
|
||||
uMod_IDirect3DDevice9Ex *pIDirect3DDevice9Ex = new uMod_IDirect3DDevice9Ex(*ppReturnedDeviceInterface, uMod_Server, count);
|
||||
|
||||
// store our pointer (the fake one) for returning it to the calling program
|
||||
*ppReturnedDeviceInterface = pIDirect3DDevice9Ex;
|
||||
|
||||
return(hres);
|
||||
return (m_pIDirect3D9Ex->CreateDeviceEx( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::EnumAdapterModesEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX *pMode)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->EnumAdapterModesEx( Adapter, pFilter, Mode, pMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::GetAdapterDisplayModeEx( UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->GetAdapterDisplayModeEx( Adapter, pMode, pRotation));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3D9Ex::GetAdapterLUID( UINT Adapter, LUID *pLUID)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->GetAdapterLUID( Adapter, pLUID));
|
||||
}
|
||||
|
||||
UINT __stdcall uMod_IDirect3D9Ex::GetAdapterModeCountEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter)
|
||||
{
|
||||
return (m_pIDirect3D9Ex->GetAdapterModeCountEx( Adapter, pFilter));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Michael Koch
|
||||
* (proxydll_9.zip)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3D9Ex_H_
|
||||
#define uMod_IDirect3D9Ex_H_
|
||||
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include "..\uMod_DXMain\uMod_TextureServer.h"
|
||||
|
||||
|
||||
class uMod_IDirect3D9Ex : public IDirect3D9Ex
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3D9Ex( IDirect3D9Ex *pOriginal, uMod_TextureServer *server);
|
||||
virtual ~uMod_IDirect3D9Ex(void);
|
||||
|
||||
// The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction);
|
||||
UINT __stdcall GetAdapterCount(void);
|
||||
HRESULT __stdcall GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier) ;
|
||||
UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format);
|
||||
HRESULT __stdcall EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode) ;
|
||||
HRESULT __stdcall CheckDeviceType(UINT iAdapter,D3DDEVTYPE DevType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) ;
|
||||
HRESULT __stdcall CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) ;
|
||||
HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) ;
|
||||
HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) ;
|
||||
HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat);
|
||||
HRESULT __stdcall GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) ;
|
||||
HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) ;
|
||||
HRESULT __stdcall CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) ;
|
||||
|
||||
HRESULT __stdcall CreateDeviceEx( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface);
|
||||
HRESULT __stdcall EnumAdapterModesEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX *pMode);
|
||||
HRESULT __stdcall GetAdapterDisplayModeEx( UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
|
||||
HRESULT __stdcall GetAdapterLUID( UINT Adapter, LUID *pLUID);
|
||||
UINT __stdcall GetAdapterModeCountEx( UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter);
|
||||
|
||||
|
||||
private:
|
||||
IDirect3D9Ex *m_pIDirect3D9Ex;
|
||||
uMod_TextureServer* uMod_Server;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* some function (e.g. AddReff()) are presumed to work on the texture object which belong to them
|
||||
* if this texture was switched, we must redirect this calls to the CrossRef_D3Dtex texture object
|
||||
*/
|
||||
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "../uMod_DXMain/uMod_TextureFunction.h"
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
#include "uMod_IDirect3DSurface9.h"
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid==IID_IDirect3D9)
|
||||
{
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return (0x01000002L);
|
||||
}
|
||||
HRESULT hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==m_D3Dtex) *ppvObj=this;
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DCubeTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) return (1); //bug, this case should never happen
|
||||
return (m_D3Dtex->AddRef());
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DCubeTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::Release(): %p\n", this);
|
||||
|
||||
void *cpy;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE)
|
||||
{
|
||||
UnswitchTextures( this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else
|
||||
{
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
|
||||
if (count==0) //if this texture is released, we clean up
|
||||
{
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
((uMod_IDirect3DDevice9*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
else
|
||||
{
|
||||
((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
|
||||
delete(this);
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
|
||||
{
|
||||
return (m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
|
||||
{
|
||||
return (m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
return (m_D3Dtex->FreePrivateData(refguid));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return (m_D3Dtex->SetPriority(PriorityNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetPriority()
|
||||
{
|
||||
return (m_D3Dtex->GetPriority());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DCubeTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DCubeTexture9::GetType()
|
||||
{
|
||||
return (m_D3Dtex->GetType());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return (m_D3Dtex->SetLOD(LODNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetLOD()
|
||||
{
|
||||
return (m_D3Dtex->GetLOD());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DCubeTexture9::GetLevelCount()
|
||||
{
|
||||
return (m_D3Dtex->GetLevelCount());
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return (m_D3Dtex->SetAutoGenFilterType(FilterType));
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DCubeTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return (m_D3Dtex->GetAutoGenFilterType());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DCubeTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::AddDirtyRect(D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect)
|
||||
{
|
||||
return (m_D3Dtex->AddDirtyRect( FaceType, pDirtyRect));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc)
|
||||
{
|
||||
return (m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::GetCubeMapSurface(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface)
|
||||
{
|
||||
Message( "uMod_IDirect3DCubeTexture9::GetCubeMapSurface( %d, %u, %p): %p\n", FaceType, Level, *ppCubeMapSurface, this);
|
||||
IDirect3DSurface9* pSurf;
|
||||
uMod_IDirect3DSurface9* puMod_Surf;
|
||||
HRESULT ret = (m_D3Dtex->GetCubeMapSurface( FaceType, Level, &pSurf));
|
||||
|
||||
if (SUCCEEDED(ret))
|
||||
{
|
||||
puMod_Surf = new uMod_IDirect3DSurface9( pSurf, NULL, this, m_D3Ddev);
|
||||
*ppCubeMapSurface = puMod_Surf;
|
||||
}
|
||||
else *ppCubeMapSurface = pSurf;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::LockRect( D3DCUBEMAP_FACES FaceType, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
|
||||
{
|
||||
return (m_D3Dtex->LockRect( FaceType, Level, pLockedRect, pRect, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DCubeTexture9::UnlockRect( D3DCUBEMAP_FACES FaceType, UINT Level)
|
||||
{
|
||||
Dirty = 1;
|
||||
return (m_D3Dtex->UnlockRect( FaceType, Level));
|
||||
}
|
||||
|
||||
|
||||
int uMod_IDirect3DCubeTexture9::ComputetHash( bool compute_crc)
|
||||
{
|
||||
if (FAKE) return (RETURN_BAD_ARGUMENT);
|
||||
IDirect3DCubeTexture9 *pTexture = m_D3Dtex;
|
||||
|
||||
|
||||
IDirect3DSurface9 *surface = NULL;
|
||||
if (compute_crc) InitCRC32(CRC32);
|
||||
InitCRC64(CRC64);
|
||||
|
||||
void *cpy;
|
||||
uMod_IDirect3DDevice9 *dev = NULL;
|
||||
uMod_IDirect3DDevice9Ex *devEx = NULL;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) dev = ((uMod_IDirect3DDevice9*)m_D3Ddev);
|
||||
else devEx = ((uMod_IDirect3DDevice9Ex*) m_D3Ddev);
|
||||
|
||||
for (int site = 0; site<6; site++)
|
||||
{
|
||||
if (pTexture->GetCubeMapSurface( (D3DCUBEMAP_FACES) site, 0, &surface)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DCubeTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (dev!=NULL) ret = dev->ComputeCRC( CRC64, CRC32, surface, compute_crc);
|
||||
else ret = devEx->ComputeCRC( CRC64, CRC32, surface, compute_crc);
|
||||
surface->Release();
|
||||
if (ret!=RETURN_OK) return (ret);
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Matthew L (Azorbix)
|
||||
* (Direct3D StarterKit v3.0)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DCubeTexture9_H
|
||||
#define uMod_IDirect3DCubeTexture9_H
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Defines.h"
|
||||
|
||||
|
||||
class uMod_IDirect3DCubeTexture9 : public IDirect3DCubeTexture9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DCubeTexture9(IDirect3DCubeTexture9 **ppTex, IDirect3DDevice9 *pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = NULL; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DCubeTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
Reference = -1; //need for fast deleting
|
||||
CRC64 = 0u;
|
||||
CRC32 = 0u;
|
||||
FAKE = false;
|
||||
Dirty = 1;
|
||||
}
|
||||
|
||||
IDirect3DCubeTexture9 *m_D3Dtex; //!< pointer to the real IDirect3DCubeTexture9 object
|
||||
uMod_IDirect3DCubeTexture9 *CrossRef_D3Dtex; //!< cross reference from the fake texture to the game texture and vice versa
|
||||
IDirect3DDevice9 *m_D3Ddev; //!< pointer to the device
|
||||
int Reference; //!< Index in the vector (needed for a fast delete).
|
||||
DWORD64 CRC64; //!< computed hash value for this game texture.
|
||||
DWORD32 CRC32; //!< computed crc32 value for this game texture.
|
||||
bool FAKE; //!< True if this texture is was loaded by uMod (fake texture)
|
||||
unsigned char Dirty;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface) (REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)();
|
||||
STDMETHOD_(ULONG,Release)();
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid,void* pData,DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)();
|
||||
STDMETHOD_(void, PreLoad)();
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew);
|
||||
STDMETHOD_(DWORD, GetLOD)();
|
||||
STDMETHOD_(DWORD, GetLevelCount)();
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType);
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)();
|
||||
STDMETHOD_(void, GenerateMipSubLevels)();
|
||||
|
||||
STDMETHOD(AddDirtyRect)(D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect);
|
||||
STDMETHOD(GetLevelDesc)(UINT Level, D3DSURFACE_DESC *pDesc);
|
||||
STDMETHOD(GetCubeMapSurface)(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface);
|
||||
STDMETHOD(LockRect)( D3DCUBEMAP_FACES FaceType, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
|
||||
STDMETHOD(UnlockRect)(D3DCUBEMAP_FACES FaceType, UINT Level);
|
||||
|
||||
|
||||
int ComputetHash( bool compute_crc);
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Michael Koch
|
||||
* (proxydll_9.zip)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DDevice9_H_
|
||||
#define uMod_IDirect3DDevice9_H_
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Main.h"
|
||||
#include "uMod_TextureClient_DX9.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
#include "uMod_IDirect3DSurface9.h"
|
||||
|
||||
class uMod_TextureClient_DX9;
|
||||
|
||||
class uMod_IDirect3DDevice9 : public IDirect3DDevice9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DDevice9(IDirect3DDevice9* pOriginal, uMod_TextureServer* server, int back_buffer_count);
|
||||
virtual ~uMod_IDirect3DDevice9(void);
|
||||
|
||||
// START: The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface (REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall TestCooperativeLevel(void);
|
||||
UINT __stdcall GetAvailableTextureMem(void);
|
||||
HRESULT __stdcall EvictManagedResources(void);
|
||||
HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9);
|
||||
HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps);
|
||||
HRESULT __stdcall GetDisplayMode(UINT iSwapChain,D3DDISPLAYMODE* pMode);
|
||||
HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters);
|
||||
HRESULT __stdcall SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap);
|
||||
void __stdcall SetCursorPosition(int X,int Y,DWORD Flags);
|
||||
BOOL __stdcall ShowCursor(BOOL bShow);
|
||||
HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) ;
|
||||
HRESULT __stdcall GetSwapChain(UINT iSwapChain,IDirect3DSwapChain9** pSwapChain);
|
||||
UINT __stdcall GetNumberOfSwapChains(void);
|
||||
HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
|
||||
HRESULT __stdcall GetBackBuffer(UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer);
|
||||
HRESULT __stdcall GetRasterStatus(UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus);
|
||||
HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs);
|
||||
void __stdcall SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp);
|
||||
void __stdcall GetGammaRamp(UINT iSwapChain,D3DGAMMARAMP* pRamp);
|
||||
HRESULT __stdcall CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint);
|
||||
HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture);
|
||||
HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall GetFrontBufferData(UINT iSwapChain,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter);
|
||||
HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color);
|
||||
HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget);
|
||||
HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget);
|
||||
HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil);
|
||||
HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface);
|
||||
HRESULT __stdcall BeginScene(void);
|
||||
HRESULT __stdcall EndScene(void);
|
||||
HRESULT __stdcall Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil);
|
||||
HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall SetLight(DWORD Index,CONST D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall GetLight(DWORD Index,D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall LightEnable(DWORD Index,BOOL Enable);
|
||||
HRESULT __stdcall GetLightEnable(DWORD Index,BOOL* pEnable);
|
||||
HRESULT __stdcall SetClipPlane(DWORD Index,CONST float* pPlane);
|
||||
HRESULT __stdcall GetClipPlane(DWORD Index,float* pPlane);
|
||||
HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State,DWORD Value);
|
||||
HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue);
|
||||
HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall BeginStateBlock(void);
|
||||
HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppTexture);
|
||||
HRESULT __stdcall SetTexture(DWORD Stage,IDirect3DBaseTexture9* pTexture);
|
||||
HRESULT __stdcall GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall GetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall ValidateDevice(DWORD* pNumPasses);
|
||||
HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber);
|
||||
HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber);
|
||||
HRESULT __stdcall SetScissorRect(CONST RECT* pRect);
|
||||
HRESULT __stdcall GetScissorRect( RECT* pRect);
|
||||
HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware);
|
||||
BOOL __stdcall GetSoftwareVertexProcessing(void);
|
||||
HRESULT __stdcall SetNPatchMode(float nSegments);
|
||||
float __stdcall GetNPatchMode(void);
|
||||
HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount);
|
||||
HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
|
||||
HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags);
|
||||
HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl);
|
||||
HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetFVF(DWORD FVF);
|
||||
HRESULT __stdcall GetFVF(DWORD* pFVF);
|
||||
HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader);
|
||||
HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride);
|
||||
HRESULT __stdcall GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* OffsetInBytes,UINT* pStride);
|
||||
HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber,UINT Divider);
|
||||
HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber,UINT* Divider);
|
||||
HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData);
|
||||
HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData);
|
||||
HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader);
|
||||
HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo);
|
||||
HRESULT __stdcall DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo);
|
||||
HRESULT __stdcall DeletePatch(UINT Handle);
|
||||
HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery);
|
||||
// END: The original DX9 function definitions
|
||||
|
||||
|
||||
|
||||
uMod_TextureClient_DX9* GetuMod_Client(void) {return (uMod_Client);}
|
||||
|
||||
uMod_IDirect3DTexture9* GetSingleTexture(void) {return (SingleTexture);}
|
||||
uMod_IDirect3DVolumeTexture9* GetSingleVolumeTexture(void) {return (SingleVolumeTexture);}
|
||||
uMod_IDirect3DCubeTexture9* GetSingleCubeTexture(void) {return (SingleCubeTexture);}
|
||||
|
||||
int ComputeCRC( DWORD64 &CRC64, DWORD32 &CRC32, IDirect3DSurface9 *surface, bool compute_crc);
|
||||
int CheckForChangeSurface(uMod_IDirect3DSurface9 *surface, bool render_target=false);
|
||||
|
||||
void SetNextTextureIsFake(bool val = true) {NextTextureIsFake=val;}
|
||||
|
||||
private:
|
||||
int CreateSingleTexture(void);
|
||||
IDirect3DDevice9* m_pIDirect3DDevice9;
|
||||
|
||||
int CounterSaveSingleTexture;
|
||||
uMod_IDirect3DTexture9* SingleTexture;
|
||||
uMod_IDirect3DVolumeTexture9* SingleVolumeTexture;
|
||||
uMod_IDirect3DCubeTexture9* SingleCubeTexture;
|
||||
char SingleTextureMod;
|
||||
|
||||
D3DCOLOR TextureColour;
|
||||
ID3DXFont *OSD_Font;
|
||||
ID3DXSprite *pSprite;
|
||||
|
||||
int BackBufferCount;
|
||||
bool NormalRendering;
|
||||
|
||||
int uMod_Reference;
|
||||
|
||||
bool NextTextureIsFake;
|
||||
|
||||
uMod_TextureServer* uMod_Server;
|
||||
uMod_TextureClient_DX9* uMod_Client;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Main.h"
|
||||
#include "uMod_IDirect3DDevice9Ex.h"
|
||||
#include "uMod_IDirect3DSurface9.h"
|
||||
|
||||
#define uMod_IDirect3DDevice9 uMod_IDirect3DDevice9Ex
|
||||
#define IDirect3DDevice9 IDirect3DDevice9Ex
|
||||
#define m_pIDirect3DDevice9 m_pIDirect3DDevice9Ex
|
||||
|
||||
#define RETURN_QueryInterface 0x01000001L
|
||||
#define PRE_MESSAGE "uMod_IDirect3DDevice9Ex"
|
||||
#define DEF_DX_VERSION VERSION_DX9EX
|
||||
|
||||
#define uMod_IDirect3DDevice9_H_
|
||||
|
||||
#include "uMod_IDirect3DDevice9.cpp"
|
||||
|
||||
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CheckDeviceState( HWND hWindow)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CheckDeviceState( hWindow));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CheckResourceResidency( IDirect3DResource9 **ppResourceArray, UINT32 NumResources)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CheckResourceResidency( ppResourceArray, NumResources));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::ComposeRects( IDirect3DSurface9 *pSource, IDirect3DSurface9 *pDestination, IDirect3DVertexBuffer9 *pSrcRectDescriptors, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescriptors, D3DCOMPOSERECTSOP Operation, INT XOffset, INT YOffset)
|
||||
{
|
||||
Message( PRE_MESSAGE "::ComposeRects( %p, %p, %p, %u, %p, ...): %p\n", pSource, pDestination, pSrcRectDescriptors, NumRects, this);
|
||||
IDirect3DSurface9* cpy;
|
||||
uMod_IDirect3DSurface9 *DestSurf=NULL;
|
||||
if( pSource != NULL )
|
||||
{
|
||||
long int ret = pSource->QueryInterface( IID_IDirect3D9, (void**) &cpy);
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
pSource = ((uMod_IDirect3DSurface9*)pSource)->m_D3Dsurf;
|
||||
}
|
||||
}
|
||||
if( pDestination != NULL )
|
||||
{
|
||||
long int ret = pDestination->QueryInterface( IID_IDirect3D9, (void**) &cpy);
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
DestSurf = ((uMod_IDirect3DSurface9*)pDestination);
|
||||
pDestination = DestSurf->m_D3Dsurf;
|
||||
}
|
||||
}
|
||||
HRESULT ret = (m_pIDirect3DDevice9Ex->ComposeRects( pSource, pDestination, pSrcRectDescriptors, NumRects, pDstRectDescriptors, Operation, XOffset, YOffset));
|
||||
|
||||
CheckForChangeSurface(DestSurf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateDepthStencilSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CreateDepthStencilSurfaceEx( Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle, Usage));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateOffscreenPlainSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CreateOffscreenPlainSurfaceEx( Width, Height, Format, Pool, ppSurface, pSharedHandle, Usage));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::CreateRenderTargetEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->CreateRenderTargetEx( Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle, Usage));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetDisplayModeEx( UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->GetDisplayModeEx( iSwapChain, pMode, pRotation));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetGPUThreadPriority( INT *pPriority)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->GetGPUThreadPriority( pPriority));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::GetMaximumFrameLatency( UINT *pMaxLatency)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->GetMaximumFrameLatency( pMaxLatency));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::PresentEx( const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->PresentEx( pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::ResetEx( D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->ResetEx( pPresentationParameters, pFullscreenDisplayMode));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetConvolutionMonoKernel( UINT Width, UINT Height, float *RowWeights, float *ColumnWeights)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->SetConvolutionMonoKernel( Width, Height, RowWeights, ColumnWeights));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetGPUThreadPriority( INT pPriority)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->SetGPUThreadPriority( pPriority));
|
||||
}
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::SetMaximumFrameLatency( UINT pMaxLatency)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->SetMaximumFrameLatency( pMaxLatency));
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::TestCooperativeLevel()
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->TestCooperativeLevel());
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT __stdcall uMod_IDirect3DDevice9Ex::WaitForVBlank( UINT SwapChainIndex)
|
||||
{
|
||||
return(m_pIDirect3DDevice9Ex->WaitForVBlank( SwapChainIndex));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DDevice9Ex_H_
|
||||
#define uMod_IDirect3DDevice9Ex_H_
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Main.h"
|
||||
#include "uMod_TextureClient_DX9.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
#include "uMod_IDirect3DSurface9.h"
|
||||
|
||||
class uMod_TextureClient_DX9;
|
||||
|
||||
class uMod_IDirect3DDevice9Ex : public IDirect3DDevice9Ex
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DDevice9Ex( IDirect3DDevice9Ex* pOriginal, uMod_TextureServer* server, int back_buffer_count);
|
||||
virtual ~uMod_IDirect3DDevice9Ex(void);
|
||||
|
||||
// START: The original DX9 function definitions
|
||||
HRESULT __stdcall QueryInterface (REFIID riid, void** ppvObj);
|
||||
ULONG __stdcall AddRef(void);
|
||||
ULONG __stdcall Release(void);
|
||||
HRESULT __stdcall TestCooperativeLevel(void);
|
||||
UINT __stdcall GetAvailableTextureMem(void);
|
||||
HRESULT __stdcall EvictManagedResources(void);
|
||||
HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9);
|
||||
HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps);
|
||||
HRESULT __stdcall GetDisplayMode(UINT iSwapChain,D3DDISPLAYMODE* pMode);
|
||||
HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters);
|
||||
HRESULT __stdcall SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap);
|
||||
void __stdcall SetCursorPosition(int X,int Y,DWORD Flags);
|
||||
BOOL __stdcall ShowCursor(BOOL bShow);
|
||||
HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain) ;
|
||||
HRESULT __stdcall GetSwapChain(UINT iSwapChain,IDirect3DSwapChain9** pSwapChain);
|
||||
UINT __stdcall GetNumberOfSwapChains(void);
|
||||
HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
HRESULT __stdcall Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
|
||||
HRESULT __stdcall GetBackBuffer(UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer);
|
||||
HRESULT __stdcall GetRasterStatus(UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus);
|
||||
HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs);
|
||||
void __stdcall SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp);
|
||||
void __stdcall GetGammaRamp(UINT iSwapChain,D3DGAMMARAMP* pRamp);
|
||||
HRESULT __stdcall CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint);
|
||||
HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture);
|
||||
HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall GetFrontBufferData(UINT iSwapChain,IDirect3DSurface9* pDestSurface);
|
||||
HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter);
|
||||
HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color);
|
||||
HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle);
|
||||
HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget);
|
||||
HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget);
|
||||
HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil);
|
||||
HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface);
|
||||
HRESULT __stdcall BeginScene(void);
|
||||
HRESULT __stdcall EndScene(void);
|
||||
HRESULT __stdcall Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil);
|
||||
HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
|
||||
HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport);
|
||||
HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial);
|
||||
HRESULT __stdcall SetLight(DWORD Index,CONST D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall GetLight(DWORD Index,D3DLIGHT9* pLight);
|
||||
HRESULT __stdcall LightEnable(DWORD Index,BOOL Enable);
|
||||
HRESULT __stdcall GetLightEnable(DWORD Index,BOOL* pEnable);
|
||||
HRESULT __stdcall SetClipPlane(DWORD Index,CONST float* pPlane);
|
||||
HRESULT __stdcall GetClipPlane(DWORD Index,float* pPlane);
|
||||
HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State,DWORD Value);
|
||||
HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue);
|
||||
HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall BeginStateBlock(void);
|
||||
HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB);
|
||||
HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus);
|
||||
HRESULT __stdcall GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppTexture);
|
||||
HRESULT __stdcall SetTexture(DWORD Stage,IDirect3DBaseTexture9* pTexture);
|
||||
HRESULT __stdcall GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall GetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue);
|
||||
HRESULT __stdcall SetSamplerState(DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value);
|
||||
HRESULT __stdcall ValidateDevice(DWORD* pNumPasses);
|
||||
HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries);
|
||||
HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber);
|
||||
HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber);
|
||||
HRESULT __stdcall SetScissorRect(CONST RECT* pRect);
|
||||
HRESULT __stdcall GetScissorRect( RECT* pRect);
|
||||
HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware);
|
||||
BOOL __stdcall GetSoftwareVertexProcessing(void);
|
||||
HRESULT __stdcall SetNPatchMode(float nSegments);
|
||||
float __stdcall GetNPatchMode(void);
|
||||
HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount);
|
||||
HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
|
||||
HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
|
||||
HRESULT __stdcall ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags);
|
||||
HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl);
|
||||
HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl);
|
||||
HRESULT __stdcall SetFVF(DWORD FVF);
|
||||
HRESULT __stdcall GetFVF(DWORD* pFVF);
|
||||
HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader);
|
||||
HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader);
|
||||
HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride);
|
||||
HRESULT __stdcall GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* OffsetInBytes,UINT* pStride);
|
||||
HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber,UINT Divider);
|
||||
HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber,UINT* Divider);
|
||||
HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData);
|
||||
HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData);
|
||||
HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader);
|
||||
HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader);
|
||||
HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister,float* pConstantData,UINT Vector4fCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister,int* pConstantData,UINT Vector4iCount);
|
||||
HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister,BOOL* pConstantData,UINT BoolCount);
|
||||
HRESULT __stdcall DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo);
|
||||
HRESULT __stdcall DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo);
|
||||
HRESULT __stdcall DeletePatch(UINT Handle);
|
||||
HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery);
|
||||
|
||||
|
||||
|
||||
HRESULT __stdcall CheckDeviceState( HWND hWindow);
|
||||
HRESULT __stdcall CheckResourceResidency( IDirect3DResource9 **pResourceArray, UINT32 NumResources);
|
||||
HRESULT __stdcall ComposeRects( IDirect3DSurface9 *pSource, IDirect3DSurface9 *pDestination, IDirect3DVertexBuffer9 *pSrcRectDescriptors, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescriptors, D3DCOMPOSERECTSOP Operation, INT XOffset, INT YOffset);
|
||||
HRESULT __stdcall CreateDepthStencilSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
|
||||
HRESULT __stdcall CreateOffscreenPlainSurfaceEx( UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
|
||||
HRESULT __stdcall CreateRenderTargetEx( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
|
||||
HRESULT __stdcall GetDisplayModeEx( UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
|
||||
HRESULT __stdcall GetGPUThreadPriority( INT *pPriority);
|
||||
HRESULT __stdcall GetMaximumFrameLatency( UINT *pMaxLatency);
|
||||
HRESULT __stdcall PresentEx( const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags);
|
||||
HRESULT __stdcall ResetEx( D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode);
|
||||
HRESULT __stdcall SetConvolutionMonoKernel( UINT Width, UINT Height, float *RowWeights, float *ColumnWeights);
|
||||
HRESULT __stdcall SetGPUThreadPriority( INT pPriority);
|
||||
HRESULT __stdcall SetMaximumFrameLatency( UINT pMaxLatency);
|
||||
//HRESULT __stdcall TestCooperativeLevel();
|
||||
HRESULT __stdcall WaitForVBlank( UINT SwapChainIndex);
|
||||
|
||||
|
||||
// END: The original DX9 function definitions
|
||||
|
||||
|
||||
uMod_TextureClient_DX9* GetuMod_Client(void) {return (uMod_Client);}
|
||||
|
||||
uMod_IDirect3DTexture9* GetSingleTexture(void) {return (SingleTexture);}
|
||||
uMod_IDirect3DVolumeTexture9* GetSingleVolumeTexture(void) {return (SingleVolumeTexture);}
|
||||
uMod_IDirect3DCubeTexture9* GetSingleCubeTexture(void) {return (SingleCubeTexture);}
|
||||
|
||||
int ComputeCRC( DWORD64 &CRC64, DWORD32 &CRC32, IDirect3DSurface9 *surface, bool compute_crc);
|
||||
int CheckForChangeSurface(uMod_IDirect3DSurface9 *surface, bool render_target=false);
|
||||
|
||||
void SetNextTextureIsFake(bool val = true) {NextTextureIsFake=val;}
|
||||
|
||||
|
||||
private:
|
||||
int CreateSingleTexture(void);
|
||||
IDirect3DDevice9Ex* m_pIDirect3DDevice9Ex;
|
||||
|
||||
int CounterSaveSingleTexture;
|
||||
uMod_IDirect3DTexture9* SingleTexture;
|
||||
uMod_IDirect3DVolumeTexture9* SingleVolumeTexture;
|
||||
uMod_IDirect3DCubeTexture9* SingleCubeTexture;
|
||||
char SingleTextureMod;
|
||||
|
||||
D3DCOLOR TextureColour;
|
||||
ID3DXFont *OSD_Font;
|
||||
ID3DXSprite *pSprite;
|
||||
|
||||
int BackBufferCount;
|
||||
bool NormalRendering;
|
||||
|
||||
int uMod_Reference;
|
||||
|
||||
bool NextTextureIsFake;
|
||||
|
||||
uMod_TextureServer* uMod_Server;
|
||||
uMod_TextureClient_DX9* uMod_Client;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DSurface9.h"
|
||||
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
//Message( "uMod_IDirect3DSurface9::uMod_IDirect3DSurface9(): %p\n", this);
|
||||
if (riid==IID_IDirect3D9)
|
||||
{
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
|
||||
*ppvObj = this;
|
||||
return (0x01000000L);
|
||||
}
|
||||
HRESULT hRes = m_D3Dsurf->QueryInterface(riid, ppvObj);
|
||||
|
||||
// return this object
|
||||
if (*ppvObj==m_D3Dsurf)
|
||||
{
|
||||
RefCounter++;
|
||||
*ppvObj=this;
|
||||
}
|
||||
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
ULONG uMod_IDirect3DSurface9::AddRef()
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::AddRef(): %p\n", this);
|
||||
RefCounter++;
|
||||
return m_D3Dsurf->AddRef();
|
||||
}
|
||||
|
||||
ULONG uMod_IDirect3DSurface9::Release()
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::Release(): %p\n", this);
|
||||
// this object might be created by uMod_IDirect3DTexture9::GetSurfaceLevel
|
||||
// thus the RefCounter might be zero although m_D3Dsurf->Release() does not delete
|
||||
// the m_D3Dsurf object
|
||||
ULONG counter = m_D3Dsurf->Release();
|
||||
if (--RefCounter==0) delete this;
|
||||
return counter;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::GetDevice( IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
//Message( "uMod_IDirect3DSurface9::GetDevice(): %p\n", this);
|
||||
*ppDevice = m_D3Ddev;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::SetPrivateData( REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::SetPrivateData(): %p\n", this);
|
||||
return m_D3Dsurf->SetPrivateData( refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::GetPrivateData( REFGUID refguid,void* pData,DWORD* pSizeOfData)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::GetPrivateData(): %p\n", this);
|
||||
return m_D3Dsurf->GetPrivateData( refguid, pData, pSizeOfData);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::FreePrivateData( REFGUID refguid)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::FreePrivateData(): %p\n", this);
|
||||
return m_D3Dsurf->FreePrivateData( refguid);
|
||||
}
|
||||
|
||||
DWORD uMod_IDirect3DSurface9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
//Message( "uMod_IDirect3DSurface9::SetPriority(): %p\n", this);
|
||||
return m_D3Dsurf->SetPriority(PriorityNew);
|
||||
}
|
||||
DWORD uMod_IDirect3DSurface9::GetPriority()
|
||||
{
|
||||
//Message( "uMod_IDirect3DSurface9::GetPriority(): %p\n", this);
|
||||
return m_D3Dsurf->GetPriority();
|
||||
}
|
||||
|
||||
void uMod_IDirect3DSurface9::PreLoad()
|
||||
{
|
||||
//Message( "uMod_IDirect3DSurface9::PreLoad(): %p\n", this);
|
||||
return m_D3Dsurf->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE uMod_IDirect3DSurface9::GetType()
|
||||
{
|
||||
//Message( "uMod_IDirect3DSurface9::GetType(): %p\n", this);
|
||||
return m_D3Dsurf->GetType();
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::GetContainer( REFIID riid,void** ppContainer)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::GetContainer(): %p\n", this);
|
||||
HRESULT ret = m_D3Dsurf->GetContainer( riid, ppContainer);
|
||||
|
||||
//return the uMod_IDirect3DTexture9 object
|
||||
if (m_D3DTex!=NULL && *ppContainer==m_D3DTex->m_D3Dtex)
|
||||
{
|
||||
RefCounter++;
|
||||
*ppContainer = m_D3DTex;
|
||||
}
|
||||
if (m_D3DCubeTex!=NULL && *ppContainer==m_D3DCubeTex->m_D3Dtex)
|
||||
{
|
||||
RefCounter++;
|
||||
*ppContainer = m_D3DCubeTex;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::GetDesc( D3DSURFACE_DESC *pDesc)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::GetDesc(): %p\n", this);
|
||||
return m_D3Dsurf->GetDesc( pDesc);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::LockRect( D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::LockRect(): %p\n", this);
|
||||
return m_D3Dsurf->LockRect( pLockedRect, pRect, Flags);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::UnlockRect()
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::UnlockRect(): %p\n", this);
|
||||
HRESULT ret = m_D3Dsurf->UnlockRect();
|
||||
|
||||
if (m_D3DTex!=NULL && !m_D3DTex->FAKE)
|
||||
m_D3DTex->Dirty=1;
|
||||
else if (m_D3DCubeTex!=NULL && !m_D3DCubeTex->FAKE)
|
||||
m_D3DCubeTex->Dirty = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::GetDC( HDC *phdc)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::GetDC(): %p\n", this);
|
||||
return m_D3Dsurf->GetDC( phdc);
|
||||
}
|
||||
|
||||
HRESULT uMod_IDirect3DSurface9::ReleaseDC( HDC hdc)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::ReleaseDC(): %p\n", this);
|
||||
HRESULT ret = m_D3Dsurf->ReleaseDC( hdc);
|
||||
|
||||
if (m_D3DTex!=NULL && !m_D3DTex->FAKE)
|
||||
m_D3DTex->Dirty=1;
|
||||
else if (m_D3DCubeTex!=NULL && !m_D3DCubeTex->FAKE)
|
||||
m_D3DCubeTex->Dirty = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UMOD_IDIRECT3DSURFACE9_H_
|
||||
#define UMOD_IDIRECT3DSURFACE9_H_
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Defines.h"
|
||||
|
||||
|
||||
|
||||
class uMod_IDirect3DSurface9 : public IDirect3DSurface9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DSurface9(IDirect3DSurface9 *pSurf, uMod_IDirect3DTexture9 *pTex, uMod_IDirect3DCubeTexture9 *pCubeTex, IDirect3DDevice9 *pIDirect3DDevice9)
|
||||
{
|
||||
Message( "uMod_IDirect3DSurface9::uMod_IDirect3DSurface9(%p, %p, %p %p): %p\n", pSurf, pTex, pCubeTex, pIDirect3DDevice9, this);
|
||||
m_D3Dsurf = pSurf;
|
||||
m_D3DTex = pTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3DCubeTex = pCubeTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
RefCounter = 1;
|
||||
}
|
||||
|
||||
IDirect3DSurface9 *m_D3Dsurf; //!< pointer to the real IDirect3DSurface9 object
|
||||
uMod_IDirect3DTexture9 *m_D3DTex; //!< pointer to the parent uMod_IDirect3DTexture9 object
|
||||
uMod_IDirect3DCubeTexture9 *m_D3DCubeTex; //!< pointer to the parent uMod_IDirect3DTexture9 object
|
||||
IDirect3DDevice9 *m_D3Ddev; //!< pointer to the device
|
||||
int RefCounter;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface) (REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)();
|
||||
STDMETHOD_(ULONG,Release)();
|
||||
|
||||
STDMETHOD(GetDevice)( IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)( REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)( REFGUID refguid,void* pData,DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)( REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)();
|
||||
STDMETHOD_(void, PreLoad)() ;
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||
STDMETHOD(GetContainer)( REFIID riid,void** ppContainer);
|
||||
STDMETHOD(GetDesc)( D3DSURFACE_DESC *pDesc);
|
||||
STDMETHOD(LockRect)( D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
|
||||
STDMETHOD(UnlockRect)();
|
||||
STDMETHOD(GetDC)( HDC *phdc);
|
||||
STDMETHOD(ReleaseDC)( HDC hdc);
|
||||
};
|
||||
|
||||
|
||||
#endif /* UMOD_IDIRECT3DSURFACE9_H_ */
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* some function (e.g. AddReff()) are presumed to work on the texture object which belong to them
|
||||
* if this texture was switched, we must redirect this calls to the CrossRef_D3Dtex texture object
|
||||
*/
|
||||
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "../uMod_DXMain/uMod_TextureFunction.h"
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DSurface9.h"
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid==IID_IDirect3D9)
|
||||
{
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return (0x01000000L);
|
||||
}
|
||||
HRESULT hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==m_D3Dtex) *ppvObj=this;
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) return (1); //bug, this case should never happen
|
||||
return (m_D3Dtex->AddRef());
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DTexture9::Release()
|
||||
{
|
||||
//Message("uMod_IDirect3DTexture9::Release(): %p\n", this);
|
||||
|
||||
void *cpy;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE)
|
||||
{
|
||||
UnswitchTextures( this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else
|
||||
{
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
|
||||
if (count==0) //if this texture is released, we clean up
|
||||
{
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
((uMod_IDirect3DDevice9*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
else
|
||||
{
|
||||
((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
|
||||
delete(this);
|
||||
}
|
||||
|
||||
//Message("uMod_IDirect3DTexture9::Release() end: %p\n", this);
|
||||
return (count);
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
|
||||
{
|
||||
return (m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
|
||||
{
|
||||
return (m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
return (m_D3Dtex->FreePrivateData(refguid));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return (m_D3Dtex->SetPriority(PriorityNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetPriority()
|
||||
{
|
||||
return (m_D3Dtex->GetPriority());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DTexture9::GetType()
|
||||
{
|
||||
return (m_D3Dtex->GetType());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return (m_D3Dtex->SetLOD(LODNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetLOD()
|
||||
{
|
||||
return (m_D3Dtex->GetLOD());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DTexture9::GetLevelCount()
|
||||
{
|
||||
return (m_D3Dtex->GetLevelCount());
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return (m_D3Dtex->SetAutoGenFilterType(FilterType));
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return (m_D3Dtex->GetAutoGenFilterType());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc)
|
||||
{
|
||||
return (m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::GetSurfaceLevel(UINT Level, IDirect3DSurface9** ppSurfaceLevel)
|
||||
{
|
||||
Message( "uMod_IDirect3DTexture9::GetSurfaceLevel( %u, %p): %p\n", Level, *ppSurfaceLevel, this);
|
||||
IDirect3DSurface9* pSurf;
|
||||
uMod_IDirect3DSurface9* puMod_Surf;
|
||||
HRESULT ret = (m_D3Dtex->GetSurfaceLevel(Level, &pSurf));
|
||||
|
||||
if (SUCCEEDED(ret))
|
||||
{
|
||||
puMod_Surf = new uMod_IDirect3DSurface9( pSurf, this, NULL, m_D3Ddev);
|
||||
*ppSurfaceLevel = puMod_Surf;
|
||||
}
|
||||
else *ppSurfaceLevel = pSurf;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
|
||||
{
|
||||
return (m_D3Dtex->LockRect(Level, pLockedRect, pRect, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::UnlockRect(UINT Level)
|
||||
{
|
||||
Dirty =1;
|
||||
return (m_D3Dtex->UnlockRect(Level));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DTexture9::AddDirtyRect(CONST RECT* pDirtyRect)
|
||||
{
|
||||
return (m_D3Dtex->AddDirtyRect(pDirtyRect));
|
||||
}
|
||||
|
||||
|
||||
int uMod_IDirect3DTexture9::ComputetHash( bool compute_crc)
|
||||
{
|
||||
if (FAKE) return (RETURN_BAD_ARGUMENT);
|
||||
IDirect3DTexture9 *pTexture = m_D3Dtex;
|
||||
|
||||
|
||||
IDirect3DSurface9 *surface = NULL;
|
||||
if (pTexture->GetSurfaceLevel(0, &surface)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
|
||||
if (compute_crc) InitCRC32(CRC32);
|
||||
else CRC32 = 0u;
|
||||
InitCRC64(CRC64);
|
||||
|
||||
void *cpy;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
if (ret == 0x01000000L) ret = ((uMod_IDirect3DDevice9*)m_D3Ddev)->ComputeCRC( CRC64, CRC32, surface, compute_crc);
|
||||
else ret = ((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->ComputeCRC( CRC64, CRC32, surface, compute_crc);
|
||||
|
||||
surface->Release();
|
||||
return (ret);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Matthew L (Azorbix)
|
||||
* (Direct3D StarterKit v3.0)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DTexture9_H
|
||||
#define uMod_IDirect3DTexture9_H
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Defines.h"
|
||||
|
||||
|
||||
|
||||
class uMod_IDirect3DTexture9 : public IDirect3DTexture9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DTexture9(IDirect3DTexture9 **ppTex, IDirect3DDevice9 *pIDirect3DDevice9)
|
||||
{
|
||||
//Message( "uMod_IDirect3DTexture9::uMod_IDirect3DTexture9(%p %p): %p\n", *ppTex, pIDirect3DDevice9, this);
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = NULL; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
Reference = -1; //need for fast deleting
|
||||
CRC64 = 0u;
|
||||
CRC32 = 0u;
|
||||
FAKE = false;
|
||||
Dirty = 1;
|
||||
}
|
||||
|
||||
IDirect3DTexture9 *m_D3Dtex; //!< pointer to the real IDirect3DCubeTexture9 object
|
||||
uMod_IDirect3DTexture9 *CrossRef_D3Dtex; //!< cross reference from the fake texture to the game texture and vice versa
|
||||
IDirect3DDevice9 *m_D3Ddev; //!< pointer to the device
|
||||
int Reference; //!< Index in the vector (needed for a fast delete).
|
||||
DWORD64 CRC64; //!< computed hash value for this game texture.
|
||||
DWORD32 CRC32; //!< computed crc32 value for this game texture.
|
||||
bool FAKE; //!< True if this texture is was loaded by uMod (fake texture)
|
||||
unsigned char Dirty;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface) (REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)();
|
||||
STDMETHOD_(ULONG,Release)();
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid,void* pData,DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)();
|
||||
STDMETHOD_(void, PreLoad)();
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew);
|
||||
STDMETHOD_(DWORD, GetLOD)();
|
||||
STDMETHOD_(DWORD, GetLevelCount)();
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType);
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)();
|
||||
STDMETHOD_(void, GenerateMipSubLevels)();
|
||||
STDMETHOD(GetLevelDesc)(UINT Level,D3DSURFACE_DESC *pDesc);
|
||||
STDMETHOD(GetSurfaceLevel)(UINT Level,IDirect3DSurface9** ppSurfaceLevel);
|
||||
STDMETHOD(LockRect)(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
|
||||
STDMETHOD(UnlockRect)(UINT Level);
|
||||
STDMETHOD(AddDirtyRect)(CONST RECT* pDirtyRect);
|
||||
|
||||
int ComputetHash( bool compute_crc);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* some function (e.g. AddReff()) are presumed to work on the texture object which belong to them
|
||||
* if this texture was switched, we must redirect this calls to the CrossRef_D3Dtex texture object
|
||||
*/
|
||||
|
||||
|
||||
#include "../uMod_DXMain/uMod_Main.h"
|
||||
#include "../uMod_DXMain/uMod_TextureFunction.h"
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::QueryInterface(REFIID riid, void** ppvObj)
|
||||
{
|
||||
if (riid==IID_IDirect3D9)
|
||||
{
|
||||
// This function should never be called with IID_IDirect3D9 by the game
|
||||
// thus this call comes from our own dll to ask for the texture type
|
||||
// 0x01000000L == uMod_IDirect3DTexture9
|
||||
// 0x01000001L == uMod_IDirect3DVolumeTexture9
|
||||
// 0x01000002L == uMod_IDirect3DCubeTexture9
|
||||
|
||||
*ppvObj = this;
|
||||
return (0x01000001L);
|
||||
}
|
||||
HRESULT hRes = m_D3Dtex->QueryInterface(riid, ppvObj);
|
||||
if (*ppvObj==m_D3Dtex) *ppvObj=this;
|
||||
|
||||
return (hRes);
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DVolumeTexture9::AddRef()
|
||||
{
|
||||
if (FAKE) return (1); //bug, this case should never happen
|
||||
return (m_D3Dtex->AddRef());
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
ULONG APIENTRY uMod_IDirect3DVolumeTexture9::Release()
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::Release(): %p\n", this);
|
||||
|
||||
void *cpy;
|
||||
long ret = m_D3Ddev->QueryInterface( IID_IDirect3DTexture9, &cpy);
|
||||
|
||||
ULONG count;
|
||||
if (FAKE)
|
||||
{
|
||||
UnswitchTextures( this);
|
||||
count = m_D3Dtex->Release(); //count must be zero, cause we don't call AddRef of fake_textures
|
||||
}
|
||||
else
|
||||
{
|
||||
count = m_D3Dtex->Release();
|
||||
}
|
||||
|
||||
if (count==0) //if this texture is released, we clean up
|
||||
{
|
||||
if (ret == 0x01000000L)
|
||||
{
|
||||
((uMod_IDirect3DDevice9*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
else
|
||||
{
|
||||
((uMod_IDirect3DDevice9Ex*) m_D3Ddev)->GetuMod_Client()->RemoveTexture(this); // remove this texture from the texture client
|
||||
}
|
||||
|
||||
delete(this);
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetDevice(IDirect3DDevice9** ppDevice)
|
||||
{
|
||||
*ppDevice = m_D3Ddev;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
|
||||
{
|
||||
return (m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
|
||||
{
|
||||
return (m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::FreePrivateData(REFGUID refguid)
|
||||
{
|
||||
return (m_D3Dtex->FreePrivateData(refguid));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::SetPriority(DWORD PriorityNew)
|
||||
{
|
||||
return (m_D3Dtex->SetPriority(PriorityNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetPriority()
|
||||
{
|
||||
return (m_D3Dtex->GetPriority());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DVolumeTexture9::PreLoad()
|
||||
{
|
||||
m_D3Dtex->PreLoad();
|
||||
}
|
||||
|
||||
D3DRESOURCETYPE APIENTRY uMod_IDirect3DVolumeTexture9::GetType()
|
||||
{
|
||||
return (m_D3Dtex->GetType());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::SetLOD(DWORD LODNew)
|
||||
{
|
||||
return (m_D3Dtex->SetLOD(LODNew));
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetLOD()
|
||||
{
|
||||
return (m_D3Dtex->GetLOD());
|
||||
}
|
||||
|
||||
DWORD APIENTRY uMod_IDirect3DVolumeTexture9::GetLevelCount()
|
||||
{
|
||||
return (m_D3Dtex->GetLevelCount());
|
||||
}
|
||||
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
|
||||
{
|
||||
return (m_D3Dtex->SetAutoGenFilterType(FilterType));
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE APIENTRY uMod_IDirect3DVolumeTexture9::GetAutoGenFilterType()
|
||||
{
|
||||
return (m_D3Dtex->GetAutoGenFilterType());
|
||||
}
|
||||
|
||||
void APIENTRY uMod_IDirect3DVolumeTexture9::GenerateMipSubLevels()
|
||||
{
|
||||
m_D3Dtex->GenerateMipSubLevels();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::AddDirtyBox(CONST D3DBOX *pDirtyBox)
|
||||
{
|
||||
return (m_D3Dtex->AddDirtyBox(pDirtyBox));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetLevelDesc(UINT Level, D3DVOLUME_DESC *pDesc)
|
||||
{
|
||||
return (m_D3Dtex->GetLevelDesc(Level, pDesc));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::GetVolumeLevel(UINT Level, IDirect3DVolume9 **ppVolumeLevel)
|
||||
{
|
||||
Dirty=1;
|
||||
return (m_D3Dtex->GetVolumeLevel(Level, ppVolumeLevel));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::LockBox(UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox ,DWORD Flags)
|
||||
{
|
||||
return (m_D3Dtex->LockBox(Level, pLockedVolume, pBox, Flags));
|
||||
}
|
||||
|
||||
//this function yields for the non switched texture object
|
||||
HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::UnlockBox(UINT Level)
|
||||
{
|
||||
Dirty=1;
|
||||
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->UnlockBox(Level));
|
||||
return (m_D3Dtex->UnlockBox(Level));
|
||||
}
|
||||
|
||||
|
||||
int uMod_IDirect3DVolumeTexture9::ComputetHash( bool compute_crc)
|
||||
{
|
||||
if (FAKE) return (RETURN_BAD_ARGUMENT);
|
||||
IDirect3DVolumeTexture9 *pTexture = m_D3Dtex;
|
||||
|
||||
//IDirect3DVolume9 *pOffscreenSurface = NULL;
|
||||
//IDirect3DVolumeTexture9 *pOffscreenTexture = NULL;
|
||||
IDirect3DVolume9 *pResolvedSurface = NULL;
|
||||
D3DLOCKED_BOX d3dlr;
|
||||
D3DVOLUME_DESC desc;
|
||||
|
||||
if (pTexture->GetLevelDesc(0, &desc)!=D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetLevelDesc \n");
|
||||
return (RETURN_GetLevelDesc_FAILED);
|
||||
}
|
||||
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() (%d %d %d) %d\n", desc.Width, desc.Height, desc.Depth, desc.Format);
|
||||
|
||||
|
||||
if (pTexture->LockBox( 0, &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect 1\n");
|
||||
if (pTexture->GetVolumeLevel(0, &pResolvedSurface)!=D3D_OK)
|
||||
{
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: GetSurfaceLevel\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
if (pResolvedSurface->LockBox( &d3dlr, NULL, D3DLOCK_READONLY)!=D3D_OK)
|
||||
{
|
||||
pResolvedSurface->Release();
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() Failed: LockRect 2\n");
|
||||
return (RETURN_LockRect_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int bits_per_pixel = GetBitsFromFormat( desc.Format);
|
||||
|
||||
{
|
||||
InitCRC64(CRC64);
|
||||
unsigned char *data = (unsigned char*) d3dlr.pBits;
|
||||
|
||||
unsigned int size;
|
||||
unsigned int h_max = desc.Height;
|
||||
if (desc.Format == D3DFMT_DXT1) // 8 bytes per block
|
||||
{
|
||||
h_max /= 4; // divide by block size
|
||||
size = desc.Width*2; // desc.Width/4 * 8
|
||||
}
|
||||
else if ( desc.Format==D3DFMT_DXT2 || desc.Format==D3DFMT_DXT3 || desc.Format==D3DFMT_DXT4 || desc.Format==D3DFMT_DXT5 ) // 16 bytes per block
|
||||
{
|
||||
h_max /= 4; // divide by block size
|
||||
size = desc.Width*4; // desc.Width/4 * 16
|
||||
}
|
||||
else size = (bits_per_pixel * desc.Width)/8;
|
||||
|
||||
//int size = (bits_per_pixel * desc.Width)/8;
|
||||
for (unsigned int d=0; d<desc.Depth; d++)
|
||||
{
|
||||
unsigned char* data_inner_loop = data;
|
||||
for (unsigned int h=0; h<h_max; h++)
|
||||
{
|
||||
GetCRC64( CRC64, data_inner_loop, size);
|
||||
data_inner_loop += d3dlr.RowPitch;
|
||||
}
|
||||
data += d3dlr.SlicePitch;
|
||||
}
|
||||
}
|
||||
|
||||
if (compute_crc)
|
||||
{
|
||||
InitCRC32(CRC32);
|
||||
int size = (bits_per_pixel * desc.Width*desc.Height*desc.Depth)/8;
|
||||
GetCRC32( CRC32, (unsigned char*) d3dlr.pBits, size); //calculate the crc32 of the texture
|
||||
}
|
||||
|
||||
|
||||
if (pResolvedSurface!=NULL)
|
||||
{
|
||||
pResolvedSurface->UnlockBox();
|
||||
pResolvedSurface->Release();
|
||||
}
|
||||
else pTexture->UnlockBox(0);
|
||||
|
||||
Message("uMod_IDirect3DVolumeTexture9::GetHash() %#llX %#LX (%d %d %d) %d\n", CRC64, CRC32, desc.Width, desc.Height, desc.Depth, desc.Format);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO Matthew L (Azorbix)
|
||||
* (Direct3D StarterKit v3.0)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_IDirect3DVolumeTexture9_H
|
||||
#define uMod_IDirect3DVolumeTexture9_H
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include "..\uMod_DXMain\uMod_Defines.h"
|
||||
|
||||
|
||||
|
||||
class uMod_IDirect3DVolumeTexture9 : public IDirect3DVolumeTexture9
|
||||
{
|
||||
public:
|
||||
uMod_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9 **ppTex, IDirect3DDevice9 *pIDirect3DDevice9)
|
||||
{
|
||||
m_D3Dtex = *ppTex; //Texture which will be displayed and will be passed to the game
|
||||
m_D3Ddev = pIDirect3DDevice9; //device pointer
|
||||
CrossRef_D3Dtex = NULL; //cross reference
|
||||
// fake texture: store the pointer to the original uMod_IDirect3DVolumeTexture9 object, needed if a fake texture is unselected
|
||||
// original texture: stores the pointer to the fake texture object, is needed if original texture is deleted,
|
||||
// thus the fake texture can also be deleted
|
||||
Reference = -1; //need for fast deleting
|
||||
CRC64 = 0u;
|
||||
CRC32 = 0u;
|
||||
FAKE = false;
|
||||
Dirty = 1;
|
||||
}
|
||||
|
||||
IDirect3DVolumeTexture9 *m_D3Dtex; //!< pointer to the real IDirect3DCubeTexture9 object
|
||||
uMod_IDirect3DVolumeTexture9 *CrossRef_D3Dtex; //!< cross reference from the fake texture to the game texture and vice versa
|
||||
IDirect3DDevice9 *m_D3Ddev; //!< pointer to the device
|
||||
int Reference; //!< Index in the vector (needed for a fast delete).
|
||||
DWORD64 CRC64; //!< computed hash value for this game texture.
|
||||
DWORD32 CRC32; //!< computed crc32 value for this game texture.
|
||||
bool FAKE; //!< True if this texture is was loaded by uMod (fake texture)
|
||||
unsigned char Dirty;
|
||||
|
||||
// original interface
|
||||
STDMETHOD(QueryInterface) (REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)();
|
||||
STDMETHOD_(ULONG,Release)();
|
||||
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)(REFGUID refguid,void* pData,DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)(REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)();
|
||||
STDMETHOD_(void, PreLoad)();
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||
STDMETHOD_(DWORD, SetLOD)(DWORD LODNew);
|
||||
STDMETHOD_(DWORD, GetLOD)();
|
||||
STDMETHOD_(DWORD, GetLevelCount)();
|
||||
STDMETHOD(SetAutoGenFilterType)(D3DTEXTUREFILTERTYPE FilterType);
|
||||
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)();
|
||||
STDMETHOD_(void, GenerateMipSubLevels)();
|
||||
STDMETHOD(AddDirtyBox)(CONST D3DBOX *pDirtyBox);
|
||||
STDMETHOD(GetLevelDesc)(UINT Level, D3DVOLUME_DESC *pDesc);
|
||||
STDMETHOD(GetVolumeLevel)(UINT Level, IDirect3DVolume9 **ppVolumeLevel);
|
||||
STDMETHOD(LockBox)(UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags);
|
||||
STDMETHOD(UnlockBox)(UINT Level);
|
||||
|
||||
|
||||
int ComputetHash( bool compute_crc);
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_TEXTURECLIENT_DX9_HPP
|
||||
#define uMod_TEXTURECLIENT_DX9_HPP
|
||||
|
||||
#include "..\uMod_Error.h"
|
||||
#include "..\uMod_DXMain\uMod_TextureClient.h"
|
||||
#include "uMod_IDirect3DTexture9.h"
|
||||
#include "uMod_IDirect3DVolumeTexture9.h"
|
||||
#include "uMod_IDirect3DCubeTexture9.h"
|
||||
#include "uMod_IDirect3DDevice9.h"
|
||||
#include "uMod_IDirect3DDevice9Ex.h"
|
||||
|
||||
|
||||
class uMod_TextureServer;
|
||||
|
||||
/*
|
||||
* An object of this class is owned by each d3d9 device.
|
||||
* functions called by the Server are called from the server thread instance.
|
||||
* All other functions are called from the render thread instance of the game itself.
|
||||
*/
|
||||
|
||||
class uMod_TextureClient_DX9 : public uMod_TextureClient
|
||||
{
|
||||
public:
|
||||
uMod_TextureClient_DX9( IDirect3DDevice9* device, const int version);
|
||||
virtual ~uMod_TextureClient_DX9(void);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DDevice9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
* @param[in] tex texture to be added
|
||||
* @return
|
||||
*/
|
||||
int AddTexture( uMod_IDirect3DTexture9* tex);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DVolumeTexture9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
* @param[in] tex texture to be added
|
||||
* @return
|
||||
*/
|
||||
int AddTexture( uMod_IDirect3DVolumeTexture9* tex);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DCubeTexture9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene()
|
||||
* @param[in] tex texture to be added
|
||||
* @return
|
||||
*/
|
||||
int AddTexture( uMod_IDirect3DCubeTexture9* tex);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DTexture9::Release()
|
||||
* @param[in] tex
|
||||
* @return
|
||||
*/
|
||||
int RemoveTexture( uMod_IDirect3DTexture9* tex);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DVolumeTexture9::Release()
|
||||
* @param[in] tex
|
||||
* @return
|
||||
*/
|
||||
int RemoveTexture( uMod_IDirect3DVolumeTexture9* tex);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DCubeTexture9::Release()
|
||||
* @param[in] tex
|
||||
* @return
|
||||
*/
|
||||
int RemoveTexture( uMod_IDirect3DCubeTexture9* tex);
|
||||
|
||||
|
||||
int ComputeCRC( uMod_IDirect3DTexture9* tex);
|
||||
int ComputeCRC( uMod_IDirect3DVolumeTexture9* tex);
|
||||
int ComputeCRC( uMod_IDirect3DCubeTexture9* tex);
|
||||
|
||||
int SaveAllTextures(bool val); //called from the Server
|
||||
int SaveSingleTexture(bool val); //called from the Server
|
||||
|
||||
/**
|
||||
* Enable/Disable the hashing with CRC32, which is needed to support also tpf mods (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
virtual int SupportTPF(bool val);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
* @param[in] pTexture
|
||||
* @param[in] save_all true if called from AddTexture(...) -> (SaveAllTextures is true)
|
||||
* @return
|
||||
*/
|
||||
int SaveTexture(uMod_IDirect3DTexture9* pTexture, bool save_all=false); //
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
* @param[in] pTexture
|
||||
* @param[in] save_all true if called from AddTexture(...) -> (SaveAllTextures is true)
|
||||
* @return
|
||||
*/
|
||||
int SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture, bool save_all=false);
|
||||
|
||||
/**
|
||||
* called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures)
|
||||
* @param[in] pTexture
|
||||
* @param[in] save_all true if called from AddTexture(...) -> (SaveAllTextures is true)
|
||||
* @return
|
||||
*/
|
||||
int SaveTexture(uMod_IDirect3DCubeTexture9* pTexture, bool save_all=false);
|
||||
|
||||
int MergeUpdate(void); //called from uMod_IDirect3DDevice9::BeginScene()
|
||||
|
||||
|
||||
int LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
int LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
int LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
|
||||
|
||||
uMod_TextureHandler<uMod_IDirect3DTexture9> OriginalTextures; // stores the pointer to the uMod_IDirect3DTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DVolumeTexture9> OriginalVolumeTextures; // stores the pointer to the uMod_IDirect3DVolumeTexture9 objects created by the game
|
||||
uMod_TextureHandler<uMod_IDirect3DCubeTexture9> OriginalCubeTextures; // stores the pointer to the uMod_IDirect3DCubeTexture9 objects created by the game
|
||||
|
||||
bool BoolComputeCRC32; //!< if true also the crc32 is calculated, which is need to support tpf
|
||||
|
||||
private:
|
||||
IDirect3DDevice9* D3D9Device;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save the texture into a file (reagrding the various file formats.
|
||||
* @param[in] pTexture
|
||||
* @param[inout] file name without trailing format extension
|
||||
* @return
|
||||
*/
|
||||
int SaveTexture(IDirect3DBaseTexture9* pTexture, wchar_t *file);
|
||||
|
||||
/**
|
||||
* Return true if this texture has the right format to pass the FormatFilter and thus it is saved
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
bool SaveTextureFilterFormat(D3DFORMAT format);
|
||||
|
||||
int LoadTexture( const TextureFileContent* file, uMod_IDirect3DTexture9 **ppTexture); // called if a target texture is found
|
||||
int LoadTexture( const TextureFileContent* file, uMod_IDirect3DVolumeTexture9 **ppTexture); // called if a target texture is found
|
||||
int LoadTexture( const TextureFileContent* file, uMod_IDirect3DCubeTexture9 **ppTexture); // called if a target texture is found
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void UnswitchTextures(T *pTexture)
|
||||
{
|
||||
T* CrossRef = pTexture->CrossRef_D3Dtex;
|
||||
if (CrossRef!=NULL)
|
||||
{
|
||||
// cancel the link
|
||||
CrossRef->CrossRef_D3Dtex = NULL;
|
||||
pTexture->CrossRef_D3Dtex = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int SwitchTextures( T *pTexture1, T *pTexture2)
|
||||
{
|
||||
if (pTexture1->m_D3Ddev == pTexture2->m_D3Ddev && pTexture1->CrossRef_D3Dtex == NULL && pTexture2->CrossRef_D3Dtex == NULL)
|
||||
{
|
||||
// make cross reference
|
||||
pTexture1->CrossRef_D3Dtex = pTexture2;
|
||||
pTexture2->CrossRef_D3Dtex = pTexture1;
|
||||
|
||||
return (RETURN_OK);
|
||||
}
|
||||
else return (RETURN_TEXTURE_NOT_SWITCHED);
|
||||
}
|
||||
|
||||
#endif /* uMod_TEXTUREHANDLER_HPP_ */
|
||||
@@ -0,0 +1,212 @@
|
||||
|
||||
|
||||
ifdef DX10
|
||||
ifdef DX9
|
||||
DX_XX_Flag = /D DEF_USE_DX9 /D DEF_USE_DX10
|
||||
DX_XX_File = 9_10
|
||||
else
|
||||
DX_XX_Flag = /D DEF_USE_DX10
|
||||
DX_XX_File = 10
|
||||
endif
|
||||
|
||||
else
|
||||
DX_XX_Flag = /D DEF_USE_DX9
|
||||
DX_XX_File = 9
|
||||
endif
|
||||
|
||||
|
||||
|
||||
ifdef NI
|
||||
|
||||
ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=3"
|
||||
else
|
||||
precompiler_flag = /D "INJECTION_METHOD=3"
|
||||
endif
|
||||
|
||||
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_NO_INJECTION.def"
|
||||
obj_suff = NI.obj
|
||||
dll = d3d$(DX_XX_File).dll
|
||||
|
||||
else
|
||||
|
||||
ifdef DI
|
||||
ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=2"
|
||||
else
|
||||
precompiler_flag = /D "INJECTION_METHOD=2"
|
||||
endif
|
||||
|
||||
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_DIRECT_INJECTION.def"
|
||||
obj_suff = DI.obj
|
||||
dll = uMod_d3d$(DX_XX_File)_DI.dll
|
||||
|
||||
else
|
||||
|
||||
ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=1"
|
||||
else
|
||||
precompiler_flag = /D "INJECTION_METHOD=1"
|
||||
endif
|
||||
|
||||
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_HOOK_INJECTION.def"
|
||||
obj_suff = HI.obj
|
||||
dll = uMod_d3d$(DX_XX_File)_HI.dll
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
CXX = cl
|
||||
CLINK = link.exe
|
||||
DEFINES = /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS" /D "_UNICODE" "/D UNICODE" $(DX_XX_Flag)
|
||||
#CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 ${DEFINES} ${precompiler_flag} /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t
|
||||
|
||||
CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 /Oi /Oy- /GL \
|
||||
${DEFINES} ${precompiler_flag} /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP /analyze-
|
||||
|
||||
LFLAGS = /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" \
|
||||
/DLL "Winmm.lib" "d3dx9.lib" "d3dx10.lib" "dxguid.lib" "user32.lib" "Kernel32.lib" ${def_file} /MANIFEST:NO \
|
||||
/SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86
|
||||
|
||||
|
||||
#/nologo /W3 /WX- /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _WINDOWS /D _USRDLL /D D3DSTARTERKIT_EXPORTS /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\" /Fd"Release\vc100.pdb" /Gd /TP /analyze-
|
||||
|
||||
obj = obj
|
||||
bin = bin
|
||||
|
||||
objects = \
|
||||
${obj}\uMod_TextureFunction.$(DX_XX_File).${obj_suff} \
|
||||
${obj}\uMod_ArrayHandler.$(DX_XX_File).${obj_suff} \
|
||||
${obj}\uMod_TextureClient.$(DX_XX_File).${obj_suff} \
|
||||
${obj}\uMod_TextureServer.$(DX_XX_File).${obj_suff} \
|
||||
${obj}\uMod_Detour.$(DX_XX_File).${obj_suff} \
|
||||
${obj}\uMod_DXMain_dll.$(DX_XX_File).${obj_suff} \
|
||||
\
|
||||
${obj}\uMod_DX9_dll.${obj_suff} \
|
||||
${obj}\uMod_TextureClient_DX9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3D9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3D9Ex.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DDevice9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DDevice9Ex.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DSurface9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DTexture9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff} \
|
||||
${obj}\uMod_IDirect3DCubeTexture9.${obj_suff} \
|
||||
\
|
||||
${obj}\uMod_DX10_dll.${obj_suff} \
|
||||
${obj}\uMod_ID3D10Device.${obj_suff} \
|
||||
${obj}\uMod_ID3D10Device1.${obj_suff} \
|
||||
${obj}\uMod_ID3D10Texture1D.${obj_suff} \
|
||||
${obj}\uMod_ID3D10Texture2D.${obj_suff} \
|
||||
${obj}\uMod_ID3D10Texture3D.${obj_suff} \
|
||||
${obj}\uMod_IDXGISwapChain.${obj_suff}
|
||||
|
||||
|
||||
headers = uMod_Main.h \
|
||||
uMod_DXMain_dll.h \
|
||||
uMod_Detour.h \
|
||||
uMod_DetourEntry.h \
|
||||
uMod_Defines.h \
|
||||
uMod_TextureFunction.h \
|
||||
uMod_ArrayHandler.h \
|
||||
uMod_TextureClient.h \
|
||||
uMod_TextureServer.h
|
||||
|
||||
DX9_headers = \
|
||||
..\uMod_DX9\uMod_DX9_dll.h \
|
||||
..\uMod_DX9\uMod_TextureClient_DX9.h \
|
||||
..\uMod_DX9\uMod_IDirect3D9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DDevice9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DDevice9Ex.h \
|
||||
..\uMod_DX9\uMod_IDirect3DSurface9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DTexture9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DVolumeTexture9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DCubeTexture9.h
|
||||
|
||||
DX10_headers = \
|
||||
..\uMod_DX10\uMod_DX10_dll.h \
|
||||
..\uMod_DX10\uMod_ID3D10Device.h \
|
||||
..\uMod_DX10\uMod_ID3D10Device1.h \
|
||||
..\uMod_DX10\uMod_ID3D10Texture1D.h \
|
||||
..\uMod_DX10\uMod_ID3D10Texture2D.h \
|
||||
..\uMod_DX10\uMod_ID3D10Texture3D.h \
|
||||
..\uMod_DX10\uMod_IDXGISwapChain.h
|
||||
|
||||
${bin}\d3d9.dll: ${objects}
|
||||
${CLINK} ${LFLAGS} ${objects} /OUT:${bin}\${dll}
|
||||
copy ${bin}\${dll} ..\uMod_GUI\bin\${dll}
|
||||
|
||||
|
||||
${obj}\uMod_DXMain_dll.$(DX_XX_File).${obj_suff}: uMod_DXMain_dll.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_Detour.$(DX_XX_File).${obj_suff}: uMod_Detour.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_ArrayHandler.$(DX_XX_File).${obj_suff}: uMod_ArrayHandler.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_TextureClient.$(DX_XX_File).${obj_suff}: uMod_TextureClient.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_TextureServer.$(DX_XX_File).${obj_suff}: uMod_TextureServer.cpp ${headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_TextureFunction.$(DX_XX_File).${obj_suff}: uMod_TextureFunction.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
|
||||
${obj}\uMod_DX9_dll.${obj_suff}: ..\uMod_DX9\uMod_DX9_dll.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_TextureClient_DX9.${obj_suff}: ..\uMod_DX9\uMod_TextureClient_DX9.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3D9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3D9.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3D9Ex.${obj_suff}: ..\uMod_DX9\uMod_IDirect3D9Ex.cpp ${headers} ${DX9_headers} ..\uMod_DX9\uMod_IDirect3D9.cpp
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DDevice9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DDevice9.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DDevice9Ex.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DDevice9Ex.cpp ${headers} ${DX9_headers} ..\uMod_DX9\uMod_IDirect3DDevice9.cpp
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DSurface9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DSurface9.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DTexture9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DTexture9.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DVolumeTexture9.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDirect3DCubeTexture9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DCubeTexture9.cpp ${headers} ${DX9_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
|
||||
${obj}\uMod_DX10_dll.${obj_suff}: ..\uMod_DX10\uMod_DX10_dll.cpp ${headers} ${DX10_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_ID3D10Device.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Device.cpp ${headers} ${DX10_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_ID3D10Device1.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Device1.cpp ${headers} ${DX10_headers} ..\uMod_DX10\uMod_ID3D10Device.cpp
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_ID3D10Texture1D.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Texture1D.cpp ${headers} ${DX10_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_ID3D10Texture2D.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Texture2D.cpp ${headers} ${DX10_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_ID3D10Texture3D.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Texture3D.cpp ${headers} ${DX10_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
${obj}\uMod_IDXGISwapChain.${obj_suff}: ..\uMod_DX10\uMod_IDXGISwapChain.cpp ${headers} ${DX10_headers}
|
||||
${CXX} ${CFLAGS} /c $< /Fo$@
|
||||
|
||||
clean:
|
||||
del ${objects} ${bin}\${dll}
|
||||
@@ -0,0 +1,212 @@
|
||||
|
||||
|
||||
!ifdef DX10
|
||||
!ifdef DX9
|
||||
DX_XX_Flag = /D DEF_USE_DX9 /D DEF_USE_DX10
|
||||
DX_XX_File = 9_10
|
||||
!else
|
||||
DX_XX_Flag = /D DEF_USE_DX10
|
||||
DX_XX_File = 10
|
||||
!endif
|
||||
|
||||
!else
|
||||
DX_XX_Flag = /D DEF_USE_DX9
|
||||
DX_XX_File = 9
|
||||
!endif
|
||||
|
||||
|
||||
|
||||
!ifdef NI
|
||||
|
||||
!ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=3"
|
||||
!else
|
||||
precompiler_flag = /D "INJECTION_METHOD=3"
|
||||
!endif
|
||||
|
||||
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_NO_INJECTION.def"
|
||||
obj_suff = NI.obj
|
||||
dll = d3d$(DX_XX_File).dll
|
||||
|
||||
!else
|
||||
|
||||
!ifdef DI
|
||||
!ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=2"
|
||||
!else
|
||||
precompiler_flag = /D "INJECTION_METHOD=2"
|
||||
!endif
|
||||
|
||||
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_DIRECT_INJECTION.def"
|
||||
obj_suff = DI.obj
|
||||
dll = uMod_d3d$(DX_XX_File)_DI.dll
|
||||
|
||||
!else
|
||||
|
||||
!ifdef LOG_MESSAGE
|
||||
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=1"
|
||||
!else
|
||||
precompiler_flag = /D "INJECTION_METHOD=1"
|
||||
!endif
|
||||
|
||||
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_HOOK_INJECTION.def"
|
||||
obj_suff = HI.obj
|
||||
dll = uMod_d3d$(DX_XX_File)_HI.dll
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
CXX = cl
|
||||
CLINK = link.exe
|
||||
DEFINES = /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS" /D "_UNICODE" "/D UNICODE" $(DX_XX_Flag)
|
||||
#CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 $(DEFINES) $(precompiler_flag) /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t
|
||||
|
||||
CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 /Oi /Oy- /GL \
|
||||
$(DEFINES) $(precompiler_flag) /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP /analyze-
|
||||
|
||||
LFLAGS = /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" \
|
||||
/DLL "Winmm.lib" "d3dx9.lib" "d3dx10.lib" "dxguid.lib" "user32.lib" "Kernel32.lib" $(def_file) /MANIFEST:NO \
|
||||
/SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86
|
||||
|
||||
|
||||
#/nologo /W3 /WX- /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _WINDOWS /D _USRDLL /D D3DSTARTERKIT_EXPORTS /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\" /Fd"Release\vc100.pdb" /Gd /TP /analyze-
|
||||
|
||||
obj = obj
|
||||
bin = bin
|
||||
|
||||
objects = \
|
||||
$(obj)\uMod_TextureFunction.$(DX_XX_File).$(obj_suff) \
|
||||
$(obj)\uMod_ArrayHandler.$(DX_XX_File).$(obj_suff) \
|
||||
$(obj)\uMod_TextureClient.$(DX_XX_File).$(obj_suff) \
|
||||
$(obj)\uMod_TextureServer.$(DX_XX_File).$(obj_suff) \
|
||||
$(obj)\uMod_Detour.$(DX_XX_File).$(obj_suff) \
|
||||
$(obj)\uMod_DXMain_dll.$(DX_XX_File).$(obj_suff) \
|
||||
\
|
||||
$(obj)\uMod_DX9_dll.$(obj_suff) \
|
||||
$(obj)\uMod_TextureClient_DX9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3D9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3D9Ex.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DDevice9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DDevice9Ex.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DSurface9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DTexture9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DVolumeTexture9.$(obj_suff) \
|
||||
$(obj)\uMod_IDirect3DCubeTexture9.$(obj_suff) \
|
||||
\
|
||||
$(obj)\uMod_DX10_dll.$(obj_suff) \
|
||||
$(obj)\uMod_ID3D10Device.$(obj_suff) \
|
||||
$(obj)\uMod_ID3D10Device1.$(obj_suff) \
|
||||
$(obj)\uMod_ID3D10Texture1D.$(obj_suff) \
|
||||
$(obj)\uMod_ID3D10Texture2D.$(obj_suff) \
|
||||
$(obj)\uMod_ID3D10Texture3D.$(obj_suff) \
|
||||
$(obj)\uMod_IDXGISwapChain.$(obj_suff)
|
||||
|
||||
|
||||
headers = uMod_Main.h \
|
||||
uMod_DXMain_dll.h \
|
||||
uMod_Detour.h \
|
||||
uMod_DetourEntry.h \
|
||||
uMod_Defines.h \
|
||||
uMod_TextureFunction.h \
|
||||
uMod_ArrayHandler.h \
|
||||
uMod_TextureClient.h \
|
||||
uMod_TextureServer.h
|
||||
|
||||
DX9_headers = \
|
||||
..\uMod_DX9\uMod_DX9_dll.h \
|
||||
..\uMod_DX9\uMod_TextureClient_DX9.h \
|
||||
..\uMod_DX9\uMod_IDirect3D9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DDevice9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DDevice9Ex.h \
|
||||
..\uMod_DX9\uMod_IDirect3DSurface9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DTexture9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DVolumeTexture9.h \
|
||||
..\uMod_DX9\uMod_IDirect3DCubeTexture9.h
|
||||
|
||||
DX10_headers = \
|
||||
..\uMod_DX10\uMod_DX10_dll.h \
|
||||
..\uMod_DX10\uMod_ID3D10Device.h \
|
||||
..\uMod_DX10\uMod_ID3D10Device1.h \
|
||||
..\uMod_DX10\uMod_ID3D10Texture1D.h \
|
||||
..\uMod_DX10\uMod_ID3D10Texture2D.h \
|
||||
..\uMod_DX10\uMod_ID3D10Texture3D.h \
|
||||
..\uMod_DX10\uMod_IDXGISwapChain.h
|
||||
|
||||
$(bin)\d3d9.dll: $(objects)
|
||||
$(CLINK) $(LFLAGS) $(objects) /OUT:$(bin)\$(dll)
|
||||
copy $(bin)\$(dll) ..\uMod_GUI\bin\$(dll)
|
||||
|
||||
|
||||
$(obj)\uMod_DXMain_dll.$(DX_XX_File).$(obj_suff): uMod_DXMain_dll.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c uMod_DXMain_dll.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_Detour.$(DX_XX_File).$(obj_suff): uMod_Detour.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c uMod_Detour.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_ArrayHandler.$(DX_XX_File).$(obj_suff): uMod_ArrayHandler.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c uMod_ArrayHandler.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_TextureClient.$(DX_XX_File).$(obj_suff): uMod_TextureClient.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c uMod_TextureClient.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_TextureServer.$(DX_XX_File).$(obj_suff): uMod_TextureServer.cpp $(headers)
|
||||
$(CXX) $(CFLAGS) /c uMod_TextureServer.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_TextureFunction.$(DX_XX_File).$(obj_suff): uMod_TextureFunction.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c uMod_TextureFunction.cpp /Fo$@
|
||||
|
||||
|
||||
$(obj)\uMod_DX9_dll.$(obj_suff): ..\uMod_DX9\uMod_DX9_dll.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_DX9_dll.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_TextureClient_DX9.$(obj_suff): ..\uMod_DX9\uMod_TextureClient_DX9.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_TextureClient_DX9.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3D9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3D9.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3D9.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3D9Ex.$(obj_suff): ..\uMod_DX9\uMod_IDirect3D9Ex.cpp $(headers) $(DX9_headers) ..\uMod_DX9\uMod_IDirect3D9.cpp
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3D9Ex.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3DDevice9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DDevice9.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DDevice9.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3DDevice9Ex.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DDevice9Ex.cpp $(headers) $(DX9_headers) ..\uMod_DX9\uMod_IDirect3DDevice9.cpp
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DDevice9Ex.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3DSurface9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DSurface9.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DSurface9.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3DTexture9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DTexture9.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DTexture9.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3DVolumeTexture9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DVolumeTexture9.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DVolumeTexture9.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDirect3DCubeTexture9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DCubeTexture9.cpp $(headers) $(DX9_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DCubeTexture9.cpp /Fo$@
|
||||
|
||||
|
||||
$(obj)\uMod_DX10_dll.$(obj_suff): ..\uMod_DX10\uMod_DX10_dll.cpp $(headers) $(DX10_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_DX10_dll.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_ID3D10Device.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Device.cpp $(headers) $(DX10_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Device.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_ID3D10Device1.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Device1.cpp $(headers) $(DX10_headers) ..\uMod_DX10\uMod_ID3D10Device.cpp
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Device1.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_ID3D10Texture1D.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Texture1D.cpp $(headers) $(DX10_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Texture1D.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_ID3D10Texture2D.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Texture2D.cpp $(headers) $(DX10_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Texture2D.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_ID3D10Texture3D.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Texture3D.cpp $(headers) $(DX10_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Texture3D.cpp /Fo$@
|
||||
|
||||
$(obj)\uMod_IDXGISwapChain.$(obj_suff): ..\uMod_DX10\uMod_IDXGISwapChain.cpp $(headers) $(DX10_headers)
|
||||
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_IDXGISwapChain.cpp /Fo$@
|
||||
|
||||
clean:
|
||||
del $(objects) $(bin)\$(dll)
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
TextureFileContent::TextureFileContent() : ForceReload(false), pFileName(NULL), pData(NULL), Size(0u), Reference(-1), Hash(0u), RefCounter(1)
|
||||
{
|
||||
}
|
||||
|
||||
TextureFileContent::~TextureFileContent()
|
||||
{
|
||||
if (pFileName!=NULL) delete [] pFileName;
|
||||
if (pData!=NULL) delete [] pData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TextureEntry::TextureEntry(void) : TexContent(NULL), NumberOfTextures(0), Textures(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
TextureEntry::~TextureEntry()
|
||||
{
|
||||
//for (int i=0; i<NumberOfTextures; i++) Textures[i]->Release();
|
||||
if (Textures!=NULL) delete [] Textures;
|
||||
if (TexContent!=NULL) TexContent->Release();
|
||||
}
|
||||
|
||||
|
||||
void TextureEntry::SetContent(TextureFileContent *content)
|
||||
{
|
||||
if (TexContent!=NULL) TexContent->Release();
|
||||
TexContent = content;
|
||||
if (TexContent!=NULL) TexContent->AddRef();
|
||||
}
|
||||
|
||||
int TextureEntry::AddTexture(IUnknown* tex)
|
||||
{
|
||||
IUnknown** temp = new IUnknown*[NumberOfTextures+1];
|
||||
for (int i=0; i<NumberOfTextures; i++) temp[i] = Textures[i];
|
||||
|
||||
if (Textures!=NULL) delete [] Textures;
|
||||
Textures = temp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TextureEntry::RemoveTexture(IUnknown* tex)
|
||||
{
|
||||
for (int i=0; i<NumberOfTextures; i++) if (Textures[i] == tex)
|
||||
{
|
||||
NumberOfTextures--;
|
||||
for (int j=i; j<NumberOfTextures; j++)
|
||||
Textures[j] = Textures[j+1];
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_FIELDHANDLER_H_
|
||||
#define uMod_FIELDHANDLER_H_
|
||||
|
||||
#include "..\uMod_GlobalDefines.h"
|
||||
|
||||
/**
|
||||
* On entry hold the pointer to the fake texture data (file content) or the filename.
|
||||
*
|
||||
* An object is created for each texture to be modded from the server.
|
||||
*/
|
||||
class TextureFileContent
|
||||
{
|
||||
public:
|
||||
TextureFileContent();
|
||||
~TextureFileContent();
|
||||
|
||||
int AddRef(void) {return ++RefCounter;}
|
||||
int Release(void) {if (--RefCounter==0) {delete this; return 0;} else return RefCounter;}
|
||||
|
||||
bool ForceReload; //!< to force a reload of the texture (only important, if it is already modded)
|
||||
wchar_t* pFileName; //!< store the texture file name (if available)
|
||||
char* pData; //!< store texture file as file in memory (if available)
|
||||
unsigned int Size; //!< size of file (\a pData)
|
||||
int Reference; //!< for a fast delete in the FileHandler
|
||||
DWORD64 Hash; //!< hash value
|
||||
|
||||
private:
|
||||
int RefCounter;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* One object holds a pointer to the data (\a TextureFileContent)
|
||||
* and a Reference to all generated fake texture.
|
||||
*
|
||||
* An object is created for each texture to be modded from the server for each client separately.
|
||||
*/
|
||||
class TextureEntry
|
||||
{
|
||||
public:
|
||||
TextureEntry(void);
|
||||
~TextureEntry();
|
||||
|
||||
int AddTexture(IUnknown *tex);
|
||||
int RemoveTexture(IUnknown* tex);
|
||||
|
||||
void SetContent(TextureFileContent *content);
|
||||
const TextureFileContent * Content() {return TexContent;}
|
||||
|
||||
|
||||
|
||||
TextureFileContent *TexContent;
|
||||
int NumberOfTextures; //!< Number of textures loaded by the game, which match the hash and thus are switched
|
||||
IUnknown **Textures; //!< pointer to all texture loaded by the game, which match the hash and thus are switched;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A simple vector class for pointers. The Object or struct must have a member variable \a int \a Reference.
|
||||
* This class stores the entries in chunks of memory. The address of each chunk is stored in \a Content.
|
||||
*/
|
||||
template <class T>
|
||||
class uMod_TextureHandler
|
||||
{
|
||||
public:
|
||||
uMod_TextureHandler(void);
|
||||
~uMod_TextureHandler(void);
|
||||
|
||||
/**
|
||||
* Append an entry at the end of the vector
|
||||
* @param entry
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int Add( T* entry);
|
||||
|
||||
/**
|
||||
* Remove this entry from the vector
|
||||
* @param entry
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int Remove( T* entry);
|
||||
|
||||
/**
|
||||
* Returns the number of entries.
|
||||
* @return
|
||||
*/
|
||||
int GetNumber(void) {return (Number);}
|
||||
|
||||
/**
|
||||
* Return the pointer to the \a i the object
|
||||
* @param i index
|
||||
* @return
|
||||
*/
|
||||
T *operator [] (int i) {if (i<0||i>=Number) return (NULL); else return (Content[i/FieldLength][i%FieldLength]);}
|
||||
|
||||
private:
|
||||
static const int FieldLength = 1024; //!< size of one chunk of memory
|
||||
long Number; //!< Number of entries.
|
||||
int FieldCounter; //!< Number of allocated chunks.
|
||||
T*** Content;//!< vector of pointers, which point to the chunks
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef uMod_TextureHandler<TextureFileContent> uMod_FileHandler;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
uMod_TextureHandler<T>::uMod_TextureHandler(void)
|
||||
{
|
||||
Message("uMod_TextureHandler(void): %p\n", this);
|
||||
Number = 0;
|
||||
FieldCounter = 0;
|
||||
|
||||
Content = NULL;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
uMod_TextureHandler<T>::~uMod_TextureHandler(void)
|
||||
{
|
||||
Message("~uMod_TextureHandler(void): %p\n", this);
|
||||
if (Content!=NULL)
|
||||
{
|
||||
for (int i=0; i<FieldCounter; i++) if (Content[i] != NULL) delete [] Content[i];
|
||||
delete [] Content;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int uMod_TextureHandler<T>::Add(T* entry)
|
||||
{
|
||||
//Message("uMod_TextureHandler::Add( %p): %p\n", entry, this);
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
if (entry->Reference>=0) return (RETURN_TEXTURE_ALLREADY_ADDED);
|
||||
|
||||
if (Number/FieldLength==FieldCounter)
|
||||
{
|
||||
T*** temp = NULL;
|
||||
try {temp = new T**[FieldCounter+10];}
|
||||
catch (...)
|
||||
{
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
|
||||
for (int i=0; i<FieldCounter; i++) temp[i] = Content[i];
|
||||
|
||||
for (int i=FieldCounter; i<FieldCounter+10; i++) temp[i] = NULL;
|
||||
|
||||
FieldCounter += 10;
|
||||
|
||||
if (Content!=NULL) delete [] Content;
|
||||
|
||||
Content = temp;
|
||||
}
|
||||
if (Number%FieldLength==0)
|
||||
{
|
||||
try {if (Content[Number/FieldLength]==NULL) Content[Number/FieldLength] = new T*[FieldLength];}
|
||||
catch (...)
|
||||
{
|
||||
Content[Number/FieldLength]=NULL;
|
||||
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
Content[Number/FieldLength][Number%FieldLength] = entry;
|
||||
entry->Reference = Number++;
|
||||
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
int uMod_TextureHandler<T>::Remove(T* entry) //will be called, if a texture is completely released
|
||||
{
|
||||
//Message("uMod_TextureHandler::Remove( %p): %p\n", entry, this);
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
int ref = entry->Reference;
|
||||
if (ref<0|| ref>=Number) return (RETURN_OK); // it is not in this list
|
||||
if (Content[ref/FieldLength][ref%FieldLength]!=entry) return (RETURN_OK); // it is not in this list
|
||||
|
||||
if (ref<(--Number))
|
||||
{
|
||||
Content[ref/FieldLength][ref%FieldLength] = Content[Number/FieldLength][Number%FieldLength];
|
||||
Content[ref/FieldLength][ref%FieldLength]->Reference = ref;
|
||||
}
|
||||
entry->Reference = -1;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* uMod_FIELDHANDLER_H_ */
|
||||
@@ -0,0 +1,5 @@
|
||||
LIBRARY "uMod_d3d10_DI"
|
||||
EXPORTS
|
||||
uMod_D3D10CreateDeviceAndSwapChain @1
|
||||
uMod_D3D10CreateDeviceAndSwapChain1 @2
|
||||
Nothing @3
|
||||
@@ -0,0 +1,6 @@
|
||||
LIBRARY "uMod_d3d10_Hook"
|
||||
EXPORTS
|
||||
uMod_D3D10CreateDeviceAndSwapChain @1
|
||||
uMod_D3D10CreateDeviceAndSwapChain1 @2
|
||||
InstallHook @3
|
||||
RemoveHook @4
|
||||
@@ -0,0 +1,7 @@
|
||||
LIBRARY "uMod_d3d9_DI"
|
||||
EXPORTS
|
||||
uMod_Direct3DCreate9 @1
|
||||
uMod_Direct3DCreate9Ex @2
|
||||
uMod_D3D10CreateDeviceAndSwapChain @3
|
||||
uMod_D3D10CreateDeviceAndSwapChain1 @4
|
||||
Nothing @5
|
||||
@@ -0,0 +1,5 @@
|
||||
LIBRARY "uMod_d3d9_DI"
|
||||
EXPORTS
|
||||
uMod_Direct3DCreate9 @1
|
||||
uMod_Direct3DCreate9Ex @2
|
||||
Nothing @3
|
||||
@@ -0,0 +1,6 @@
|
||||
LIBRARY "uMod_d3d9_Hook"
|
||||
EXPORTS
|
||||
uMod_Direct3DCreate9 @1
|
||||
uMod_Direct3DCreate9Ex @2
|
||||
InstallHook @3
|
||||
RemoveHook @4
|
||||
@@ -0,0 +1,13 @@
|
||||
LIBRARY "d3d9"
|
||||
EXPORTS
|
||||
Direct3DCreate9 @1
|
||||
Direct3DCreate9Ex @2
|
||||
|
||||
D3DPERF_BeginEvent @3
|
||||
D3DPERF_EndEvent @4
|
||||
D3DPERF_SetMarker @5
|
||||
D3DPERF_SetRegion @6
|
||||
D3DPERF_QueryRepeatFrame @7
|
||||
|
||||
D3DPERF_SetOptions @8
|
||||
D3DPERF_GetStatus @9
|
||||
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
NEVER USE THIS CODE FOR ILLEGAL PURPOSE
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __CDT_PARSER__
|
||||
#define INJECTION_METHOD 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
/*
|
||||
* global variable which are not linked external
|
||||
*/
|
||||
|
||||
HINSTANCE gl_hThisInstance = NULL;
|
||||
uMod_TextureServer* gl_TextureServer = NULL;
|
||||
HANDLE gl_ServerThread = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* global variable which are linked external
|
||||
*/
|
||||
unsigned int gl_ErrorState = 0u;
|
||||
|
||||
#ifdef LOG_MESSAGE
|
||||
FILE* gl_File = NULL;
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD == DIRECT_INJECTION
|
||||
void Nothing(void) {(void)NULL;}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* dll entry routine, here we initialize or clean up
|
||||
*/
|
||||
BOOL WINAPI DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{
|
||||
InitInstance(hModule);
|
||||
break;
|
||||
}
|
||||
case DLL_PROCESS_DETACH:
|
||||
{
|
||||
ExitInstance();
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
DWORD WINAPI ServerThread( LPVOID lpParam )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lpParam);
|
||||
if (gl_TextureServer!=NULL) gl_TextureServer->MainLoop(); //This is and endless mainloop, it sleep till something is written into the pipe.
|
||||
return (0);
|
||||
}
|
||||
|
||||
void InitInstance(HINSTANCE hModule)
|
||||
{
|
||||
|
||||
DisableThreadLibraryCalls( hModule ); //reduce overhead
|
||||
|
||||
gl_hThisInstance = (HINSTANCE) hModule;
|
||||
|
||||
wchar_t game[10*MAX_PATH];
|
||||
if (HookThisProgram( game, 10*MAX_PATH)) //ask if we need to hook this program
|
||||
{
|
||||
OpenMessage();
|
||||
Message("InitInstance: %p (%ls)\n", hModule, game);
|
||||
|
||||
gl_TextureServer = new uMod_TextureServer(game); //create the server which listen on the pipe and prepare the update for the texture clients
|
||||
|
||||
GlobalDetour.Init();
|
||||
#ifdef DEF_USE_DX9
|
||||
InitDX9();
|
||||
#endif
|
||||
#ifdef DEF_USE_DX10
|
||||
InitDX10();
|
||||
#endif
|
||||
|
||||
|
||||
if (gl_TextureServer->OpenPipe(game, INJECTION_METHOD)) //open the pipe and send the name+path of this executable
|
||||
{
|
||||
Message("InitInstance: Pipe not opened\n");
|
||||
return;
|
||||
}
|
||||
|
||||
gl_ServerThread = CreateThread( NULL, 0, ServerThread, NULL, 0, NULL); //creating a thread for the mainloop
|
||||
if (gl_ServerThread==NULL) {Message("InitInstance: Serverthread not started\n");}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ExitInstance()
|
||||
{
|
||||
if (gl_TextureServer!=NULL)
|
||||
{
|
||||
gl_TextureServer->ClosePipe(); //This must be done before the server thread is killed, because the server thread will endless wait on the ReadFile()
|
||||
}
|
||||
if (gl_ServerThread!=NULL)
|
||||
{
|
||||
CloseHandle(gl_ServerThread); // kill the server thread
|
||||
gl_ServerThread = NULL;
|
||||
}
|
||||
if (gl_TextureServer!=NULL)
|
||||
{
|
||||
delete gl_TextureServer; //delete the texture server
|
||||
gl_TextureServer = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEF_USE_DX9
|
||||
ExitDX9();
|
||||
#endif
|
||||
#ifdef DEF_USE_DX10
|
||||
ExitDX10();
|
||||
#endif
|
||||
|
||||
GlobalDetour.Exit();
|
||||
CloseMessage();
|
||||
}
|
||||
|
||||
|
||||
bool HookThisProgram( wchar_t *ret, const int ret_len)
|
||||
{
|
||||
const int max_len = ret_len < MAX_PATH ? MAX_PATH : ret_len;
|
||||
wchar_t *Executable = NULL;
|
||||
if (GetMemory( Executable, max_len))
|
||||
{
|
||||
ret[0]=0;
|
||||
return false;
|
||||
}
|
||||
GetModuleFileNameW( GetModuleHandle( NULL ), Executable, max_len ); //ask for name and path of this executable
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==NO_INJECTION
|
||||
// we inject directly
|
||||
int i=0;
|
||||
while (i<max_len && i<ret_len-1 && Executable[i]) {ret[i]=Executable[i]; i++;}
|
||||
ret[i]=0;
|
||||
delete [] Executable;
|
||||
return true;
|
||||
|
||||
#elif INJECTION_METHOD==HOOK_INJECTION
|
||||
//we use the gloabal hook
|
||||
|
||||
wchar_t *Game = NULL;
|
||||
if (GetMemory( Game, max_len))
|
||||
{
|
||||
delete [] Executable;
|
||||
ret[0]=0;
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE* file;
|
||||
wchar_t *app_path = _wgetenv( L"APPDATA"); //asc for the user application directory
|
||||
wchar_t *file_name = NULL;
|
||||
if (GetMemory( file_name, max_len))
|
||||
{
|
||||
delete [] Executable;
|
||||
delete [] Game;
|
||||
ret[0]=0;
|
||||
return false;
|
||||
}
|
||||
swprintf_s( file_name, max_len, L"%ls\\%ls\\%ls", app_path, uMod_APP_DIR, uMod_APP_DX9);
|
||||
if (_wfopen_s( &file, file_name, L"rt,ccs=UTF-16LE")) return (false); // open the file in utf-16 LE mode
|
||||
delete [] file_name;
|
||||
|
||||
while (!feof(file))
|
||||
{
|
||||
if ( fgetws( Game, MAX_PATH, file) != NULL ) //get each line of the file
|
||||
{
|
||||
int len = 0;
|
||||
while (len<max_len-1 &&Game[len])
|
||||
{
|
||||
if (Game[len]==L'\r' || Game[len]==L'\n') {Game[len]=0; break;} //removing the new line symbols
|
||||
len++;
|
||||
}
|
||||
if ( _wcsicmp( Executable, Game ) == 0 ) //compare both strings
|
||||
{
|
||||
for (int i=0; i<len && i<ret_len-1; i++) ret[i] = Game[i];
|
||||
ret[len] = 0;
|
||||
fclose(file);
|
||||
delete [] Executable;
|
||||
delete [] Game;
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] Executable;
|
||||
delete [] Game;
|
||||
fclose(file);
|
||||
return (false);
|
||||
#else
|
||||
#error No injection method was set.
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
|
||||
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
|
||||
{
|
||||
BYTE *jmp = (BYTE*)malloc(len+5);
|
||||
DWORD dwback = 0;
|
||||
//(jmp, len+5, PAGE_EXECUTE_READWRITE, &dwback); //This is the addition needed for Windows 7 RC
|
||||
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
|
||||
memcpy(jmp, src, len); jmp += len;
|
||||
jmp[0] = 0xE9;
|
||||
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
|
||||
//memset(src, 0x90, len);
|
||||
src[0] = 0xE9;
|
||||
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
|
||||
VirtualProtect(src, len, dwback, &dwback);
|
||||
return (jmp-len);
|
||||
}
|
||||
|
||||
bool RetourFunc(BYTE *src, BYTE *restore, const int len)
|
||||
{
|
||||
DWORD dwback;
|
||||
if(!VirtualProtect(src, len, PAGE_READWRITE, &dwback)) { return (false); }
|
||||
if(!memcpy(src, restore, len)) { return (false); }
|
||||
restore[0] = 0xE9;
|
||||
*(DWORD*)(restore+1) = (DWORD)(src - restore) - 5;
|
||||
if(!VirtualProtect(src, len, dwback, &dwback)) { return (false); }
|
||||
return (true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if INJECTION_METHOD==HOOK_INJECTION
|
||||
/*
|
||||
* We do not change something, if our hook function is called.
|
||||
* We need this hook only to get our dll loaded into a starting program.
|
||||
*/
|
||||
|
||||
HHOOK gl_hHook = NULL;
|
||||
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return (CallNextHookEx( gl_hHook, nCode, wParam, lParam));
|
||||
}
|
||||
|
||||
void InstallHook(void)
|
||||
{
|
||||
gl_hHook = SetWindowsHookEx( WH_CBT, HookProc, gl_hThisInstance, 0 );
|
||||
}
|
||||
|
||||
void RemoveHook(void)
|
||||
{
|
||||
UnhookWindowsHookEx( gl_hHook );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_DXMAIN_DLL_H_
|
||||
#define uMod_DXMAIN_DLL_H_
|
||||
|
||||
#ifdef DEF_USE_DX9
|
||||
#include "../uMod_DX9/uMod_DX9_dll.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEF_USE_DX10
|
||||
#include "../uMod_DX10/uMod_DX10_dll.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function is called during the dll load sequence (dll entry)
|
||||
* @param[in] hModule
|
||||
*/
|
||||
void InitInstance(HINSTANCE hModule);
|
||||
|
||||
/**
|
||||
* This function is called, when the dll gets unloaded.
|
||||
*/
|
||||
void ExitInstance(void);
|
||||
|
||||
/**
|
||||
* Returns true if this game shall be injected (DirectX hook). It returns also the name and path of the game executable.
|
||||
* This function always return true, when compiled for "Direct Injection" of for "No Injection".
|
||||
* @param[out] ret buffer where the name and path of the game executable should be stored
|
||||
* @param[in] max_len length of the buffer
|
||||
* @return
|
||||
*/
|
||||
bool HookThisProgram( wchar_t *ret, const int max_len);
|
||||
|
||||
/**
|
||||
* This function is called, when the server thread is created. It only calls the mainloop function of the \a TextureServer.
|
||||
* @param[in] lpParam Pointer to the \a TextureServer.
|
||||
*/
|
||||
DWORD WINAPI ServerThread( LPVOID lpParam);
|
||||
|
||||
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
|
||||
/**
|
||||
* Detour a function to another function.
|
||||
* @param[in] src pointer to function which shall be detoured
|
||||
* @param[in] dst pointer to function which shall be called instead
|
||||
* @param[in] len number of byte to be stored
|
||||
* @return trampoline = pointer to detoured function
|
||||
*/
|
||||
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
|
||||
|
||||
/**
|
||||
* Retour the function.
|
||||
* @param src pointer to the detoured function
|
||||
* @param restore trampoline = pointer to the detoured function
|
||||
* @param len number of saved bytes
|
||||
* @return
|
||||
*/
|
||||
bool RetourFunc(BYTE *src, BYTE *restore, const int len);
|
||||
#endif
|
||||
|
||||
|
||||
#if INJECTION_METHOD==HOOK_INJECTION
|
||||
/**
|
||||
* This function is insert into the hook.
|
||||
*/
|
||||
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
/**
|
||||
* This function install the hook, our dll will be loaded into each running process (if we have sufficient permission).
|
||||
*/
|
||||
void InstallHook(void);
|
||||
/**
|
||||
* This function remove the hook, our dll will get unloaded from each process.
|
||||
*/
|
||||
void RemoveHook(void);
|
||||
#endif
|
||||
|
||||
|
||||
#if INJECTION_METHOD==DIRECT_INJECTION
|
||||
/**
|
||||
* Dummy function need for the "Direct Injection" mehtod.
|
||||
*/
|
||||
void Nothing(void);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_DEFINES_H_
|
||||
#define uMod_DEFINES_H_
|
||||
|
||||
|
||||
#ifdef LOG_MESSAGE
|
||||
extern FILE *gl_File;
|
||||
|
||||
#define Message(...) {if (gl_File!=NULL) {fprintf( gl_File, __VA_ARGS__); fflush(gl_File);}}
|
||||
#if INJECTION_METHOD == HOOK_INJECTION
|
||||
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "HI " uMod_VERSION_char ": 0000001\n");}
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD == DIRECT_INJECTION
|
||||
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "DI " uMod_VERSION_char ": 0000001\n");}
|
||||
#endif
|
||||
|
||||
#if INJECTION_METHOD == NO_INJECTION
|
||||
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "NI " uMod_VERSION_char ": 0000001\n");}
|
||||
#endif
|
||||
|
||||
#define CloseMessage(...) {if (gl_File!=NULL) fclose(gl_File);}
|
||||
|
||||
|
||||
#else
|
||||
/**
|
||||
* Open the file for logging (if LOG_MESSAGE=1 was passed during compilation)
|
||||
*/
|
||||
#define OpenMessage(...)
|
||||
/**
|
||||
* Print a message (like printf) into the file ant flush the content to disk (if LOG_MESSAGE=1 was passed during compilation)
|
||||
*/
|
||||
#define Message(...)
|
||||
/**
|
||||
* Close the file for logging (if LOG_MESSAGE=1 was passed during compilation)
|
||||
*/
|
||||
#define CloseMessage(...)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __CDT_PARSER__
|
||||
typedef unsigned long DWORD64;
|
||||
typedef unsigned long DWORD32;
|
||||
|
||||
#define STDMETHOD(method) virtual HRESULT method
|
||||
#define STDMETHOD_(ret, method) virtual ret method
|
||||
#define sprintf_s(...)
|
||||
#define swprintf_s(...)
|
||||
#define strcat_s(...)
|
||||
#define fprintf(...)
|
||||
#define fclose(...)
|
||||
#define fseek(...)
|
||||
#define ftell(...) 0
|
||||
#define fflush(...)
|
||||
#define qsort(...)
|
||||
typedef LONG HRESULT;
|
||||
|
||||
#define UNREFERENCED_PARAMETER(...)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* uMod_DEFINES_H_ */
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "uMod_Detour.h"
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
uMod_Detour::uMod_Detour() : NumOfEntries(0), Entries(NULL),
|
||||
Detour_FreeLibrary(5),
|
||||
Detour_LoadLibraryA(5),
|
||||
Detour_LoadLibraryW(5),
|
||||
Detour_LoadLibraryExA(5),
|
||||
Detour_LoadLibraryExW(5)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uMod_Detour::~uMod_Detour()
|
||||
{
|
||||
if (Entries!=NULL) delete [] Entries;
|
||||
}
|
||||
|
||||
|
||||
void uMod_Detour::Init(void)
|
||||
{
|
||||
Detour_FreeLibrary.SetOrigFunction(FreeLibrary);
|
||||
Detour_FreeLibrary.SetTargetFunction(uMod_FreeLibrary);
|
||||
Detour_FreeLibrary.Detour();
|
||||
|
||||
Detour_LoadLibraryA.SetOrigFunction(LoadLibraryA);
|
||||
Detour_LoadLibraryA.SetTargetFunction(uMod_LoadLibraryA);
|
||||
Detour_LoadLibraryA.Detour();
|
||||
|
||||
Detour_LoadLibraryW.SetOrigFunction(LoadLibraryW);
|
||||
Detour_LoadLibraryW.SetTargetFunction(uMod_LoadLibraryW);
|
||||
Detour_LoadLibraryW.Detour();
|
||||
|
||||
Detour_LoadLibraryExA.SetOrigFunction(LoadLibraryExA);
|
||||
Detour_LoadLibraryExA.SetTargetFunction(uMod_LoadLibraryExA);
|
||||
Detour_LoadLibraryExA.Detour();
|
||||
|
||||
Detour_LoadLibraryExW.SetOrigFunction(LoadLibraryExW);
|
||||
Detour_LoadLibraryExW.SetTargetFunction(uMod_LoadLibraryExW);
|
||||
Detour_LoadLibraryExW.Detour();
|
||||
|
||||
|
||||
//for (int i=0; i<NumOfEntries; i++)
|
||||
// Entries[i]->Detour();
|
||||
}
|
||||
|
||||
void uMod_Detour::Exit(void)
|
||||
{
|
||||
Detour_FreeLibrary.Retour();
|
||||
Detour_LoadLibraryA.Retour();
|
||||
Detour_LoadLibraryW.Retour();
|
||||
Detour_LoadLibraryExA.Retour();
|
||||
Detour_LoadLibraryExW.Retour();
|
||||
|
||||
//for (int i=0; i<NumOfEntries; i++)
|
||||
// Entries[i]->Retour();
|
||||
}
|
||||
|
||||
int uMod_Detour::AddEntry( uMod_Detour_Entry_Base* entry)
|
||||
{
|
||||
uMod_Detour_Entry_Base** temp = new uMod_Detour_Entry_Base*[NumOfEntries+1];
|
||||
|
||||
if (Entries!=NULL)
|
||||
{
|
||||
for (int i=0; i<NumOfEntries; i++)
|
||||
temp[i] = Entries[i];
|
||||
delete [] Entries;
|
||||
}
|
||||
Entries = temp;
|
||||
|
||||
Entries[NumOfEntries] = entry;
|
||||
|
||||
NumOfEntries++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void uMod_Detour::FreeLib( HMODULE plib)
|
||||
{
|
||||
Message("uMod_Detour::FreeLib( %p )\n", plib);
|
||||
if (plib==NULL) return;
|
||||
|
||||
for (int i=0; i<NumOfEntries; i++)
|
||||
Entries[i]->FreeLib( plib);
|
||||
}
|
||||
|
||||
void uMod_Detour::TestLib(const char* lib_name, HMODULE plib)
|
||||
{
|
||||
Message("uMod_Detour::TestLib( %s, %p )\n", lib_name, plib);
|
||||
if (lib_name==NULL) return;
|
||||
if (plib==NULL) return;
|
||||
|
||||
for (int i=0; i<NumOfEntries; i++)
|
||||
Entries[i]->TestLib( lib_name, plib);
|
||||
}
|
||||
|
||||
void uMod_Detour::TestLib(const wchar_t* lib_name, HMODULE plib)
|
||||
{
|
||||
Message("uMod_Detour::TestLib( %ls, %p )\n", lib_name, plib);
|
||||
if (lib_name==NULL) return;
|
||||
if (plib==NULL) return;
|
||||
|
||||
for (int i=0; i<NumOfEntries; i++)
|
||||
Entries[i]->TestLib( lib_name, plib);
|
||||
}
|
||||
|
||||
|
||||
uMod_Detour GlobalDetour;
|
||||
|
||||
|
||||
BOOL WINAPI uMod_FreeLibrary( HMODULE hModule)
|
||||
{
|
||||
GlobalDetour.Detour_FreeLibrary.Retour(); //retour the FreeLibrary function
|
||||
|
||||
BOOL ret = FreeLibrary( hModule); // now call the original function
|
||||
Message("%d = uMod_FreeLibrary( %p )\n", ret, hModule);
|
||||
|
||||
GlobalDetour.FreeLib(hModule); // notify all detoured function, that this library was once more freed
|
||||
|
||||
GlobalDetour.Detour_FreeLibrary.Detour(); // detour again the FreeLibrary function
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HMODULE WINAPI uMod_LoadLibraryA( LPCSTR lpFileName)
|
||||
{
|
||||
GlobalDetour.Detour_LoadLibraryA.Retour(); //retour the LoadLibraryA function
|
||||
|
||||
HMODULE ret = LoadLibraryA( lpFileName); // now call the original function
|
||||
Message("%p = uMod_LoadLibraryA( %s )\n", ret, lpFileName);
|
||||
|
||||
GlobalDetour.TestLib( lpFileName, ret); // notify all detoured function, that this library was once more loaded
|
||||
|
||||
GlobalDetour.Detour_LoadLibraryA.Detour(); // detour again the LoadLibraryA function
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HMODULE WINAPI uMod_LoadLibraryW( LPCWSTR lpFileName)
|
||||
{
|
||||
GlobalDetour.Detour_LoadLibraryW.Retour(); //retour the LoadLibraryW function
|
||||
|
||||
HMODULE ret = LoadLibraryW( lpFileName); // now call the original function
|
||||
GlobalDetour.TestLib( lpFileName, ret); // notify all detoured function, that this library was once more loaded
|
||||
Message("%p = uMod_LoadLibraryW( %ls )\n", ret, lpFileName);
|
||||
|
||||
GlobalDetour.Detour_LoadLibraryW.Detour(); // detour again the LoadLibraryW function
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HMODULE WINAPI uMod_LoadLibraryExA( LPCSTR lpFileName, HANDLE hFile, DWORD dwFlags)
|
||||
{
|
||||
GlobalDetour.Detour_LoadLibraryExA.Retour(); //retour the LoadLibraryExA function
|
||||
|
||||
HMODULE ret = LoadLibraryExA( lpFileName, hFile, dwFlags); // now call the original function
|
||||
Message("%p = uMod_LoadLibraryExA( %s, %p, %d)\n", ret, lpFileName, hFile, dwFlags);
|
||||
|
||||
if (dwFlags==0)
|
||||
{
|
||||
GlobalDetour.TestLib( lpFileName, ret); // notify all detoured function, that this library was once more loaded
|
||||
}
|
||||
|
||||
GlobalDetour.Detour_LoadLibraryExA.Detour(); // detour again the LoadLibraryExA function
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HMODULE WINAPI uMod_LoadLibraryExW( LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags)
|
||||
{
|
||||
GlobalDetour.Detour_LoadLibraryExW.Retour(); //retour the LoadLibraryExA function
|
||||
|
||||
HMODULE ret = LoadLibraryExW( lpFileName, hFile, dwFlags); // now call the original function
|
||||
Message("%p = uMod_LoadLibraryExW( %ls, %p, %d)\n", ret, lpFileName, hFile, dwFlags);
|
||||
|
||||
if (dwFlags==0)
|
||||
{
|
||||
GlobalDetour.TestLib( lpFileName, ret); // notify all detoured function, that this library was once more loaded
|
||||
}
|
||||
|
||||
GlobalDetour.Detour_LoadLibraryExW.Detour(); // detour again the LoadLibraryExA function
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef UMOD_DETOUR_H_
|
||||
#define UMOD_DETOUR_H_
|
||||
|
||||
#include "uMod_DetourEntry.h"
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __CDT_PARSER__
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
typedef BOOL (WINAPI *FreeLibrary_type)( HMODULE hModule);
|
||||
typedef HMODULE (WINAPI *LoadLibraryA_type)( LPCSTR lpFileName);
|
||||
typedef HMODULE (WINAPI *LoadLibraryW_type)( LPCWSTR lpFileName);
|
||||
typedef HMODULE (WINAPI *LoadLibraryExA_type)( LPCSTR lpFileName, HANDLE hFile, DWORD dwFlags);
|
||||
typedef HMODULE (WINAPI *LoadLibraryExW_type)( LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags);
|
||||
|
||||
BOOL WINAPI uMod_FreeLibrary( HMODULE hModule);
|
||||
HMODULE WINAPI uMod_LoadLibraryA( LPCSTR lpFileName);
|
||||
HMODULE WINAPI uMod_LoadLibraryW( LPCWSTR lpFileName);
|
||||
HMODULE WINAPI uMod_LoadLibraryExA( LPCSTR lpFileName, HANDLE hFile, DWORD dwFlags);
|
||||
HMODULE WINAPI uMod_LoadLibraryExW( LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags);
|
||||
|
||||
class uMod_Detour
|
||||
{
|
||||
public:
|
||||
uMod_Detour();
|
||||
~uMod_Detour();
|
||||
|
||||
|
||||
void Init();
|
||||
void Exit();
|
||||
|
||||
int AddEntry( uMod_Detour_Entry_Base* entry);
|
||||
|
||||
|
||||
void FreeLib( HMODULE plib);
|
||||
void TestLib(const char* lib_name, HMODULE plib);
|
||||
void TestLib(const wchar_t* lib_name, HMODULE plib);
|
||||
|
||||
|
||||
uMod_Detour_Entry<FreeLibrary_type> Detour_FreeLibrary;
|
||||
uMod_Detour_Entry<LoadLibraryA_type> Detour_LoadLibraryA;
|
||||
uMod_Detour_Entry<LoadLibraryW_type> Detour_LoadLibraryW;
|
||||
uMod_Detour_Entry<LoadLibraryExA_type> Detour_LoadLibraryExA;
|
||||
uMod_Detour_Entry<LoadLibraryExW_type> Detour_LoadLibraryExW;
|
||||
|
||||
private:
|
||||
int NumOfEntries;
|
||||
uMod_Detour_Entry_Base** Entries;
|
||||
};
|
||||
|
||||
extern uMod_Detour GlobalDetour;
|
||||
|
||||
#endif /* UMOD_DETOUR_H_ */
|
||||
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* uMod_DetourEntry.h
|
||||
*
|
||||
* Created on: 13.01.2013
|
||||
* Author: marts
|
||||
*/
|
||||
|
||||
#ifndef UMOD_DETOURENTRY_H_
|
||||
#define UMOD_DETOURENTRY_H_
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
#ifdef __CDT_PARSER__
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
class uMod_Detour_Entry_Base
|
||||
{
|
||||
public:
|
||||
uMod_Detour_Entry_Base() {}
|
||||
virtual ~uMod_Detour_Entry_Base() {}
|
||||
|
||||
virtual void TestLib(const char* lib_name, HMODULE plib) = 0;
|
||||
virtual void TestLib(const wchar_t* lib_name, HMODULE plib) = 0;
|
||||
virtual void FreeLib(HMODULE plib) = 0;
|
||||
|
||||
|
||||
virtual void Detour(void) = 0;
|
||||
virtual void Retour(void) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
class uMod_Detour_Entry : public uMod_Detour_Entry_Base
|
||||
{
|
||||
public:
|
||||
uMod_Detour_Entry(const int num_bytes);
|
||||
virtual ~uMod_Detour_Entry();
|
||||
|
||||
|
||||
virtual void TestLib(const char* lib_name, HMODULE plib);
|
||||
virtual void TestLib(const wchar_t* lib_name, HMODULE plib);
|
||||
virtual void FreeLib(HMODULE plib);
|
||||
|
||||
virtual void Detour(void);
|
||||
virtual void Retour(void);
|
||||
bool CheckForDetour();
|
||||
|
||||
int SetFunctionName( const char* name) {return SetName( FunctionName, name);}
|
||||
int SetLibName( const char* name) {return SetName( LibName, name);}
|
||||
int SetFullLibName( const char* name) {return SetName( FullLibName, name);}
|
||||
|
||||
int SetLibName( const wchar_t* name) {return SetName( LibNameW, name);}
|
||||
int SetFullLibName( const wchar_t* name) {return SetName( FullLibNameW, name);}
|
||||
|
||||
void SetOrigFunction(T func) {OrigFunction = func;}
|
||||
void SetTargetFunction(T func) {TargetFunction = func;}
|
||||
|
||||
T Function(void) const {return OrigFunction;}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int SetName( char* &member_var, const char* name);
|
||||
int SetName( wchar_t* &member_var, const wchar_t* name);
|
||||
|
||||
char* FunctionName;
|
||||
char* LibName;
|
||||
char* FullLibName;
|
||||
|
||||
wchar_t* LibNameW;
|
||||
wchar_t* FullLibNameW;
|
||||
|
||||
HMODULE PLibrary;
|
||||
int RefCounter;
|
||||
|
||||
|
||||
|
||||
const int NumBytes;
|
||||
T OrigFunction;
|
||||
T TargetFunction;
|
||||
|
||||
BYTE* DetourFunction;
|
||||
bool IsDetoured;
|
||||
bool IsFailed;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
uMod_Detour_Entry<T>::uMod_Detour_Entry(const int num_bytes) : FunctionName(NULL), LibName(NULL), FullLibName(NULL),
|
||||
LibNameW(NULL), FullLibNameW(NULL), PLibrary(NULL),
|
||||
NumBytes(num_bytes), OrigFunction(NULL), TargetFunction(NULL), DetourFunction(NULL), IsDetoured(false), IsFailed(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
uMod_Detour_Entry<T>::~uMod_Detour_Entry()
|
||||
{
|
||||
if (FunctionName!=NULL) delete [] FunctionName;
|
||||
if (LibName!=NULL) delete [] LibName;
|
||||
if (FullLibName!=NULL) delete [] FullLibName;
|
||||
if (LibNameW!=NULL) delete [] LibNameW;
|
||||
if (FullLibNameW!=NULL) delete [] FullLibNameW;
|
||||
if (DetourFunction!=NULL) delete [] DetourFunction;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void uMod_Detour_Entry<T>::TestLib(const char* lib_name, HMODULE plib)
|
||||
{
|
||||
if (lib_name==NULL) return;
|
||||
if (plib==NULL) return;
|
||||
if (FunctionName==NULL) return;
|
||||
if (LibName==NULL) return;
|
||||
|
||||
if (PLibrary==plib)
|
||||
{
|
||||
RefCounter++;
|
||||
//return;
|
||||
}
|
||||
|
||||
int len=0;
|
||||
while (lib_name[len]) len++;
|
||||
while (len>=0 && (lib_name[len]!='/' && lib_name[len]!='\\')) len--;
|
||||
len++;
|
||||
|
||||
if (_stricmp( &lib_name[len], LibName)==0)
|
||||
{
|
||||
bool set_detour = true;
|
||||
if (FullLibName!=NULL)
|
||||
{
|
||||
set_detour = false;
|
||||
GlobalDetour.Detour_LoadLibraryA.Retour();
|
||||
GlobalDetour.Detour_FreeLibrary.Retour();
|
||||
HMODULE test_handle = LoadLibraryA( FullLibName); //get handle of original library
|
||||
if (test_handle==NULL || test_handle==plib) set_detour = true; // test if library (loaded by the game) is the original one or a fake one
|
||||
//if (test_handle!=NULL) FreeLibrary( test_handle); // free the library (we don't want top disturb our own RefCounter)
|
||||
GlobalDetour.Detour_LoadLibraryA.Detour();
|
||||
GlobalDetour.Detour_FreeLibrary.Detour();
|
||||
}
|
||||
|
||||
if (!set_detour) return; // it is not the official library (or FullLibName is not set)
|
||||
if (CheckForDetour()) return;
|
||||
|
||||
OrigFunction = (T) GetProcAddress(plib, FunctionName);
|
||||
if (OrigFunction==NULL) return; // this library does not contain the function we want to detour
|
||||
|
||||
|
||||
Message("uMod_Detour_Entry<T>::TestLib( %s, %p ) set detour -> %s \n", lib_name, plib, FunctionName);
|
||||
|
||||
RefCounter = 1;
|
||||
PLibrary = plib;
|
||||
|
||||
IsDetoured = false;
|
||||
IsFailed = false;
|
||||
Detour();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void uMod_Detour_Entry<T>::TestLib(const wchar_t* lib_name, HMODULE plib)
|
||||
{
|
||||
if (lib_name==NULL) return;
|
||||
if (plib==NULL) return;
|
||||
if (FunctionName==NULL) return;
|
||||
if (LibNameW==NULL) return;
|
||||
|
||||
if (PLibrary==plib)
|
||||
{
|
||||
RefCounter++;
|
||||
// return;
|
||||
}
|
||||
|
||||
int len=0;
|
||||
while (lib_name[len]) len++;
|
||||
while (len>=0 && (lib_name[len]!='/' && lib_name[len]!='\\' )) len--;
|
||||
len++;
|
||||
|
||||
if (_wcsicmp( &lib_name[len], LibNameW)==0)
|
||||
{
|
||||
bool set_detour = true;
|
||||
if (FullLibNameW!=NULL)
|
||||
{
|
||||
set_detour = false;
|
||||
|
||||
GlobalDetour.Detour_LoadLibraryW.Retour();
|
||||
GlobalDetour.Detour_FreeLibrary.Retour();
|
||||
HMODULE test_handle = LoadLibraryW( FullLibNameW); //get handle of original library
|
||||
if (test_handle==NULL || test_handle==plib) set_detour = true; // test if library (loaded by the game) is the original one or a fake one
|
||||
if (test_handle!=NULL) FreeLibrary( test_handle); // free the library (we don't want top disturb our own RefCounter)
|
||||
|
||||
GlobalDetour.Detour_LoadLibraryW.Detour();
|
||||
GlobalDetour.Detour_FreeLibrary.Detour();
|
||||
}
|
||||
|
||||
if (!set_detour) return; // it is not the official library (or FullLibName is not set)
|
||||
if (CheckForDetour()) return;
|
||||
|
||||
OrigFunction = (T) GetProcAddress(plib, FunctionName);
|
||||
if (OrigFunction==NULL) return; // this library does not contain the function we want to detour
|
||||
|
||||
|
||||
Message("uMod_Detour_Entry<T>::TestLib( %ls, %p ) set detour -> %s \n", lib_name, plib, FunctionName);
|
||||
|
||||
RefCounter = 1;
|
||||
PLibrary = plib;
|
||||
|
||||
IsDetoured = false;
|
||||
IsFailed = false;
|
||||
Detour();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void uMod_Detour_Entry<T>::FreeLib(HMODULE plib)
|
||||
{
|
||||
if (plib==NULL) return;
|
||||
if (plib==PLibrary) RefCounter--;
|
||||
if (RefCounter<=0) PLibrary = NULL;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void uMod_Detour_Entry<T>::Detour(void)
|
||||
{
|
||||
if (IsDetoured || IsFailed) return;
|
||||
if (DetourFunction==NULL)
|
||||
{
|
||||
DetourFunction = new BYTE[NumBytes+5];
|
||||
}
|
||||
BYTE *jmp = DetourFunction;
|
||||
BYTE *src = (BYTE*) OrigFunction;
|
||||
const BYTE *dst = (BYTE*) TargetFunction;
|
||||
const int len = NumBytes;
|
||||
|
||||
DWORD dwback = 0;
|
||||
//(jmp, len+5, PAGE_EXECUTE_READWRITE, &dwback); //This is the addition needed for Windows 7 RC
|
||||
if(!VirtualProtect(src, NumBytes, PAGE_READWRITE, &dwback)) IsFailed = true;
|
||||
if(!memcpy(jmp, src, len)) IsFailed = true;
|
||||
jmp += len;
|
||||
jmp[0] = 0xE9;
|
||||
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
|
||||
//memset(src, 0x90, len);
|
||||
src[0] = 0xE9;
|
||||
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
|
||||
if(!VirtualProtect(src, len, dwback, &dwback)) IsFailed = true;
|
||||
|
||||
IsDetoured = true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void uMod_Detour_Entry<T>::Retour(void)
|
||||
{
|
||||
if (!IsDetoured || IsFailed) return;
|
||||
|
||||
BYTE *src = (BYTE*) OrigFunction;
|
||||
BYTE *restore = DetourFunction;
|
||||
const int len = NumBytes;
|
||||
DWORD dwback;
|
||||
if(!VirtualProtect(src, len, PAGE_READWRITE, &dwback)) IsFailed = true;
|
||||
if(!memcpy(src, restore, len)) IsFailed = true;
|
||||
restore[0] = 0xE9;
|
||||
*(DWORD*)(restore+1) = (DWORD)(src - restore) - 5;
|
||||
|
||||
if(!VirtualProtect(src, len, dwback, &dwback)) IsFailed = true;
|
||||
|
||||
IsDetoured = false;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
bool uMod_Detour_Entry<T>::CheckForDetour()
|
||||
{
|
||||
if (DetourFunction==NULL) return false;
|
||||
|
||||
//BYTE *jmp = DetourFunction;
|
||||
BYTE *src = (BYTE*) OrigFunction;
|
||||
const BYTE *dst = (BYTE*) TargetFunction;
|
||||
//const int len = NumBytes;
|
||||
|
||||
if (src[0] != 0xE9) return false;
|
||||
if ( *(DWORD*)(src+1) != (DWORD)(dst - src) - 5) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int uMod_Detour_Entry<T>::SetName( char* &member_var, const char* name)
|
||||
{
|
||||
if (member_var!=NULL) delete [] member_var;
|
||||
member_var = NULL;
|
||||
int len=0;
|
||||
while (name[len]) len++;
|
||||
len++;
|
||||
|
||||
member_var = new char[len];
|
||||
len = 0;
|
||||
|
||||
while (name[len]) {member_var[len] = name[len]; len++;}
|
||||
member_var[len] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int uMod_Detour_Entry<T>::SetName( wchar_t* &member_var, const wchar_t* name)
|
||||
{
|
||||
if (member_var!=NULL) delete [] member_var;
|
||||
member_var = NULL;
|
||||
int len=0;
|
||||
while (name[len]) len++;
|
||||
len++;
|
||||
|
||||
member_var = new wchar_t[len];
|
||||
len = 0;
|
||||
|
||||
while (name[len]) {member_var[len] = name[len]; len++;}
|
||||
member_var[len] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* UMOD_DETOURENTRY_H_ */
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_MAIN_H_
|
||||
#define uMod_MAIN_H_
|
||||
|
||||
#define WINVER _WIN32_WINNT_WINXP
|
||||
#define _WIN32_WINNT _WIN32_WINNT_WINXP
|
||||
#define _WIN32_WINDOWS _WIN32_WINNT_WINXP
|
||||
#define NTDDI_VERSION NTDDI_WINXP
|
||||
//#define NTDDI_LONGHORN NTDDI_WINXP
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#include <D3D10Misc.h>
|
||||
#include <d3dx10.h>
|
||||
//#include "detours.h"
|
||||
|
||||
|
||||
#include "../uMod_GlobalDefines.h"
|
||||
#include "../uMod_Error.h"
|
||||
#include "../uMod_Utils.h"
|
||||
|
||||
#include "uMod_Defines.h"
|
||||
|
||||
#include "uMod_TextureFunction.h"
|
||||
|
||||
#include "uMod_DetourEntry.h"
|
||||
#include "uMod_Detour.h"
|
||||
#include "uMod_DXMain_dll.h"
|
||||
|
||||
|
||||
#include "uMod_ArrayHandler.h"
|
||||
#include "uMod_TextureServer.h"
|
||||
#include "uMod_TextureClient.h"
|
||||
|
||||
/**
|
||||
* global variable: HINSTANCE
|
||||
*/
|
||||
extern HINSTANCE gl_hThisInstance;
|
||||
|
||||
/**
|
||||
* gloabal variable: pointer to TextureServer
|
||||
*/
|
||||
extern uMod_TextureServer* gl_TextureServer;
|
||||
|
||||
/**
|
||||
* gloabal variable: pointer to the server thread
|
||||
*/
|
||||
extern HANDLE gl_ServerThread;
|
||||
|
||||
/**
|
||||
* gloabal variable: error state. This is not supported at the moment.
|
||||
*/
|
||||
extern unsigned int gl_ErrorState;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
uMod_TextureClient::uMod_TextureClient(const int version) : Version(version)
|
||||
{
|
||||
Message("uMod_TextureClient::uMod_TextureClient(void): %p\n", this);
|
||||
Server = NULL;
|
||||
BoolSaveAllTextures = false;
|
||||
BoolSaveSingleTexture = false;
|
||||
BoolShowTextureString = false;
|
||||
|
||||
KeyBack = 0;
|
||||
KeySave = 0;
|
||||
KeyNext = 0;
|
||||
SavePath[0]=0;
|
||||
GameName[0]=0;
|
||||
|
||||
NumberToMod = 0;
|
||||
FileToMod = NULL;
|
||||
|
||||
Mutex = CreateMutex(NULL, false, NULL);
|
||||
|
||||
Update = NULL;
|
||||
NumberOfUpdate = -1;
|
||||
FontColour = D3DCOLOR_ARGB(255,255,0,0);
|
||||
TextureColour = D3DCOLOR_ARGB(255,0,255,0);
|
||||
|
||||
WidthFilter = 0u;
|
||||
HeightFilter = 0u;
|
||||
DepthFilter = 0u;
|
||||
|
||||
FormatFilter = 0u;
|
||||
|
||||
FileFormat = uMod_D3DXIFF_DDS;
|
||||
}
|
||||
|
||||
uMod_TextureClient::~uMod_TextureClient(void)
|
||||
{
|
||||
Message("uMod_TextureClient::~uMod_TextureClient(void): %p\n", this);
|
||||
if (Server!=NULL) Server->RemoveClient(this, Version);
|
||||
|
||||
if (Mutex!=NULL) CloseHandle(Mutex);
|
||||
|
||||
if (Update!=NULL) delete [] Update;
|
||||
if (FileToMod!=NULL) delete [] FileToMod;
|
||||
/*
|
||||
{
|
||||
for (int i=0; i<NumberToMod; i++) if (FileToMod[i].Textures!=NULL) delete [] FileToMod[i].Textures;
|
||||
delete [] FileToMod;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
int uMod_TextureClient::ConnectToServer(uMod_TextureServer* server)
|
||||
{
|
||||
Server = server;
|
||||
if (Server!=NULL)
|
||||
{
|
||||
if (Server->AddClient( this, FileToMod, NumberToMod, Version))
|
||||
{
|
||||
Server=NULL;
|
||||
NumberToMod = 0;
|
||||
FileToMod = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<NumberToMod; i++) {FileToMod[i].NumberOfTextures=0; FileToMod[i].Textures = NULL;}
|
||||
}
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::SetSaveDirectory( wchar_t *dir)
|
||||
{
|
||||
Message("uMod_TextureClient::SetSaveDirectory( %ls): %p\n", dir, this);
|
||||
int i = 0;
|
||||
for (i=0; i<MAX_PATH && (dir[i]); i++) SavePath[i] = dir[i];
|
||||
if (i==MAX_PATH)
|
||||
{
|
||||
SavePath[0]=0;
|
||||
return (RETURN_BAD_ARGUMENT);
|
||||
}
|
||||
else SavePath[i]=0;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::SetGameName( wchar_t *name)
|
||||
{
|
||||
Message("uMod_TextureClient::SetGameName( %ls): %p\n", name, this);
|
||||
int i = 0;
|
||||
for (i=0; i<MAX_PATH && (name[i]); i++) GameName[i] = name[i];
|
||||
if (i==MAX_PATH)
|
||||
{
|
||||
GameName[0]=0;
|
||||
return (RETURN_BAD_ARGUMENT);
|
||||
}
|
||||
else GameName[i]=0;
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int uMod_TextureClient::AddUpdate(TextureEntry* update, int number) //client must delete the update array
|
||||
{
|
||||
Message("AddUpdate( %p, %d): %p\n", update, number, this);
|
||||
if (int ret = LockMutex()) {gl_ErrorState |= uMod_ERROR_TEXTURE; return (ret);}
|
||||
if (Update!=NULL) delete [] Update;
|
||||
Update = update;
|
||||
NumberOfUpdate = number;
|
||||
return (UnlockMutex());
|
||||
}
|
||||
|
||||
|
||||
int uMod_TextureClient::LockMutex(void)
|
||||
{
|
||||
if (( gl_ErrorState & (uMod_ERROR_FATAL | uMod_ERROR_MUTEX) )) return (RETURN_NO_MUTEX);
|
||||
if (WAIT_OBJECT_0!=WaitForSingleObject( Mutex, 100)) return (RETURN_MUTEX_LOCK); //waiting 100ms, to wait infinite pass INFINITE
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient::UnlockMutex(void)
|
||||
{
|
||||
if (ReleaseMutex(Mutex)==0) return (RETURN_MUTEX_UNLOCK);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
int uMod_TextureClient::GetIndex( DWORD64 hash, int num_index_list, int *index_list)
|
||||
{
|
||||
if(NumberToMod>0)
|
||||
{
|
||||
if (index_list==NULL || num_index_list==0)
|
||||
{
|
||||
if (hash<FileToMod[0].Content()->Hash || hash>FileToMod[NumberToMod-1].Content()->Hash) return (-1);
|
||||
int pos = NumberToMod/2;
|
||||
int begin = 0;
|
||||
int end = NumberToMod-1;
|
||||
|
||||
// We look in the middle of the interval and each step we halve the interval,
|
||||
// unless we find the texture or the size of the interval is less than 3.
|
||||
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
|
||||
while (begin+1<end) // as long as the interval is longer than two
|
||||
{
|
||||
if (hash > FileToMod[pos].Content()->Hash) // the new interval is the right half of the actual interval
|
||||
{
|
||||
begin = pos+1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else if (hash < FileToMod[pos].Content()->Hash) // the new interval is the left half of the actual interval
|
||||
{
|
||||
end = pos-1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else {return (pos); break;} // we hit the correct hash
|
||||
}
|
||||
for ( pos=begin; pos<=end; pos++) if (FileToMod[pos].Content()->Hash==hash) return (pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hash<FileToMod[index_list[0]].Content()->Hash || hash>FileToMod[index_list[num_index_list-1]].Content()->Hash) return (-1);
|
||||
int pos = num_index_list/2;
|
||||
int begin = 0;
|
||||
int end = num_index_list-1;
|
||||
|
||||
// We look in the middle of the interval and each step we halve the interval,
|
||||
// unless we find the texture or the size of the interval is less than 3.
|
||||
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
|
||||
while (begin+1<end) // as long as the interval is longer than two
|
||||
{
|
||||
if (hash > FileToMod[index_list[pos]].Content()->Hash) // the new interval is the right half of the actual interval
|
||||
{
|
||||
begin = pos+1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else if (hash < FileToMod[index_list[pos]].Content()->Hash) // the new interval is the left half of the actual interval
|
||||
{
|
||||
end = pos-1; // the new interval does not contain the index "pos"
|
||||
pos = (begin + end)/2; // set "pos" somewhere inside the new interval
|
||||
}
|
||||
else {return (index_list[pos]); break;} // we hit the correct hash
|
||||
}
|
||||
for ( pos=begin; pos<=end; pos++) if (FileToMod[index_list[pos]].Content()->Hash==hash) return (index_list[pos]);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef uMod_TEXTURECLIENT_HPP
|
||||
#define uMod_TEXTURECLIENT_HPP
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3d10.h>
|
||||
#include "..\uMod_GlobalDefines.h"
|
||||
#include "..\uMod_Error.h"
|
||||
|
||||
|
||||
class uMod_TextureServer;
|
||||
|
||||
/**
|
||||
* An object of this class is owned by each d3dXX device.
|
||||
* functions called by the Server are called from the server thread instance.
|
||||
* All other functions are called from the render thread instance of the game itself.
|
||||
*/
|
||||
|
||||
class uMod_TextureClient
|
||||
{
|
||||
public:
|
||||
uMod_TextureClient(const int version);
|
||||
virtual ~uMod_TextureClient(void);
|
||||
|
||||
/**
|
||||
* Connect to the server. (called from the instance, which creates the client, e.g. uMod_IDirect3DDevice9::uMod_IDirect3DDevice9)
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int ConnectToServer(uMod_TextureServer* server);
|
||||
|
||||
/**
|
||||
* Enable/Disable the "save all texture" mode. (called from the server)
|
||||
* @param val
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
virtual int SaveAllTextures(bool val) = 0;
|
||||
|
||||
/**
|
||||
* Enable/Disable the "save all texture" mode. (called from the server)
|
||||
* @param val
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
virtual int SaveSingleTexture(bool val) = 0;
|
||||
|
||||
/**
|
||||
* Enable/Disable the string in the left upper corner during save single texture mode (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int ShowTextureString(bool val) {BoolShowTextureString = val; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* Enable/Disable the string in the left upper corner during save single texture mode (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int ShowSingleTexture(bool val) {BoolShowSingleTexture = val; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* Enable/Disable the hashing with CRC32, which is needed to support also tpf mods (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
virtual int SupportTPF(bool val) = 0;
|
||||
|
||||
/**
|
||||
* Enable/Disable the computation of the hash of render targets.
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int ComputeRenderTargets(bool val) {BoolComputeRenderTargets = val; return (RETURN_OK);}
|
||||
|
||||
/**ComputeRenderTargets
|
||||
* Set the directory, wher the texture should be stored (called from the server)
|
||||
* @param dir
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int SetSaveDirectory( wchar_t *dir);
|
||||
|
||||
/**
|
||||
* Set the name of the game (default name of executabel without the extension .exe) (called from the server)
|
||||
* @param name
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int SetGameName( wchar_t *name);
|
||||
|
||||
/**
|
||||
* Set the key to got to the previous texture (called from the server)
|
||||
* @param key
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
int SetKeyBack( int key) {if (key>0) KeyBack = key; return (RETURN_OK);}
|
||||
/**
|
||||
* Set the key for saving the texture (called from the server)
|
||||
* @param key
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
int SetKeySave( int key) {if (key>0) KeySave = key; return (RETURN_OK);}
|
||||
/**
|
||||
* Set the key to go to the next texture (called from the server)
|
||||
* @param key
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
int SetKeyNext( int key) {if (key>0) KeyNext = key; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* Set the font color "during save single" texture mode. (called from the server)
|
||||
* @param colour
|
||||
* @return
|
||||
*/
|
||||
int SetFontColour( DWORD64 colour) {FontColour = (D3DCOLOR) colour; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* Set the texture color "during save single" texture mode. (called from the server)
|
||||
* @param colour
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
int SetTextureColour( DWORD64 colour) {TextureColour = (D3DCOLOR) colour; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* @param[in] format
|
||||
* @return
|
||||
*/
|
||||
int SetFileFormat(DWORD64 format) {FileFormat = format; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* @param[in] format
|
||||
* @return
|
||||
*/
|
||||
int SetFormatFilter(DWORD64 format) {FormatFilter = format; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* @param[in] size
|
||||
* @return
|
||||
*/
|
||||
int SetWidthFilter(DWORD64 size) {WidthFilter = size; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* @param[in] size
|
||||
* @return
|
||||
*/
|
||||
int SetHeightFilter(DWORD64 size) {HeightFilter = size; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* @param[in] size
|
||||
* @return
|
||||
*/
|
||||
int SetDepthFilter(DWORD64 size) {DepthFilter = size; return (RETURN_OK);}
|
||||
|
||||
/**
|
||||
* The server add an update to the client.(called from server)
|
||||
* @param update Pointer to an array of TextureFileStruct, the client \b must delete this array!
|
||||
* @param number number of entries
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int AddUpdate(TextureEntry* update, int number);
|
||||
|
||||
|
||||
/**
|
||||
* Merge the latest update (called from client -> e.g. uMod_IDirect3DDevice9::BeginScene())
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
virtual int MergeUpdate(void) = 0;
|
||||
|
||||
|
||||
bool BoolSaveAllTextures; //!< true if all textures should be saved
|
||||
bool BoolSaveSingleTexture; //!< true if "save single texture" mode is enabled
|
||||
bool BoolShowTextureString; //!< true if a string should be displayed during "save single texture" mode is enabled
|
||||
bool BoolShowSingleTexture; //!< true if the texture should be displayed during "save single texture" mode is enabled
|
||||
bool BoolComputeRenderTargets; //!< true if the hash of render targets should be computed (very slow because each frame the hash must be recomputed)
|
||||
|
||||
|
||||
int KeyBack; //!< key value for going to the previous texture
|
||||
int KeySave; //!< key value for saving the current texture
|
||||
int KeyNext; //!< key value for going to the next texture
|
||||
|
||||
D3DCOLOR FontColour; //!< color of the message ("save single texture" mode)
|
||||
D3DCOLOR TextureColour; //!< color of the texture ("save single texture" mode)
|
||||
|
||||
|
||||
DWORD64 FileFormat; //!< file format to which the texture should be saved
|
||||
DWORD64 FormatFilter; //!< texture format which should be saved (all==0, else bitwise 1=save,0=don't save)
|
||||
DWORD64 WidthFilter; //!< filter min<<32 max, texture size must be min<=size<=max
|
||||
DWORD64 HeightFilter; //!< filter min<<32 max, texture size must be min<=size<=max
|
||||
DWORD64 DepthFilter; //!< filter min<<32 max, texture size must be min<=size<=max
|
||||
|
||||
const int Version;
|
||||
uMod_TextureServer* Server; //!< Pointer to the server
|
||||
wchar_t SavePath[MAX_PATH]; //!< saving directory
|
||||
wchar_t GameName[MAX_PATH]; //!< game name
|
||||
|
||||
TextureEntry* Update; //!< array which stores the file in memory and the hash of each texture to be modded
|
||||
int NumberOfUpdate; //!< number of texture to be modded
|
||||
|
||||
/**
|
||||
* Lock the mutex. The mutex protect the AddUpdate and MergeUpdate function to be called simultaneously.
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int LockMutex();
|
||||
/**
|
||||
* Unloock the mutex. The mutex protect the AddUpdate and MergeUpdate function to be called simultaneously.
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int UnlockMutex();
|
||||
HANDLE Mutex; //!< The mutex protect the AddUpdate and MergeUpdate function to be called simultaneously.
|
||||
|
||||
int NumberToMod; //!< number of texture to be modded
|
||||
TextureEntry* FileToMod; //!< array which stores the file in memory and the hash of each texture to be modded
|
||||
|
||||
/**
|
||||
* Find the given hash value in the \a FileToMod list. A vector with index can be passed. If so, only these index are considered in the search
|
||||
* @param hash hash value
|
||||
* @param num_index_list number of index vector
|
||||
* @param index_list pointer to the index vector
|
||||
* @return index or a negative value if the hash value was not found
|
||||
*/
|
||||
int GetIndex( DWORD64 hash, int num_index_list=0, int *index_list=(int*)0); // called from LookUpToMod(...);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* uMod_TEXTUREHANDLER_HPP_ */
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "uMod_Main.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* BIG THANKS TO RS !!
|
||||
*
|
||||
* who gave me his hashing algorithm (well or crc32 algorithm^^)
|
||||
*
|
||||
The hash function is CRC32 using polynomial 0xEDB88320.
|
||||
However, the hashed data is calculated incorrectly in TexMod: it's simply BytesPerPixel * Width * Height, from the beginning of the data (that is mapped using LockRect).
|
||||
The problem is that it doesn't take the pitch into account and BytesPerPixel may be wrong for some rare formats (not sure about that).
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define CRC32POLY 0xEDB88320 /* CRC-32 Polynom */
|
||||
#define ulCrc_in 0xffffffff
|
||||
/*
|
||||
DWORD32 GetCRC32( unsigned char *pcDatabuf, unsigned int ulDatalen)
|
||||
{
|
||||
unsigned int crc = ulCrc_in;
|
||||
for (unsigned int idx = 0u; idx<ulDatalen; idx++)
|
||||
{
|
||||
unsigned int data = *pcDatabuf++;
|
||||
for (unsigned int bit = 0u; bit<8u; bit++, data >>=1)
|
||||
{
|
||||
crc = (crc >> 1) ^ (((crc ^ data) & 1) ? CRC32POLY : 0);
|
||||
}
|
||||
}
|
||||
return (crc);
|
||||
}
|
||||
*/
|
||||
|
||||
void GetCRC32( DWORD32 &crc, unsigned char *pcDatabuf, unsigned int ulDatalen)
|
||||
{
|
||||
unsigned int byte;
|
||||
static unsigned int table[256];
|
||||
|
||||
// Set up the table, if necessary.
|
||||
|
||||
if (table[1] == 0)
|
||||
{
|
||||
for (byte = 0u; byte <= 255u; byte++)
|
||||
{
|
||||
crc = byte;
|
||||
for (int j = 7; j >= 0; j--)
|
||||
{ // Do eight times.
|
||||
unsigned int mask = -(crc & 1);
|
||||
crc = (crc >> 1) ^ (CRC32POLY & mask);
|
||||
}
|
||||
table[byte] = crc;
|
||||
}
|
||||
}
|
||||
|
||||
// Through with table setup, now calculate the CRC.
|
||||
|
||||
for (unsigned int i=0; i<ulDatalen; i++)
|
||||
{
|
||||
byte = pcDatabuf[i];
|
||||
crc = (crc >> 8) ^ table[(crc ^ byte) & 0xFF];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* poly 0x95AC9329AC4BC9B5ULL and init 0xFFFFFFFFFFFFFFFFULL
|
||||
*/
|
||||
const DWORD64 crctab64[256] = {
|
||||
0x0000000000000000ULL, 0x7ad870c830358979ULL, 0xf5b0e190606b12f2ULL,
|
||||
0x8f689158505e9b8bULL, 0xc038e5739841b68fULL, 0xbae095bba8743ff6ULL,
|
||||
0x358804e3f82aa47dULL, 0x4f50742bc81f2d04ULL, 0xab28ecb46814fe75ULL,
|
||||
0xd1f09c7c5821770cULL, 0x5e980d24087fec87ULL, 0x24407dec384a65feULL,
|
||||
0x6b1009c7f05548faULL, 0x11c8790fc060c183ULL, 0x9ea0e857903e5a08ULL,
|
||||
0xe478989fa00bd371ULL, 0x7d08ff3b88be6f81ULL, 0x07d08ff3b88be6f8ULL,
|
||||
0x88b81eabe8d57d73ULL, 0xf2606e63d8e0f40aULL, 0xbd301a4810ffd90eULL,
|
||||
0xc7e86a8020ca5077ULL, 0x4880fbd87094cbfcULL, 0x32588b1040a14285ULL,
|
||||
0xd620138fe0aa91f4ULL, 0xacf86347d09f188dULL, 0x2390f21f80c18306ULL,
|
||||
0x594882d7b0f40a7fULL, 0x1618f6fc78eb277bULL, 0x6cc0863448deae02ULL,
|
||||
0xe3a8176c18803589ULL, 0x997067a428b5bcf0ULL, 0xfa11fe77117cdf02ULL,
|
||||
0x80c98ebf2149567bULL, 0x0fa11fe77117cdf0ULL, 0x75796f2f41224489ULL,
|
||||
0x3a291b04893d698dULL, 0x40f16bccb908e0f4ULL, 0xcf99fa94e9567b7fULL,
|
||||
0xb5418a5cd963f206ULL, 0x513912c379682177ULL, 0x2be1620b495da80eULL,
|
||||
0xa489f35319033385ULL, 0xde51839b2936bafcULL, 0x9101f7b0e12997f8ULL,
|
||||
0xebd98778d11c1e81ULL, 0x64b116208142850aULL, 0x1e6966e8b1770c73ULL,
|
||||
0x8719014c99c2b083ULL, 0xfdc17184a9f739faULL, 0x72a9e0dcf9a9a271ULL,
|
||||
0x08719014c99c2b08ULL, 0x4721e43f0183060cULL, 0x3df994f731b68f75ULL,
|
||||
0xb29105af61e814feULL, 0xc849756751dd9d87ULL, 0x2c31edf8f1d64ef6ULL,
|
||||
0x56e99d30c1e3c78fULL, 0xd9810c6891bd5c04ULL, 0xa3597ca0a188d57dULL,
|
||||
0xec09088b6997f879ULL, 0x96d1784359a27100ULL, 0x19b9e91b09fcea8bULL,
|
||||
0x636199d339c963f2ULL, 0xdf7adabd7a6e2d6fULL, 0xa5a2aa754a5ba416ULL,
|
||||
0x2aca3b2d1a053f9dULL, 0x50124be52a30b6e4ULL, 0x1f423fcee22f9be0ULL,
|
||||
0x659a4f06d21a1299ULL, 0xeaf2de5e82448912ULL, 0x902aae96b271006bULL,
|
||||
0x74523609127ad31aULL, 0x0e8a46c1224f5a63ULL, 0x81e2d7997211c1e8ULL,
|
||||
0xfb3aa75142244891ULL, 0xb46ad37a8a3b6595ULL, 0xceb2a3b2ba0eececULL,
|
||||
0x41da32eaea507767ULL, 0x3b024222da65fe1eULL, 0xa2722586f2d042eeULL,
|
||||
0xd8aa554ec2e5cb97ULL, 0x57c2c41692bb501cULL, 0x2d1ab4dea28ed965ULL,
|
||||
0x624ac0f56a91f461ULL, 0x1892b03d5aa47d18ULL, 0x97fa21650afae693ULL,
|
||||
0xed2251ad3acf6feaULL, 0x095ac9329ac4bc9bULL, 0x7382b9faaaf135e2ULL,
|
||||
0xfcea28a2faafae69ULL, 0x8632586aca9a2710ULL, 0xc9622c4102850a14ULL,
|
||||
0xb3ba5c8932b0836dULL, 0x3cd2cdd162ee18e6ULL, 0x460abd1952db919fULL,
|
||||
0x256b24ca6b12f26dULL, 0x5fb354025b277b14ULL, 0xd0dbc55a0b79e09fULL,
|
||||
0xaa03b5923b4c69e6ULL, 0xe553c1b9f35344e2ULL, 0x9f8bb171c366cd9bULL,
|
||||
0x10e3202993385610ULL, 0x6a3b50e1a30ddf69ULL, 0x8e43c87e03060c18ULL,
|
||||
0xf49bb8b633338561ULL, 0x7bf329ee636d1eeaULL, 0x012b592653589793ULL,
|
||||
0x4e7b2d0d9b47ba97ULL, 0x34a35dc5ab7233eeULL, 0xbbcbcc9dfb2ca865ULL,
|
||||
0xc113bc55cb19211cULL, 0x5863dbf1e3ac9decULL, 0x22bbab39d3991495ULL,
|
||||
0xadd33a6183c78f1eULL, 0xd70b4aa9b3f20667ULL, 0x985b3e827bed2b63ULL,
|
||||
0xe2834e4a4bd8a21aULL, 0x6debdf121b863991ULL, 0x1733afda2bb3b0e8ULL,
|
||||
0xf34b37458bb86399ULL, 0x8993478dbb8deae0ULL, 0x06fbd6d5ebd3716bULL,
|
||||
0x7c23a61ddbe6f812ULL, 0x3373d23613f9d516ULL, 0x49aba2fe23cc5c6fULL,
|
||||
0xc6c333a67392c7e4ULL, 0xbc1b436e43a74e9dULL, 0x95ac9329ac4bc9b5ULL,
|
||||
0xef74e3e19c7e40ccULL, 0x601c72b9cc20db47ULL, 0x1ac40271fc15523eULL,
|
||||
0x5594765a340a7f3aULL, 0x2f4c0692043ff643ULL, 0xa02497ca54616dc8ULL,
|
||||
0xdafce7026454e4b1ULL, 0x3e847f9dc45f37c0ULL, 0x445c0f55f46abeb9ULL,
|
||||
0xcb349e0da4342532ULL, 0xb1eceec59401ac4bULL, 0xfebc9aee5c1e814fULL,
|
||||
0x8464ea266c2b0836ULL, 0x0b0c7b7e3c7593bdULL, 0x71d40bb60c401ac4ULL,
|
||||
0xe8a46c1224f5a634ULL, 0x927c1cda14c02f4dULL, 0x1d148d82449eb4c6ULL,
|
||||
0x67ccfd4a74ab3dbfULL, 0x289c8961bcb410bbULL, 0x5244f9a98c8199c2ULL,
|
||||
0xdd2c68f1dcdf0249ULL, 0xa7f41839ecea8b30ULL, 0x438c80a64ce15841ULL,
|
||||
0x3954f06e7cd4d138ULL, 0xb63c61362c8a4ab3ULL, 0xcce411fe1cbfc3caULL,
|
||||
0x83b465d5d4a0eeceULL, 0xf96c151de49567b7ULL, 0x76048445b4cbfc3cULL,
|
||||
0x0cdcf48d84fe7545ULL, 0x6fbd6d5ebd3716b7ULL, 0x15651d968d029fceULL,
|
||||
0x9a0d8ccedd5c0445ULL, 0xe0d5fc06ed698d3cULL, 0xaf85882d2576a038ULL,
|
||||
0xd55df8e515432941ULL, 0x5a3569bd451db2caULL, 0x20ed197575283bb3ULL,
|
||||
0xc49581ead523e8c2ULL, 0xbe4df122e51661bbULL, 0x3125607ab548fa30ULL,
|
||||
0x4bfd10b2857d7349ULL, 0x04ad64994d625e4dULL, 0x7e7514517d57d734ULL,
|
||||
0xf11d85092d094cbfULL, 0x8bc5f5c11d3cc5c6ULL, 0x12b5926535897936ULL,
|
||||
0x686de2ad05bcf04fULL, 0xe70573f555e26bc4ULL, 0x9ddd033d65d7e2bdULL,
|
||||
0xd28d7716adc8cfb9ULL, 0xa85507de9dfd46c0ULL, 0x273d9686cda3dd4bULL,
|
||||
0x5de5e64efd965432ULL, 0xb99d7ed15d9d8743ULL, 0xc3450e196da80e3aULL,
|
||||
0x4c2d9f413df695b1ULL, 0x36f5ef890dc31cc8ULL, 0x79a59ba2c5dc31ccULL,
|
||||
0x037deb6af5e9b8b5ULL, 0x8c157a32a5b7233eULL, 0xf6cd0afa9582aa47ULL,
|
||||
0x4ad64994d625e4daULL, 0x300e395ce6106da3ULL, 0xbf66a804b64ef628ULL,
|
||||
0xc5bed8cc867b7f51ULL, 0x8aeeace74e645255ULL, 0xf036dc2f7e51db2cULL,
|
||||
0x7f5e4d772e0f40a7ULL, 0x05863dbf1e3ac9deULL, 0xe1fea520be311aafULL,
|
||||
0x9b26d5e88e0493d6ULL, 0x144e44b0de5a085dULL, 0x6e963478ee6f8124ULL,
|
||||
0x21c640532670ac20ULL, 0x5b1e309b16452559ULL, 0xd476a1c3461bbed2ULL,
|
||||
0xaeaed10b762e37abULL, 0x37deb6af5e9b8b5bULL, 0x4d06c6676eae0222ULL,
|
||||
0xc26e573f3ef099a9ULL, 0xb8b627f70ec510d0ULL, 0xf7e653dcc6da3dd4ULL,
|
||||
0x8d3e2314f6efb4adULL, 0x0256b24ca6b12f26ULL, 0x788ec2849684a65fULL,
|
||||
0x9cf65a1b368f752eULL, 0xe62e2ad306bafc57ULL, 0x6946bb8b56e467dcULL,
|
||||
0x139ecb4366d1eea5ULL, 0x5ccebf68aecec3a1ULL, 0x2616cfa09efb4ad8ULL,
|
||||
0xa97e5ef8cea5d153ULL, 0xd3a62e30fe90582aULL, 0xb0c7b7e3c7593bd8ULL,
|
||||
0xca1fc72bf76cb2a1ULL, 0x45775673a732292aULL, 0x3faf26bb9707a053ULL,
|
||||
0x70ff52905f188d57ULL, 0x0a2722586f2d042eULL, 0x854fb3003f739fa5ULL,
|
||||
0xff97c3c80f4616dcULL, 0x1bef5b57af4dc5adULL, 0x61372b9f9f784cd4ULL,
|
||||
0xee5fbac7cf26d75fULL, 0x9487ca0fff135e26ULL, 0xdbd7be24370c7322ULL,
|
||||
0xa10fceec0739fa5bULL, 0x2e675fb4576761d0ULL, 0x54bf2f7c6752e8a9ULL,
|
||||
0xcdcf48d84fe75459ULL, 0xb71738107fd2dd20ULL, 0x387fa9482f8c46abULL,
|
||||
0x42a7d9801fb9cfd2ULL, 0x0df7adabd7a6e2d6ULL, 0x772fdd63e7936bafULL,
|
||||
0xf8474c3bb7cdf024ULL, 0x829f3cf387f8795dULL, 0x66e7a46c27f3aa2cULL,
|
||||
0x1c3fd4a417c62355ULL, 0x935745fc4798b8deULL, 0xe98f353477ad31a7ULL,
|
||||
0xa6df411fbfb21ca3ULL, 0xdc0731d78f8795daULL, 0x536fa08fdfd90e51ULL,
|
||||
0x29b7d047efec8728ULL
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef uMod_TEXTUREFUNCTION_H_
|
||||
#define uMod_TEXTUREFUNCTION_H_
|
||||
|
||||
|
||||
|
||||
inline void InitCRC64(DWORD64 &crc)
|
||||
{
|
||||
crc = 0xFFFFFFFFFFFFFFFFULL;
|
||||
}
|
||||
|
||||
extern const DWORD64 crctab64[256];
|
||||
/**
|
||||
* CRC64 function
|
||||
*
|
||||
* @param[in] data pointer to the buffer
|
||||
* @param[in] len length of buffer in bytes
|
||||
* @param[in,out] hash in = initial value of the hash; out = returned hash
|
||||
*/
|
||||
inline void GetCRC64(DWORD64 &crc, const unsigned char *cp, unsigned long length)
|
||||
{
|
||||
while (length--)
|
||||
crc = crctab64[(crc ^ *(cp++)) & 0xff] ^ (crc >> 8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void InitCRC32(DWORD32 &crc)
|
||||
{
|
||||
crc = 0xffffffff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caluclate the CRC32 value over a buffer. This function is used in texmod. Thanks to RS for given me this information!
|
||||
* @param[in] data pointer to the buffer
|
||||
* @param[in] len length of buffer in bytes
|
||||
* @return CRC32 value
|
||||
*/
|
||||
void GetCRC32( DWORD32 &crc, unsigned char *data, unsigned int len);
|
||||
/*
|
||||
case D3DFMT_MULTI2_ARGB8:
|
||||
case D3DFMT_VERTEXDATA:
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the number of bits used per pixel.
|
||||
* @param[in] format DX format.
|
||||
* @return
|
||||
*/
|
||||
inline int GetBitsFromFormat(D3DFORMAT format)
|
||||
{
|
||||
switch(format) //switch trough the formats to calculate the size of the raw data
|
||||
{
|
||||
case D3DFMT_A1: // 1-bit monochrome.
|
||||
{
|
||||
return (1);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_R3G3B2: // 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
|
||||
case D3DFMT_A8: // 8-bit alpha only.
|
||||
case D3DFMT_A8P8: // 8-bit color indexed with 8 bits of alpha.
|
||||
case D3DFMT_P8: // 8-bit color indexed.
|
||||
case D3DFMT_L8: // 8-bit luminance only.
|
||||
case D3DFMT_A4L4: // 8-bit using 4 bits each for alpha and luminance.
|
||||
case D3DFMT_FORCE_DWORD:
|
||||
case D3DFMT_S8_LOCKABLE: // A lockable 8-bit stencil buffer.
|
||||
{
|
||||
return (8);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_D16_LOCKABLE: //16-bit z-buffer bit depth.
|
||||
case D3DFMT_D15S1: // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
|
||||
case D3DFMT_L6V5U5: // 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
|
||||
case D3DFMT_V8U8: // 16-bit bump-map format using 8 bits each for u and v data.
|
||||
case D3DFMT_CxV8U8: // 16-bit normal compression format. The texture sampler computes the C channel from: C = sqrt(1 - U2 - V2).
|
||||
case D3DFMT_R5G6B5: // 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
|
||||
case D3DFMT_X1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color.
|
||||
case D3DFMT_A1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
|
||||
case D3DFMT_A4R4G4B4: // 16-bit ARGB pixel format with 4 bits for each channel.
|
||||
case D3DFMT_A8R3G3B2: // 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
|
||||
case D3DFMT_X4R4G4B4: // 16-bit RGB pixel format using 4 bits for each color.
|
||||
case D3DFMT_L16: // 16-bit luminance only.
|
||||
case D3DFMT_R16F: // 16-bit float format using 16 bits for the red channel.
|
||||
case D3DFMT_A8L8: // 16-bit using 8 bits each for alpha and luminance.
|
||||
case D3DFMT_D16: // 16-bit z-buffer bit depth.
|
||||
case D3DFMT_INDEX16: // 16-bit index buffer bit depth.
|
||||
case D3DFMT_G8R8_G8B8: // ??
|
||||
case D3DFMT_R8G8_B8G8: // ??
|
||||
case D3DFMT_UYVY: // ??
|
||||
case D3DFMT_YUY2: // ??
|
||||
{
|
||||
return (16);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case D3DFMT_R8G8B8: //24-bit RGB pixel format with 8 bits per channel.
|
||||
{
|
||||
return (24);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_R32F: // 32-bit float format using 32 bits for the red channel.
|
||||
case D3DFMT_X8L8V8U8: // 32-bit bump-map format with luminance using 8 bits for each channel.
|
||||
case D3DFMT_A2W10V10U10: // 32-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.
|
||||
case D3DFMT_Q8W8V8U8: // 32-bit bump-map format using 8 bits for each channel.
|
||||
case D3DFMT_V16U16: // 32-bit bump-map format using 16 bits for each channel.
|
||||
case D3DFMT_A8R8G8B8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8R8G8B8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_A2B10G10R10: // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
|
||||
case D3DFMT_A8B8G8R8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
case D3DFMT_X8B8G8R8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
case D3DFMT_G16R16: // 32-bit pixel format using 16 bits each for green and red.
|
||||
case D3DFMT_G16R16F: // 32-bit float format using 16 bits for the red channel and 16 bits for the green channel.
|
||||
case D3DFMT_A2R10G10B10: // 32-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
|
||||
case D3DFMT_D32: // 32-bit z-buffer bit depth.
|
||||
case D3DFMT_D24S8: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
|
||||
case D3DFMT_D24X8: //32-bit z-buffer bit depth using 24 bits for the depth channel.
|
||||
case D3DFMT_D24X4S4: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
|
||||
case D3DFMT_D32F_LOCKABLE: // A lockable format where the depth value is represented as a standard IEEE floating-point number.
|
||||
case D3DFMT_D24FS8: // A non-lockable format that contains 24 bits of depth (in a 24-bit floating point format - 20e4) and 8 bits of stencil.
|
||||
case D3DFMT_D32_LOCKABLE: // A lockable 32-bit depth buffer.
|
||||
case D3DFMT_INDEX32: // 32-bit index buffer bit depth.
|
||||
//case : //
|
||||
//case : //
|
||||
//case : //
|
||||
//case : //
|
||||
{
|
||||
return (32);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_G32R32F: // 64-bit float format using 32 bits for the red channel and 32 bits for the green channel.
|
||||
case D3DFMT_Q16W16V16U16: // 64-bit bump-map format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16: // 64-bit pixel format using 16 bits for each component.
|
||||
case D3DFMT_A16B16G16R16F: // 64-bit float format using 16 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return (64);
|
||||
break;
|
||||
}
|
||||
|
||||
case D3DFMT_A32B32G32R32F: // 128-bit float format using 32 bits for the each channel (alpha, blue, green, red).
|
||||
{
|
||||
return (128);
|
||||
break;
|
||||
}
|
||||
case D3DFMT_DXT2:
|
||||
case D3DFMT_DXT3:
|
||||
case D3DFMT_DXT4:
|
||||
case D3DFMT_DXT5:
|
||||
{
|
||||
return (8);
|
||||
break;
|
||||
}
|
||||
case D3DFMT_DXT1:
|
||||
{
|
||||
return (4);
|
||||
break;
|
||||
}
|
||||
default: //compressed formats
|
||||
{
|
||||
return (4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* uMod_TEXTUREFUNCTION_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
This file is part of Universal Modding Engine.
|
||||
|
||||
|
||||
Universal Modding Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Universal Modding Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef uMod_TEXTURESERVER_H_
|
||||
#define uMod_TEXTURESERVER_H_
|
||||
|
||||
#include "../uMod_GlobalDefines.h"
|
||||
#include "uMod_ArrayHandler.h"
|
||||
|
||||
|
||||
/**
|
||||
* An object of this class is created only once.
|
||||
* The Mainloop functions is executed by a server thread,
|
||||
* which listen on a pipe.
|
||||
*
|
||||
* Functions called by the Client are called from the a thread instance of the game itself.
|
||||
* Nearly all other functions are called from the server thread instance.
|
||||
*/
|
||||
|
||||
|
||||
class uMod_TextureClient;
|
||||
|
||||
class uMod_TextureServer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The server is created from the dll entry routine.
|
||||
* @param[in] name Name of the game executable (without the extension)
|
||||
*/
|
||||
uMod_TextureServer(wchar_t *name);
|
||||
~uMod_TextureServer(void);
|
||||
|
||||
/**
|
||||
* Each client connect itself to the server via this function.
|
||||
* @param[in] client This-pointer of the client
|
||||
* @param[out] update Current texture to be modded
|
||||
* @param[out] number Number of modded textures
|
||||
* @param[in] version The device version (DX9, DX9EX, DX10, or DX101)
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int AddClient(uMod_TextureClient *client, TextureEntry* &update, int &number, const int version); // called from a Client
|
||||
|
||||
/**
|
||||
* On destruction of client, it disconnect from the server.
|
||||
* @param[in] client This-pointer of the client
|
||||
* @param[in] version The device version (DX9, DX9EX, DX10, or DX101)
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int RemoveClient(uMod_TextureClient *client, const int version); // called from a Client
|
||||
|
||||
/**
|
||||
* Opens the pipe to the GUI (called from the dll entry routine)
|
||||
* @param[in] name Name of the game
|
||||
* @param[in] injection_method global hook=1, direct injection=2, no injection=3
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int OpenPipe(wchar_t *name, int injection_method); // called on initialization of our d3d9 fake dll
|
||||
|
||||
/**
|
||||
* Close the Pipe to the GUI (called if dll entry is called to attach from the game)
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int ClosePipe(void); // called on exit of our d3d9 fake dll
|
||||
|
||||
/**
|
||||
* The mainloop reads from the pipe (blocking reading). It is running in a separate server thread.
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int MainLoop(void); // is executed in a server thread
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Add a file to the list of texture to be modded (called from the mainloop).
|
||||
* @param[in] buffer hold the file content of the texture
|
||||
* @param[in] size size of the file content
|
||||
* @param[in] hash hash of the texture to be replaced
|
||||
* @param[in] force set to TRUE to force a reload of the texture
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int AddFile( char* buffer, DWORD64 size, DWORD64 hash, bool force); // called from Mainloop(), if the content of the texture is sent
|
||||
|
||||
/**
|
||||
* Add a file to the list of texture to be modded (called from the mainloop).
|
||||
* @param[in] file_name Name and path to the file to be loaded.
|
||||
* @param[in] hash hash of the texture to be replaced
|
||||
* @param[in] force set to TRUE to force a reload of the texture
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int AddFile( wchar_t* file_name, DWORD64 hash, bool force); // called from Mainloop(), if the name and the path to the file is sent
|
||||
|
||||
/**
|
||||
* Remove a texture (called from the mainloop).
|
||||
* @param[in] hash Hash of the target texture.
|
||||
* @return RETURN_OK on success
|
||||
*/
|
||||
int RemoveFile( DWORD64 hash); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* Save all texture, which are loade by the game (called from the mainloop).
|
||||
* @param[in] val Set TRUE to enable the mode.
|
||||
* @return
|
||||
*/
|
||||
int SaveAllTextures(bool val); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* Enable/Disable the save single texture mode (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int SaveSingleTexture(bool val); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* Enable/Disable the string in the left upper corner during save single texture mode (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int ShowTextureString(bool val); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* Enable/Disable the rendering of the current selected texture in the upper corner during save single texture mode (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int ShowSingleTexture(bool val); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* Enable/Disable the hashing with CRC32, which is needed to support tpf mods (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int SupportTPF(bool val); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* Enable/Disable the computation of the hash of render targets (called from the mainloop).
|
||||
* @param[in] val
|
||||
* @return
|
||||
*/
|
||||
int ComputeRenderTargets(bool val); // called from Mainloop()
|
||||
/**
|
||||
* Set saving directory (called from the mainloop).
|
||||
* @param[in] dir
|
||||
* @return
|
||||
*/
|
||||
int SetSaveDirectory( wchar_t *dir); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] key
|
||||
* @return
|
||||
*/
|
||||
int SetKeyBack( int key); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] key
|
||||
* @return
|
||||
*/
|
||||
int SetKeySave( int key); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] key
|
||||
* @return
|
||||
*/
|
||||
int SetKeyNext( int key); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] colour
|
||||
* @return
|
||||
*/
|
||||
int SetFontColour(DWORD64 colour); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] colour
|
||||
* @return
|
||||
*/
|
||||
int SetTextureColour(DWORD64 colour); // called from Mainloop()
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] format
|
||||
* @return
|
||||
*/
|
||||
int SetFileFormat(DWORD64 format);
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] format
|
||||
* @return
|
||||
*/
|
||||
int SetFormatFilter(DWORD64 format);
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] size
|
||||
* @return
|
||||
*/
|
||||
int SetWidthFilter(DWORD64 size);
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] size
|
||||
* @return
|
||||
*/
|
||||
int SetHeightFilter(DWORD64 size);
|
||||
|
||||
/**
|
||||
* (called from the mainloop).
|
||||
* @param[in] size
|
||||
* @return
|
||||
*/
|
||||
int SetDepthFilter(DWORD64 size);
|
||||
|
||||
/**
|
||||
* Send the files to be modded (Update) to a client (called from the mainloop).
|
||||
* @param[in] client Pointer to a client (if NULL is passed, the data is send to all clients)
|
||||
* @return
|
||||
*/
|
||||
int PropagateUpdate(uMod_TextureClient* client=NULL); // called from Mainloop() if texture are loaded or removed
|
||||
|
||||
/**
|
||||
* Prepare the texture data for the clients (e.g. Load the texture from disk, sort the texture according the hash values) (called from the mainloop).
|
||||
* @param[out] update
|
||||
* @param[out] number
|
||||
* @return
|
||||
*/
|
||||
int PrepareUpdate(TextureEntry* &update, int &number);
|
||||
|
||||
/**
|
||||
* Locks the mutex.
|
||||
* @return
|
||||
*/
|
||||
int LockMutex();
|
||||
/**
|
||||
* Locks the mutex.
|
||||
* @return
|
||||
*/
|
||||
int UnlockMutex();
|
||||
HANDLE Mutex; //!< Mutex protects the simultaneously add or remove of multiple clients.
|
||||
|
||||
|
||||
bool BoolSaveAllTextures;
|
||||
bool BoolSaveSingleTexture;
|
||||
bool BoolShowTextureString;
|
||||
bool BoolShowSingleTexture;
|
||||
bool BoolSupportTPF;
|
||||
bool BoolComputeRenderTargets; //!< true if the hash of render targets should be computed (very slow because each frame the hash must be recomputed)
|
||||
|
||||
wchar_t SavePath[MAX_PATH];
|
||||
wchar_t GameName[MAX_PATH];
|
||||
|
||||
|
||||
int KeyBack;
|
||||
int KeySave;
|
||||
int KeyNext;
|
||||
|
||||
DWORD64 FontColour;
|
||||
DWORD64 TextureColour;
|
||||
|
||||
DWORD64 FileFormat;
|
||||
DWORD64 FormatFilter;
|
||||
DWORD64 WidthFilter;
|
||||
DWORD64 HeightFilter;
|
||||
DWORD64 DepthFilter;
|
||||
|
||||
PipeStruct Pipe;
|
||||
|
||||
uMod_TextureClient** Clients;
|
||||
int NumberOfClients;
|
||||
int LenghtOfClients;
|
||||
|
||||
uMod_FileHandler CurrentMod; // hold the file content of texture
|
||||
};
|
||||
|
||||
|
||||
#endif /* uMod_TEXTURESERVER_H_ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user