From c7274d764fef82b78f4bfa84e02cf95be22a7668 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Sat, 9 Nov 2024 22:28:17 +0300 Subject: [PATCH] stash 3 --- OptiScaler/dllmain.cpp | 119 ----------------------------------------- OptiScaler/pch.h | 40 +++++++++++++- 2 files changed, 39 insertions(+), 120 deletions(-) diff --git a/OptiScaler/dllmain.cpp b/OptiScaler/dllmain.cpp index 221f1d90..4c8a5979 100644 --- a/OptiScaler/dllmain.cpp +++ b/OptiScaler/dllmain.cpp @@ -87,125 +87,6 @@ static HMODULE LoadNvgxDlss(std::wstring originalPath) return nullptr; } -static void DetachHooks() -{ - if (!isNvngxMode) - { - ImGuiOverlayDx::UnHookDx(); - ImGuiOverlayVk::UnHookVk(); - } - - if (o_LoadLibraryA != nullptr || o_LoadLibraryW != nullptr || o_LoadLibraryExA != nullptr || o_LoadLibraryExW != nullptr) - { - DetourTransactionBegin(); - - DetourUpdateThread(GetCurrentThread()); - - if (o_FreeLibrary) - { - DetourDetach(&(PVOID&)o_FreeLibrary, hkFreeLibrary); - o_FreeLibrary = nullptr; - } - - if (o_LoadLibraryA) - { - DetourDetach(&(PVOID&)o_LoadLibraryA, hkLoadLibraryA); - o_LoadLibraryA = nullptr; - } - - if (o_LoadLibraryW) - { - DetourDetach(&(PVOID&)o_LoadLibraryW, hkLoadLibraryW); - o_LoadLibraryW = nullptr; - } - - if (o_LoadLibraryExA) - { - DetourDetach(&(PVOID&)o_LoadLibraryExA, hkLoadLibraryExA); - o_LoadLibraryExA = nullptr; - } - - if (o_LoadLibraryExW) - { - DetourDetach(&(PVOID&)o_LoadLibraryExW, hkLoadLibraryExW); - o_LoadLibraryExW = nullptr; - } - - if (o_GetProcAddress) - { - DetourDetach(&(PVOID&)o_GetProcAddress, hkGetProcAddress); - o_GetProcAddress = nullptr; - } - - if (o_vkGetPhysicalDeviceProperties) - { - DetourDetach(&(PVOID&)o_vkGetPhysicalDeviceProperties, hkvkGetPhysicalDeviceProperties); - o_vkGetPhysicalDeviceProperties = nullptr; - } - - if (o_vkGetPhysicalDeviceProperties2) - { - DetourDetach(&(PVOID&)o_vkGetPhysicalDeviceProperties2, hkvkGetPhysicalDeviceProperties2); - o_vkGetPhysicalDeviceProperties2 = nullptr; - } - - if (o_vkGetPhysicalDeviceProperties2KHR) - { - DetourDetach(&(PVOID&)o_vkGetPhysicalDeviceProperties2KHR, hkvkGetPhysicalDeviceProperties2KHR); - o_vkGetPhysicalDeviceProperties2KHR = nullptr; - } - - if (o_vkEnumerateInstanceExtensionProperties) - { - DetourDetach(&(PVOID&)o_vkEnumerateInstanceExtensionProperties, hkvkEnumerateInstanceExtensionProperties); - o_vkEnumerateInstanceExtensionProperties = nullptr; - } - - if (o_vkEnumerateDeviceExtensionProperties) - { - DetourDetach(&(PVOID&)o_vkEnumerateDeviceExtensionProperties, hkvkEnumerateDeviceExtensionProperties); - o_vkEnumerateDeviceExtensionProperties = nullptr; - } - - if (o_vkCreateDevice) - { - DetourDetach(&(PVOID&)o_vkCreateDevice, hkvkCreateDevice); - o_vkCreateDevice = nullptr; - } - - if (o_vkCreateInstance) - { - DetourDetach(&(PVOID&)o_vkCreateInstance, hkvkCreateInstance); - o_vkCreateInstance = nullptr; - } - - //if (!Config::Instance()->IsDxgiMode && Config::Instance()->DxgiSpoofing.value_or(true)) - //{ - // if (dxgi.CreateDxgiFactory != nullptr) - // { - // DetourDetach(&(PVOID&)dxgi.CreateDxgiFactory, _CreateDXGIFactory); - // dxgi.CreateDxgiFactory = nullptr; - // } - - // if (dxgi.CreateDxgiFactory1 != nullptr) - // { - // DetourDetach(&(PVOID&)dxgi.CreateDxgiFactory1, _CreateDXGIFactory1); - // dxgi.CreateDxgiFactory1 = nullptr; - // } - - // if (dxgi.CreateDxgiFactory2 != nullptr) - // { - // DetourDetach(&(PVOID&)dxgi.CreateDxgiFactory2, _CreateDXGIFactory2); - // dxgi.CreateDxgiFactory2 = nullptr; - // } - //} - - DetourTransactionCommit(); - - //FreeLibrary(shared.dll); - } -} - BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) diff --git a/OptiScaler/pch.h b/OptiScaler/pch.h index b30fcbfd..c635d540 100644 --- a/OptiScaler/pch.h +++ b/OptiScaler/pch.h @@ -35,6 +35,20 @@ inline DWORD processId; #define LOG_DEBUG(msg, ...) \ spdlog::debug(__FUNCTION__ " " msg, ##__VA_ARGS__) +#ifdef DETAILED_DEBUG_LOGS +#define LOG_DEBUG_ONLY(msg, ...) \ + spdlog::debug(__FUNCTION__ " " msg, ##__VA_ARGS__) +#else +#define LOG_DEBUG_ONLY(msg, ...) +#endif + +#ifdef LOG_ASYNC +#define LOG_DEBUG_ASYNC(msg, ...) \ + spdlog::debug(__FUNCTION__ " " msg, ##__VA_ARGS__) +#else +#define LOG_DEBUG_ASYNC(msg, ...) +#endif + #define LOG_INFO(msg, ...) \ spdlog::info(__FUNCTION__ " " msg, ##__VA_ARGS__) @@ -48,7 +62,31 @@ inline DWORD processId; spdlog::trace(__FUNCTION__) #define LOG_FUNC_RESULT(result) \ - spdlog::trace(__FUNCTION__ " result: {0:X}" , (UINT)result) + spdlog::trace(__FUNCTION__ " result: {0:X}" , (UINT64)result) + +typedef struct _feature_version +{ + unsigned int major; + unsigned int minor; + unsigned int patch; +} feature_version; + +inline static bool isVersionOrBetter(const feature_version& current, const feature_version& required) { + if (current.major > required.major) { + return true; + } + if (current.major == required.major) { + if (current.minor > required.minor) { + return true; + } + if (current.minor == required.minor) { + if (current.patch >= required.patch) { + return true; + } + } + } + return false; +} inline static std::string wstring_to_string(const std::wstring& wide_str) {