Compare commits

...

32 commits

Author SHA1 Message Date
rebtd7 e463304365
Merge pull request #64 from Nucleoprotein/spdlog
Use spdlog
2021-03-30 21:09:36 +00:00
Robert Krawczyk 409d223465 Use spdlog https://github.com/gabime/spdlog 2021-03-30 19:55:13 +02:00
rebtd7 6caa8027d2
Update README.md 2021-03-28 14:40:07 +00:00
rebtd7 9e486fc986 Always SetForegroundWindow 2021-03-24 22:09:47 -03:00
rebtd7 e8db5d2923
Update AutoFix.cpp 2021-03-25 00:52:04 +00:00
Robert Krawczyk 9c5f81cc27
Merge pull request #60 from Nucleoprotein/FF13Fix
Properly manage D3D9 objects i.e. proper reference count
2021-03-24 20:10:49 +01:00
Robert Krawczyk 7619ef4806 *The Proper Reference Count*
*Implement Ex interfaces and count their references:
-Fixes crashes related to too low count
-Fixes Steam Overlay in D3D9 and DXVK

*Small fixes to compile with /std:c++latest (C++20)
2021-03-24 20:08:00 +01:00
rebtd7 0bf518084a
Update README.md 2021-03-24 18:58:27 +00:00
rebtd7 31d3d351a9
Update README.md 2021-03-23 23:01:00 +00:00
rebtd7 5626c52c43 Fix crashes at startup 2021-03-22 09:12:20 -03:00
rebtd7 09d3764182
Update README.md 2021-03-21 14:24:05 +00:00
rebtd7 6017b1c08f
Increment version number 2021-03-21 14:20:03 +00:00
rebtd7 3f5d4d4737
Merge pull request #55 from rebtd7/reshade
Add ReShade support;' add instructions to use it
2021-03-21 14:18:49 +00:00
rebtd7 3bca88bd72 Add ReShade support;' add instructions to use it 2021-03-21 11:08:03 -03:00
rebtd7 2249c4cdb0
Merge pull request #52 from rebtd7/laa_patch
[FF13] Allow usage of 4GB memory patch
2021-03-21 13:48:48 +00:00
rebtd7 240ee9a015 [FF13] Allow usage of 4GB memory patch 2021-03-21 10:46:34 -03:00
rebtd7 511e343535
Increment version number 2021-03-20 17:05:34 +00:00
Robert Krawczyk e9bbbf04b5 Fix reference counting for GameOverlayRenderer (Steam Overlay) 2021-03-20 17:38:59 +01:00
rebtd7 308d4a9464 Fix possible crash when exit after disabling messagebox 2021-03-16 12:00:04 -03:00
rebtd7 6723a31b6a fix mistake when merging commits 2021-03-16 11:25:21 -03:00
rebtd7 e8c64649b5 Update README 2021-03-16 11:19:55 -03:00
rebtd7 ee30d54edb Incremente version number 2021-03-16 11:19:43 -03:00
rebtd7 8898ba5013 Fix mouse input at start when using borderless mode 2021-03-16 11:19:21 -03:00
rebtd7 94be154c77 Remove messagebox when using dxvk (it is not being displayed in full screen mode) 2021-03-16 11:17:01 -03:00
rebtd7 53cbce83a2 Fix misaligned full screen effects (proper fix for 1440p issue) 2021-03-16 11:16:55 -03:00
Robert Krawczyk 5a551b80b9 Fix mouse input when using DXVK 2021-03-13 22:40:39 +01:00
Robert Krawczyk 3a844cc3ca Changes:
Fixed DXVK window starting in background and required clicking to activate
Added experimental (disabled by default) DiscardUIVertexBuffer option
Improved D3D9 reference counting
Two step initialization, check is correct window was created, then initialize 2s after IDirect3D9::CreateDevice call

Other:
Fix some include hell
Settings.h now include all comments so it will autogenerated ini file
Deleted IDirect3DVertexBuffer9.cpp/h
2021-03-13 03:54:05 +01:00
Robert Krawczyk d389cc6dec Merge branch 'master' of https://github.com/rebtd7/FF13Fix 2021-03-12 23:31:36 +01:00
Robert Krawczyk 2001b94945 Fix for https://github.com/rebtd7/FF13Fix/issues/46 2021-03-12 23:31:22 +01:00
rebtd7 60f6031179
Increment version number 2021-03-11 09:47:01 -03:00
Robert Krawczyk f2c53b9735 Change PresentationInterval (V-Sync) option behavior to force it off:
-1 = V-Sync forced off
0 = no change
1 = forced on
2021-03-11 07:40:59 +01:00
Robert Krawczyk e15529e67e Fix typo in FF13_FixScissorRect and also NOP whole 7 bytes block - old code unprotect 5 bytes and write 7 2021-03-11 07:31:54 +01:00
23 changed files with 1194 additions and 879 deletions

7
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "MinHook"] [submodule "Deps/MinHook"]
path = MinHook path = Deps/MinHook
url = https://github.com/TsudaKageyu/minhook.git url = https://github.com/TsudaKageyu/minhook.git
[submodule "Deps/spdlog"]
path = Deps/spdlog
url = https://github.com/gabime/spdlog.git

View file

@ -1,141 +0,0 @@
#pragma once
#include <io.h>
#include <fcntl.h>
#include <memory>
#include <string>
#include "StringUtil.h"
#include "WinUtil.h"
#ifndef LOGGER_DISABLE
class Logger
{
public:
Logger(const Logger&) = delete;
const Logger& operator=(Logger& other) = delete;
Logger() : m_systime(), m_console(INVALID_HANDLE_VALUE), m_file(INVALID_HANDLE_VALUE) {}
Logger::~Logger()
{
if (m_console)
FreeConsole();
if (m_file)
CloseHandle(m_file);
}
std::mutex& writeMutex() const { return m_writeMutex; }
static Logger& Logger::Get()
{
static Logger instance;
return instance;
};
bool File(const std::string& filename)
{
std::string logpath = FullPathFromPath(filename);
m_file = CreateFileA(logpath.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
OutputDebugStringA(logpath.c_str());
if (m_file != INVALID_HANDLE_VALUE)
PrintStamp(false);
return m_file != INVALID_HANDLE_VALUE;
}
bool Console(const char* title)
{
AllocConsole();
m_console = GetStdHandle(STD_OUTPUT_HANDLE);
if (m_console != INVALID_HANDLE_VALUE)
{
ShowWindow(GetConsoleWindow(), SW_MAXIMIZE);
if (title) SetConsoleTitleA(title);
}
if (m_console != INVALID_HANDLE_VALUE)
PrintStamp(true);
return m_console != INVALID_HANDLE_VALUE;
}
void Print(const char* format, va_list args)
{
bool to_console = m_console != INVALID_HANDLE_VALUE;
bool to_file = m_file != INVALID_HANDLE_VALUE;
if ((to_console || to_file) && format)
{
int outsize = _vscprintf(format, args) + 1;
std::unique_ptr<char[]> buffer(new char[outsize]);
CharArrayFromFormatV(buffer.get(), outsize, format, args);
#ifdef LOGGER_DISABLE_TIME
std::string to_print(buffer.get(), outsize - 1);
#else
std::string to_print;
GetTime(&to_print);
to_print.append(buffer.get(), outsize - 1);
#endif
to_print.append("\r\n");
DWORD lenout = 0;
if (to_console) WriteConsoleA(m_console, to_print.c_str(), (DWORD)to_print.size(), &lenout, NULL);
if (to_file) WriteFile(m_file, to_print.c_str(), (DWORD)to_print.size(), &lenout, NULL);
}
}
private:
void PrintStamp(bool console)
{
static char stamp[] = "[TIME]\t\t[THREAD]\t[LOG]\r\n";
DWORD lenout = 0;
if (console) WriteConsoleA(m_console, stamp, _countof(stamp) - 1, &lenout, NULL);
else WriteFile(m_file, stamp, _countof(stamp) - 1, &lenout, NULL);
}
void GetTime(std::string* out)
{
GetLocalTime(&m_systime);
*out = StringFromFormat("%02u:%02u:%02u.%03u\t%08u\t", m_systime.wHour, m_systime.wMinute,
m_systime.wSecond, m_systime.wMilliseconds, GetCurrentThreadId());
}
SYSTEMTIME m_systime;
HANDLE m_console;
HANDLE m_file;
mutable std::mutex m_writeMutex;
};
inline void LogFile(const std::string& logname)
{
Logger::Get().File(logname);
}
inline void LogConsole(const char* title = nullptr)
{
Logger::Get().Console(title);
}
inline void PrintLog(const char* format, ...)
{
const std::lock_guard<std::mutex> lock(Logger::Get().writeMutex());
va_list args;
va_start(args, format);
Logger::Get().Print(format, args);
va_end(args);
}
#else
#define LogFile(logname) (logname)
#define LogConsole(title, notice) (title)
#define PrintLog(format, ...) (format)
#endif

View file

@ -328,16 +328,16 @@ public:
#endif #endif
/** Strict less ordering by name of key only */ /** Strict less ordering by name of key only */
struct KeyOrder : std::binary_function<Entry, Entry, bool> { struct KeyOrder {
bool operator()(const Entry & lhs, const Entry & rhs) const { bool operator()(const Entry& lhs, const Entry& rhs) const {
const static SI_STRLESS isLess = SI_STRLESS(); const static SI_STRLESS isLess = SI_STRLESS();
return isLess(lhs.pItem, rhs.pItem); return isLess(lhs.pItem, rhs.pItem);
} }
}; };
/** Strict less ordering by order, and then name of key */ /** Strict less ordering by order, and then name of key */
struct LoadOrder : std::binary_function<Entry, Entry, bool> { struct LoadOrder {
bool operator()(const Entry & lhs, const Entry & rhs) const { bool operator()(const Entry& lhs, const Entry& rhs) const {
if (lhs.nOrder != rhs.nOrder) { if (lhs.nOrder != rhs.nOrder) {
return lhs.nOrder < rhs.nOrder; return lhs.nOrder < rhs.nOrder;
} }

View file

@ -149,13 +149,15 @@ inline std::string CP1252ToUTF8(const std::string& input)
// trim from start // trim from start
static inline std::string &ltrim(std::string &s) { static inline std::string &ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); //workaround for template deduction after including <locale>
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not_fn([&](int i) { return std::isspace(i); })));
return s; return s;
} }
// trim from end // trim from end
static inline std::string &rtrim(std::string &s) { static inline std::string &rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); //workaround for template deduction after including <locale>
s.erase(std::find_if(s.rbegin(), s.rend(), std::not_fn([&](int i) { return std::isspace(i); })).base(), s.end());
return s; return s;
} }

1
Deps/spdlog Submodule

@ -0,0 +1 @@
Subproject commit 100f30043f33277122e0991c83845a2617172ffd

View file

