This commit is contained in:
Robert Krawczyk 2021-03-25 07:16:39 +01:00
parent 9e486fc986
commit 409d223465
16 changed files with 321 additions and 432 deletions

7
.gitmodules vendored
View File

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

View File

@ -1,148 +0,0 @@
#pragma once
#include <io.h>
#include <fcntl.h>
#include <memory>
#include <string>
#include <mutex>
#include "StringUtil.h"
#include "WinUtil.h"
#define LOGGER_DISABLE_MUTEX
#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) {}
virtual ~Logger()
{
if (m_console)
FreeConsole();
if (m_file)
CloseHandle(m_file);
}
#ifndef LOGGER_DISABLE_MUTEX
std::mutex& writeMutex() const { return m_writeMutex; }
#endif
static 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_FLAG_WRITE_THROUGH, 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, ...)
{
#ifndef LOGGER_DISABLE_MUTEX
const std::lock_guard<std::mutex> lock(Logger::Get().writeMutex());
#endif
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

@ -149,13 +149,15 @@ inline std::string CP1252ToUTF8(const std::string& input)
// trim from start
static inline std::string &ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not_fn(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;
}
// trim from end
static inline std::string &rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not_fn(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;
}

1
Deps/spdlog Submodule

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

View File

@ -8,7 +8,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5DB3A8C9-CF87-4AB6-A7C2-07B81A0DA625}"
ProjectSection(SolutionItems) = preProject
Common\Defines.h = Common\Defines.h
Common\Logger.h = Common\Logger.h
Common\MemPatch.h = Common\MemPatch.h
Common\SimpleIni.h = Common\SimpleIni.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
EndProjectSection
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -49,7 +50,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC332D21-3B2D-4534-AD8E-2525081AECA5}
VisualSVNWorkingCopyRoot = .
SolutionGuid = {CC332D21-3B2D-4534-AD8E-2525081AECA5}
EndGlobalSection
EndGlobal

View File