@ -38,17 +38,38 @@ By default the game forced a 60Hz refresh rate in full screen mode. With this mo
## Changes to where the memory is allocated on certain vertex buffers ## Changes to where the memory is allocated on certain vertex buffers
This considerably improves the frame rate when 2D elements are being disabled on the screen (i.e. minimap or battle menu HUD). This fix is not new, it is from [OneTweakNG](https://github.com/Nucleoprotein/OneTweakNG). This considerably improves the frame rate when 2D elements are being disabled on the screen (i.e. minimap or battle menu HUD). This fix is not new, it is from [OneTweakNG](https://github.com/Nucleoprotein/OneTweakNG).
## Works around pixelated screen bug that happens when using 2560x1440 resolution ## Fixes misaligned screen space effects (fixes 1440p resolution)
## Fix the enemy scan text on resolutions over 720p (FFXIII only) ## Fix the enemy scan text on resolutions over 720p (FFXIII only)
The game calls [SetScissorRect](https://docs.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-setscissorrect) using a rectangle hardcoded with the 720p coordenates. This correct the coordenates and rectangle size in order to fix it. The game calls [SetScissorRect](https://docs.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-setscissorrect) using a rectangle hardcoded with the 720p coordenates. This correct the coordenates and rectangle size in order to fix it.
## Reporting issues # Usage with DXVK
People use DXVK on Windows to work around crashes with recent AMD Navi cards. If you are using Nvidia on Windows, you probably don't need it.
* Rename DXVK's x86 ```d3d9.dll``` file to ```dxvk.dll```. Keep FF13Fix as ```d3d9.dll```.
# Usage with the 4GB Large Address Aware patch (Recommended)
You may wish to patch the games to allow them to access more than 2GB of RAM.
This seems to avoid crashes in FF13-2 and FF13 (especially when using triple buffering, playing on 4K+ resolutions, using DXVK and/or Reshade, or using HD texture/model mods).
## FF13:
* Create a copy of the unpatched ```ffxiiiimg.exe``` to the folder ```FINAL FANTASY XIII\white_data\prog\win\bin```. Name it ```untouched.exe```.
* Patch the original ```ffxiiiimg.exe``` (you can use https://ntcore.com/?page_id=371)
## FF13-2:
* Patch ```ffxiii2img.exe``` (you can use https://ntcore.com/?page_id=371)
# Usage with Reshade
## Regular Direct3D9 users:
* Install ReShade first. Rename ReShade's ```d3d9.dll``` to ```ReShade32.dll```; Install FF13Fix normally, keeping FF13Fix as ```d3d9.dll```
## DXVK users:
* Install ReShade targeting Vulkan; enable it globally
# Reporting issues
* Please specify what game are you talking about, which mods are you using (dxvk?) post system specs, and post FF13Fix.log * Please specify what game are you talking about, which mods are you using (dxvk?) post system specs, and post FF13Fix.log
* Add a save file and steps to reproduce the issue if possible * Add a save file and steps to reproduce the issue if possible
## Other notes # Other notes
* This is currently not compatible with GeDoSaTo. * This is currently not compatible with GeDoSaTo.
* I strongly recommend forcing anisotropic filtering on your GPU driver to improve the quality of the textures. * I strongly recommend forcing anisotropic filtering on your GPU driver to improve the quality of the textures.
* Using "Maximum Performance" power management in the GPU driver can also help keeping the frame rate smooth. * Using "Maximum Performance" power management in the GPU driver can also help keeping the frame rate smooth.
* If you are using dxvk, rename its x86 dll file to dxvk.dll and keep FF13Fix as d3d9.dll

View file

@ -8,7 +8,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5DB3A8C9-CF87-4AB6-A7C2-07B81A0DA625}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5DB3A8C9-CF87-4AB6-A7C2-07B81A0DA625}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
Common\Defines.h = Common\Defines.h Common\Defines.h = Common\Defines.h
Common\Logger.h = Common\Logger.h
Common\MemPatch.h = Common\MemPatch.h Common\MemPatch.h = Common\MemPatch.h
Common\SimpleIni.h = Common\SimpleIni.h Common\SimpleIni.h = Common\SimpleIni.h
Common\StringUtil.h = Common\StringUtil.h Common\StringUtil.h = Common\StringUtil.h
@ -18,7 +17,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5DB3A8
Common\WinVer.h = Common\WinVer.h Common\WinVer.h = Common\WinVer.h
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "MinHook\build\VC16\libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Deps", "Deps", "{908757C5-6B19-44A6-9C35-1F913D016F6F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "Deps\MinHook\build\VC16\libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -49,7 +50,7 @@ Global
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC332D21-3B2D-4534-AD8E-2525081AECA5}
VisualSVNWorkingCopyRoot = . VisualSVNWorkingCopyRoot = .
SolutionGuid = {CC332D21-3B2D-4534-AD8E-2525081AECA5}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -1,34 +1,107 @@
#include "stdafx.h" #include "stdafx.h"
#include "MemPatch.h"
#include "Context.h" #include "Context.h"
#include "IDirect3DVertexBuffer9.h" #include <MinHook.h>
void MainContext::EnableAutoFix() void MainContext::EnableAutoFix()
{ {
std::string exe_name = ModuleNameA(NULL); std::string exe_name = ModuleNameA(NULL);
std::transform(exe_name.begin(), exe_name.end(), exe_name.begin(), std::tolower); //workaround for template deduction after including <locale>
std::transform(exe_name.begin(), exe_name.end(), exe_name.begin(), [&](int i) { return std::tolower(i); });
if (exe_name == "ffxiiiimg.exe") if (exe_name == "ffxiiiimg.exe")
{ {
autofix = AutoFixes::FINAL_FANTASY_XIII; autofix = AutoFixes::FINAL_FANTASY_XIII;
PrintLog("AutoFix for \"Final Fantasy XIII\" enabled"); spdlog::info("AutoFix for \"Final Fantasy XIII\" enabled");
FF13_InitializeGameAddresses(); FF13_InitializeGameAddresses();
FF13_HandleLargeAddressAwarePatch();
} }
if (exe_name == "ffxiii2img.exe") if (exe_name == "ffxiii2img.exe")
{ {
autofix = AutoFixes::FINAL_FANTASY_XIII2; autofix = AutoFixes::FINAL_FANTASY_XIII2;
PrintLog("AutoFix for \"Final Fantasy XIII-2\" enabled"); spdlog::info("AutoFix for \"Final Fantasy XIII-2\" enabled");
FF13_2_InitializeGameAddresses(); FF13_2_InitializeGameAddresses();
FF13_2_CreateSetFrameRateCodeBlock(); FF13_2_CreateSetFrameRateCodeBlock();
} }
} }
const std::map<const MainContext::AutoFixes, const uint32_t> MainContext::behaviorflags_fixes = const std::map<const MainContext::AutoFixes, const uint32_t> MainContext::behaviorflags_add =
{ {
}; };
const std::map<const MainContext::AutoFixes, const uint32_t> MainContext::behaviorflags_sub =
{
//{ AutoFixes::FINAL_FANTASY_XIII, D3DCREATE_PUREDEVICE },
//{ AutoFixes::FINAL_FANTASY_XIII2, D3DCREATE_PUREDEVICE }
};
HANDLE WINAPI MainContext::HookCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) {
const char* ffxiiiimgPrt = strstr(lpFileName, "ffxiiiimg.exe");
if (ffxiiiimgPrt) {
spdlog::info("HookCreateFileA Before Replacement: {}", lpFileName);
int arrayPosition = ffxiiiimgPrt - lpFileName;
int len = strlen(lpFileName);
char* newFileName = new char[len + 1];
strcpy_s(newFileName, len + 1, lpFileName);
const char* untouched = "untouched"; // needs to have the size of "ffxiiiimg"
memcpy(newFileName + arrayPosition, untouched, strlen(untouched));
spdlog::info("HookCreateFileA After Replacement: {}", newFileName);
MH_STATUS disableHookCreateFileA = MH_DisableHook(CreateFileA);
spdlog::info("disableHookCreateFileA = {}", disableHookCreateFileA);
MH_STATUS disableHookCreateFileW = MH_DisableHook(CreateFileW);
spdlog::info("disableHookCreateFileW = {}", disableHookCreateFileW);
if (GetFileAttributesA(newFileName) == INVALID_FILE_ATTRIBUTES) {
spdlog::info("ERROR: Unable to get attributes of {}. Does the file exist? Using the regular ffxiiiimg.exe", newFileName);
strcpy_s(newFileName, len + 1, lpFileName);
}
HANDLE fileHandle = context.TrueCreateFileA(newFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);;
spdlog::info("Returning File Handle for {}", newFileName);
delete[] newFileName;
return fileHandle;
}
else {
return context.TrueCreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
}
HANDLE WINAPI MainContext::HookCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) {
const wchar_t* ffxiiiimgPrt = wcsstr(lpFileName, L"ffxiiiimg.exe");;
if (ffxiiiimgPrt) {
spdlog::info(L"HookCreateFileW Before Replacement: {}", lpFileName);
int arrayPosition = ffxiiiimgPrt - lpFileName;
int len = wcslen(lpFileName);
wchar_t* newFileName = new wchar_t[len + 1];
wcscpy_s(newFileName, len + 1, lpFileName);
const wchar_t* untouched = L"untouched"; //needs to have the size of L"ffxiiiimg"
wmemcpy(newFileName + arrayPosition, untouched, wcslen(untouched));
spdlog::info(L"HookCreateFileW After Replacement: {}", newFileName);
MH_STATUS disableHookCreateFileA = MH_DisableHook(CreateFileA);
spdlog::info("disableHookCreateFileA = {}", disableHookCreateFileA);
MH_STATUS disableHookCreateFileW = MH_DisableHook(CreateFileW);
spdlog::info("disableHookCreateFileW = {}", disableHookCreateFileW);
if (GetFileAttributesW(newFileName) == INVALID_FILE_ATTRIBUTES) {
spdlog::info(L"ERROR: Unable to get attributes of {}. Does the file exist?", newFileName);
wcscpy_s(newFileName, len + 1, lpFileName);
}
HANDLE fileHandle = context.TrueCreateFileW(newFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);;
spdlog::info(L"Returning File Handle {}", newFileName);
delete[] newFileName;
return fileHandle;
}
else {
return context.TrueCreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
}
void MainContext::FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out) void MainContext::FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out)
{ {
if (flags_in & D3DCREATE_SOFTWARE_VERTEXPROCESSING) if (flags_in & D3DCREATE_SOFTWARE_VERTEXPROCESSING)
@ -48,24 +121,26 @@ void MainContext::FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out
} }
} }
bool MainContext::ApplyBehaviorFlagsFix(DWORD* flags) void MainContext::ApplyBehaviorFlagsFix(DWORD* flags)
{ {
if (autofix == AutoFixes::NONE) return false; if (autofix == AutoFixes::NONE) return;
auto&& fix = behaviorflags_fixes.find(autofix); auto&& add = behaviorflags_add.find(autofix);
if (fix != behaviorflags_fixes.end()) if (add != behaviorflags_add.end())
FixBehaviorFlagConflict(add->second, flags);
auto&& sub = behaviorflags_sub.find(autofix);
if (sub != behaviorflags_sub.end())
{ {
FixBehaviorFlagConflict(fix->second, flags); *flags = *flags & ~sub->second;
return true; FixBehaviorFlagConflict(sub->second, flags);
} }
return false;
} }
HRESULT MainContext::SetScissorRect(IDirect3DDevice9* pIDirect3DDevice9, CONST RECT* rect) HRESULT MainContext::SetScissorRect(IDirect3DDevice9* pIDirect3DDevice9, CONST RECT* rect)
{ {
if (rect) if (rect)
{ {
RECT* r = const_cast<RECT*>(rect); RECT* r = const_cast<RECT*>(rect);
r->left = (LONG)(r->left * scissor_scaling_factor_w); r->left = (LONG)(r->left * scissor_scaling_factor_w);
r->top = (LONG)(r->top * scissor_scaling_factor_h); r->top = (LONG)(r->top * scissor_scaling_factor_h);
@ -76,55 +151,67 @@ HRESULT MainContext::SetScissorRect(IDirect3DDevice9* pIDirect3DDevice9, CONST R
return pIDirect3DDevice9->SetScissorRect(rect); return pIDirect3DDevice9->SetScissorRect(rect);
} }
HRESULT MainContext::SetViewport(IDirect3DDevice9* pIDirect3DDevice9, CONST D3DVIEWPORT9* pViewport) // hate this workaround but we cant directly mix d3d9 include with and without defined CINTERFACE
{ namespace cinterface {
if (pViewport) void VertexBufferFix(IDirect3DVertexBuffer9* pVertexBuffer);
{
D3DVIEWPORT9* vp = const_cast<D3DVIEWPORT9*>(pViewport);
if (pViewport->Width > 1280 && pViewport->Height > 720)
{
vp->Width--;
vp->X++;
vp->Height--;
vp->Y++;
}
return pIDirect3DDevice9->SetViewport(vp);
}
return pIDirect3DDevice9->SetViewport(pViewport);
} }
HRESULT MainContext::CreateVertexBuffer(IDirect3DDevice9* pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) HRESULT MainContext::CreateVertexBuffer(IDirect3DDevice9* pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle)
{ {
switch (autofix) if (autofix == AutoFixes::FINAL_FANTASY_XIII ||
autofix == AutoFixes::FINAL_FANTASY_XIII2)
{ {
case AutoFixes::FINAL_FANTASY_XIII:
case AutoFixes::FINAL_FANTASY_XIII2:
// Both games lock a vertex buffer 358400 before drawing any 2D element on screen (sometimes multiple times per frame) // Both games lock a vertex buffer 358400 before drawing any 2D element on screen (sometimes multiple times per frame)
if (Length == 358400 && Pool == D3DPOOL_MANAGED) { if (Length == 358400 && Pool == D3DPOOL_MANAGED) {
Usage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY; Usage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY;
Pool = D3DPOOL_SYSTEMMEM; Pool = D3DPOOL_SYSTEMMEM;
HRESULT hr = pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
if (config.GetFFXIIIDiscardUIVertexBuffer() && ppVertexBuffer && *ppVertexBuffer)
{
//Pool = D3DPOOL_DEFAULT;
cinterface::VertexBufferFix(*ppVertexBuffer);
}
return hr;
} }
// Crashing on Lock/Unlock, why???
// //IDirect3DVertexBuffer9* buffer = nullptr;
// //HRESULT hr = pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, &buffer, NULL);
// //if (FAILED(hr))
// //{
// // return pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
// //}
// //if(ppVertexBuffer) *ppVertexBuffer = new hkIDirect3DVertexBuffer9(pIDirect3DDevice9, buffer);
// //return hr;
break;
} }
return pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle); return pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
} }
HRESULT MainContext::DrawPrimitiveUP(IDirect3DDevice9* pIDirect3DDevice9, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void* pVertexStreamZeroData, UINT VertexStreamZeroStride)
{
if (PrimitiveType == D3DPT_TRIANGLEFAN && PrimitiveCount == 2 && VertexStreamZeroStride == 20 && MatchesExpectedVertexStream((const float*)pVertexStreamZeroData)) {
return pIDirect3DDevice9->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, fixedDrawPrimitiveUpVertexData, VertexStreamZeroStride);
}
else {
return pIDirect3DDevice9->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
}
}
void MainContext::OneTimeFix(std::unique_ptr<wchar_t[]>& className) bool MainContext::MatchesExpectedVertexStream(const float* pVertexStreamZeroData) {
for (int i = 0; i < 4 * 5; i++) {
if (fabs(expectedDrawPrimitiveUpVertexData[i] - pVertexStreamZeroData[i]) > 0.000001f) {
return false;
}
}
return true;
}
bool MainContext::OneTimeFixInit(std::unique_ptr<wchar_t[]>& className, HWND hWnd)
{ {
if (wcscmp(className.get(), L"SQEX.CDev.Engine.Framework.MainWindow") == 0) { if (wcscmp(className.get(), L"SQEX.CDev.Engine.Framework.MainWindow") == 0) {
otf_init = true;
hWndFF13 = hWnd;
return true;
}
return false;
}
void MainContext::OneTimeFix()
{
if (otf_init)
{
otf_init = false;
std::thread fix(&context.Fix_Thread); std::thread fix(&context.Fix_Thread);
fix.detach(); fix.detach();
} }
@ -132,15 +219,19 @@ void MainContext::OneTimeFix(std::unique_ptr<wchar_t[]>& className)
void MainContext::Fix_Thread() void MainContext::Fix_Thread()
{ {
auto start = std::chrono::high_resolution_clock::now();
std::this_thread::sleep_for(std::chrono::milliseconds(2000)); std::this_thread::sleep_for(std::chrono::milliseconds(2000));
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> elapsed = end - start;
spdlog::info("Waited {} ms", elapsed.count());
std::lock_guard<std::mutex> lock(context.fix_mutex); std::lock_guard<std::mutex> lock(context.fix_mutex);
if (context.autofix == AutoFixes::FINAL_FANTASY_XIII) { if (context.autofix == AutoFixes::FINAL_FANTASY_XIII) {
PrintLog("Starting FFXIII one time RAM patches."); spdlog::info("Starting FFXIII one time RAM patches.");
context.FF13_OneTimeFixes(); context.FF13_OneTimeFixes();
} }
else if (context.autofix == AutoFixes::FINAL_FANTASY_XIII2) { else if (context.autofix == AutoFixes::FINAL_FANTASY_XIII2) {
PrintLog("Starting FFXIII-2 one time RAM patches."); spdlog::info("Starting FFXIII-2 one time RAM patches.");
context.FF13_2_OneTimeFixes(); context.FF13_2_OneTimeFixes();
} }
MessageBeep(MB_ICONASTERISK); MessageBeep(MB_ICONASTERISK);
@ -150,7 +241,7 @@ void MainContext::FF13_InitializeGameAddresses()
{ {
// FF13 always seem to use the same addresses (even if you force ASLR on the OS), but we are calculating the addresses just in case... // FF13 always seem to use the same addresses (even if you force ASLR on the OS), but we are calculating the addresses just in case...
uint8_t* baseAddr = (uint8_t*)GetModuleHandle(NULL); // Should be 400000 uint8_t* baseAddr = (uint8_t*)GetModuleHandle(NULL); // Should be 400000
PrintLog("Base Addr = %x", baseAddr); spdlog::info("Base Addr = {}", (void*)baseAddr);
ff13_frame_pacer_ptr = (float**)(baseAddr + 0x243E34C); ff13_frame_pacer_ptr = (float**)(baseAddr + 0x243E34C);
ff13_set_framerate_ingame_instruction_address = baseAddr + 0xA8D65F; ff13_set_framerate_ingame_instruction_address = baseAddr + 0xA8D65F;
@ -170,29 +261,89 @@ void MainContext::FF13_InitializeGameAddresses()
ff13_party_screen_scissor_scaling_factor_2 = baseAddr + 0x668E1E; ff13_party_screen_scissor_scaling_factor_2 = baseAddr + 0x668E1E;
ff13_party_screen_scissor_scaling_factor_3 = baseAddr + 0x668E56; ff13_party_screen_scissor_scaling_factor_3 = baseAddr + 0x668E56;
ff13_party_screen_scissor_scaling_factor_4 = baseAddr + 0x668E91; ff13_party_screen_scissor_scaling_factor_4 = baseAddr + 0x668E91;
ff13_message_box_call_address = baseAddr + 0xA8A98F;
ff13_message_box_stack_push_address = baseAddr + 0xA8A982;
ff13_exe_large_address_aware_flag_address = baseAddr + 0x126;
ff13_exe_checksum_address = (uint32_t*)(baseAddr + 0x168);
}
void MainContext::FF13_HandleLargeAddressAwarePatch() {
const uint8_t laaMask = 0x20;
if (*ff13_exe_large_address_aware_flag_address & laaMask) {
spdlog::info("LargeAddressAwarePatch found. ff13_exe_large_address_aware_flag = {:X}; ff13_exe_checksum = {:X}", *ff13_exe_large_address_aware_flag_address, *ff13_exe_checksum_address);
const MH_STATUS createHookCreateFileA = MH_CreateHook(CreateFileA, HookCreateFileA, reinterpret_cast<void**>(&TrueCreateFileA));
spdlog::info("createHookCreateFileA = {}", createHookCreateFileA);
const MH_STATUS enableHookCreateFileA = MH_EnableHook(CreateFileA);
spdlog::info("enableHookCreateFileA = {}", enableHookCreateFileA);
const MH_STATUS createHookCreateFileW = MH_CreateHook(CreateFileW, HookCreateFileW, reinterpret_cast<void**>(&TrueCreateFileW));
spdlog::info("createHookCreateFileW = {}", createHookCreateFileW);
const MH_STATUS enableHookCreateFileW = MH_EnableHook(CreateFileW);
spdlog::info("enableHookCreateFileW = {}", enableHookCreateFileW);
uint8_t new_ff13_exe_large_address_aware_flag = *ff13_exe_large_address_aware_flag_address & ~laaMask;
MemPatch::Patch(ff13_exe_large_address_aware_flag_address, &new_ff13_exe_large_address_aware_flag, 1);
spdlog::info("LargeAddressAware patched back. ff13_exe_large_address_aware_flag = {:X};", *ff13_exe_large_address_aware_flag_address);
uint32_t new_ff13_exe_checksum = 0;
MemPatch::Patch(ff13_exe_checksum_address, &new_ff13_exe_checksum, sizeof(uint32_t));
spdlog::info("Checksum patched back. ff13_exe_checksum = {:X}", *ff13_exe_checksum_address);
spdlog::info("LargeAddressAwarePatch handled");
}
else {
spdlog::info("LargeAddressAwarePatch not found.");
}
}
void MainContext::ForceWindowActivate(const HWND hWnd) {
PostMessage(hWnd, WM_ACTIVATE, WA_INACTIVE, NULL);
PostMessage(hWnd, WM_ACTIVATE, WA_CLICKACTIVE, NULL);
SetForegroundWindow(hWnd);
} }
void MainContext::FF13_OneTimeFixes() { void MainContext::FF13_OneTimeFixes() {
if (IsDXVK()) {
FF13_PatchMessageBox();
}
ForceWindowActivate(hWndFF13);
FF13_NOPIngameFrameRateLimitSetter(); FF13_NOPIngameFrameRateLimitSetter();
FF13_RemoveContinuousControllerScan(); FF13_RemoveContinuousControllerScan();
FF13_FixScissorRect(); FF13_FixScissorRect();
FF13_EnableControllerVibration(); FF13_EnableControllerVibration();
FF13_SetFrameRateVariables(); FF13_SetFrameRateVariables();
AdjustVertexData(*ff13_internal_res_w, *ff13_internal_res_h);
PrintLog("Finished FF13 One Time Fixes"); spdlog::info("Finished FF13 One Time Fixes");
}
void MainContext::FF13_PatchMessageBox()
{
spdlog::info("Removing 'Quit game' textbox");
MemPatch::Nop(ff13_message_box_stack_push_address, 1);
MemPatch::Nop(ff13_message_box_stack_push_address + 1 * 4, 1);
MemPatch::Nop(ff13_message_box_stack_push_address + 2 * 4, 1);
MemPatch::Nop(ff13_message_box_stack_push_address + 3 * 4, 1);
PatchMessageBoxCall(ff13_message_box_call_address);
} }
void MainContext::FF13_EnableControllerVibration() void MainContext::FF13_EnableControllerVibration()
{ {
if (!config.GetFFXIIIEnableControllerVibration()) { if (!config.GetFFXIIIEnableControllerVibration()) {
PrintLog("Vibration should not be enabled (config file)"); spdlog::info("Vibration should not be enabled (config file)");
return; return;
} }
if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) { if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) {
PrintLog("Vibration disabled because FFXIIIDisableIngameControllerHotSwapping is set to false (config file)"); spdlog::info("Vibration disabled because FFXIIIDisableIngameControllerHotSwapping is set to false (config file)");
return; return;
} }
PrintLog("Enabling controller vibration..."); spdlog::info("Enabling controller vibration...");
MemPatch::Nop(ff13_vibration_low_set_zero_address, 5); MemPatch::Nop(ff13_vibration_low_set_zero_address, 5);
MemPatch::Nop(ff13_vibration_high_set_zero_address, 5); MemPatch::Nop(ff13_vibration_high_set_zero_address, 5);
@ -202,19 +353,19 @@ void MainContext::FF13_EnableControllerVibration()
void MainContext::FF13_RemoveContinuousControllerScan() void MainContext::FF13_RemoveContinuousControllerScan()
{ {
if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) { if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) {
PrintLog("Continuous controller scanning not disabled (config)"); spdlog::info("Continuous controller scanning not disabled (config)");
return; return;
} }
// Disable continuous controller scanning. // Disable continuous controller scanning.
PrintLog("Removing game slow and synchronous controller continuous controller scanning..."); spdlog::info("Removing game slow and synchronous controller continuous controller scanning...");
// change a jne to jmp // change a jne to jmp
MemPatch::Fill(ff13_continuous_scan_instruction_address, 0xEB, 1); MemPatch::Fill(ff13_continuous_scan_instruction_address, 0xEB, 1);
} }
void MainContext::FF13_FixScissorRect() void MainContext::FF13_FixScissorRect()
{ {
PrintLog("Fixing ScissorRect..."); spdlog::info("Fixing ScissorRect...");
const float originalWidth = 1280.0F; const float originalWidth = 1280.0F;
const float resolutionFactorW = (float)*ff13_internal_res_w / originalWidth; const float resolutionFactorW = (float)*ff13_internal_res_w / originalWidth;
scissor_scaling_factor_w = resolutionFactorW; scissor_scaling_factor_w = resolutionFactorW;
@ -234,12 +385,12 @@ void MainContext::FF13_FixScissorRect()
MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_1, 4); MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_1, 4);
MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_2, 7); MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_2, 7);
MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_3, 7); MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_3, 7);
MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_3, 5); MemPatch::Nop(ff13_party_screen_scissor_scaling_factor_4, 7);
} }
void MainContext::FF13_NOPIngameFrameRateLimitSetter() void MainContext::FF13_NOPIngameFrameRateLimitSetter()
{ {
PrintLog("NOPing the in-game instruction that sets the frame rate."); spdlog::info("NOPing the in-game instruction that sets the frame rate.");
MemPatch::Nop(ff13_set_framerate_ingame_instruction_address, 5); MemPatch::Nop(ff13_set_framerate_ingame_instruction_address, 5);
} }
@ -247,11 +398,11 @@ void MainContext::FF13_SetFrameRateVariables()
{ {
float* framePacerTargetPtr = *ff13_frame_pacer_ptr; float* framePacerTargetPtr = *ff13_frame_pacer_ptr;
if (framePacerTargetPtr) { if (framePacerTargetPtr) {
PrintLog("Frame pacer target frame rate is at address %x", framePacerTargetPtr); spdlog::info("Frame pacer target frame rate is at address {}", (void*)framePacerTargetPtr);
float* ingameFrameRateFramePacerTarget = framePacerTargetPtr; float* ingameFrameRateFramePacerTarget = framePacerTargetPtr;
*ingameFrameRateFramePacerTarget = MAX_FRAME_RATE_LIMIT; *ingameFrameRateFramePacerTarget = MAX_FRAME_RATE_LIMIT;
PrintLog("Frame pacer disabled."); spdlog::info("Frame pacer disabled.");
if (config.GetFFXIIIIngameFrameRateLimit() != 0) if (config.GetFFXIIIIngameFrameRateLimit() != 0)
{ {
@ -267,37 +418,66 @@ void MainContext::FF13_SetFrameRateVariables()
float* ingameFrameRateLimitPtr = framePacerTargetPtr + 1; float* ingameFrameRateLimitPtr = framePacerTargetPtr + 1;
*ingameFrameRateLimitPtr = frameRateLimit; *ingameFrameRateLimitPtr = frameRateLimit;
PrintLog("Target frame rate set to %f", frameRateLimit); spdlog::info("Target frame rate set to {}", frameRateLimit); }
}
} }
else { else {
PrintLog("Unable to find frame pacer / frame rate address. This shouldn't happen! Report this."); spdlog::info("Unable to find frame pacer / frame rate address. This shouldn't happen! Report this.");
} }
} }
void MainContext::FF13_2_OneTimeFixes() void MainContext::FF13_2_OneTimeFixes()
{ {
ForceWindowActivate(hWndFF13);
if (IsDXVK()) {
FF13_2_PatchMessageBox();
}
if (*ff13_2_frame_pacer_ptr_address) { if (*ff13_2_frame_pacer_ptr_address) {
**ff13_2_frame_pacer_ptr_address = MAX_FRAME_RATE_LIMIT; **ff13_2_frame_pacer_ptr_address = MAX_FRAME_RATE_LIMIT;
PrintLog("Frame pacer disabled"); spdlog::info("Frame pacer disabled");
FF13_2_AddHookIngameFrameRateLimitSetter(); FF13_2_AddHookIngameFrameRateLimitSetter();
FF13_2_RemoveContinuousControllerScan(); FF13_2_RemoveContinuousControllerScan();
FF13_2_EnableControllerVibration(); FF13_2_EnableControllerVibration();
PrintLog("Finished FF13-2 One Time Fixes"); AdjustVertexData(*ff13_2_internal_res_w, *ff13_2_internal_res_h);
spdlog::info("Finished FF13-2 One Time Fixes");
} }
else { else {
PrintLog("Unable to apply FF13-2 One Time Fixes. Report this!"); spdlog::info("Unable to apply FF13-2 One Time Fixes. Report this!");
} }
} }
void MainContext::FF13_2_PatchMessageBox()
{
spdlog::info("Removing 'Quit game' textbox");
// NOP push of registers to call MessageBox
MemPatch::Nop(ff13_2_message_box_stack_push_address, 5);
PatchMessageBoxCall(ff13_2_message_box_call_address);
}
void MainContext::PatchMessageBoxCall(uint8_t* callInstructionAddress)
{
const int patchSize = 6;
uint8_t patch[patchSize];
// mov eax, IDYES
patch[0] = 0xB8;
*((uint32_t*)(patch + 1)) = IDYES;
// nop
patch[5] = 0x90;
MemPatch::Patch(callInstructionAddress, patch, patchSize);
}
void MainContext::FF13_2_EnableControllerVibration() void MainContext::FF13_2_EnableControllerVibration()
{ {
if (!config.GetFFXIIIEnableControllerVibration()) { if (!config.GetFFXIIIEnableControllerVibration()) {
PrintLog("Vibration should not be enabled (config file)"); spdlog::info("Vibration should not be enabled (config file)");
return; return;
} }
PrintLog("Enabling controller vibration..."); spdlog::info("Enabling controller vibration...");
MemPatch::Nop(ff13_2_vibration_low_set_zero_address, 5); MemPatch::Nop(ff13_2_vibration_low_set_zero_address, 5);
MemPatch::Nop(ff13_2_vibration_high_set_zero_address, 5); MemPatch::Nop(ff13_2_vibration_high_set_zero_address, 5);
@ -305,11 +485,22 @@ void MainContext::FF13_2_EnableControllerVibration()
xinputManager = new XInputManager(ff13_2_base_controller_input_address_ptr, config.GetFFXIIIVibrationStrengthFactor()); xinputManager = new XInputManager(ff13_2_base_controller_input_address_ptr, config.GetFFXIIIVibrationStrengthFactor());
} }
void MainContext::AdjustVertexData(const uint32_t width, const uint32_t height)
{
const float widthHalfPixelSize = 1.0f / width;
const float heightHalfPixelSize = 1.0f / height;
for (int i = 0; i < 4; i++) {
const unsigned int rowBaseIndex = i * 5;
context.fixedDrawPrimitiveUpVertexData[rowBaseIndex] -= widthHalfPixelSize;
context.fixedDrawPrimitiveUpVertexData[1 + rowBaseIndex] += heightHalfPixelSize;
}
}
void MainContext::FF13_2_InitializeGameAddresses() void MainContext::FF13_2_InitializeGameAddresses()
{ {
// FF13-2 uses address space layout randomization (ASLR) so we can't rely on fixed addresses without considering the base address // FF13-2 uses address space layout randomization (ASLR) so we can't rely on fixed addresses without considering the base address
uint8_t* baseAddr = (uint8_t*)GetModuleHandle(NULL); uint8_t* baseAddr = (uint8_t*)GetModuleHandle(NULL);
PrintLog("Base Addr = %x", baseAddr); spdlog::info("Base Addr = {}", (void*)baseAddr);
ff13_2_continuous_scan_instruction_address = baseAddr + 0x2A6E7F; ff13_2_continuous_scan_instruction_address = baseAddr + 0x2A6E7F;
ff13_2_set_frame_rate_address = baseAddr + 0x802616; ff13_2_set_frame_rate_address = baseAddr + 0x802616;
@ -319,17 +510,19 @@ void MainContext::FF13_2_InitializeGameAddresses()
ff13_2_vibration_high_set_zero_address = baseAddr + 0x2A7226; ff13_2_vibration_high_set_zero_address = baseAddr + 0x2A7226;
ff13_2_internal_res_w = (uint32_t*)(baseAddr + 0x1FA864C); ff13_2_internal_res_w = (uint32_t*)(baseAddr + 0x1FA864C);
ff13_2_internal_res_h = ff13_2_internal_res_w + 1; ff13_2_internal_res_h = ff13_2_internal_res_w + 1;
ff13_2_message_box_call_address = baseAddr + 0x8047C0;
ff13_2_message_box_stack_push_address = baseAddr + 0x8047B4;
} }
void MainContext::FF13_2_RemoveContinuousControllerScan() void MainContext::FF13_2_RemoveContinuousControllerScan()
{ {
if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) { if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) {
PrintLog("Continuous controller scanning not disabled (config)"); spdlog::info("Continuous controller scanning not disabled (config)");
return; return;
} }
// Disable continuous controller scanning. // Disable continuous controller scanning.
PrintLog("Removing game slow and synchronous controller continuous controller scanning..."); spdlog::info("Removing game slow and synchronous controller continuous controller scanning...");
// change a jne to jmp // change a jne to jmp
MemPatch::Fill(ff13_2_continuous_scan_instruction_address, 0xEB, 1); MemPatch::Fill(ff13_2_continuous_scan_instruction_address, 0xEB, 1);
} }
@ -337,11 +530,11 @@ void MainContext::FF13_2_RemoveContinuousControllerScan()
void MainContext::FF13_2_AddHookIngameFrameRateLimitSetter() void MainContext::FF13_2_AddHookIngameFrameRateLimitSetter()
{ {
if (config.GetFFXIIIIngameFrameRateLimit() == 0) { if (config.GetFFXIIIIngameFrameRateLimit() == 0) {
PrintLog("Frame rate should not be changed (config = 0)"); spdlog::info("Frame rate should not be changed (config = 0)");
return; return;
} }
PrintLog("Hooking the instruction that sets the frame rate..."); spdlog::info("Hooking the instruction that sets the frame rate...");
MemPatch::CUnprotect unp(ff13_2_set_frame_rate_address, 5); MemPatch::CUnprotect unp(ff13_2_set_frame_rate_address, 5);
@ -355,7 +548,7 @@ void MainContext::FF13_2_CreateSetFrameRateCodeBlock()
const int blockSize = 31; const int blockSize = 31;
FF13_2_SET_FRAME_RATE_INJECTED_CODE = new(std::nothrow) uint8_t[blockSize]; FF13_2_SET_FRAME_RATE_INJECTED_CODE = new(std::nothrow) uint8_t[blockSize];
if (!FF13_2_SET_FRAME_RATE_INJECTED_CODE) { if (!FF13_2_SET_FRAME_RATE_INJECTED_CODE) {
PrintLog("Failed to initialize FFXIII-2 code block"); spdlog::info("Failed to initialize FFXIII-2 code block");
return; return;
} }
DWORD oldProtect; DWORD oldProtect;
@ -372,7 +565,7 @@ void MainContext::FF13_2_CreateSetFrameRateCodeBlock()
ff13_2_targetFrameRate = (float)std::min(frameRateConfig, (s32)FF13_2_MAX_FRAME_CAP); ff13_2_targetFrameRate = (float)std::min(frameRateConfig, (s32)FF13_2_MAX_FRAME_CAP);
} }
PrintLog("Target frame rate set to %f", ff13_2_targetFrameRate); spdlog::info("Target frame rate set to {}", ff13_2_targetFrameRate);
} }
// movss xmm1,[&FF13_2_30_FPS] // movss xmm1,[&FF13_2_30_FPS]
@ -412,9 +605,5 @@ void MainContext::FF13_2_CreateSetFrameRateCodeBlock()
} }
void MainContext::PrintVersionInfo() { void MainContext::PrintVersionInfo() {
PrintLog("FF13Fix 1.5.1 https://github.com/rebtd7/FF13Fix"); spdlog::info("FF13Fix 1.6.5 https://github.com/rebtd7/FF13Fix");
} }
bool MainContext::AreAlmostTheSame(float a, float b) {
return fabs(a - b) < 0.01f;
}