@ -1,6 +1,5 @@
#include "stdafx.h"
#include "Logger.h"
#include "MemPatch.h"
#include "Context.h"
@ -9,12 +8,13 @@
void MainContext::EnableAutoFix()
{
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")
{
autofix = AutoFixes::FINAL_FANTASY_XIII;
PrintLog("AutoFix for \"Final Fantasy XIII\" enabled");
spdlog::info("AutoFix for \"Final Fantasy XIII\" enabled");
FF13_InitializeGameAddresses();
FF13_HandleLargeAddressAwarePatch();
}
@ -22,7 +22,7 @@ void MainContext::EnableAutoFix()
if (exe_name == "ffxiii2img.exe")
{
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_CreateSetFrameRateCodeBlock();
}
@ -43,7 +43,7 @@ const std::map<const MainContext::AutoFixes, const uint32_t> MainContext::behavi
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) {
PrintLog("HookCreateFileA Before Replacement: %s", lpFileName);
spdlog::info("HookCreateFileA Before Replacement: {}", lpFileName);
int arrayPosition = ffxiiiimgPrt - lpFileName;
int len = strlen(lpFileName);
@ -52,17 +52,17 @@ HANDLE WINAPI MainContext::HookCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAcc
const char* untouched = "untouched"; // needs to have the size of "ffxiiiimg"
memcpy(newFileName + arrayPosition, untouched, strlen(untouched));
PrintLog("HookCreateFileA After Replacement: %s", newFileName);
spdlog::info("HookCreateFileA After Replacement: {}", newFileName);
MH_STATUS disableHookCreateFileA = MH_DisableHook(CreateFileA);
PrintLog("disableHookCreateFileA = %d", disableHookCreateFileA);
spdlog::info("disableHookCreateFileA = {}", disableHookCreateFileA);
MH_STATUS disableHookCreateFileW = MH_DisableHook(CreateFileW);
PrintLog("disableHookCreateFileW = %d", disableHookCreateFileW);
spdlog::info("disableHookCreateFileW = {}", disableHookCreateFileW);
if (GetFileAttributesA(newFileName) == INVALID_FILE_ATTRIBUTES) {
PrintLog("ERROR: Unable to get attributes of %s. Does the file exist? Using the regular ffxiiiimg.exe", newFileName);
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);;
PrintLog("Returning File Handle for %s", newFileName);
spdlog::info("Returning File Handle for {}", newFileName);
delete[] newFileName;
return fileHandle;
}
@ -75,7 +75,7 @@ HANDLE WINAPI MainContext::HookCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAc
const wchar_t* ffxiiiimgPrt = wcsstr(lpFileName, L"ffxiiiimg.exe");;
if (ffxiiiimgPrt) {
PrintLog("HookCreateFileW Before Replacement: %s", lpFileName);
spdlog::info(L"HookCreateFileW Before Replacement: {}", lpFileName);
int arrayPosition = ffxiiiimgPrt - lpFileName;
int len = wcslen(lpFileName);
@ -83,17 +83,17 @@ HANDLE WINAPI MainContext::HookCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAc
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));
PrintLog("HookCreateFileW After Replacement: %s", newFileName);
spdlog::info(L"HookCreateFileW After Replacement: {}", newFileName);
MH_STATUS disableHookCreateFileA = MH_DisableHook(CreateFileA);
PrintLog("disableHookCreateFileA = %d", disableHookCreateFileA);
spdlog::info("disableHookCreateFileA = {}", disableHookCreateFileA);
MH_STATUS disableHookCreateFileW = MH_DisableHook(CreateFileW);
PrintLog("disableHookCreateFileW = %d", disableHookCreateFileW);
spdlog::info("disableHookCreateFileW = {}", disableHookCreateFileW);
if (GetFileAttributesW(newFileName) == INVALID_FILE_ATTRIBUTES) {
PrintLog("ERROR: Unable to get attributes of %s. Does the file exist?", newFileName);
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);;
PrintLog("Returning File Handle %s", newFileName);
spdlog::info(L"Returning File Handle {}", newFileName);
delete[] newFileName;
return fileHandle;
}
@ -223,15 +223,15 @@ void MainContext::Fix_Thread()
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;
PrintLog("Waited %f ms", elapsed.count());
spdlog::info("Waited {} ms", elapsed.count());
std::lock_guard<std::mutex> lock(context.fix_mutex);
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();
}
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();
}
MessageBeep(MB_ICONASTERISK);
@ -241,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...
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_set_framerate_ingame_instruction_address = baseAddr + 0xA8D65F;
@ -270,30 +270,30 @@ void MainContext::FF13_InitializeGameAddresses()
void MainContext::FF13_HandleLargeAddressAwarePatch() {
const uint8_t laaMask = 0x20;
if (*ff13_exe_large_address_aware_flag_address & laaMask) {
PrintLog("LargeAddressAwarePatch found. ff13_exe_large_address_aware_flag = 0x%02x; ff13_exe_checksum = 0x%08x", *ff13_exe_large_address_aware_flag_address, *ff13_exe_checksum_address);
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));
PrintLog("createHookCreateFileA = %d", createHookCreateFileA);
spdlog::info("createHookCreateFileA = {}", createHookCreateFileA);
const MH_STATUS enableHookCreateFileA = MH_EnableHook(CreateFileA);
PrintLog("enableHookCreateFileA = %d", enableHookCreateFileA);
spdlog::info("enableHookCreateFileA = {}", enableHookCreateFileA);
const MH_STATUS createHookCreateFileW = MH_CreateHook(CreateFileW, HookCreateFileW, reinterpret_cast<void**>(&TrueCreateFileW));
PrintLog("createHookCreateFileW = %d", createHookCreateFileW);
spdlog::info("createHookCreateFileW = {}", createHookCreateFileW);
const MH_STATUS enableHookCreateFileW = MH_EnableHook(CreateFileW);
PrintLog("enableHookCreateFileW = %d", enableHookCreateFileW);
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);
PrintLog("LargeAddressAware patched back. ff13_exe_large_address_aware_flag = 0x%02x;", *ff13_exe_large_address_aware_flag_address);
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));
PrintLog("Checksum patched back. ff13_exe_checksum = 0x%08x", *ff13_exe_checksum_address);
spdlog::info("Checksum patched back. ff13_exe_checksum = {:X}", *ff13_exe_checksum_address);
PrintLog("LargeAddressAwarePatch handled");
spdlog::info("LargeAddressAwarePatch handled");
}
else {
PrintLog("LargeAddressAwarePatch not found.");
spdlog::info("LargeAddressAwarePatch not found.");
}
}
@ -319,12 +319,12 @@ void MainContext::FF13_OneTimeFixes() {
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()
{
PrintLog("Removing 'Quit game' textbox");
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);
@ -336,14 +336,14 @@ void MainContext::FF13_PatchMessageBox()
void MainContext::FF13_EnableControllerVibration()
{
if (!config.GetFFXIIIEnableControllerVibration()) {
PrintLog("Vibration should not be enabled (config file)");
spdlog::info("Vibration should not be enabled (config file)");
return;
}
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;
}
PrintLog("Enabling controller vibration...");
spdlog::info("Enabling controller vibration...");
MemPatch::Nop(ff13_vibration_low_set_zero_address, 5);
MemPatch::Nop(ff13_vibration_high_set_zero_address, 5);
@ -353,19 +353,19 @@ void MainContext::FF13_EnableControllerVibration()
void MainContext::FF13_RemoveContinuousControllerScan()
{
if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) {
PrintLog("Continuous controller scanning not disabled (config)");
spdlog::info("Continuous controller scanning not disabled (config)");
return;
}
// 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
MemPatch::Fill(ff13_continuous_scan_instruction_address, 0xEB, 1);
}
void MainContext::FF13_FixScissorRect()
{
PrintLog("Fixing ScissorRect...");
spdlog::info("Fixing ScissorRect...");
const float originalWidth = 1280.0F;
const float resolutionFactorW = (float)*ff13_internal_res_w / originalWidth;
scissor_scaling_factor_w = resolutionFactorW;
@ -390,7 +390,7 @@ void MainContext::FF13_FixScissorRect()
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);
}
@ -398,11 +398,11 @@ void MainContext::FF13_SetFrameRateVariables()
{
float* framePacerTargetPtr = *ff13_frame_pacer_ptr;
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;
*ingameFrameRateFramePacerTarget = MAX_FRAME_RATE_LIMIT;
PrintLog("Frame pacer disabled.");
spdlog::info("Frame pacer disabled.");
if (config.GetFFXIIIIngameFrameRateLimit() != 0)
{
@ -418,11 +418,10 @@ void MainContext::FF13_SetFrameRateVariables()
float* ingameFrameRateLimitPtr = framePacerTargetPtr + 1;
*ingameFrameRateLimitPtr = frameRateLimit;
PrintLog("Target frame rate set to %f", frameRateLimit);
}
spdlog::info("Target frame rate set to {}", frameRateLimit); }
}
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.");
}
}
@ -435,22 +434,22 @@ void MainContext::FF13_2_OneTimeFixes()
if (*ff13_2_frame_pacer_ptr_address) {
**ff13_2_frame_pacer_ptr_address = MAX_FRAME_RATE_LIMIT;
PrintLog("Frame pacer disabled");
spdlog::info("Frame pacer disabled");
FF13_2_AddHookIngameFrameRateLimitSetter();
FF13_2_RemoveContinuousControllerScan();
FF13_2_EnableControllerVibration();
AdjustVertexData(*ff13_2_internal_res_w, *ff13_2_internal_res_h);
PrintLog("Finished FF13-2 One Time Fixes");
spdlog::info("Finished FF13-2 One Time Fixes");
}
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()
{
PrintLog("Removing 'Quit game' textbox");
spdlog::info("Removing 'Quit game' textbox");
// NOP push of registers to call MessageBox
MemPatch::Nop(ff13_2_message_box_stack_push_address, 5);
@ -475,10 +474,10 @@ void MainContext::PatchMessageBoxCall(uint8_t* callInstructionAddress)
void MainContext::FF13_2_EnableControllerVibration()
{
if (!config.GetFFXIIIEnableControllerVibration()) {
PrintLog("Vibration should not be enabled (config file)");
spdlog::info("Vibration should not be enabled (config file)");
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_high_set_zero_address, 5);
@ -501,7 +500,7 @@ 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
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_set_frame_rate_address = baseAddr + 0x802616;
@ -518,12 +517,12 @@ void MainContext::FF13_2_InitializeGameAddresses()
void MainContext::FF13_2_RemoveContinuousControllerScan()
{
if (!config.GetFFXIIIDisableIngameControllerHotSwapping()) {
PrintLog("Continuous controller scanning not disabled (config)");
spdlog::info("Continuous controller scanning not disabled (config)");
return;
}
// 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
MemPatch::Fill(ff13_2_continuous_scan_instruction_address, 0xEB, 1);
}
@ -531,11 +530,11 @@ void MainContext::FF13_2_RemoveContinuousControllerScan()
void MainContext::FF13_2_AddHookIngameFrameRateLimitSetter()
{
if (config.GetFFXIIIIngameFrameRateLimit() == 0) {
PrintLog("Frame rate should not be changed (config = 0)");
spdlog::info("Frame rate should not be changed (config = 0)");
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);
@ -549,7 +548,7 @@ void MainContext::FF13_2_CreateSetFrameRateCodeBlock()
const int blockSize = 31;
FF13_2_SET_FRAME_RATE_INJECTED_CODE = new(std::nothrow) uint8_t[blockSize];
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;
}
DWORD oldProtect;
@ -566,7 +565,7 @@ void MainContext::FF13_2_CreateSetFrameRateCodeBlock()
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]
@ -606,5 +605,5 @@ void MainContext::FF13_2_CreateSetFrameRateCodeBlock()
}
void MainContext::PrintVersionInfo() {
PrintLog("FF13Fix 1.6.4 https://github.com/rebtd7/FF13Fix");
spdlog::info("FF13Fix 1.6.5 https://github.com/rebtd7/FF13Fix");
}