View file

@ -1,11 +1,15 @@
#include "stdafx.h" #include "stdafx.h"
#include <windows.h>
#include "Wrapper.h"
#include "Context.h"
#include "IDirect3D9.h"
#include <thread> #include <thread>
#include <array>
#include "MinHook.h"
#include "SimpleIni.h"
#include "IDirect3D9.h"
#include "IDirect3DDevice9.h"
#include "Context.h"
#include "Wrapper.h"
MainContext context; MainContext context;
@ -22,8 +26,8 @@ Config::Config()
// save file and reload // save file and reload
ini.Reset(); ini.Reset();
#define SETTING(_type, _func, _var, _section, _defaultval) \ #define SETTING(_type, _func, _var, _section, _defaultval, _comment) \
ini.Set##_func(L#_section, L#_var, _defaultval) ini.Set##_func(L#_section, L#_var, _defaultval, _comment)
#include "Settings.h" #include "Settings.h"
#undef SETTING #undef SETTING
@ -33,47 +37,63 @@ Config::Config()
ini.LoadFile(inifile.c_str()); ini.LoadFile(inifile.c_str());
} }
#define SETTING(_type, _func, _var, _section, _defaultval) \ #define SETTING(_type, _func, _var, _section, _defaultval, _comment) \
_var = ini.Get##_func(L#_section, L#_var) _var = ini.Get##_func(L#_section, L#_var)
#include "Settings.h" #include "Settings.h"
#undef SETTING #undef SETTING
} }
MainContext::MainContext() : oldWndProc(nullptr) MainContext::MainContext()
{ {
LogFile("FF13Fix.log"); std::string logfilename = FullPathFromPath("FF13Fix.log");
auto file_logger = spdlog::basic_logger_mt("file_logger", logfilename, true);
spdlog::set_default_logger(file_logger);
//[2014-10-31 23:46:59.678] [thread] [level] Some message
spdlog::set_pattern("[%Y-%m-%d %T.%e] [%6t] [%l] %v");
spdlog::set_level(static_cast<spdlog::level::level_enum>(config.GetLogLogLevel()));
spdlog::flush_on(spdlog::level::err); // trigger flush whenever errors or more severe messages are logged
if(config.GetLogLogFlush())
spdlog::flush_on(spdlog::level::trace); // trigger flush whenever trace or more severe messages are logged => always
context.PrintVersionInfo(); context.PrintVersionInfo();
if (config.GetOptionsAutoFix()) EnableAutoFix(); spdlog::info("Enabling hooks:");
PrintLog("Enabling hooks:");
const MH_STATUS initializeHooks = MH_Initialize(); const MH_STATUS initializeHooks = MH_Initialize();
PrintLog("initializeHooks = %d", initializeHooks); spdlog::info("initializeHooks = {}", initializeHooks);
const MH_STATUS createHookDirect3DCreate9 = MH_CreateHook(D3D9DLL::Get().Direct3DCreate9, HookDirect3DCreate9, reinterpret_cast<void**>(&TrueDirect3DCreate9)); const MH_STATUS createHookDirect3DCreate9 = MH_CreateHook(D3D9DLL::Get().Direct3DCreate9, HookDirect3DCreate9, reinterpret_cast<void**>(&TrueDirect3DCreate9));
PrintLog("createHookDirect3DCreate9 = %d", createHookDirect3DCreate9); spdlog::info("createHookDirect3DCreate9 = {}", createHookDirect3DCreate9);
const MH_STATUS enableHookDirect3DCreate9 = MH_EnableHook(D3D9DLL::Get().Direct3DCreate9); const MH_STATUS enableHookDirect3DCreate9 = MH_EnableHook(D3D9DLL::Get().Direct3DCreate9);
PrintLog("enableHookDirect3DCreate9 = %d", enableHookDirect3DCreate9); spdlog::info("enableHookDirect3DCreate9 = {}", enableHookDirect3DCreate9);
const MH_STATUS createHookDirect3DCreate9Ex = MH_CreateHook(D3D9DLL::Get().Direct3DCreate9Ex, HookDirect3DCreate9Ex, reinterpret_cast<void**>(&TrueDirect3DCreate9Ex));
spdlog::info("createHookDirect3DCreate9Ex = {}", createHookDirect3DCreate9Ex);
const MH_STATUS enableHookDirect3DCreate9Ex = MH_EnableHook(D3D9DLL::Get().Direct3DCreate9Ex);
spdlog::info("enableHookDirect3DCreate9Ex = {}", enableHookDirect3DCreate9Ex);
const MH_STATUS createHookCreateWindowExA = MH_CreateHook(CreateWindowExA, HookCreateWindowExA, reinterpret_cast<void**>(&TrueCreateWindowExA)); const MH_STATUS createHookCreateWindowExA = MH_CreateHook(CreateWindowExA, HookCreateWindowExA, reinterpret_cast<void**>(&TrueCreateWindowExA));
PrintLog("createHookCreateWindowExA = %d", createHookCreateWindowExA); spdlog::info("createHookCreateWindowExA = {}", createHookCreateWindowExA);
const MH_STATUS enableHookCreateWindowExA = MH_EnableHook(CreateWindowExA); const MH_STATUS enableHookCreateWindowExA = MH_EnableHook(CreateWindowExA);
PrintLog("enableHookCreateWindowExA = %d", enableHookCreateWindowExA); spdlog::info("enableHookCreateWindowExA = {}", enableHookCreateWindowExA);
const MH_STATUS createHookCreateWindowExW = MH_CreateHook(CreateWindowExW, HookCreateWindowExW, reinterpret_cast<void**>(&TrueCreateWindowExW)); const MH_STATUS createHookCreateWindowExW = MH_CreateHook(CreateWindowExW, HookCreateWindowExW, reinterpret_cast<void**>(&TrueCreateWindowExW));
PrintLog("createHookCreateWindowExW = %d", createHookCreateWindowExW); spdlog::info("createHookCreateWindowExW = {}", createHookCreateWindowExW);
const MH_STATUS enableHookCreateWindowExW = MH_EnableHook(CreateWindowExW); const MH_STATUS enableHookCreateWindowExW = MH_EnableHook(CreateWindowExW);
PrintLog("enableHookCreateWindowExW = %d", enableHookCreateWindowExW); spdlog::info("enableHookCreateWindowExW = {}", enableHookCreateWindowExW);
const MH_STATUS createHookSetWindowLongA = MH_CreateHook(SetWindowLongA, HookSetWindowLongA, reinterpret_cast<void**>(&TrueSetWindowLongA)); const MH_STATUS createHookSetWindowLongA = MH_CreateHook(SetWindowLongA, HookSetWindowLongA, reinterpret_cast<void**>(&TrueSetWindowLongA));
PrintLog("createHookSetWindowLongA = %d", createHookSetWindowLongA); spdlog::info("createHookSetWindowLongA = {}", createHookSetWindowLongA);
const MH_STATUS enableHookSetWindowLongA = MH_EnableHook(SetWindowLongA); const MH_STATUS enableHookSetWindowLongA = MH_EnableHook(SetWindowLongA);
PrintLog("enableHookSetWindowLongA = %d", enableHookSetWindowLongA); spdlog::info("enableHookSetWindowLongA = {}", enableHookSetWindowLongA);
const MH_STATUS createHookSetWindowLongW = MH_CreateHook(SetWindowLongW, HookSetWindowLongW, reinterpret_cast<void**>(&TrueSetWindowLongW)); const MH_STATUS createHookSetWindowLongW = MH_CreateHook(SetWindowLongW, HookSetWindowLongW, reinterpret_cast<void**>(&TrueSetWindowLongW));
PrintLog("createHookSetWindowLongW = %d", createHookSetWindowLongW); spdlog::info("createHookSetWindowLongW = {}", createHookSetWindowLongW);
const MH_STATUS enableHookSetWindowLongW = MH_EnableHook(SetWindowLongW); const MH_STATUS enableHookSetWindowLongW = MH_EnableHook(SetWindowLongW);
PrintLog("enableHookSetWindowLongW = %d", enableHookSetWindowLongW); spdlog::info("enableHookSetWindowLongW = {}", enableHookSetWindowLongW);
if (config.GetOptionsAutoFix()) EnableAutoFix();
} }
MainContext::~MainContext() MainContext::~MainContext()
@ -83,15 +103,27 @@ MainContext::~MainContext()
IDirect3D9* WINAPI MainContext::HookDirect3DCreate9(UINT SDKVersion) IDirect3D9* WINAPI MainContext::HookDirect3DCreate9(UINT SDKVersion)
{ {
spdlog::info(__FUNCTION__);
IDirect3D9* d3d9 = context.TrueDirect3DCreate9(SDKVersion); IDirect3D9* d3d9 = context.TrueDirect3DCreate9(SDKVersion);
if (d3d9) if (d3d9) {
{ return new hkIDirect3D9(static_cast<IDirect3D9Ex*>(d3d9));
return new hkIDirect3D9(d3d9);
} }
return d3d9; return d3d9;
} }
HRESULT WINAPI MainContext::HookDirect3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex** ppIDirect3D9Ex)
{
spdlog::info(__FUNCTION__);
HRESULT hr = context.TrueDirect3DCreate9Ex(SDKVersion, ppIDirect3D9Ex);
if (SUCCEEDED(hr)) {
hkIDirect3D9* pIDirect3D9Ex = new hkIDirect3D9(*ppIDirect3D9Ex);
*ppIDirect3D9Ex = pIDirect3D9Ex;
}
return hr;
}
bool MainContext::BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString) bool MainContext::BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString)
{ {
#define BF2STR(x) if (BehaviorFlags & x) BehaviorFlagsString->append(#x" "); #define BF2STR(x) if (BehaviorFlags & x) BehaviorFlagsString->append(#x" ");
@ -124,15 +156,15 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati
if (pPresentationParameters) if (pPresentationParameters)
{ {
// -1 = Auto, enabled when no DXVK is used // -1 = Auto, enabled when no DXVK is used
if (config.GetOptionsTripleBuffering() == 1 || (config.GetOptionsTripleBuffering() == -1 && !D3D9DLL::Get().IsDXVK())) if (config.GetOptionsTripleBuffering() == 1 || (config.GetOptionsTripleBuffering() == -1 && !IsDXVK()))
{ {
pPresentationParameters->BackBufferCount = 3; pPresentationParameters->BackBufferCount = 3;
PrintLog("BackBufferCount: BackBufferCount set to %u", pPresentationParameters->BackBufferCount); spdlog::info("BackBufferCount: BackBufferCount set to {}", pPresentationParameters->BackBufferCount);
} }
if ((s32)config.GetOptionsFullScreenRefreshRate() >= 0 && pPresentationParameters->FullScreen_RefreshRateInHz != 0) if ((s32)config.GetOptionsFullScreenRefreshRate() >= 0 && pPresentationParameters->FullScreen_RefreshRateInHz != 0)
{ {
PrintLog("Changing refresh rate from %u to %u", pPresentationParameters->FullScreen_RefreshRateInHz, config.GetOptionsFullScreenRefreshRate()); spdlog::info("Changing refresh rate from {} to {}", pPresentationParameters->FullScreen_RefreshRateInHz, config.GetOptionsFullScreenRefreshRate());
pPresentationParameters->FullScreen_RefreshRateInHz = config.GetOptionsFullScreenRefreshRate(); pPresentationParameters->FullScreen_RefreshRateInHz = config.GetOptionsFullScreenRefreshRate();
} }
@ -142,19 +174,23 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati
pPresentationParameters->MultiSampleType = (D3DMULTISAMPLE_TYPE)config.GetOptionsMultisample(); pPresentationParameters->MultiSampleType = (D3DMULTISAMPLE_TYPE)config.GetOptionsMultisample();
pPresentationParameters->MultiSampleQuality = 0; pPresentationParameters->MultiSampleQuality = 0;
PrintLog("MultiSampleType %u, MultiSampleQuality %u", pPresentationParameters->MultiSampleType, pPresentationParameters->MultiSampleQuality); spdlog::info("MultiSampleType {}, MultiSampleQuality {}", pPresentationParameters->MultiSampleType, pPresentationParameters->MultiSampleQuality);
} }
if (config.GetOptionsPresentationInterval() != -1) if (config.GetOptionsPresentationInterval() != 0)
{ {
pPresentationParameters->PresentationInterval = config.GetOptionsPresentationInterval(); if (config.GetOptionsPresentationInterval() == -1)
PrintLog("PresentationInterval: PresentationInterval set to %u", pPresentationParameters->PresentationInterval); pPresentationParameters->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
else if (config.GetOptionsPresentationInterval() > 0)
pPresentationParameters->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
spdlog::info("PresentationInterval: PresentationInterval set to {:X}", pPresentationParameters->PresentationInterval);
} }
if (config.GetOptionsSwapEffect() != -1) if (config.GetOptionsSwapEffect() != -1)
{ {
pPresentationParameters->SwapEffect = (D3DSWAPEFFECT)config.GetOptionsSwapEffect(); pPresentationParameters->SwapEffect = (D3DSWAPEFFECT)config.GetOptionsSwapEffect();
PrintLog("SwapEffect: SwapEffect set to %u", pPresentationParameters->SwapEffect); spdlog::info("SwapEffect: SwapEffect set to {}", pPresentationParameters->SwapEffect);
} }
if (config.GetBorderlessBorderless()) if (config.GetBorderlessBorderless())
@ -169,7 +205,8 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati
pPresentationParameters->SwapEffect = pPresentationParameters->MultiSampleType == D3DMULTISAMPLE_NONE ? D3DSWAPEFFECT_DISCARD : D3DSWAPEFFECT_FLIP; pPresentationParameters->SwapEffect = pPresentationParameters->MultiSampleType == D3DMULTISAMPLE_NONE ? D3DSWAPEFFECT_DISCARD : D3DSWAPEFFECT_FLIP;
pPresentationParameters->Windowed = TRUE; pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0; pPresentationParameters->FullScreen_RefreshRateInHz = 0;
PrintLog("ForceWindowedMode");
spdlog::info("ForceWindowedMode");
} }
} }
@ -188,18 +225,17 @@ bool MainContext::CheckWindow(HWND hWnd)
GetClassNameW(hWnd, className.get(), MAX_PATH); GetClassNameW(hWnd, className.get(), MAX_PATH);
GetWindowTextW(hWnd, windowName.get(), MAX_PATH); GetWindowTextW(hWnd, windowName.get(), MAX_PATH);
PrintLog("HWND 0x%p: ClassName \"%ls\", WindowName: \"%ls\"", hWnd, className.get(), windowName.get()); spdlog::info(L"HWND {}: ClassName \"{}\", WindowName: \"{}\"", (void*)hWnd, className.get(), windowName.get());
OneTimeFix(className); bool class_found = config.GetWindowWindowClass().compare(className.get()) == 0;
bool window_found = config.GetWindowWindowName().compare(windowName.get()) == 0;
bool class_found = config.GetBorderlessWindowClass().compare(className.get()) == 0;
bool window_found = config.GetBorderlessWindowName().compare(windowName.get()) == 0;
bool force = config.GetBorderlessAllWindows(); bool force = config.GetBorderlessAllWindows();
bool ff13fix = OneTimeFixInit(className, hWnd);
return class_found || window_found || force; return class_found || window_found || force || ff13fix;
} }
void MainContext::ApplyWndProc(HWND hWnd) void MainContext::ApplyWindow(HWND hWnd)
{ {
if (config.GetOptionsAlwaysActive() || config.GetOptionsHideCursor()) if (config.GetOptionsAlwaysActive() || config.GetOptionsHideCursor())
{ {
@ -223,11 +259,16 @@ void MainContext::ApplyBorderless(HWND hWnd)
int cx = GetSystemMetrics(SM_CXSCREEN); int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN); int cy = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(hWnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); HWND insertAfter = HWND_TOP;
if (config.GetWindowTopMost())
insertAfter = HWND_TOPMOST;
SetWindowPos(hWnd, insertAfter, 0, 0, cx, cy, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
SetFocus(hWnd); SetFocus(hWnd);
PrintLog("HWND 0x%p: Borderless dwStyle: %lX->%lX", hWnd, dwStyle, new_dwStyle); spdlog::info("HWND {:X}: Borderless dwStyle: {:X}->{:X}", (void*)hWnd, dwStyle, new_dwStyle);
PrintLog("HWND 0x%p: Borderless dwExStyle: %lX->%lX", hWnd, dwExStyle, new_dwExStyle); spdlog::info("HWND {:X}: Borderless dwExStyle: {:X}->{:X}", (void*)hWnd, dwExStyle, new_dwExStyle);
} }
} }
@ -256,7 +297,6 @@ LRESULT CALLBACK MainContext::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
case WM_ACTIVATEAPP: case WM_ACTIVATEAPP:
if (context.config.GetOptionsAlwaysActive()) if (context.config.GetOptionsAlwaysActive())
return TRUE; return TRUE;
} }
if (context.config.GetOptionsForceHideCursor()) if (context.config.GetOptionsForceHideCursor())
@ -273,13 +313,13 @@ LONG WINAPI MainContext::HookSetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLon
if (nIndex == GWL_STYLE) if (nIndex == GWL_STYLE)
{ {
dwNewLong &= ~WS_OVERLAPPEDWINDOW; dwNewLong &= ~WS_OVERLAPPEDWINDOW;
PrintLog("SetWindowLongA dwStyle: %lX->%lX", olddwNewLong, dwNewLong); spdlog::info("SetWindowLongA dwStyle: {:X}->{:X}", olddwNewLong, dwNewLong);
} }
if (nIndex == GWL_EXSTYLE) if (nIndex == GWL_EXSTYLE)
{ {
dwNewLong &= ~(WS_EX_OVERLAPPEDWINDOW); dwNewLong &= ~(WS_EX_OVERLAPPEDWINDOW);
PrintLog("SetWindowLongA dwExStyle: %lX->%lX", olddwNewLong, dwNewLong); spdlog::info("SetWindowLongA dwExStyle: {:X}->{:X}", olddwNewLong, dwNewLong);
} }
} }
return context.TrueSetWindowLongA(hWnd, nIndex, dwNewLong); return context.TrueSetWindowLongA(hWnd, nIndex, dwNewLong);
@ -293,13 +333,13 @@ LONG WINAPI MainContext::HookSetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLon
if (nIndex == GWL_STYLE) if (nIndex == GWL_STYLE)
{ {
dwNewLong &= ~WS_OVERLAPPEDWINDOW; dwNewLong &= ~WS_OVERLAPPEDWINDOW;
PrintLog("SetWindowLongW dwStyle: %lX->%lX", olddwNewLong, dwNewLong); spdlog::info("SetWindowLongW dwStyle: {:X}->{:X}", olddwNewLong, dwNewLong);
} }
if (nIndex == GWL_EXSTYLE) if (nIndex == GWL_EXSTYLE)
{ {
dwNewLong &= ~(WS_EX_OVERLAPPEDWINDOW); dwNewLong &= ~(WS_EX_OVERLAPPEDWINDOW);
PrintLog("SetWindowLongW dwExStyle: %lX->%lX", olddwNewLong, dwNewLong); spdlog::info("SetWindowLongW dwExStyle: {:X}->{:X}", olddwNewLong, dwNewLong);
} }
} }
return context.TrueSetWindowLongW(hWnd, nIndex, dwNewLong); return context.TrueSetWindowLongW(hWnd, nIndex, dwNewLong);
@ -310,13 +350,13 @@ HWND WINAPI MainContext::HookCreateWindowExA(DWORD dwExStyle, LPCSTR lpClassName
HWND hWnd = context.TrueCreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); HWND hWnd = context.TrueCreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
if (!hWnd) if (!hWnd)
{ {
PrintLog("CreateWindowExA failed"); spdlog::info("CreateWindowExA failed");
return hWnd; return hWnd;
} }
if (context.CheckWindow(hWnd)) if (context.CheckWindow(hWnd))
{ {
context.ApplyWndProc(hWnd); context.ApplyWindow(hWnd);
context.ApplyBorderless(hWnd); context.ApplyBorderless(hWnd);
} }
@ -328,15 +368,17 @@ HWND WINAPI MainContext::HookCreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassNam
HWND hWnd = context.TrueCreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); HWND hWnd = context.TrueCreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
if (!hWnd) if (!hWnd)
{ {
PrintLog("CreateWindowExW failed"); spdlog::info("CreateWindowExW failed");
return hWnd; return hWnd;
} }
if (context.CheckWindow(hWnd)) if (context.CheckWindow(hWnd))
{ {
context.ApplyWndProc(hWnd); context.ApplyWindow(hWnd);
context.ApplyBorderless(hWnd); context.ApplyBorderless(hWnd);
} }
return hWnd; return hWnd;
} }
bool MainContext::IsDXVK() { return D3D9DLL::Get().IsDXVK(); }

View file

@ -1,16 +1,18 @@
#pragma once #pragma once
#include <array> #include <atomic>
#include "d3d9.h" #include <d3d9.h>
#include <MinHook.h>
#include "SimpleIni.h"
#include "XInputManager.h"
#include "MemPatch.h"
struct hkIDirect3D9; #include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "WinUtil.h"
#include "Types.h"
#include "XInputManager.h"
static const char* inifilename = "FF13Fix.ini"; static const char* inifilename = "FF13Fix.ini";
#define CONFIG_VERSION 5 #define CONFIG_VERSION 7
class Config class Config
{ {
@ -20,7 +22,7 @@ public:
Config(); Config();
#define SETTING(_type, _func, _var, _section, _defaultval) \ #define SETTING(_type, _func, _var, _section, _defaultval, _comment) \
private: _type _var; \ private: _type _var; \
public: const _type& Get##_section##_var() const { return _var; }; public: const _type& Get##_section##_var() const { return _var; };
#include "Settings.h" #include "Settings.h"
@ -37,6 +39,7 @@ class MainContext
const MainContext& operator=(MainContext& other) = delete; const MainContext& operator=(MainContext& other) = delete;
DECLARE_HOOK(IDirect3D9*, WINAPI, Direct3DCreate9, UINT SDKVersion); DECLARE_HOOK(IDirect3D9*, WINAPI, Direct3DCreate9, UINT SDKVersion);
DECLARE_HOOK(HRESULT, WINAPI, Direct3DCreate9Ex, UINT SDKVersion, IDirect3D9Ex** ppIDirect3D9Ex);
DECLARE_HOOK(LONG, WINAPI, SetWindowLongA, HWND hWnd, int nIndex, LONG dwNewLong); DECLARE_HOOK(LONG, WINAPI, SetWindowLongA, HWND hWnd, int nIndex, LONG dwNewLong);
DECLARE_HOOK(LONG, WINAPI, SetWindowLongW, HWND hWnd, int nIndex, LONG dwNewLong); DECLARE_HOOK(LONG, WINAPI, SetWindowLongW, HWND hWnd, int nIndex, LONG dwNewLong);
DECLARE_HOOK(HWND, WINAPI, CreateWindowExA, DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DECLARE_HOOK(HWND, WINAPI, CreateWindowExA, DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName,
@ -44,30 +47,33 @@ class MainContext
DECLARE_HOOK(HWND, WINAPI, CreateWindowExW, DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DECLARE_HOOK(HWND, WINAPI, CreateWindowExW, DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName,
DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
DECLARE_HOOK(HANDLE, WINAPI, CreateFileA, LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
DECLARE_HOOK(HANDLE, WINAPI, CreateFileW, LPCWSTR lpFileName,DWORD dwDesiredAccess,DWORD dwShareMode,LPSECURITY_ATTRIBUTES lpSecurityAttributes,DWORD dwCreationDisposition,DWORD dwFlagsAndAttributes,HANDLE hTemplateFile);
public: public:
MainContext(); MainContext();
~MainContext(); virtual ~MainContext();
bool ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentationParameters); bool ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentationParameters);
bool ApplyBehaviorFlagsFix(DWORD* flags); void ApplyBehaviorFlagsFix(DWORD* flags);
HRESULT SetScissorRect(IDirect3DDevice9* pIDirect3DDevice9, CONST RECT* rect); HRESULT SetScissorRect(IDirect3DDevice9* pIDirect3DDevice9, CONST RECT* rect);
HRESULT CreateVertexBuffer(IDirect3DDevice9* pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); HRESULT CreateVertexBuffer(IDirect3DDevice9* pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);
HRESULT SetViewport(IDirect3DDevice9* pIDirect3DDevice9, CONST D3DVIEWPORT9* pViewport); HRESULT DrawPrimitiveUP(IDirect3DDevice9* pIDirect3DDevice9, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
bool BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString); bool BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString);
bool CheckWindow(HWND hWnd); bool CheckWindow(HWND hWnd);
void ApplyWndProc(HWND hWnd); void ApplyWindow(HWND hWnd);
void ApplyBorderless(HWND hWnd); void ApplyBorderless(HWND hWnd);
Config config; Config config;
void OneTimeFix();
bool IsDXVK();
private: private:
enum class AutoFixes : u32 enum class AutoFixes : u32
{ {
NONE = 0, NONE = 0,
RESIDENT_EVIL_4,
KINGS_BOUNTY_LEGEND,
FINAL_FANTASY_XIII, FINAL_FANTASY_XIII,
FINAL_FANTASY_XIII2, FINAL_FANTASY_XIII2,
}; };
@ -75,9 +81,13 @@ private:
void EnableAutoFix(); void EnableAutoFix();
AutoFixes autofix = AutoFixes::NONE; AutoFixes autofix = AutoFixes::NONE;
HWND hWndFF13 = 0;
std::mutex fix_mutex; std::mutex fix_mutex;
//MainContext is global!
//TODO this class is cluttered, separate fixes class from MainContext
const float MAX_FRAME_RATE_LIMIT = 250000.0F; const float MAX_FRAME_RATE_LIMIT = 250000.0F;
float** ff13_frame_pacer_ptr = NULL; float** ff13_frame_pacer_ptr = NULL;
uint8_t* ff13_set_framerate_ingame_instruction_address = NULL; uint8_t* ff13_set_framerate_ingame_instruction_address = NULL;
@ -95,6 +105,10 @@ private:
uint8_t* ff13_party_screen_scissor_scaling_factor_2 = NULL; uint8_t* ff13_party_screen_scissor_scaling_factor_2 = NULL;
uint8_t* ff13_party_screen_scissor_scaling_factor_3 = NULL; uint8_t* ff13_party_screen_scissor_scaling_factor_3 = NULL;
uint8_t* ff13_party_screen_scissor_scaling_factor_4 = NULL; uint8_t* ff13_party_screen_scissor_scaling_factor_4 = NULL;
uint8_t* ff13_message_box_stack_push_address = NULL;
uint8_t* ff13_message_box_call_address = NULL;
uint8_t* ff13_exe_large_address_aware_flag_address = NULL;
uint32_t* ff13_exe_checksum_address = NULL;
uint32_t* ff13_internal_res_w; uint32_t* ff13_internal_res_w;
uint32_t* ff13_internal_res_h; uint32_t* ff13_internal_res_h;
@ -106,9 +120,25 @@ private:
uint8_t** ff13_2_base_controller_input_address_ptr = NULL; uint8_t** ff13_2_base_controller_input_address_ptr = NULL;
uint8_t* ff13_2_vibration_high_set_zero_address = NULL; uint8_t* ff13_2_vibration_high_set_zero_address = NULL;
uint8_t* ff13_2_vibration_low_set_zero_address = NULL; uint8_t* ff13_2_vibration_low_set_zero_address = NULL;
uint8_t* ff13_2_message_box_stack_push_address = NULL;
uint8_t* ff13_2_message_box_call_address = NULL;
uint32_t* ff13_2_internal_res_w; uint32_t* ff13_2_internal_res_w;
uint32_t* ff13_2_internal_res_h; uint32_t* ff13_2_internal_res_h;
float expectedDrawPrimitiveUpVertexData[5 * 4]
{ -1.00f - 1.0f / 1280.0f, 1.00f + 1.0f / 720.0f, 0.0f, 0.0f, 0.0f,
1.00f - 1.0f / 1280.0f, 1.00f + 1.0f / 720.0f, 0.0f, 1.0f, 0.0f,
1.00f - 1.0f / 1280.0f, -1.00f + 1.0f / 720.0f, 0.0f, 1.0f, 1.0f,
-1.00f - 1.0f / 1280.0f, -1.00f + 1.0f / 720.0f, 0.0f, 0.0f, 1.0f
};
float fixedDrawPrimitiveUpVertexData[5 * 4]
{ -1.00f, 1.00f, 0.0f, 0.0f, 0.0f,
1.00f, 1.00f, 0.0f, 1.0f, 0.0f,
1.00f, -1.00f, 0.0f, 1.0f, 1.0f,
-1.00f, -1.00f, 0.0f, 0.0f, 1.0f
};
const float FF13_2_30_FPS = 30.0F; const float FF13_2_30_FPS = 30.0F;
const float FF13_2_MAX_FRAME_CAP = 1000.0F; const float FF13_2_MAX_FRAME_CAP = 1000.0F;
@ -118,30 +148,41 @@ private:
XInputManager* xinputManager; XInputManager* xinputManager;
void FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out); void FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out);
static const std::map<const AutoFixes, const uint32_t> behaviorflags_fixes; static const std::map<const AutoFixes, const uint32_t> behaviorflags_add;
static const std::map<const AutoFixes, const uint32_t> behaviorflags_sub;
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
WNDPROC oldWndProc; WNDPROC oldWndProc = nullptr;
bool AreAlmostTheSame(float a, float b);
void PrintVersionInfo(); void PrintVersionInfo();
void FF13_InitializeGameAddresses(); void FF13_InitializeGameAddresses();
void FF13_OneTimeFixes(); void FF13_OneTimeFixes();
void FF13_PatchMessageBox();
void FF13_EnableControllerVibration(); void FF13_EnableControllerVibration();
void FF13_NOPIngameFrameRateLimitSetter(); void FF13_NOPIngameFrameRateLimitSetter();
void FF13_SetFrameRateVariables(); void FF13_SetFrameRateVariables();
void FF13_FixScissorRect(); void FF13_FixScissorRect();
void FF13_RemoveContinuousControllerScan(); void FF13_RemoveContinuousControllerScan();
void FF13_HandleLargeAddressAwarePatch();
void FF13_2_CreateSetFrameRateCodeBlock(); void FF13_2_CreateSetFrameRateCodeBlock();
void FF13_2_InitializeGameAddresses(); void FF13_2_InitializeGameAddresses();
void FF13_2_RemoveContinuousControllerScan(); void FF13_2_RemoveContinuousControllerScan();
void FF13_2_AddHookIngameFrameRateLimitSetter(); void FF13_2_AddHookIngameFrameRateLimitSetter();
void FF13_2_OneTimeFixes(); void FF13_2_OneTimeFixes();
void FF13_2_PatchMessageBox();
void FF13_2_EnableControllerVibration(); void FF13_2_EnableControllerVibration();
void OneTimeFix(std::unique_ptr<wchar_t[]>& className); void AdjustVertexData(const uint32_t width, const uint32_t height);
bool MatchesExpectedVertexStream(const float* pVertexStreamZeroData);
void ForceWindowActivate(const HWND hWnd);
void PatchMessageBoxCall(uint8_t* callInstructionAddress);
bool OneTimeFixInit(std::unique_ptr<wchar_t[]>& className, HWND hWnd);
std::atomic_bool otf_init = false;
static void Fix_Thread(); static void Fix_Thread();
}; };

View file