View File

@ -3,9 +3,6 @@
#include <thread>
#include <array>
#include "Logger.h"
#include "MinHook.h"
#include "SimpleIni.h"
@ -48,42 +45,53 @@ Config::Config()
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();
PrintLog("Enabling hooks:");
spdlog::info("Enabling hooks:");
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));
PrintLog("createHookDirect3DCreate9 = %d", createHookDirect3DCreate9);
spdlog::info("createHookDirect3DCreate9 = {}", createHookDirect3DCreate9);
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));
PrintLog("createHookDirect3DCreate9Ex = %d", createHookDirect3DCreate9Ex);
spdlog::info("createHookDirect3DCreate9Ex = {}", createHookDirect3DCreate9Ex);
const MH_STATUS enableHookDirect3DCreate9Ex = MH_EnableHook(D3D9DLL::Get().Direct3DCreate9Ex);
PrintLog("enableHookDirect3DCreate9Ex = %d", enableHookDirect3DCreate9Ex);
spdlog::info("enableHookDirect3DCreate9Ex = {}", enableHookDirect3DCreate9Ex);
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);
PrintLog("enableHookCreateWindowExA = %d", enableHookCreateWindowExA);
spdlog::info("enableHookCreateWindowExA = {}", enableHookCreateWindowExA);
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);
PrintLog("enableHookCreateWindowExW = %d", enableHookCreateWindowExW);
spdlog::info("enableHookCreateWindowExW = {}", enableHookCreateWindowExW);
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);
PrintLog("enableHookSetWindowLongA = %d", enableHookSetWindowLongA);
spdlog::info("enableHookSetWindowLongA = {}", enableHookSetWindowLongA);
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);
PrintLog("enableHookSetWindowLongW = %d", enableHookSetWindowLongW);
spdlog::info("enableHookSetWindowLongW = {}", enableHookSetWindowLongW);
if (config.GetOptionsAutoFix()) EnableAutoFix();
}
@ -95,7 +103,7 @@ MainContext::~MainContext()
IDirect3D9* WINAPI MainContext::HookDirect3DCreate9(UINT SDKVersion)
{
PrintLog(__FUNCTION__);
spdlog::info(__FUNCTION__);
IDirect3D9* d3d9 = context.TrueDirect3DCreate9(SDKVersion);
if (d3d9) {
return new hkIDirect3D9(static_cast<IDirect3D9Ex*>(d3d9));
@ -106,7 +114,7 @@ IDirect3D9* WINAPI MainContext::HookDirect3DCreate9(UINT SDKVersion)
HRESULT WINAPI MainContext::HookDirect3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex** ppIDirect3D9Ex)
{
PrintLog(__FUNCTION__);
spdlog::info(__FUNCTION__);
HRESULT hr = context.TrueDirect3DCreate9Ex(SDKVersion, ppIDirect3D9Ex);
if (SUCCEEDED(hr)) {
hkIDirect3D9* pIDirect3D9Ex = new hkIDirect3D9(*ppIDirect3D9Ex);
@ -151,12 +159,12 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati
if (config.GetOptionsTripleBuffering() == 1 || (config.GetOptionsTripleBuffering() == -1 && !IsDXVK()))
{
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)
{
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();
}
@ -166,7 +174,7 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati
pPresentationParameters->MultiSampleType = (D3DMULTISAMPLE_TYPE)config.GetOptionsMultisample();
pPresentationParameters->MultiSampleQuality = 0;
PrintLog("MultiSampleType %u, MultiSampleQuality %u", pPresentationParameters->MultiSampleType, pPresentationParameters->MultiSampleQuality);
spdlog::info("MultiSampleType {}, MultiSampleQuality {}", pPresentationParameters->MultiSampleType, pPresentationParameters->MultiSampleQuality);
}
if (config.GetOptionsPresentationInterval() != 0)
@ -176,13 +184,13 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati
else if (config.GetOptionsPresentationInterval() > 0)
pPresentationParameters->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
PrintLog("PresentationInterval: PresentationInterval set to 0x%x", pPresentationParameters->PresentationInterval);
spdlog::info("PresentationInterval: PresentationInterval set to {:X}", pPresentationParameters->PresentationInterval);
}
if (config.GetOptionsSwapEffect() != -1)
{
pPresentationParameters->SwapEffect = (D3DSWAPEFFECT)config.GetOptionsSwapEffect();
PrintLog("SwapEffect: SwapEffect set to %u", pPresentationParameters->SwapEffect);
spdlog::info("SwapEffect: SwapEffect set to {}", pPresentationParameters->SwapEffect);
}
if (config.GetBorderlessBorderless())
@ -198,7 +206,7 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati
pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
PrintLog("ForceWindowedMode");
spdlog::info("ForceWindowedMode");
}
}
@ -217,7 +225,7 @@ bool MainContext::CheckWindow(HWND hWnd)
GetClassNameW(hWnd, className.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());
bool class_found = config.GetWindowWindowClass().compare(className.get()) == 0;
bool window_found = config.GetWindowWindowName().compare(windowName.get()) == 0;
@ -259,8 +267,8 @@ void MainContext::ApplyBorderless(HWND hWnd)
SetWindowPos(hWnd, insertAfter, 0, 0, cx, cy, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
SetFocus(hWnd);
PrintLog("HWND 0x%p: Borderless dwStyle: %lX->%lX", hWnd, dwStyle, new_dwStyle);
PrintLog("HWND 0x%p: Borderless dwExStyle: %lX->%lX", hWnd, dwExStyle, new_dwExStyle);
spdlog::info("HWND {:X}: Borderless dwStyle: {:X}->{:X}", (void*)hWnd, dwStyle, new_dwStyle);
spdlog::info("HWND {:X}: Borderless dwExStyle: {:X}->{:X}", (void*)hWnd, dwExStyle, new_dwExStyle);
}
}
@ -305,13 +313,13 @@ LONG WINAPI MainContext::HookSetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLon
if (nIndex == GWL_STYLE)
{
dwNewLong &= ~WS_OVERLAPPEDWINDOW;
PrintLog("SetWindowLongA dwStyle: %lX->%lX", olddwNewLong, dwNewLong);
spdlog::info("SetWindowLongA dwStyle: {:X}->{:X}", olddwNewLong, dwNewLong);
}
if (nIndex == GWL_EXSTYLE)
{
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);
@ -325,13 +333,13 @@ LONG WINAPI MainContext::HookSetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLon
if (nIndex == GWL_STYLE)
{
dwNewLong &= ~WS_OVERLAPPEDWINDOW;
PrintLog("SetWindowLongW dwStyle: %lX->%lX", olddwNewLong, dwNewLong);
spdlog::info("SetWindowLongW dwStyle: {:X}->{:X}", olddwNewLong, dwNewLong);
}
if (nIndex == GWL_EXSTYLE)
{
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);
@ -342,7 +350,7 @@ HWND WINAPI MainContext::HookCreateWindowExA(DWORD dwExStyle, LPCSTR lpClassName
HWND hWnd = context.TrueCreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
if (!hWnd)
{
PrintLog("CreateWindowExA failed");
spdlog::info("CreateWindowExA failed");
return hWnd;
}
@ -360,7 +368,7 @@ HWND WINAPI MainContext::HookCreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassNam
HWND hWnd = context.TrueCreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
if (!hWnd)
{
PrintLog("CreateWindowExW failed");
spdlog::info("CreateWindowExW failed");
return hWnd;
}

View File

@ -3,11 +3,16 @@
#include <atomic>
#include <d3d9.h>
#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";
#define CONFIG_VERSION 6
#define CONFIG_VERSION 7
class Config
{
@ -61,6 +66,7 @@ public:
void ApplyBorderless(HWND hWnd);
Config config;
void OneTimeFix();
bool IsDXVK();

View File

@ -1,15 +1,12 @@
#include "stdafx.h"
#include "Logger.h"
#include "Context.h"
#include "IDirect3D9.h"
#include "IDirect3DDevice9.h"
#define IDirect3D9_PrintLog(format, ...) //PrintLog(format, __VA_ARGS__);
HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) {
PrintLog(__FUNCTION__);
spdlog::info(__FUNCTION__);
if (ppvObj == nullptr)
return E_POINTER;
@ -58,23 +55,23 @@ ULONG STDMETHODCALLTYPE hkIDirect3D9::Release() {
const ULONG ref_last = pWrapped->Release();
if (ref_last != 0)
PrintLog("WARNING: Reference count for IDirect3D9 is wrong: %p %u %u", this, ref, ref_last);
spdlog::error("Reference count for IDirect3D9 is wrong: {} {} {}", (void*)this, ref, ref_last);
return 0;
}
HRESULT APIENTRY hkIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->RegisterSoftwareDevice(pInitializeFunction);
}
UINT APIENTRY hkIDirect3D9::GetAdapterCount() {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterCount();
}
HRESULT APIENTRY hkIDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
PrintLog(__FUNCTION__);
spdlog::info(__FUNCTION__);
HRESULT rt = m_pWrapped->GetAdapterIdentifier(Adapter, Flags, pIdentifier);
if (context.config.GetAdapterAdapter() && SUCCEEDED(rt) && pIdentifier)
{
@ -85,84 +82,84 @@ HRESULT APIENTRY hkIDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D
}
UINT APIENTRY hkIDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterModeCount(Adapter, Format);
}
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);
}
HRESULT APIENTRY hkIDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterDisplayMode(Adapter, pMode);
}
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;
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) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
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) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels);
}
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);
}
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);
}
HRESULT APIENTRY hkIDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDeviceCaps(Adapter, DeviceType, pCaps);
}
HMONITOR APIENTRY hkIDirect3D9::GetAdapterMonitor(UINT Adapter) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAdapterMonitor(Adapter);
}
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) {
IDirect3D9_PrintLog(__FUNCTION__);
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) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return static_cast<IDirect3D9Ex*>(m_pWrapped)->EnumAdapterModesEx(Adapter, pFilter, Mode, pMode);
}
HRESULT STDMETHODCALLTYPE hkIDirect3D9::GetAdapterDisplayModeEx(UINT Adapter, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation) {
IDirect3D9_PrintLog(__FUNCTION__);
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) {
PrintLog(__FUNCTION__);
spdlog::info(__FUNCTION__);
return ApplyCreateDeviceFix<IDirect3DDevice9Ex, true>(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
}
HRESULT STDMETHODCALLTYPE hkIDirect3D9::GetAdapterLUID(UINT Adapter, LUID* pLUID) {
IDirect3D9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return static_cast<IDirect3D9Ex*>(m_pWrapped)->GetAdapterLUID(Adapter, pLUID);
}
@ -170,17 +167,17 @@ HRESULT STDMETHODCALLTYPE hkIDirect3D9::GetAdapterLUID(UINT Adapter, LUID* pLUID
template <typename T, bool ex>
HRESULT hkIDirect3D9::ApplyCreateDeviceFix(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, T** ppReturnedDeviceInterface)
{
PrintLog(__FUNCTION__);
spdlog::info(__FUNCTION__);
DWORD OriginalBehaviorFlags = BehaviorFlags;
std::string BehaviorFlagsString;
context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString);
PrintLog("BehaviorFlags: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str());
spdlog::info("BehaviorFlags: {:#08x} {}", BehaviorFlags, BehaviorFlagsString);
if (context.config.GetOptionsBehaviorFlags() > 0) {
BehaviorFlags = context.config.GetOptionsBehaviorFlags();
PrintLog("Advanced Mode: BehaviorFlags set");
spdlog::info("Advanced Mode: BehaviorFlags set");
}
else {
context.ApplyBehaviorFlagsFix(&BehaviorFlags);
@ -194,7 +191,7 @@ HRESULT hkIDirect3D9::ApplyCreateDeviceFix(UINT Adapter, D3DDEVTYPE DeviceType,
if (OriginalBehaviorFlags != BehaviorFlags) {
std::string BehaviorFlagsString;
context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString);
PrintLog("BehaviorFlags changed: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str());
spdlog::info("BehaviorFlags changed: {:#08x} {}", BehaviorFlags, BehaviorFlagsString);
}
T* device = nullptr;
@ -211,7 +208,7 @@ HRESULT hkIDirect3D9::ApplyCreateDeviceFix(UINT Adapter, D3DDEVTYPE DeviceType,
}
if (FAILED(hr)) {
PrintLog("CreateDevice fail with HRESULT: %08X", hr);
spdlog::info("CreateDevice fail with HRESULT: {:X}", hr);
*ppReturnedDeviceInterface = nullptr;
return hr;
}

View File

@ -1,17 +1,14 @@
#pragma once
#include "stdafx.h"
#include "Logger.h"
#include "Context.h"
#include "IDirect3DDevice9.h"
#include <intrin.h>
#define IDirect3DDevice9_PrintLog(...) //PrintLog("%s", __VA_ARGS__);
HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
if (ppvObj == nullptr) return E_POINTER;
if (riid == __uuidof(this) ||
@ -59,70 +56,70 @@ ULONG STDMETHODCALLTYPE hkIDirect3DDevice9::Release() {
const ULONG ref_last = pWrapped->Release();
if (ref_last != 0) {
PrintLog("WARNING: Reference count for IDirect3DDevice9 is wrong: %p %u %u", this, ref, ref_last);
spdlog::error("Reference count for IDirect3DDevice9 is wrong: {} {} {}", (void*)this, ref, ref_last);
}
return 0;
}
HRESULT APIENTRY hkIDirect3DDevice9::TestCooperativeLevel() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->TestCooperativeLevel();
}
UINT APIENTRY hkIDirect3DDevice9::GetAvailableTextureMem() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetAvailableTextureMem();
}
HRESULT APIENTRY hkIDirect3DDevice9::EvictManagedResources() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->EvictManagedResources();
}
HRESULT APIENTRY hkIDirect3DDevice9::GetDirect3D(IDirect3D9** ppD3D9) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDirect3D(ppD3D9);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetDeviceCaps(D3DCAPS9* pCaps) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDeviceCaps(pCaps);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDisplayMode(iSwapChain, pMode);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS* pParameters) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetCreationParameters(pParameters);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap);
}
void APIENTRY hkIDirect3DDevice9::SetCursorPosition(int X, int Y, DWORD Flags) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetCursorPosition(X, Y, Flags);
}
BOOL APIENTRY hkIDirect3DDevice9::ShowCursor(BOOL bShow) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->ShowCursor(bShow);
}
HRESULT APIENTRY hkIDirect3DDevice9::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) {
PrintLog(__FUNCTION__);
spdlog::info(__FUNCTION__);
context.ApplyPresentationParameters(pPresentationParameters);
return m_pWrapped->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
// Steam Overlay crash fix
// Add some space, 16bytes should be more than enough
@ -135,598 +132,597 @@ HRESULT APIENTRY hkIDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwap
}
UINT APIENTRY hkIDirect3DDevice9::GetNumberOfSwapChains() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetNumberOfSwapChains();
}
HRESULT APIENTRY hkIDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) {
PrintLog("hkIDirect3DDevice9::Reset");
spdlog::debug("hkIDirect3DDevice9::Reset");
context.ApplyPresentationParameters(pPresentationParameters);
return m_pWrapped->Reset(pPresentationParameters);
}
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);
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRasterStatus(iSwapChain, pRasterStatus);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetDialogBoxMode(BOOL bEnableDialogs) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetDialogBoxMode(bEnableDialogs);
}
void APIENTRY hkIDirect3DDevice9::SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetGammaRamp(iSwapChain, Flags, pRamp);
}
void APIENTRY hkIDirect3DDevice9::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
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) {
//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);
}
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);
}
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);
}
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);
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->UpdateTexture(pSourceTexture, pDestinationTexture);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRenderTargetData(pRenderTarget, pDestSurface);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetFrontBufferData(iSwapChain, pDestSurface);
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->ColorFill(pSurface, pRect, color);
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetRenderTarget(RenderTargetIndex, pRenderTarget);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRenderTarget(RenderTargetIndex, ppRenderTarget);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetDepthStencilSurface(pNewZStencil);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDepthStencilSurface(ppZStencilSurface);
}
HRESULT APIENTRY hkIDirect3DDevice9::BeginScene() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->BeginScene();
}
HRESULT APIENTRY hkIDirect3DDevice9::EndScene() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->EndScene();
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetTransform(State, pMatrix);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetTransform(State, pMatrix);
}
HRESULT APIENTRY hkIDirect3DDevice9::MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->MultiplyTransform(State, pMatrix);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetViewport(pViewport);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetViewport(D3DVIEWPORT9* pViewport) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetViewport(pViewport);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetMaterial(pMaterial);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetMaterial(D3DMATERIAL9* pMaterial) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetMaterial(pMaterial);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetLight(Index, pLight);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetLight(DWORD Index, D3DLIGHT9* pLight) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetLight(Index, pLight);
}
HRESULT APIENTRY hkIDirect3DDevice9::LightEnable(DWORD Index, BOOL Enable) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->LightEnable(Index, Enable);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetLightEnable(DWORD Index, BOOL* pEnable) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetLightEnable(Index, pEnable);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetClipPlane(DWORD Index, CONST float* pPlane) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetClipPlane(Index, pPlane);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetClipPlane(DWORD Index, float* pPlane) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetClipPlane(Index, pPlane);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetRenderState(State, Value);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetRenderState(State, pValue);
}
HRESULT APIENTRY hkIDirect3DDevice9::CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateStateBlock(Type, ppSB);
}
HRESULT APIENTRY hkIDirect3DDevice9::BeginStateBlock() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->BeginStateBlock();
}
HRESULT APIENTRY hkIDirect3DDevice9::EndStateBlock(IDirect3DStateBlock9** ppSB) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->EndStateBlock(ppSB);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetClipStatus(pClipStatus);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetClipStatus(D3DCLIPSTATUS9* pClipStatus) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetClipStatus(pClipStatus);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetTexture(Stage, ppTexture);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetTexture(Stage, pTexture);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetTextureStageState(Stage, Type, pValue);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetTextureStageState(Stage, Type, Value);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetSamplerState(Sampler, Type, pValue);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetSamplerState(Sampler, Type, Value);
}
HRESULT APIENTRY hkIDirect3DDevice9::ValidateDevice(DWORD* pNumPasses) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->ValidateDevice(pNumPasses);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPaletteEntries(PaletteNumber, pEntries);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPaletteEntries(PaletteNumber, pEntries);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetCurrentTexturePalette(UINT PaletteNumber) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetCurrentTexturePalette(PaletteNumber);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetCurrentTexturePalette(UINT* PaletteNumber) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetCurrentTexturePalette(PaletteNumber);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetScissorRect(CONST RECT* pRect) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return context.SetScissorRect(m_pWrapped, pRect);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetScissorRect(RECT* pRect) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetScissorRect(pRect);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetSoftwareVertexProcessing(BOOL bSoftware) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetSoftwareVertexProcessing(bSoftware);
}
BOOL APIENTRY hkIDirect3DDevice9::GetSoftwareVertexProcessing() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetSoftwareVertexProcessing();
}
HRESULT APIENTRY hkIDirect3DDevice9::SetNPatchMode(float nSegments) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetNPatchMode(nSegments);
}
float APIENTRY hkIDirect3DDevice9::GetNPatchMode() {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetNPatchMode();
}
HRESULT APIENTRY hkIDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount);
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
}
HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateVertexDeclaration(pVertexElements, ppDecl);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexDeclaration(pDecl);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexDeclaration(ppDecl);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetFVF(DWORD FVF) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetFVF(FVF);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetFVF(DWORD* pFVF) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetFVF(pFVF);
}
HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateVertexShader(pFunction, ppShader);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShader(pShader);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShader(IDirect3DVertexShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShader(ppShader);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetVertexShaderConstantB(StartRegister, pConstantData, BoolCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetVertexShaderConstantB(StartRegister, pConstantData, BoolCount);
}
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);
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetStreamSourceFreq(UINT StreamNumber, UINT Setting) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetStreamSourceFreq(StreamNumber, Setting);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetStreamSourceFreq(UINT StreamNumber, UINT* pSetting) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetStreamSourceFreq(StreamNumber, pSetting);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetIndices(pIndexData);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetIndices(IDirect3DIndexBuffer9** ppIndexData) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetIndices(ppIndexData);
}
HRESULT APIENTRY hkIDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreatePixelShader(pFunction, ppShader);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShader(pShader);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShader(IDirect3DPixelShader9** ppShader) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShader(ppShader);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetPixelShaderConstantB(StartRegister, pConstantData, BoolCount);
}
HRESULT APIENTRY hkIDirect3DDevice9::GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetPixelShaderConstantB(StartRegister, pConstantData, BoolCount);
}
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);
}
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);
}
HRESULT APIENTRY hkIDirect3DDevice9::DeletePatch(UINT Handle) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->DeletePatch(Handle);
}
HRESULT APIENTRY hkIDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->CreateQuery(Type, ppQuery);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::SetConvolutionMonoKernel(UINT width, UINT height, float* rows, float* columns) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->PresentEx(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::GetGPUThreadPriority(INT* pPriority) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetGPUThreadPriority(pPriority);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::SetGPUThreadPriority(INT Priority) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetGPUThreadPriority(Priority);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::WaitForVBlank(UINT iSwapChain) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->WaitForVBlank(iSwapChain);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::CheckResourceResidency(IDirect3DResource9** pResourceArray, UINT32 NumResources) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->CheckResourceResidency(pResourceArray, NumResources);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::SetMaximumFrameLatency(UINT MaxLatency) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->SetMaximumFrameLatency(MaxLatency);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::GetMaximumFrameLatency(UINT* pMaxLatency) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetMaximumFrameLatency(pMaxLatency);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::CheckDeviceState(HWND hDestinationWindow) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
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) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->ResetEx(pPresentationParameters, pFullscreenDisplayMode);
}
HRESULT STDMETHODCALLTYPE hkIDirect3DDevice9::GetDisplayModeEx(UINT iSwapChain, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation) {
IDirect3DDevice9_PrintLog(__FUNCTION__);
spdlog::trace(__FUNCTION__);
return m_pWrapped->GetDisplayModeEx(iSwapChain, pMode, pRotation);
}