@ -1,156 +1,221 @@
// wrapper for IDirect3D9 in d3d9.h
// generated using wrapper_gen.rb
#include "stdafx.h" #include "stdafx.h"
#include "Context.h" #include "Context.h"
#include "IDirect3D9.h" #include "IDirect3D9.h"
#include "IDirect3DDevice9.h" #include "IDirect3DDevice9.h"
#define IDirect3D9_PrintLog(format, ...) //PrintLog(format, __VA_ARGS__);
HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) { HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) {
PrintLog(__FUNCTION__); spdlog::info(__FUNCTION__);
if (ppvObj == nullptr) return E_POINTER; if (ppvObj == nullptr)
return E_POINTER;
if (riid == __uuidof(IUnknown) || if (riid == __uuidof(this) ||
riid == __uuidof(IDirect3D9)) riid == __uuidof(IUnknown) ||
riid == __uuidof(IDirect3D9) ||
riid == __uuidof(IDirect3D9Ex))
{ {
*ppvObj = static_cast<IDirect3D9*>(this); if (!m_is_ex && riid == __uuidof(IDirect3D9Ex))
{
//we are queried for IDirect3D9Ex but we hold IDirect3D9
//upgrade wrapped interface, query it
IDirect3D9Ex* pIDirect3D9Ex = nullptr;
HRESULT hr = m_pWrapped->QueryInterface(riid, reinterpret_cast<void**>(&pIDirect3D9Ex));
if (FAILED(hr))
return hr;
// release one reference from old one and take new IDirect3DDevice9Ex pointer
m_pWrapped->Release();
m_pWrapped = pIDirect3D9Ex;
m_is_ex = true;
}
AddRef(); AddRef();
*ppvObj = this;
return S_OK; return S_OK;
} }
*ppvObj = nullptr; return m_pWrapped->QueryInterface(riid, ppvObj);
return E_NOINTERFACE;
} }
ULONG APIENTRY hkIDirect3D9::AddRef() { ULONG STDMETHODCALLTYPE hkIDirect3D9::AddRef() {
PrintLog(__FUNCTION__); m_pWrapped->AddRef();
return _InterlockedIncrement(&m_refCount); return InterlockedIncrement(&m_ref);
} }
ULONG APIENTRY hkIDirect3D9::Release() { ULONG STDMETHODCALLTYPE hkIDirect3D9::Release() {
PrintLog(__FUNCTION__); const ULONG ref = InterlockedDecrement(&m_ref);
const LONG ref = _InterlockedDecrement(&m_refCount); if (ref != 0) {
if (ref == 0) m_pWrapped->Release();
{ return ref;
delete this;
} }
return ref; const auto pWrapped = m_pWrapped;
m_pWrapped = nullptr;
delete this;
const ULONG ref_last = pWrapped->Release();
if (ref_last != 0)
spdlog::error("Reference count for IDirect3D9 is wrong: {} {} {}", (void*)this, ref, ref_last);
return 0;
} }
HRESULT APIENTRY hkIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) { HRESULT APIENTRY hkIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->RegisterSoftwareDevice(pInitializeFunction); return m_pWrapped->RegisterSoftwareDevice(pInitializeFunction);
} }
UINT APIENTRY hkIDirect3D9::GetAdapterCount() { UINT APIENTRY hkIDirect3D9::GetAdapterCount() {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterCount(); return m_pWrapped->GetAdapterCount();
} }
HRESULT APIENTRY hkIDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) { HRESULT APIENTRY hkIDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
PrintLog(__FUNCTION__); spdlog::info(__FUNCTION__);
HRESULT rt = m_pWrapped->GetAdapterIdentifier(Adapter, Flags, pIdentifier); HRESULT rt = m_pWrapped->GetAdapterIdentifier(Adapter, Flags, pIdentifier);
if (context.config.GetAdapterAdapter() && SUCCEEDED(rt) && pIdentifier) if (context.config.GetAdapterAdapter() && SUCCEEDED(rt) && pIdentifier)
{ {
pIdentifier->VendorId = context.config.GetAdapterVendorId(); pIdentifier->VendorId = context.config.GetAdapterVendorId();
pIdentifier->DeviceId = context.config.GetAdapterDeviceId(); pIdentifier->DeviceId = context.config.GetAdapterDeviceId();
} }
return rt; return rt;
} }
UINT APIENTRY hkIDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) { UINT APIENTRY hkIDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterModeCount(Adapter, Format); return m_pWrapped->GetAdapterModeCount(Adapter, Format);
} }
HRESULT APIENTRY hkIDirect3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) { HRESULT APIENTRY hkIDirect3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->EnumAdapterModes(Adapter, Format, Mode, pMode); return m_pWrapped->EnumAdapterModes(Adapter, Format, Mode, pMode);
} }
HRESULT APIENTRY hkIDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) { HRESULT APIENTRY hkIDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterDisplayMode(Adapter, pMode); return m_pWrapped->GetAdapterDisplayMode(Adapter, pMode);
} }
HRESULT APIENTRY hkIDirect3D9::CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) { HRESULT APIENTRY hkIDirect3D9::CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
if (context.config.GetBorderlessForceWindowedMode()) bWindowed = TRUE; if (context.config.GetBorderlessForceWindowedMode()) bWindowed = TRUE;
return m_pWrapped->CheckDeviceType(Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); return m_pWrapped->CheckDeviceType(Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed);
} }
HRESULT APIENTRY hkIDirect3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) { HRESULT APIENTRY hkIDirect3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat); return m_pWrapped->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
} }
HRESULT APIENTRY hkIDirect3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) { HRESULT APIENTRY hkIDirect3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels); return m_pWrapped->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels);
} }
HRESULT APIENTRY hkIDirect3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) { HRESULT APIENTRY hkIDirect3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); return m_pWrapped->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
} }
HRESULT APIENTRY hkIDirect3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) { HRESULT APIENTRY hkIDirect3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat); return m_pWrapped->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat);
} }
HRESULT APIENTRY hkIDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) { HRESULT APIENTRY hkIDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDeviceCaps(Adapter, DeviceType, pCaps); return m_pWrapped->GetDeviceCaps(Adapter, DeviceType, pCaps);
} }
HMONITOR APIENTRY hkIDirect3D9::GetAdapterMonitor(UINT Adapter) { HMONITOR APIENTRY hkIDirect3D9::GetAdapterMonitor(UINT Adapter) {
IDirect3D9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterMonitor(Adapter); return m_pWrapped->GetAdapterMonitor(Adapter);
} }
HRESULT APIENTRY hkIDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) { HRESULT APIENTRY hkIDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) {
PrintLog(__FUNCTION__); spdlog::info(__FUNCTION__);
return ApplyCreateDeviceFix<IDirect3DDevice9, false>(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, nullptr, ppReturnedDeviceInterface);
}
UINT STDMETHODCALLTYPE hkIDirect3D9::GetAdapterModeCountEx(UINT Adapter, CONST D3DDISPLAYMODEFILTER* pFilter) {
spdlog::trace(__FUNCTION__);
return static_cast<IDirect3D9Ex*>(m_pWrapped)->GetAdapterModeCountEx(Adapter, pFilter);
}
HRESULT STDMETHODCALLTYPE hkIDirect3D9::EnumAdapterModesEx(UINT Adapter, CONST D3DDISPLAYMODEFILTER* pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode) {
spdlog::trace(__FUNCTION__);
return static_cast<IDirect3D9Ex*>(m_pWrapped)->EnumAdapterModesEx(Adapter, pFilter, Mode, pMode);
}
HRESULT STDMETHODCALLTYPE hkIDirect3D9::GetAdapterDisplayModeEx(UINT Adapter, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation) {
spdlog::trace(__FUNCTION__);
return static_cast<IDirect3D9Ex*>(m_pWrapped)->GetAdapterDisplayModeEx(Adapter, pMode, pRotation);
}
HRESULT STDMETHODCALLTYPE hkIDirect3D9::CreateDeviceEx(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, IDirect3DDevice9Ex** ppReturnedDeviceInterface) {
spdlog::info(__FUNCTION__);
return ApplyCreateDeviceFix<IDirect3DDevice9Ex, true>(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
}
HRESULT STDMETHODCALLTYPE hkIDirect3D9::GetAdapterLUID(UINT Adapter, LUID* pLUID) {
spdlog::trace(__FUNCTION__);
return static_cast<IDirect3D9Ex*>(m_pWrapped)->GetAdapterLUID(Adapter, pLUID);
}
//TODO move this to other file
template <typename T, bool ex>
HRESULT hkIDirect3D9::ApplyCreateDeviceFix(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, T** ppReturnedDeviceInterface)
{
spdlog::info(__FUNCTION__);
DWORD OriginalBehaviorFlags = BehaviorFlags; DWORD OriginalBehaviorFlags = BehaviorFlags;
std::string BehaviorFlagsString; std::string BehaviorFlagsString;
context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString); context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString);
PrintLog("BehaviorFlags: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str()); spdlog::info("BehaviorFlags: {:#08x} {}", BehaviorFlags, BehaviorFlagsString);
if (context.config.GetOptionsBehaviorFlags() > 0) if (context.config.GetOptionsBehaviorFlags() > 0) {
{
BehaviorFlags = context.config.GetOptionsBehaviorFlags(); BehaviorFlags = context.config.GetOptionsBehaviorFlags();
PrintLog("Advanced Mode: BehaviorFlags set"); spdlog::info("Advanced Mode: BehaviorFlags set");
} }
else else {
{
context.ApplyBehaviorFlagsFix(&BehaviorFlags); context.ApplyBehaviorFlagsFix(&BehaviorFlags);
} }
if (hFocusWindow == NULL) hFocusWindow = pPresentationParameters->hDeviceWindow; if (hFocusWindow == NULL)
hFocusWindow = pPresentationParameters->hDeviceWindow;
context.ApplyPresentationParameters(pPresentationParameters); context.ApplyPresentationParameters(pPresentationParameters);
if (OriginalBehaviorFlags != BehaviorFlags) if (OriginalBehaviorFlags != BehaviorFlags) {
{
std::string BehaviorFlagsString; std::string BehaviorFlagsString;
context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString); context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString);
PrintLog("BehaviorFlags changed: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str()); spdlog::info("BehaviorFlags changed: {:#08x} {}", BehaviorFlags, BehaviorFlagsString);
} }
IDirect3DDevice9* device = nullptr; T* device = nullptr;
HRESULT hr = m_pWrapped->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, &device); HRESULT hr = S_FALSE;
if (FAILED(hr)) bool is_ex;
{
PrintLog("CreateDevice fail with HRESULT: %08X", hr); if (ex) {
hr = m_pWrapped->CreateDeviceEx(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, reinterpret_cast<IDirect3DDevice9Ex**>(&device));
is_ex = true;
}
else {
hr = m_pWrapped->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, reinterpret_cast<IDirect3DDevice9**>(&device));
is_ex = false;
}
if (FAILED(hr)) {
spdlog::info("CreateDevice fail with HRESULT: {:X}", hr);
*ppReturnedDeviceInterface = nullptr; *ppReturnedDeviceInterface = nullptr;
return hr; return hr;
} }
else {
*ppReturnedDeviceInterface = new hkIDirect3DDevice9(device); *ppReturnedDeviceInterface = new hkIDirect3DDevice9(static_cast<IDirect3DDevice9Ex*>(device), is_ex);
context.OneTimeFix();
}
return hr; return hr;
} }

View file

@ -1,44 +1,52 @@
// wrapper for IDirect3D9 in d3d9.h #pragma once
// generated using wrapper_gen.rb #include <d3d9.h>
#include "d3d9.h" interface DECLSPEC_UUID("16760376-B89E-4CD9-9CE1-5B1C7AFC2E16") hkIDirect3D9 final : public IDirect3D9Ex{
#include "IDirect3DDevice9.h"
interface hkIDirect3D9 final : public IDirect3D9 {
public: public:
// original interface #pragma region IUnknown
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObj);
STDMETHOD_(ULONG, AddRef)(); ULONG STDMETHODCALLTYPE AddRef();
STDMETHOD_(ULONG, Release)(); ULONG STDMETHODCALLTYPE Release();
STDMETHOD(RegisterSoftwareDevice)(void* pInitializeFunction); #pragma endregion
STDMETHOD_(UINT, GetAdapterCount)(); #pragma region IDirect3D9
STDMETHOD(GetAdapterIdentifier)(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier); HRESULT STDMETHODCALLTYPE RegisterSoftwareDevice(void* pInitializeFunction);
STDMETHOD_(UINT, GetAdapterModeCount)(UINT Adapter, D3DFORMAT Format); UINT STDMETHODCALLTYPE GetAdapterCount();
STDMETHOD(EnumAdapterModes)(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode); HRESULT STDMETHODCALLTYPE GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier);
STDMETHOD(GetAdapterDisplayMode)(UINT Adapter, D3DDISPLAYMODE* pMode); UINT STDMETHODCALLTYPE GetAdapterModeCount(UINT Adapter, D3DFORMAT Format);
STDMETHOD(CheckDeviceType)(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); HRESULT STDMETHODCALLTYPE EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode);
STDMETHOD(CheckDeviceFormat)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); HRESULT STDMETHODCALLTYPE GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode);
STDMETHOD(CheckDeviceMultiSampleType)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels); HRESULT STDMETHODCALLTYPE CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed);
STDMETHOD(CheckDepthStencilMatch)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); HRESULT STDMETHODCALLTYPE CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
STDMETHOD(CheckDeviceFormatConversion)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); HRESULT STDMETHODCALLTYPE CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels);
STDMETHOD(GetDeviceCaps)(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps); HRESULT STDMETHODCALLTYPE CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
STDMETHOD_(HMONITOR, GetAdapterMonitor)(UINT Adapter); HRESULT STDMETHODCALLTYPE CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
STDMETHOD(CreateDevice)(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); HRESULT STDMETHODCALLTYPE GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps);
HMONITOR STDMETHODCALLTYPE GetAdapterMonitor(UINT Adapter);
HRESULT STDMETHODCALLTYPE CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface);
#pragma endregion
#pragma region IDirect3D9Ex
UINT STDMETHODCALLTYPE GetAdapterModeCountEx(UINT Adapter, const D3DDISPLAYMODEFILTER* pFilter);
HRESULT STDMETHODCALLTYPE EnumAdapterModesEx(UINT Adapter, const D3DDISPLAYMODEFILTER* pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode);
HRESULT STDMETHODCALLTYPE GetAdapterDisplayModeEx(UINT Adapter, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation);
HRESULT STDMETHODCALLTYPE CreateDeviceEx(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, IDirect3DDevice9Ex** ppReturnedDeviceInterface);
HRESULT STDMETHODCALLTYPE GetAdapterLUID(UINT Adapter, LUID* pLUID);
#pragma endregion
public: hkIDirect3D9(IDirect3D9Ex* pIDirect3D9)
hkIDirect3D9(IDirect3D9 *pIDirect3D9)
: m_pWrapped(pIDirect3D9) : m_pWrapped(pIDirect3D9)
{ {
} }
private: virtual ~hkIDirect3D9() { }
~hkIDirect3D9()
{ private:
m_pWrapped->Release(); IDirect3D9Ex* m_pWrapped;
} ULONG m_ref = 1;
bool m_is_ex = false;
template <typename T, bool ex>
HRESULT ApplyCreateDeviceFix(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, T** ppReturnedDeviceInterface);
LONG m_refCount = 1;
IDirect3D9 *m_pWrapped;
}; };

View file

@ -1,108 +1,129 @@
// wrapper for IDirect3DDevice9 in d3d9.h
// generated using wrapper_gen.rb
#pragma once #pragma once
#include "stdafx.h" #include "stdafx.h"
#include "Context.h" #include "Context.h"
#include "IDirect3DDevice9.h" #include "IDirect3DDevice9.h"
#include <intrin.h> #include <intrin.h>
#define IDirect3DDevice9_PrintLog(...) //PrintLog("%s", __VA_ARGS__);
HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) { HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
if (ppvObj == nullptr) return E_POINTER; if (ppvObj == nullptr) return E_POINTER;
if (riid == __uuidof(IUnknown) || if (riid == __uuidof(this) ||
riid == __uuidof(IDirect3DDevice9)) riid == __uuidof(IUnknown) ||
riid == __uuidof(IDirect3DDevice9) ||
riid == __uuidof(IDirect3DDevice9Ex))
{ {
*ppvObj = static_cast<IDirect3DDevice9*>(this); if (!m_is_ex && riid == __uuidof(IDirect3DDevice9Ex))
{
//we are queried for IDirect3DDevice9Ex but we hold IDirect3DDevice9
//upgrade wrapped interface, query it
IDirect3DDevice9Ex* pIDirect3DDevice9Ex = nullptr;
HRESULT hr = m_pWrapped->QueryInterface(riid, reinterpret_cast<void**>(&pIDirect3DDevice9Ex));
if (FAILED(hr))
return hr;
// release one reference from old one and take new IDirect3DDevice9Ex pointer
m_pWrapped->Release();
m_pWrapped = pIDirect3DDevice9Ex;
m_is_ex = true;
}
AddRef(); AddRef();
*ppvObj = this;
return S_OK; return S_OK;
} }
*ppvObj = nullptr; return m_pWrapped->QueryInterface(riid, ppvObj);
return E_NOINTERFACE;
} }
ULONG APIENTRY hkIDirect3DDevice9::AddRef() { ULONG STDMETHODCALLTYPE hkIDirect3DDevice9::AddRef() {
IDirect3DDevice9_PrintLog(__FUNCTION__); m_pWrapped->AddRef();
return _InterlockedIncrement(&m_refCount); return InterlockedIncrement(&m_ref);
} }
ULONG APIENTRY hkIDirect3DDevice9::Release() { ULONG STDMETHODCALLTYPE hkIDirect3DDevice9::Release() {
const LONG ref = _InterlockedDecrement(&m_refCount); const ULONG ref = InterlockedDecrement(&m_ref);
if (ref == 0) if (ref != 0) {
{ m_pWrapped->Release();
delete this; return ref;
} }
return ref; const auto pWrapped = m_pWrapped;
m_pWrapped = nullptr;
delete this;
const ULONG ref_last = pWrapped->Release();
if (ref_last != 0) {
spdlog::error("Reference count for IDirect3DDevice9 is wrong: {} {} {}", (void*)this, ref, ref_last);
}
return 0;
} }
HRESULT APIENTRY hkIDirect3DDevice9::TestCooperativeLevel() { HRESULT APIENTRY hkIDirect3DDevice9::TestCooperativeLevel() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->TestCooperativeLevel(); return m_pWrapped->TestCooperativeLevel();
} }
UINT APIENTRY hkIDirect3DDevice9::GetAvailableTextureMem() { UINT APIENTRY hkIDirect3DDevice9::GetAvailableTextureMem() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAvailableTextureMem(); return m_pWrapped->GetAvailableTextureMem();
} }
HRESULT APIENTRY hkIDirect3DDevice9::EvictManagedResources() { HRESULT APIENTRY hkIDirect3DDevice9::EvictManagedResources() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->EvictManagedResources(); return m_pWrapped->EvictManagedResources();
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetDirect3D(IDirect3D9** ppD3D9) { HRESULT APIENTRY hkIDirect3DDevice9::GetDirect3D(IDirect3D9** ppD3D9) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDirect3D(ppD3D9); return m_pWrapped->GetDirect3D(ppD3D9);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetDeviceCaps(D3DCAPS9* pCaps) { HRESULT APIENTRY hkIDirect3DDevice9::GetDeviceCaps(D3DCAPS9* pCaps) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDeviceCaps(pCaps); return m_pWrapped->GetDeviceCaps(pCaps);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) { HRESULT APIENTRY hkIDirect3DDevice9::GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDisplayMode(iSwapChain, pMode); return m_pWrapped->GetDisplayMode(iSwapChain, pMode);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters) { HRESULT APIENTRY hkIDirect3DDevice9::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetCreationParameters(pParameters); return m_pWrapped->GetCreationParameters(pParameters);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) { HRESULT APIENTRY hkIDirect3DDevice9::SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap); return m_pWrapped->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap);
} }
void APIENTRY hkIDirect3DDevice9::SetCursorPosition(int X, int Y, DWORD Flags) { void APIENTRY hkIDirect3DDevice9::SetCursorPosition(int X, int Y, DWORD Flags) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetCursorPosition(X, Y, Flags); return m_pWrapped->SetCursorPosition(X, Y, Flags);
} }
BOOL APIENTRY hkIDirect3DDevice9::ShowCursor(BOOL bShow) { BOOL APIENTRY hkIDirect3DDevice9::ShowCursor(BOOL bShow) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->ShowCursor(bShow); return m_pWrapped->ShowCursor(bShow);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) { HRESULT APIENTRY hkIDirect3DDevice9::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) {
PrintLog(__FUNCTION__); spdlog::info(__FUNCTION__);
context.ApplyPresentationParameters(pPresentationParameters); context.ApplyPresentationParameters(pPresentationParameters);
return m_pWrapped->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain); return m_pWrapped->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) { HRESULT APIENTRY hkIDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
// Steam Overlay Fix // Steam Overlay crash fix
// Add some space, 16bytes should be enough // Add some space, 16bytes should be more than enough
__nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop();
__nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop();
__nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop();
__nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop();
@ -111,523 +132,597 @@ HRESULT APIENTRY hkIDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwap
} }
UINT APIENTRY hkIDirect3DDevice9::GetNumberOfSwapChains() { UINT APIENTRY hkIDirect3DDevice9::GetNumberOfSwapChains() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetNumberOfSwapChains(); return m_pWrapped->GetNumberOfSwapChains();
} }
HRESULT APIENTRY hkIDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) { HRESULT APIENTRY hkIDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) {
PrintLog("hkIDirect3DDevice9::Reset"); spdlog::debug("hkIDirect3DDevice9::Reset");
context.ApplyPresentationParameters(pPresentationParameters); context.ApplyPresentationParameters(pPresentationParameters);
return m_pWrapped->Reset(pPresentationParameters); return m_pWrapped->Reset(pPresentationParameters);
} }
HRESULT APIENTRY hkIDirect3DDevice9::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) { HRESULT APIENTRY hkIDirect3DDevice9::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); return m_pWrapped->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) { HRESULT APIENTRY hkIDirect3DDevice9::GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetBackBuffer(iSwapChain, iBackBuffer, Type, ppBackBuffer); return m_pWrapped->GetBackBuffer(iSwapChain, iBackBuffer, Type, ppBackBuffer);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) { HRESULT APIENTRY hkIDirect3DDevice9::GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRasterStatus(iSwapChain, pRasterStatus); return m_pWrapped->GetRasterStatus(iSwapChain, pRasterStatus);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetDialogBoxMode(BOOL bEnableDialogs) { HRESULT APIENTRY hkIDirect3DDevice9::SetDialogBoxMode(BOOL bEnableDialogs) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetDialogBoxMode(bEnableDialogs); return m_pWrapped->SetDialogBoxMode(bEnableDialogs);
} }
void APIENTRY hkIDirect3DDevice9::SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) { void APIENTRY hkIDirect3DDevice9::SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetGammaRamp(iSwapChain, Flags, pRamp); return m_pWrapped->SetGammaRamp(iSwapChain, Flags, pRamp);
} }
void APIENTRY hkIDirect3DDevice9::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) { void APIENTRY hkIDirect3DDevice9::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetGammaRamp(iSwapChain, pRamp); return m_pWrapped->GetGammaRamp(iSwapChain, pRamp);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle); return m_pWrapped->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateVolumeTexture(Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle); return m_pWrapped->CreateVolumeTexture(Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateCubeTexture(EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle); return m_pWrapped->CreateCubeTexture(EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
//PrintLog("hkIDirect3DDevice9::CreateVertexBuffer %08u %x %x %x %p %p", Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle); spdlog::trace(__FUNCTION__" {} {} {} {} {} {}", Length, Usage, FVF, Pool, (void*)ppVertexBuffer, (void*)pSharedHandle);
return context.CreateVertexBuffer(m_pWrapped, Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle); return context.CreateVertexBuffer(m_pWrapped, Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
//PrintLog("hkIDirect3DDevice9::CreateIndexBuffer %u %x %x %x %p %p", Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle); return m_pWrapped->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateRenderTarget(Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle); return m_pWrapped->CreateRenderTarget(Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateDepthStencilSurface(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle); return m_pWrapped->CreateDepthStencilSurface(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) { HRESULT APIENTRY hkIDirect3DDevice9::UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->UpdateSurface(pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint); return m_pWrapped->UpdateSurface(pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
} }
HRESULT APIENTRY hkIDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) { HRESULT APIENTRY hkIDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->UpdateTexture(pSourceTexture, pDestinationTexture); return m_pWrapped->UpdateTexture(pSourceTexture, pDestinationTexture);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) { HRESULT APIENTRY hkIDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRenderTargetData(pRenderTarget, pDestSurface); return m_pWrapped->GetRenderTargetData(pRenderTarget, pDestSurface);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) { HRESULT APIENTRY hkIDirect3DDevice9::GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetFrontBufferData(iSwapChain, pDestSurface); return m_pWrapped->GetFrontBufferData(iSwapChain, pDestSurface);
} }
HRESULT APIENTRY hkIDirect3DDevice9::StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) { HRESULT APIENTRY hkIDirect3DDevice9::StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->StretchRect(pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter); return m_pWrapped->StretchRect(pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter);
} }
HRESULT APIENTRY hkIDirect3DDevice9::ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) { HRESULT APIENTRY hkIDirect3DDevice9::ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->ColorFill(pSurface, pRect, color); return m_pWrapped->ColorFill(pSurface, pRect, color);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) { HRESULT APIENTRY hkIDirect3DDevice9::CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateOffscreenPlainSurface(Width, Height, Format, Pool, ppSurface, pSharedHandle); return m_pWrapped->CreateOffscreenPlainSurface(Width, Height, Format, Pool, ppSurface, pSharedHandle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) { HRESULT APIENTRY hkIDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetRenderTarget(RenderTargetIndex, pRenderTarget); return m_pWrapped->SetRenderTarget(RenderTargetIndex, pRenderTarget);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) { HRESULT APIENTRY hkIDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRenderTarget(RenderTargetIndex, ppRenderTarget); return m_pWrapped->GetRenderTarget(RenderTargetIndex, ppRenderTarget);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) { HRESULT APIENTRY hkIDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetDepthStencilSurface(pNewZStencil); return m_pWrapped->SetDepthStencilSurface(pNewZStencil);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) { HRESULT APIENTRY hkIDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDepthStencilSurface(ppZStencilSurface); return m_pWrapped->GetDepthStencilSurface(ppZStencilSurface);
} }
HRESULT APIENTRY hkIDirect3DDevice9::BeginScene() { HRESULT APIENTRY hkIDirect3DDevice9::BeginScene() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->BeginScene(); return m_pWrapped->BeginScene();
} }
HRESULT APIENTRY hkIDirect3DDevice9::EndScene() { HRESULT APIENTRY hkIDirect3DDevice9::EndScene() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->EndScene(); return m_pWrapped->EndScene();
} }
HRESULT APIENTRY hkIDirect3DDevice9::Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) { HRESULT APIENTRY hkIDirect3DDevice9::Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->Clear(Count, pRects, Flags, Color, Z, Stencil); return m_pWrapped->Clear(Count, pRects, Flags, Color, Z, Stencil);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) { HRESULT APIENTRY hkIDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetTransform(State, pMatrix); return m_pWrapped->SetTransform(State, pMatrix);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) { HRESULT APIENTRY hkIDirect3DDevice9::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetTransform(State, pMatrix); return m_pWrapped->GetTransform(State, pMatrix);
} }
HRESULT APIENTRY hkIDirect3DDevice9::MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) { HRESULT APIENTRY hkIDirect3DDevice9::MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->MultiplyTransform(State, pMatrix); return m_pWrapped->MultiplyTransform(State, pMatrix);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport) { HRESULT APIENTRY hkIDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return context.SetViewport(m_pWrapped, pViewport); return m_pWrapped->SetViewport(pViewport);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetViewport(D3DVIEWPORT9* pViewport) { HRESULT APIENTRY hkIDirect3DDevice9::GetViewport(D3DVIEWPORT9* pViewport) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetViewport(pViewport); return m_pWrapped->GetViewport(pViewport);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial) { HRESULT APIENTRY hkIDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetMaterial(pMaterial); return m_pWrapped->SetMaterial(pMaterial);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetMaterial(D3DMATERIAL9* pMaterial) { HRESULT APIENTRY hkIDirect3DDevice9::GetMaterial(D3DMATERIAL9* pMaterial) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetMaterial(pMaterial); return m_pWrapped->GetMaterial(pMaterial);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) { HRESULT APIENTRY hkIDirect3DDevice9::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetLight(Index, pLight); return m_pWrapped->SetLight(Index, pLight);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetLight(DWORD Index, D3DLIGHT9* pLight) { HRESULT APIENTRY hkIDirect3DDevice9::GetLight(DWORD Index, D3DLIGHT9* pLight) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetLight(Index, pLight); return m_pWrapped->GetLight(Index, pLight);
} }
HRESULT APIENTRY hkIDirect3DDevice9::LightEnable(DWORD Index, BOOL Enable) { HRESULT APIENTRY hkIDirect3DDevice9::LightEnable(DWORD Index, BOOL Enable) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->LightEnable(Index, Enable); return m_pWrapped->LightEnable(Index, Enable);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetLightEnable(DWORD Index, BOOL* pEnable) { HRESULT APIENTRY hkIDirect3DDevice9::GetLightEnable(DWORD Index, BOOL* pEnable) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetLightEnable(Index, pEnable); return m_pWrapped->GetLightEnable(Index, pEnable);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetClipPlane(DWORD Index, CONST float* pPlane) { HRESULT APIENTRY hkIDirect3DDevice9::SetClipPlane(DWORD Index, CONST float* pPlane) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetClipPlane(Index, pPlane); return m_pWrapped->SetClipPlane(Index, pPlane);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetClipPlane(DWORD Index, float* pPlane) { HRESULT APIENTRY hkIDirect3DDevice9::GetClipPlane(DWORD Index, float* pPlane) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetClipPlane(Index, pPlane); return m_pWrapped->GetClipPlane(Index, pPlane);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) { HRESULT APIENTRY hkIDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetRenderState(State, Value); return m_pWrapped->SetRenderState(State, Value);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) { HRESULT APIENTRY hkIDirect3DDevice9::GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRenderState(State, pValue); return m_pWrapped->GetRenderState(State, pValue);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) { HRESULT APIENTRY hkIDirect3DDevice9::CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateStateBlock(Type, ppSB); return m_pWrapped->CreateStateBlock(Type, ppSB);
} }
HRESULT APIENTRY hkIDirect3DDevice9::BeginStateBlock() { HRESULT APIENTRY hkIDirect3DDevice9::BeginStateBlock() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->BeginStateBlock(); return m_pWrapped->BeginStateBlock();
} }
HRESULT APIENTRY hkIDirect3DDevice9::EndStateBlock(IDirect3DStateBlock9** ppSB) { HRESULT APIENTRY hkIDirect3DDevice9::EndStateBlock(IDirect3DStateBlock9** ppSB) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->EndStateBlock(ppSB); return m_pWrapped->EndStateBlock(ppSB);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) { HRESULT APIENTRY hkIDirect3DDevice9::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetClipStatus(pClipStatus); return m_pWrapped->SetClipStatus(pClipStatus);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetClipStatus(D3DCLIPSTATUS9* pClipStatus) { HRESULT APIENTRY hkIDirect3DDevice9::GetClipStatus(D3DCLIPSTATUS9* pClipStatus) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetClipStatus(pClipStatus); return m_pWrapped->GetClipStatus(pClipStatus);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) { HRESULT APIENTRY hkIDirect3DDevice9::GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetTexture(Stage, ppTexture); return m_pWrapped->GetTexture(Stage, ppTexture);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) { HRESULT APIENTRY hkIDirect3DDevice9::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetTexture(Stage, pTexture); return m_pWrapped->SetTexture(Stage, pTexture);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) { HRESULT APIENTRY hkIDirect3DDevice9::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetTextureStageState(Stage, Type, pValue); return m_pWrapped->GetTextureStageState(Stage, Type, pValue);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) { HRESULT APIENTRY hkIDirect3DDevice9::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetTextureStageState(Stage, Type, Value); return m_pWrapped->SetTextureStageState(Stage, Type, Value);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) { HRESULT APIENTRY hkIDirect3DDevice9::GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetSamplerState(Sampler, Type, pValue); return m_pWrapped->GetSamplerState(Sampler, Type, pValue);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) { HRESULT APIENTRY hkIDirect3DDevice9::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetSamplerState(Sampler, Type, Value); return m_pWrapped->SetSamplerState(Sampler, Type, Value);
} }
HRESULT APIENTRY hkIDirect3DDevice9::ValidateDevice(DWORD* pNumPasses) { HRESULT APIENTRY hkIDirect3DDevice9::ValidateDevice(DWORD* pNumPasses) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->ValidateDevice(pNumPasses); return m_pWrapped->ValidateDevice(pNumPasses);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) { HRESULT APIENTRY hkIDirect3DDevice9::SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPaletteEntries(PaletteNumber, pEntries); return m_pWrapped->SetPaletteEntries(PaletteNumber, pEntries);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) { HRESULT APIENTRY hkIDirect3DDevice9::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPaletteEntries(PaletteNumber, pEntries); return m_pWrapped->GetPaletteEntries(PaletteNumber, pEntries);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetCurrentTexturePalette(UINT PaletteNumber) { HRESULT APIENTRY hkIDirect3DDevice9::SetCurrentTexturePalette(UINT PaletteNumber) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetCurrentTexturePalette(PaletteNumber); return m_pWrapped->SetCurrentTexturePalette(PaletteNumber);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetCurrentTexturePalette(UINT *PaletteNumber) { HRESULT APIENTRY hkIDirect3DDevice9::GetCurrentTexturePalette(UINT* PaletteNumber) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetCurrentTexturePalette(PaletteNumber); return m_pWrapped->GetCurrentTexturePalette(PaletteNumber);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetScissorRect(CONST RECT* pRect) { HRESULT APIENTRY hkIDirect3DDevice9::SetScissorRect(CONST RECT* pRect) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return context.SetScissorRect(m_pWrapped, pRect); return context.SetScissorRect(m_pWrapped, pRect);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetScissorRect(RECT* pRect) { HRESULT APIENTRY hkIDirect3DDevice9::GetScissorRect(RECT* pRect) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetScissorRect(pRect); return m_pWrapped->GetScissorRect(pRect);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetSoftwareVertexProcessing(BOOL bSoftware) { HRESULT APIENTRY hkIDirect3DDevice9::SetSoftwareVertexProcessing(BOOL bSoftware) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetSoftwareVertexProcessing(bSoftware); return m_pWrapped->SetSoftwareVertexProcessing(bSoftware);
} }
BOOL APIENTRY hkIDirect3DDevice9::GetSoftwareVertexProcessing() { BOOL APIENTRY hkIDirect3DDevice9::GetSoftwareVertexProcessing() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetSoftwareVertexProcessing(); return m_pWrapped->GetSoftwareVertexProcessing();
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetNPatchMode(float nSegments) { HRESULT APIENTRY hkIDirect3DDevice9::SetNPatchMode(float nSegments) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetNPatchMode(nSegments); return m_pWrapped->SetNPatchMode(nSegments);
} }
float APIENTRY hkIDirect3DDevice9::GetNPatchMode() { float APIENTRY hkIDirect3DDevice9::GetNPatchMode() {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetNPatchMode(); return m_pWrapped->GetNPatchMode();
} }
HRESULT APIENTRY hkIDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) { HRESULT APIENTRY hkIDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount); return m_pWrapped->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) { HRESULT APIENTRY hkIDirect3DDevice9::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->DrawIndexedPrimitive(PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); return m_pWrapped->DrawIndexedPrimitive(PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) { HRESULT APIENTRY hkIDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride); return context.DrawPrimitiveUP(m_pWrapped, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
} }
HRESULT APIENTRY hkIDirect3DDevice9::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) { HRESULT APIENTRY hkIDirect3DDevice9::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->DrawIndexedPrimitiveUP(PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride); return m_pWrapped->DrawIndexedPrimitiveUP(PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
} }
HRESULT APIENTRY hkIDirect3DDevice9::ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) { HRESULT APIENTRY hkIDirect3DDevice9::ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags); return m_pWrapped->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) { HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateVertexDeclaration(pVertexElements, ppDecl); return m_pWrapped->CreateVertexDeclaration(pVertexElements, ppDecl);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) { HRESULT APIENTRY hkIDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexDeclaration(pDecl); return m_pWrapped->SetVertexDeclaration(pDecl);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) { HRESULT APIENTRY hkIDirect3DDevice9::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexDeclaration(ppDecl); return m_pWrapped->GetVertexDeclaration(ppDecl);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetFVF(DWORD FVF) { HRESULT APIENTRY hkIDirect3DDevice9::SetFVF(DWORD FVF) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetFVF(FVF); return m_pWrapped->SetFVF(FVF);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetFVF(DWORD* pFVF) { HRESULT APIENTRY hkIDirect3DDevice9::GetFVF(DWORD* pFVF) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetFVF(pFVF); return m_pWrapped->GetFVF(pFVF);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) { HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateVertexShader(pFunction, ppShader); return m_pWrapped->CreateVertexShader(pFunction, ppShader);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader) { HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShader(pShader); return m_pWrapped->SetVertexShader(pShader);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShader(IDirect3DVertexShader9** ppShader) { HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShader(IDirect3DVertexShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShader(ppShader); return m_pWrapped->GetVertexShader(ppShader);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) { HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount); return m_pWrapped->SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) { HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount); return m_pWrapped->GetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) { HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount); return m_pWrapped->SetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) { HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount); return m_pWrapped->GetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) { HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShaderConstantB(StartRegister, pConstantData, BoolCount); return m_pWrapped->SetVertexShaderConstantB(StartRegister, pConstantData, BoolCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) { HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShaderConstantB(StartRegister, pConstantData, BoolCount); return m_pWrapped->GetVertexShaderConstantB(StartRegister, pConstantData, BoolCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) { HRESULT APIENTRY hkIDirect3DDevice9::SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetStreamSource(StreamNumber, pStreamData, OffsetInBytes, Stride); return m_pWrapped->SetStreamSource(StreamNumber, pStreamData, OffsetInBytes, Stride);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* pOffsetInBytes, UINT* pStride) { HRESULT APIENTRY hkIDirect3DDevice9::GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* pOffsetInBytes, UINT* pStride) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetStreamSource(StreamNumber, ppStreamData, pOffsetInBytes, pStride); return m_pWrapped->GetStreamSource(StreamNumber, ppStreamData, pOffsetInBytes, pStride);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetStreamSourceFreq(UINT StreamNumber, UINT Setting) { HRESULT APIENTRY hkIDirect3DDevice9::SetStreamSourceFreq(UINT StreamNumber, UINT Setting) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetStreamSourceFreq(StreamNumber, Setting); return m_pWrapped->SetStreamSourceFreq(StreamNumber, Setting);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetStreamSourceFreq(UINT StreamNumber, UINT* pSetting) { HRESULT APIENTRY hkIDirect3DDevice9::GetStreamSourceFreq(UINT StreamNumber, UINT* pSetting) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetStreamSourceFreq(StreamNumber, pSetting); return m_pWrapped->GetStreamSourceFreq(StreamNumber, pSetting);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData) { HRESULT APIENTRY hkIDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetIndices(pIndexData); return m_pWrapped->SetIndices(pIndexData);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetIndices(IDirect3DIndexBuffer9** ppIndexData) { HRESULT APIENTRY hkIDirect3DDevice9::GetIndices(IDirect3DIndexBuffer9** ppIndexData) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetIndices(ppIndexData); return m_pWrapped->GetIndices(ppIndexData);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) { HRESULT APIENTRY hkIDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreatePixelShader(pFunction, ppShader); return m_pWrapped->CreatePixelShader(pFunction, ppShader);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader) { HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShader(pShader); return m_pWrapped->SetPixelShader(pShader);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShader(IDirect3DPixelShader9** ppShader) { HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShader(IDirect3DPixelShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShader(ppShader); return m_pWrapped->GetPixelShader(ppShader);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) { HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount); return m_pWrapped->SetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) { HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount); return m_pWrapped->GetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) { HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount); return m_pWrapped->SetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) { HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount); return m_pWrapped->GetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) { HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShaderConstantB(StartRegister, pConstantData, BoolCount); return m_pWrapped->SetPixelShaderConstantB(StartRegister, pConstantData, BoolCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) { HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShaderConstantB(StartRegister, pConstantData, BoolCount); return m_pWrapped->GetPixelShaderConstantB(StartRegister, pConstantData, BoolCount);
} }
HRESULT APIENTRY hkIDirect3DDevice9::DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) { HRESULT APIENTRY hkIDirect3DDevice9::DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo); return m_pWrapped->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo);
} }
HRESULT APIENTRY hkIDirect3DDevice9::DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) { HRESULT APIENTRY hkIDirect3DDevice9::DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo); return m_pWrapped->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo);
} }
HRESULT APIENTRY hkIDirect3DDevice9::DeletePatch(UINT Handle) { HRESULT APIENTRY hkIDirect3DDevice9::DeletePatch(UINT Handle) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->DeletePatch(Handle); return m_pWrapped->DeletePatch(Handle);
} }
HRESULT APIENTRY hkIDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) { HRESULT APIENTRY hkIDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
IDirect3DDevice9_PrintLog(__FUNCTION__); spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateQuery(Type, ppQuery); return m_pWrapped->CreateQuery(Type, ppQuery);
} }
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::SetConvolutionMonoKernel(UINT width, UINT height, float* rows, float* columns) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetConvolutionMonoKernel(width, height, rows, columns);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::ComposeRects(IDirect3DSurface9* pSrc, IDirect3DSurface9* pDst, IDirect3DVertexBuffer9* pSrcRectDescs, UINT NumRects, IDirect3DVertexBuffer9* pDstRectDescs, D3DCOMPOSERECTSOP Operation, int Xoffset, int Yoffset) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->ComposeRects(pSrc, pDst, pSrcRectDescs, NumRects, pDstRectDescs, Operation, Xoffset, Yoffset);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::PresentEx(const RECT* pSourceRect, const RECT* pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion, DWORD dwFlags) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->PresentEx(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::GetGPUThreadPriority(INT* pPriority) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetGPUThreadPriority(pPriority);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::SetGPUThreadPriority(INT Priority) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetGPUThreadPriority(Priority);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::WaitForVBlank(UINT iSwapChain) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->WaitForVBlank(iSwapChain);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::CheckResourceResidency(IDirect3DResource9** pResourceArray, UINT32 NumResources) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckResourceResidency(pResourceArray, NumResources);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::SetMaximumFrameLatency(UINT MaxLatency) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetMaximumFrameLatency(MaxLatency);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::GetMaximumFrameLatency(UINT* pMaxLatency) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetMaximumFrameLatency(pMaxLatency);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::CheckDeviceState(HWND hDestinationWindow) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckDeviceState(hDestinationWindow);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::CreateRenderTargetEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateRenderTargetEx(Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle, Usage);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::CreateOffscreenPlainSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateOffscreenPlainSurfaceEx(Width, Height, Format, Pool, ppSurface, pSharedHandle, Usage);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::CreateDepthStencilSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateDepthStencilSurfaceEx(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle, Usage);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::ResetEx(D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->ResetEx(pPresentationParameters, pFullscreenDisplayMode);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::GetDisplayModeEx(UINT iSwapChain, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation) {
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDisplayModeEx(iSwapChain, pMode, pRotation);
}

View file

@ -1,145 +1,159 @@
// wrapper for IDirect3DDevice9 in d3d9.h
// generated using wrapper_gen.rb
#pragma once #pragma once
#include "d3d9.h" #include <d3d9.h>
interface hkIDirect3DDevice9 final : public IDirect3DDevice9 { interface DECLSPEC_UUID("DD98C5F4-40E6-43D9-A0EA-0C32ABDFDF9C") hkIDirect3DDevice9 final : public IDirect3DDevice9Ex{
public: public:
// original interface #pragma region IUnknown
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObj);
STDMETHOD_(ULONG, AddRef)(); ULONG STDMETHODCALLTYPE AddRef();
STDMETHOD_(ULONG, Release)(); ULONG STDMETHODCALLTYPE Release();
STDMETHOD(TestCooperativeLevel)(); #pragma endregion
STDMETHOD_(UINT, GetAvailableTextureMem)(); #pragma region IDirect3DDevice9
STDMETHOD(EvictManagedResources)(); HRESULT STDMETHODCALLTYPE TestCooperativeLevel();
STDMETHOD(GetDirect3D)(IDirect3D9** ppD3D9); UINT STDMETHODCALLTYPE GetAvailableTextureMem();
STDMETHOD(GetDeviceCaps)(D3DCAPS9* pCaps); HRESULT STDMETHODCALLTYPE EvictManagedResources();
STDMETHOD(GetDisplayMode)(UINT iSwapChain, D3DDISPLAYMODE* pMode); HRESULT STDMETHODCALLTYPE GetDirect3D(IDirect3D9** ppD3D9);
STDMETHOD(GetCreationParameters)(D3DDEVICE_CREATION_PARAMETERS *pParameters); HRESULT STDMETHODCALLTYPE GetDeviceCaps(D3DCAPS9* pCaps);
STDMETHOD(SetCursorProperties)(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap); HRESULT STDMETHODCALLTYPE GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode);
STDMETHOD_(void, SetCursorPosition)(int X, int Y, DWORD Flags); HRESULT STDMETHODCALLTYPE GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters);
STDMETHOD_(BOOL, ShowCursor)(BOOL bShow); HRESULT STDMETHODCALLTYPE SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap);
STDMETHOD(CreateAdditionalSwapChain)(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain); void STDMETHODCALLTYPE SetCursorPosition(int X, int Y, DWORD Flags);
STDMETHOD(GetSwapChain)(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain); BOOL STDMETHODCALLTYPE ShowCursor(BOOL bShow);
STDMETHOD_(UINT, GetNumberOfSwapChains)(); HRESULT STDMETHODCALLTYPE CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain);
STDMETHOD(Reset)(D3DPRESENT_PARAMETERS* pPresentationParameters); HRESULT STDMETHODCALLTYPE GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain);
STDMETHOD(Present)(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion); UINT STDMETHODCALLTYPE GetNumberOfSwapChains();
STDMETHOD(GetBackBuffer)(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); HRESULT STDMETHODCALLTYPE Reset(D3DPRESENT_PARAMETERS* pPresentationParameters);
STDMETHOD(GetRasterStatus)(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus); HRESULT STDMETHODCALLTYPE Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
STDMETHOD(SetDialogBoxMode)(BOOL bEnableDialogs); HRESULT STDMETHODCALLTYPE GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer);
STDMETHOD_(void, SetGammaRamp)(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp); HRESULT STDMETHODCALLTYPE GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus);
STDMETHOD_(void, GetGammaRamp)(UINT iSwapChain, D3DGAMMARAMP* pRamp); HRESULT STDMETHODCALLTYPE SetDialogBoxMode(BOOL bEnableDialogs);
STDMETHOD(CreateTexture)(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle); void STDMETHODCALLTYPE SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp);
STDMETHOD(CreateVolumeTexture)(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle); void STDMETHODCALLTYPE GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp);
STDMETHOD(CreateCubeTexture)(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle); HRESULT STDMETHODCALLTYPE CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle);
STDMETHOD(CreateVertexBuffer)(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); HRESULT STDMETHODCALLTYPE CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle);
STDMETHOD(CreateIndexBuffer)(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle); HRESULT STDMETHODCALLTYPE CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle);
STDMETHOD(CreateRenderTarget)(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); HRESULT STDMETHODCALLTYPE CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);
STDMETHOD(CreateDepthStencilSurface)(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); HRESULT STDMETHODCALLTYPE CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle);
STDMETHOD(UpdateSurface)(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint); HRESULT STDMETHODCALLTYPE CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
STDMETHOD(UpdateTexture)(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture); HRESULT STDMETHODCALLTYPE CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
STDMETHOD(GetRenderTargetData)(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface); HRESULT STDMETHODCALLTYPE UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint);
STDMETHOD(GetFrontBufferData)(UINT iSwapChain, IDirect3DSurface9* pDestSurface); HRESULT STDMETHODCALLTYPE UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture);
STDMETHOD(StretchRect)(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter); HRESULT STDMETHODCALLTYPE GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface);
STDMETHOD(ColorFill)(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color); HRESULT STDMETHODCALLTYPE GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface);
STDMETHOD(CreateOffscreenPlainSurface)(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); HRESULT STDMETHODCALLTYPE StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter);
STDMETHOD(SetRenderTarget)(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget); HRESULT STDMETHODCALLTYPE ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color);
STDMETHOD(GetRenderTarget)(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget); HRESULT STDMETHODCALLTYPE CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
STDMETHOD(SetDepthStencilSurface)(IDirect3DSurface9* pNewZStencil); HRESULT STDMETHODCALLTYPE SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget);
STDMETHOD(GetDepthStencilSurface)(IDirect3DSurface9** ppZStencilSurface); HRESULT STDMETHODCALLTYPE GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget);
STDMETHOD(BeginScene)(); HRESULT STDMETHODCALLTYPE SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil);
STDMETHOD(EndScene)(); HRESULT STDMETHODCALLTYPE GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface);
STDMETHOD(Clear)(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil); HRESULT STDMETHODCALLTYPE BeginScene();
STDMETHOD(SetTransform)(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); HRESULT STDMETHODCALLTYPE EndScene();
STDMETHOD(GetTransform)(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix); HRESULT STDMETHODCALLTYPE Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
STDMETHOD(MultiplyTransform)(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); HRESULT STDMETHODCALLTYPE SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
STDMETHOD(SetViewport)(CONST D3DVIEWPORT9* pViewport); HRESULT STDMETHODCALLTYPE GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix);
STDMETHOD(GetViewport)(D3DVIEWPORT9* pViewport); HRESULT STDMETHODCALLTYPE MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
STDMETHOD(SetMaterial)(CONST D3DMATERIAL9* pMaterial); HRESULT STDMETHODCALLTYPE SetViewport(CONST D3DVIEWPORT9* pViewport);
STDMETHOD(GetMaterial)(D3DMATERIAL9* pMaterial); HRESULT STDMETHODCALLTYPE GetViewport(D3DVIEWPORT9* pViewport);
STDMETHOD(SetLight)(DWORD Index, CONST D3DLIGHT9* pLight); HRESULT STDMETHODCALLTYPE SetMaterial(CONST D3DMATERIAL9* pMaterial);
STDMETHOD(GetLight)(DWORD Index, D3DLIGHT9* pLight); HRESULT STDMETHODCALLTYPE GetMaterial(D3DMATERIAL9* pMaterial);
STDMETHOD(LightEnable)(DWORD Index, BOOL Enable); HRESULT STDMETHODCALLTYPE SetLight(DWORD Index, CONST D3DLIGHT9* pLight);
STDMETHOD(GetLightEnable)(DWORD Index, BOOL* pEnable); HRESULT STDMETHODCALLTYPE GetLight(DWORD Index, D3DLIGHT9* pLight);
STDMETHOD(SetClipPlane)(DWORD Index, CONST float* pPlane); HRESULT STDMETHODCALLTYPE LightEnable(DWORD Index, BOOL Enable);
STDMETHOD(GetClipPlane)(DWORD Index, float* pPlane); HRESULT STDMETHODCALLTYPE GetLightEnable(DWORD Index, BOOL* pEnable);
STDMETHOD(SetRenderState)(D3DRENDERSTATETYPE State, DWORD Value); HRESULT STDMETHODCALLTYPE SetClipPlane(DWORD Index, CONST float* pPlane);
STDMETHOD(GetRenderState)(D3DRENDERSTATETYPE State, DWORD* pValue); HRESULT STDMETHODCALLTYPE GetClipPlane(DWORD Index, float* pPlane);
STDMETHOD(CreateStateBlock)(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB); HRESULT STDMETHODCALLTYPE SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
STDMETHOD(BeginStateBlock)(); HRESULT STDMETHODCALLTYPE GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue);
STDMETHOD(EndStateBlock)(IDirect3DStateBlock9** ppSB); HRESULT STDMETHODCALLTYPE CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB);
STDMETHOD(SetClipStatus)(CONST D3DCLIPSTATUS9* pClipStatus); HRESULT STDMETHODCALLTYPE BeginStateBlock();
STDMETHOD(GetClipStatus)(D3DCLIPSTATUS9* pClipStatus); HRESULT STDMETHODCALLTYPE EndStateBlock(IDirect3DStateBlock9** ppSB);
STDMETHOD(GetTexture)(DWORD Stage, IDirect3DBaseTexture9** ppTexture); HRESULT STDMETHODCALLTYPE SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus);
STDMETHOD(SetTexture)(DWORD Stage, IDirect3DBaseTexture9* pTexture); HRESULT STDMETHODCALLTYPE GetClipStatus(D3DCLIPSTATUS9* pClipStatus);
STDMETHOD(GetTextureStageState)(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue); HRESULT STDMETHODCALLTYPE GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture);
STDMETHOD(SetTextureStageState)(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); HRESULT STDMETHODCALLTYPE SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture);
STDMETHOD(GetSamplerState)(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue); HRESULT STDMETHODCALLTYPE GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue);
STDMETHOD(SetSamplerState)(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); HRESULT STDMETHODCALLTYPE SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
STDMETHOD(ValidateDevice)(DWORD* pNumPasses); HRESULT STDMETHODCALLTYPE GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue);
STDMETHOD(SetPaletteEntries)(UINT PaletteNumber, CONST PALETTEENTRY* pEntries); HRESULT STDMETHODCALLTYPE SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
STDMETHOD(GetPaletteEntries)(UINT PaletteNumber, PALETTEENTRY* pEntries); HRESULT STDMETHODCALLTYPE ValidateDevice(DWORD* pNumPasses);
STDMETHOD(SetCurrentTexturePalette)(UINT PaletteNumber); HRESULT STDMETHODCALLTYPE SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries);
STDMETHOD(GetCurrentTexturePalette)(UINT *PaletteNumber); HRESULT STDMETHODCALLTYPE GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries);
STDMETHOD(SetScissorRect)(CONST RECT* pRect); HRESULT STDMETHODCALLTYPE SetCurrentTexturePalette(UINT PaletteNumber);
STDMETHOD(GetScissorRect)(RECT* pRect); HRESULT STDMETHODCALLTYPE GetCurrentTexturePalette(UINT* PaletteNumber);
STDMETHOD(SetSoftwareVertexProcessing)(BOOL bSoftware); HRESULT STDMETHODCALLTYPE SetScissorRect(CONST RECT* pRect);
STDMETHOD_(BOOL, GetSoftwareVertexProcessing)(); HRESULT STDMETHODCALLTYPE GetScissorRect(RECT* pRect);
STDMETHOD(SetNPatchMode)(float nSegments); HRESULT STDMETHODCALLTYPE SetSoftwareVertexProcessing(BOOL bSoftware);
STDMETHOD_(float, GetNPatchMode)(); BOOL STDMETHODCALLTYPE GetSoftwareVertexProcessing();
STDMETHOD(DrawPrimitive)(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount); HRESULT STDMETHODCALLTYPE SetNPatchMode(float nSegments);
STDMETHOD(DrawIndexedPrimitive)(D3DPRIMITIVETYPE, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount); float STDMETHODCALLTYPE GetNPatchMode();
STDMETHOD(DrawPrimitiveUP)(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); HRESULT STDMETHODCALLTYPE DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
STDMETHOD(DrawIndexedPrimitiveUP)(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); HRESULT STDMETHODCALLTYPE DrawIndexedPrimitive(D3DPRIMITIVETYPE, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
STDMETHOD(ProcessVertices)(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags); HRESULT STDMETHODCALLTYPE DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
STDMETHOD(CreateVertexDeclaration)(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl); HRESULT STDMETHODCALLTYPE DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
STDMETHOD(SetVertexDeclaration)(IDirect3DVertexDeclaration9* pDecl); HRESULT STDMETHODCALLTYPE ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags);
STDMETHOD(GetVertexDeclaration)(IDirect3DVertexDeclaration9** ppDecl); HRESULT STDMETHODCALLTYPE CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl);
STDMETHOD(SetFVF)(DWORD FVF); HRESULT STDMETHODCALLTYPE SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl);
STDMETHOD(GetFVF)(DWORD* pFVF); HRESULT STDMETHODCALLTYPE GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl);
STDMETHOD(CreateVertexShader)(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader); HRESULT STDMETHODCALLTYPE SetFVF(DWORD FVF);
STDMETHOD(SetVertexShader)(IDirect3DVertexShader9* pShader); HRESULT STDMETHODCALLTYPE GetFVF(DWORD* pFVF);
STDMETHOD(GetVertexShader)(IDirect3DVertexShader9** ppShader); HRESULT STDMETHODCALLTYPE CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader);
STDMETHOD(SetVertexShaderConstantF)(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); HRESULT STDMETHODCALLTYPE SetVertexShader(IDirect3DVertexShader9* pShader);
STDMETHOD(GetVertexShaderConstantF)(UINT StartRegister, float* pConstantData, UINT Vector4fCount); HRESULT STDMETHODCALLTYPE GetVertexShader(IDirect3DVertexShader9** ppShader);
STDMETHOD(SetVertexShaderConstantI)(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); HRESULT STDMETHODCALLTYPE SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
STDMETHOD(GetVertexShaderConstantI)(UINT StartRegister, int* pConstantData, UINT Vector4iCount); HRESULT STDMETHODCALLTYPE GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount);
STDMETHOD(SetVertexShaderConstantB)(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); HRESULT STDMETHODCALLTYPE SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
STDMETHOD(GetVertexShaderConstantB)(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); HRESULT STDMETHODCALLTYPE GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount);
STDMETHOD(SetStreamSource)(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride); HRESULT STDMETHODCALLTYPE SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
STDMETHOD(GetStreamSource)(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* pOffsetInBytes, UINT* pStride); HRESULT STDMETHODCALLTYPE GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
STDMETHOD(SetStreamSourceFreq)(UINT StreamNumber, UINT Setting); HRESULT STDMETHODCALLTYPE SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride);
STDMETHOD(GetStreamSourceFreq)(UINT StreamNumber, UINT* pSetting); HRESULT STDMETHODCALLTYPE GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* pOffsetInBytes, UINT* pStride);
STDMETHOD(SetIndices)(IDirect3DIndexBuffer9* pIndexData); HRESULT STDMETHODCALLTYPE SetStreamSourceFreq(UINT StreamNumber, UINT Setting);
STDMETHOD(GetIndices)(IDirect3DIndexBuffer9** ppIndexData); HRESULT STDMETHODCALLTYPE GetStreamSourceFreq(UINT StreamNumber, UINT* pSetting);
STDMETHOD(CreatePixelShader)(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader); HRESULT STDMETHODCALLTYPE SetIndices(IDirect3DIndexBuffer9* pIndexData);
STDMETHOD(SetPixelShader)(IDirect3DPixelShader9* pShader); HRESULT STDMETHODCALLTYPE GetIndices(IDirect3DIndexBuffer9** ppIndexData);
STDMETHOD(GetPixelShader)(IDirect3DPixelShader9** ppShader); HRESULT STDMETHODCALLTYPE CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader);
STDMETHOD(SetPixelShaderConstantF)(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); HRESULT STDMETHODCALLTYPE SetPixelShader(IDirect3DPixelShader9* pShader);
STDMETHOD(GetPixelShaderConstantF)(UINT StartRegister, float* pConstantData, UINT Vector4fCount); HRESULT STDMETHODCALLTYPE GetPixelShader(IDirect3DPixelShader9** ppShader);
STDMETHOD(SetPixelShaderConstantI)(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); HRESULT STDMETHODCALLTYPE SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
STDMETHOD(GetPixelShaderConstantI)(UINT StartRegister, int* pConstantData, UINT Vector4iCount); HRESULT STDMETHODCALLTYPE GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount);
STDMETHOD(SetPixelShaderConstantB)(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); HRESULT STDMETHODCALLTYPE SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
STDMETHOD(GetPixelShaderConstantB)(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); HRESULT STDMETHODCALLTYPE GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount);
STDMETHOD(DrawRectPatch)(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo); HRESULT STDMETHODCALLTYPE SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
STDMETHOD(DrawTriPatch)(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo); HRESULT STDMETHODCALLTYPE GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
STDMETHOD(DeletePatch)(UINT Handle); HRESULT STDMETHODCALLTYPE DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo);
STDMETHOD(CreateQuery)(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery); HRESULT STDMETHODCALLTYPE DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo);
HRESULT STDMETHODCALLTYPE DeletePatch(UINT Handle);
HRESULT STDMETHODCALLTYPE CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
#pragma endregion
#pragma region IDirect3DDevice9Ex
HRESULT STDMETHODCALLTYPE SetConvolutionMonoKernel(THIS_ UINT width, UINT height, float* rows, float* columns);
HRESULT STDMETHODCALLTYPE ComposeRects(THIS_ IDirect3DSurface9* pSrc, IDirect3DSurface9* pDst, IDirect3DVertexBuffer9* pSrcRectDescs, UINT NumRects, IDirect3DVertexBuffer9* pDstRectDescs, D3DCOMPOSERECTSOP Operation, int Xoffset, int Yoffset);
HRESULT STDMETHODCALLTYPE PresentEx(THIS_ CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags);
HRESULT STDMETHODCALLTYPE GetGPUThreadPriority(THIS_ INT* pPriority);
HRESULT STDMETHODCALLTYPE SetGPUThreadPriority(THIS_ INT Priority);
HRESULT STDMETHODCALLTYPE WaitForVBlank(THIS_ UINT iSwapChain);
HRESULT STDMETHODCALLTYPE CheckResourceResidency(THIS_ IDirect3DResource9** pResourceArray, UINT32 NumResources);
HRESULT STDMETHODCALLTYPE SetMaximumFrameLatency(THIS_ UINT MaxLatency);
HRESULT STDMETHODCALLTYPE GetMaximumFrameLatency(THIS_ UINT* pMaxLatency);
HRESULT STDMETHODCALLTYPE CheckDeviceState(THIS_ HWND hDestinationWindow);
HRESULT STDMETHODCALLTYPE CreateRenderTargetEx(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage);
HRESULT STDMETHODCALLTYPE CreateOffscreenPlainSurfaceEx(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage);
HRESULT STDMETHODCALLTYPE CreateDepthStencilSurfaceEx(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage);
HRESULT STDMETHODCALLTYPE ResetEx(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode);
HRESULT STDMETHODCALLTYPE GetDisplayModeEx(THIS_ UINT iSwapChain, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation);
#pragma endregion
public: hkIDirect3DDevice9(IDirect3DDevice9Ex* pIDirect3DDevice9, bool is_ex)
hkIDirect3DDevice9(IDirect3DDevice9 *pIDirect3DDevice9) : m_pWrapped(pIDirect3DDevice9), m_is_ex(is_ex)
: m_pWrapped(pIDirect3DDevice9)
{
}
private:
~hkIDirect3DDevice9()
{ {
m_pWrapped->Release();
} }
LONG m_refCount = 1; virtual ~hkIDirect3DDevice9() { }
IDirect3DDevice9* m_pWrapped;
private:
IDirect3DDevice9Ex* m_pWrapped;
ULONG m_ref = 1;
bool m_is_ex = false;
}; };