View File

@ -4,14 +4,14 @@ SETTING(s32, LongValue, PresentationInterval, Options, 0,
L"# PresentationInterval (V-Sync)\n"
L"#\n"
L"# -1 = V-Sync forced off\n"
L"# 0 = V-Sync not changed\n"
L"# 0 = V-Sync not changed (default)\n"
L"# 1 = V-Sync forced on"
);
SETTING(s32, LongValue, TripleBuffering, Options, -1,
L"# TripleBuffering\n"
L"#\n"
L"# -1 = Auto (Disabled for dxvk.dll; else, enabled)\n"
L"# -1 = Auto (Disabled for dxvk.dll; else, enabled) (default)\n"
L"# 0 = Off\n"
L"# 1 = On"
);
@ -87,5 +87,23 @@ 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

View File

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

View File

@ -1,8 +1,10 @@
#pragma once
#include "comdef.h"
#include <comdef.h>
#include <d3d9.h>
#include "StringUtil.h"
template <class T>
class WrapperBase
{
@ -17,7 +19,7 @@ public:
if (m_module)
{
FreeLibrary(m_module);
PrintLog("Unloaded %s", module_path.c_str());
spdlog::info("Unloaded {}", module_path);
}
}
@ -34,16 +36,16 @@ protected:
m_module = LoadLibraryA(module_path.c_str());
if (m_module) {
PrintLog("Loaded %s", module_path.c_str());
spdlog::info("Loaded {}", module_path);
return true;
}
else if(fail_is_critical) {
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
_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);
ExitProcess(hr);
}

View File

@ -74,7 +74,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
@ -84,7 +84,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<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 Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
@ -96,10 +96,11 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<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>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -128,13 +129,14 @@
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<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>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpplatest</LanguageStandard>
<CreateHotpatchableImage>true</CreateHotpatchableImage>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -212,7 +214,7 @@
<None Include="exports.def" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MinHook\build\VC16\libMinHook.vcxproj">
<ProjectReference Include="..\Deps\MinHook\build\VC16\libMinHook.vcxproj">
<Project>{f142a341-5ee0-442d-a15f-98ae9b48dbae}</Project>
</ProjectReference>
</ItemGroup>

View File

@ -24,4 +24,6 @@
#include <array>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_map>
#include "Context.h"