View file

@ -1,104 +0,0 @@
// wrapper for IDirect3DVertexBuffer9 in d3d9.h
// generated using wrapper_gen.rb
#include "stdafx.h"
#include "Context.h"
#include "IDirect3D9.h"
#include "IDirect3DDevice9.h"
#include "IDirect3DVertexBuffer9.h"
#define IDirect3DVertexBuffer9_PrintLog(format, ...) PrintLog(format, __VA_ARGS__);
HRESULT APIENTRY hkIDirect3DVertexBuffer9::QueryInterface(REFIID riid, void** ppvObj) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
if (ppvObj == nullptr) return E_POINTER;
if (riid == __uuidof(IUnknown) ||
riid == __uuidof(IDirect3DResource9) ||
riid == __uuidof(IDirect3DVertexBuffer9))
{
*ppvObj = static_cast<IDirect3DVertexBuffer9*>(this);
AddRef();
return S_OK;
}
*ppvObj = nullptr;
return E_NOINTERFACE;
}
ULONG APIENTRY hkIDirect3DVertexBuffer9::AddRef() {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return _InterlockedIncrement(&m_refCount);
}
ULONG APIENTRY hkIDirect3DVertexBuffer9::Release() {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
const LONG ref = _InterlockedDecrement(&m_refCount);
if (ref == 0)
{
delete this;
}
return ref;
}
HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetDevice(IDirect3DDevice9** ppDevice) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
if (ppDevice == nullptr)
return D3DERR_INVALIDCALL;
m_pIDirect3DDevice9->AddRef();
*ppDevice = m_pIDirect3DDevice9;
return D3D_OK;
}
HRESULT APIENTRY hkIDirect3DVertexBuffer9::SetPrivateData(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__ " %s", GUIDtoStringA(refguid));
return m_pWrapped->SetPrivateData(refguid, pData, SizeOfData, Flags);
}
HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__ " %s", GUIDtoStringA(refguid));
return m_pWrapped->GetPrivateData(refguid, pData, pSizeOfData);
}
HRESULT APIENTRY hkIDirect3DVertexBuffer9::FreePrivateData(REFGUID refguid) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->FreePrivateData(refguid);
}
DWORD APIENTRY hkIDirect3DVertexBuffer9::SetPriority(DWORD PriorityNew) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->SetPriority(PriorityNew);
}
DWORD APIENTRY hkIDirect3DVertexBuffer9::GetPriority() {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->GetPriority();
}
void APIENTRY hkIDirect3DVertexBuffer9::PreLoad() {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->PreLoad();
}
D3DRESOURCETYPE APIENTRY hkIDirect3DVertexBuffer9::GetType() {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->GetType();
}
HRESULT APIENTRY hkIDirect3DVertexBuffer9::Lock(UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->Lock(OffsetToLock, SizeToLock, ppbData, Flags);
}
HRESULT APIENTRY hkIDirect3DVertexBuffer9::Unlock() {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->Unlock();
}
HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetDesc(D3DVERTEXBUFFER_DESC *pDesc) {
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
return m_pWrapped->GetDesc(pDesc);
}

View file

@ -1,42 +0,0 @@
// wrapper for IDirect3DVertexBuffer9 in d3d9.h
// generated using wrapper_gen.rb
#pragma once
#include "d3d9.h"
interface hkIDirect3DVertexBuffer9 final : public IDirect3DVertexBuffer9 {
public:
/*** IUnknown methods ***/
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj);
STDMETHOD_(ULONG, AddRef)(THIS);
STDMETHOD_(ULONG, Release)(THIS);
/*** IDirect3DResource9 methods ***/
STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice);
STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData);
STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid);
STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew);
STDMETHOD_(DWORD, GetPriority)(THIS);
STDMETHOD_(void, PreLoad)(THIS);
STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS);
STDMETHOD(Lock)(THIS_ UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags);
STDMETHOD(Unlock)(THIS);
STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC* pDesc);
public:
hkIDirect3DVertexBuffer9(IDirect3DDevice9* pIDirect3DDevice9, IDirect3DVertexBuffer9* pIDirect3DVertexBuffer9)
: m_pWrapped(pIDirect3DVertexBuffer9), m_pIDirect3DDevice9(pIDirect3DDevice9)
{}
private:
~hkIDirect3DVertexBuffer9()
{
m_pWrapped->Release();
}
LONG m_refCount = 1;
IDirect3DVertexBuffer9 *m_pWrapped;
IDirect3DDevice9* m_pIDirect3DDevice9;
};

View file

@ -1,28 +1,109 @@
#ifdef SETTING
SETTING(s32, LongValue, PresentationInterval, Options, 1); SETTING(s32, LongValue, PresentationInterval, Options, 0,
SETTING(s32, LongValue, TripleBuffering, Options, -1); L"# PresentationInterval (V-Sync)\n"
SETTING(s32, LongValue, FullScreenRefreshRate, Options, 0); L"#\n"
SETTING(s32, LongValue, SwapEffect, Options, -1); L"# -1 = V-Sync forced off\n"
SETTING(bool, BoolValue, AlwaysActive, Options, false); L"# 0 = V-Sync not changed (default)\n"
SETTING(bool, BoolValue, AutoFix, Options, true); L"# 1 = V-Sync forced on"
SETTING(s32, LongValue, Multisample, Options, 0); );
SETTING(bool, BoolValue, HideCursor, Options, false);
SETTING(bool, BoolValue, ForceHideCursor, Options, false);
SETTING(u32, LongValue, BehaviorFlags, Options, 0);
SETTING(s32, LongValue, IngameFrameRateLimit, FFXIII, 0); SETTING(s32, LongValue, TripleBuffering, Options, -1,
SETTING(bool, BoolValue, DisableIngameControllerHotSwapping, FFXIII, true); L"# TripleBuffering\n"
SETTING(bool, BoolValue, EnableControllerVibration, FFXIII, true); L"#\n"
SETTING(bool, DoubleValue, VibrationStrengthFactor, FFXIII, 2.0); L"# -1 = Auto (Disabled for dxvk.dll; else, enabled) (default)\n"
L"# 0 = Off\n"
L"# 1 = On"
);
SETTING(bool, BoolValue, Adapter, Adapter, false); SETTING(s32, LongValue, FullScreenRefreshRate, Options, 0,
SETTING(u32, LongValue, VendorId, Adapter, 0); L"# FullScreenRefreshRate\n"
SETTING(u32, LongValue, DeviceId, Adapter, 0); L"#\n"
L"# If you are not using any adaptive sync technology (e.g. FreeSync/Gsync) you may want to set this to the highest\n"
L"# multiple of your frame rate that your monitor can handle to improve frame pacing.\n"
L"# i.e. if you are using a 60FPS cap, you can possibly improve the frame pacing when you are reaching the cap\n"
L"# by using refresh rates 60, 120, 180, 240...\n"
L"#\n"
L"# 0 = Same as configured in the operating system\n"
L"# other = Use the number provided as the display refresh rate (in Hz)"
);
SETTING(bool, BoolValue, Borderless, Borderless, false); SETTING(s32, LongValue, SwapEffect, Options, -1, 0);
SETTING(bool, BoolValue, ForceWindowedMode, Borderless, false); SETTING(bool, BoolValue, AlwaysActive, Options, false, 0);
SETTING(bool, BoolValue, AllWindows, Borderless, false); SETTING(bool, BoolValue, AutoFix, Options, true, 0);
SETTING(bool, BoolValue, TopMost, Borderless, false); SETTING(s32, LongValue, Multisample, Options, 0, 0);
SETTING(std::wstring, StringValue, WindowClass, Borderless, L""); SETTING(bool, BoolValue, HideCursor, Options, false, 0);
SETTING(std::wstring, StringValue, WindowName, Borderless, L""); SETTING(bool, BoolValue, ForceHideCursor, Options, false, 0);
SETTING(u32, LongValue, BehaviorFlags, Options, 0, 0);
SETTING(s32, LongValue, IngameFrameRateLimit, FFXIII, 0,
L"# IngameFrameRateLimit\n"
L"#\n"
L"# Using higher numbers may cause noticiable facial animation jankness during cutscenes.\n"
L"# See https://github.com/rebtd7/FF13Fix/issues/3\n"
L"#\n"
L"# Note that the frame pacer is always disabled by this mod, regardless of the value this option is set.\n"
L"#\n"
L"# -1 = Use the maximum FPS cap possible\n"
L"# 0 = Use the game's default FPS limit (59.94005966 FPS)\n"
L"# other = Use the number provided as the FPS limit (e.g. set 30 to limit to 30 FPS)"
);
SETTING(bool, BoolValue, DiscardUIVertexBuffer, FFXIII, false,
L"# DiscardUIVertexBuffer (EXPERIMENTAL!)\n"
L"#\n"
L"# Discards UI vertex buffer to improve performance\n"
L"#\n"
L"# false = default, do not hook and discard vertex buffer\n"
L"# true = hook and discard vertex buffer"
);
SETTING(bool, BoolValue, DisableIngameControllerHotSwapping, FFXIII, true,
L"# DisableIngameControllerHotSwapping\n"
L"#\n"
L"# By default FF13Fix disables the game's continuous controller scanning that causes stuttering (especially if you do not have any controller connected)\n"
L"# If you with you can enable it again (by setting the config to 'false', so you can re-connect your controller while playing.\n"
L"# Note that EnableControllerVibration is incompatible with the controller hotswapping, \n"
L"# so it is automatically disabled if DisableIngameControllerHotSwapping is set to 'false'"
);
SETTING(bool, BoolValue, EnableControllerVibration, FFXIII, true,
L"# EnableControllerVibration\n"
L"#\n"
L"# Enables controller vibration on the first connected XInput device."
);
SETTING(bool, DoubleValue, VibrationStrengthFactor, FFXIII, 2.0,
L"# VibrationStrengthFactor\n"
L"#\n"
L"# Higher numbers = stronger vibration"
);
SETTING(bool, BoolValue, Adapter, Adapter, false, 0);
SETTING(u32, LongValue, VendorId, Adapter, 0, 0);
SETTING(u32, LongValue, DeviceId, Adapter, 0, 0);
SETTING(bool, BoolValue, TopMost, Window, false, 0);
SETTING(std::wstring, StringValue, WindowClass, Window, L"", 0);
SETTING(std::wstring, StringValue, WindowName, Window, L"", 0);
SETTING(bool, BoolValue, Borderless, Borderless, false, 0);
SETTING(bool, BoolValue, ForceWindowedMode, Borderless, false, 0);
SETTING(bool, BoolValue, AllWindows, Borderless, false, 0);
SETTING(s32, LongValue, LogLevel, Log, 2,
L"# LogLevel\n"
L"#\n"
L"# 0 = trace\n"
L"# 1 = debug\n"
L"# 2 = info (default)\n"
L"# 3 = warning\n"
L"# 4 = error\n"
L"# 5 = critical"
);
SETTING(bool, BoolValue, LogFlush, Log, false,
L"# LogFlush\n"
L"#\n"
L"# true = flush log file every line (very slow!)\n"
L"# false = flush log file only when error level message is logged (default)"
);
#endif

32
d3d9ex/VertexFix.cpp Normal file
View file

@ -0,0 +1,32 @@
#define CINTERFACE
#include <d3d9.h>
#include "spdlog/spdlog.h"
#include "MinHook.h"
namespace cinterface
{
HRESULT(STDMETHODCALLTYPE* TrueLock)(IDirect3DVertexBuffer9* This, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) = nullptr;
HRESULT STDMETHODCALLTYPE HookLock(IDirect3DVertexBuffer9* This, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags)
{
spdlog::trace(__FUNCTION__" {}", SizeToLock);
if (SizeToLock == 358400)
Flags = D3DLOCK_DISCARD;
return TrueLock(This, OffsetToLock, SizeToLock, ppbData, Flags);
}
void VertexBufferFix(IDirect3DVertexBuffer9* pVertexBuffer)
{
if (pVertexBuffer->lpVtbl->Lock && TrueLock == nullptr)
{
spdlog::warn("Experimental DiscardUIVertexBuffer enabled!");
const MH_STATUS createHookLock = MH_CreateHook(pVertexBuffer->lpVtbl->Lock, HookLock, reinterpret_cast<void**>(&TrueLock));
spdlog::info("CreateHookLock = {}", createHookLock);
const MH_STATUS enableHookLock = MH_EnableHook(pVertexBuffer->lpVtbl->Lock);
spdlog::info("EnableHookLock = {}", enableHookLock);
}
}
}

View file

@ -1,9 +1,9 @@
#pragma once #pragma once
#include "comdef.h" #include <comdef.h>
#include <d3d9.h>
#include "d3d9.h" #include "StringUtil.h"
#include "xinput.h"
template <class T> template <class T>
class WrapperBase class WrapperBase
@ -19,7 +19,7 @@ public:
if (m_module) if (m_module)
{ {
FreeLibrary(m_module); FreeLibrary(m_module);
PrintLog("Unloaded %s", module_path.c_str()); spdlog::info("Unloaded {}", module_path);
} }
} }
@ -36,16 +36,16 @@ protected:
m_module = LoadLibraryA(module_path.c_str()); m_module = LoadLibraryA(module_path.c_str());
if (m_module) { if (m_module) {
PrintLog("Loaded %s", module_path.c_str()); spdlog::info("Loaded {}", module_path);
return true; return true;
} }
else if(fail_is_critical) { else if(fail_is_critical) {
HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
_com_error err(hr); _com_error err(hr);
std::string msg = StringFromFormat("Cannot load %s\nHRESULT 0x%08X: \"%s\"", module_path.c_str(), err.Error(), err.ErrorMessage()); std::string msg = StringFromFormat("Cannot load %s\nHRESULT 0x{:X} \"{}\"", module_path.c_str(), err.Error(), err.ErrorMessage());
PrintLog(msg.c_str()); spdlog::critical(msg);
MessageBoxA(NULL, msg.c_str(), "Error", MB_ICONERROR); MessageBoxA(NULL, msg.c_str(), "Error", MB_ICONERROR);
ExitProcess(hr); ExitProcess(hr);
} }
@ -82,7 +82,14 @@ public:
D3D9DLL() D3D9DLL()
{ {
WrapperLoad("dxvk.dll", false, false) ? m_isdxvk = true : WrapperLoad("d3d9.dll"); m_isdxvk = WrapperLoad("dxvk.dll", false, false);
if (!m_isdxvk) {
const bool isreshade = WrapperLoad("ReShade32.dll", false, false);
if (!isreshade) {
WrapperLoad("d3d9.dll");
}
}
StoreAddress(&Direct3DCreate9, "Direct3DCreate9"); StoreAddress(&Direct3DCreate9, "Direct3DCreate9");
StoreAddress(&Direct3DCreate9Ex, "Direct3DCreate9Ex"); StoreAddress(&Direct3DCreate9Ex, "Direct3DCreate9Ex");
@ -104,12 +111,12 @@ private:
extern "C" extern "C"
{ {
IDirect3D9 * WINAPI _Direct3DCreate9(UINT SDKVersion) IDirect3D9* WINAPI _Direct3DCreate9(UINT SDKVersion)
{ {
return D3D9DLL::Get().Direct3DCreate9(SDKVersion); return D3D9DLL::Get().Direct3DCreate9(SDKVersion);
} }
HRESULT WINAPI _Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **ppD3D) HRESULT WINAPI _Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex** ppD3D)
{ {
return D3D9DLL::Get().Direct3DCreate9Ex(SDKVersion, ppD3D); return D3D9DLL::Get().Direct3DCreate9Ex(SDKVersion, ppD3D);
} }

View file

@ -73,8 +73,8 @@
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<TargetName>dinput8</TargetName> <TargetName>d3d9</TargetName>
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(DXSDK_DIR)\Include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)\Common;$(SolutionDir)\Deps\MinHook\include;$(SolutionDir)\Deps\spdlog\include;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
@ -84,7 +84,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<TargetName>d3d9</TargetName> <TargetName>d3d9</TargetName>
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(DXSDK_DIR)\Include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)\Common;$(SolutionDir)\Deps\MinHook\include;$(SolutionDir)\Deps\spdlog\include;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
@ -96,14 +96,17 @@
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;D3D9EX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;SPDLOG_DISABLE_DEFAULT_LOGGER;SPDLOG_WCHAR_TO_UTF8_SUPPORT;_DEBUG;_WINDOWS;_USRDLL;D3D9EX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile> <ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
<AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;XINPUT9_1_0.LIB;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -126,11 +129,14 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9EX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;SPDLOG_DISABLE_DEFAULT_LOGGER;SPDLOG_WCHAR_TO_UTF8_SUPPORT;NDEBUG;_WINDOWS;_USRDLL;D3D9EX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpplatest</LanguageStandard>
<CreateHotpatchableImage>true</CreateHotpatchableImage>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -165,7 +171,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Context.h" /> <ClInclude Include="Context.h" />
<ClInclude Include="IDirect3DVertexBuffer9.h" />
<ClInclude Include="Wrapper.h" /> <ClInclude Include="Wrapper.h" />
<ClInclude Include="IDirect3D9.h" /> <ClInclude Include="IDirect3D9.h" />
<ClInclude Include="IDirect3DDevice9.h" /> <ClInclude Include="IDirect3DDevice9.h" />
@ -193,22 +198,23 @@
</ClCompile> </ClCompile>
<ClCompile Include="IDirect3D9.cpp" /> <ClCompile Include="IDirect3D9.cpp" />
<ClCompile Include="IDirect3DDevice9.cpp" /> <ClCompile Include="IDirect3DDevice9.cpp" />
<ClCompile Include="IDirect3DVertexBuffer9.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="VertexFix.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="XInputManager.cpp" /> <ClCompile Include="XInputManager.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="exports.def" /> <None Include="exports.def" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MinHook\build\VC16\libMinHook.vcxproj"> <ProjectReference Include="..\Deps\MinHook\build\VC16\libMinHook.vcxproj">
<Project>{f142a341-5ee0-442d-a15f-98ae9b48dbae}</Project> <Project>{f142a341-5ee0-442d-a15f-98ae9b48dbae}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>

View file

@ -33,16 +33,13 @@
<ClInclude Include="Context.h"> <ClInclude Include="Context.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Settings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Wrapper.h"> <ClInclude Include="Wrapper.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="IDirect3DVertexBuffer9.h"> <ClInclude Include="XInputManager.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="XInputManager.h"> <ClInclude Include="Settings.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@ -65,10 +62,10 @@
<ClCompile Include="Context.cpp"> <ClCompile Include="Context.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="IDirect3DVertexBuffer9.cpp"> <ClCompile Include="XInputManager.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="XInputManager.cpp"> <ClCompile Include="VertexFix.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>

View file

@ -26,7 +26,4 @@
#include <map> #include <map>
#include <unordered_map> #include <unordered_map>
#include <d3d9.h> #include "Context.h"
#include "WinUtil.h"
#include "Logger.h"