From 3b6bd03c4938539e64b23c039057a51d92213baf Mon Sep 17 00:00:00 2001 From: nastys <7950891+nastys@users.noreply.github.com> Date: Sat, 3 Feb 2024 13:46:52 +0100 Subject: [PATCH 01/14] Render.dva: don't force WQHD --- source-code/source/plugins/Render/dllmain.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source-code/source/plugins/Render/dllmain.cpp b/source-code/source/plugins/Render/dllmain.cpp index 4510bb0..9175f90 100644 --- a/source-code/source/plugins/Render/dllmain.cpp +++ b/source-code/source/plugins/Render/dllmain.cpp @@ -286,14 +286,14 @@ BOOL APIENTRY DllMain(HMODULE hModule, DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); - switch (game_version) - { - case 600: - DetourAttach(&(PVOID&)divaParseParameters_600, hookedParseParameters); - break; - default: - DetourAttach(&(PVOID&)divaParseParameters_710, hookedParseParameters); - } + //switch (game_version) + //{ + //case 600: + // DetourAttach(&(PVOID&)divaParseParameters_600, hookedParseParameters); + // break; + //default: + // DetourAttach(&(PVOID&)divaParseParameters_710, hookedParseParameters); + //} DetourTransactionCommit(); @@ -390,4 +390,4 @@ extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void) extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void) { return L"Applies window mode/size and FPS limiting."; -} \ No newline at end of file +} From 60958cc3c172df15cbb9d5a727d1860aa98a0634 Mon Sep 17 00:00:00 2001 From: nastys <7950891+nastys@users.noreply.github.com> Date: Sat, 3 Feb 2024 13:48:22 +0100 Subject: [PATCH 02/14] Cleanup --- source-code/source/plugins/Render/dllmain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source-code/source/plugins/Render/dllmain.cpp b/source-code/source/plugins/Render/dllmain.cpp index 9175f90..df181d6 100644 --- a/source-code/source/plugins/Render/dllmain.cpp +++ b/source-code/source/plugins/Render/dllmain.cpp @@ -284,8 +284,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, } DetourTransactionCommit(); - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); + //DetourTransactionBegin(); + //DetourUpdateThread(GetCurrentThread()); //switch (game_version) //{ //case 600: @@ -294,7 +294,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, //default: // DetourAttach(&(PVOID&)divaParseParameters_710, hookedParseParameters); //} - DetourTransactionCommit(); + //DetourTransactionCommit(); // set sleep time resolution to 2ms or device minimum (whichever's lower) From 0b7083edadefaaeba53da3eff005767bfe0d2341 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sun, 4 Feb 2024 01:21:18 +1100 Subject: [PATCH 03/14] new hook for UpdateDraw2D (should be compatible with DivaGL) --- source-code/source/plugins/TLAC/Constants.h | 2 +- source-code/source/plugins/TLAC/dllmain.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source-code/source/plugins/TLAC/Constants.h b/source-code/source/plugins/TLAC/Constants.h index d4b2d14..4d32b70 100644 --- a/source-code/source/plugins/TLAC/Constants.h +++ b/source-code/source/plugins/TLAC/Constants.h @@ -8,7 +8,7 @@ constexpr uint8_t JNE_OPCODE = 0x85; //constexpr uint64_t ENGINE_UPDATE_HOOK_TARGET_ADDRESS = 0x000000014018CC40; constexpr uint64_t ENGINE_UPDATE_INPUT_ADDRESS = 0x000000014018CBB0; -constexpr uint64_t ENGINE_DRAW_2D_ADDRESS = 0x0000000140501F70; +constexpr uint64_t ENGINE_STAGE_DISP_SHADOW_ADDRESS = 0x0000000140649840; constexpr uint64_t ENGINE_FINISH_DRAW_ADDRESS = 0x0000000140192730; constexpr uint64_t CURRENT_GAME_STATE_ADDRESS = 0x0000000140EDA810; diff --git a/source-code/source/plugins/TLAC/dllmain.cpp b/source-code/source/plugins/TLAC/dllmain.cpp index c9aece5..90b1c36 100644 --- a/source-code/source/plugins/TLAC/dllmain.cpp +++ b/source-code/source/plugins/TLAC/dllmain.cpp @@ -22,7 +22,7 @@ #pragma comment(lib, "detours.lib") void(__cdecl* divaEngineUpdate)() = (void(__cdecl*)())0x14018CC40; -void(__cdecl* divaEngineDraw2D)(void* addr) = (void(__cdecl*)(void* addr))ENGINE_DRAW_2D_ADDRESS; +void(__cdecl* divaEngineStageDispShadow)() = (void(__cdecl*)())ENGINE_STAGE_DISP_SHADOW_ADDRESS; LRESULT CALLBACK MessageWindowProcessCallback(HWND, UINT, WPARAM, LPARAM); DWORD WINAPI WindowMessageDispatcher(LPVOID); @@ -396,10 +396,10 @@ void hookedEngineUpdate() //divaEngineUpdate(); } -void hookedEngineDraw2D(void* addr) +void hookedEngineStageDispShadow() { + divaEngineStageDispShadow(); TLAC::UpdateDraw2D(); - divaEngineDraw2D(addr); } BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) @@ -425,7 +425,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); - DetourAttach(&(PVOID&)divaEngineDraw2D, hookedEngineDraw2D); + DetourAttach(&(PVOID&)divaEngineStageDispShadow, hookedEngineStageDispShadow); DetourTransactionCommit(); //TLAC::InitializeExtraSettings(); From d70e20496a063ee75cba774f2a5b713c16cfb7f1 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Tue, 19 Mar 2024 15:35:09 +0300 Subject: [PATCH 04/14] Fixed Auth3D not appearing when disabling Reflections --- source-code/source/plugins/Patches/PatchApplier710.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-code/source/plugins/Patches/PatchApplier710.h b/source-code/source/plugins/Patches/PatchApplier710.h index 4bdb678..2a24f70 100644 --- a/source-code/source/plugins/Patches/PatchApplier710.h +++ b/source-code/source/plugins/Patches/PatchApplier710.h @@ -555,7 +555,7 @@ class PatchApplier710 : public PatchApplier { // Reflections if (!nReflections) { - InjectCode((void*)0x1406477C0, { 0xE9, 0xF3, 0x00, 0x00, 0x00, 0x90 }); + InjectCode((void*)0x1406477C6, { 0xE9, 0xE9, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90 }); InjectCode((void*)0x1411ADAFC, { 0x00 }); } // Shadows From b746ddf00180ff1432baa9748044f404e42efd16 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Tue, 19 Mar 2024 16:23:03 +0300 Subject: [PATCH 05/14] Fixed -wqhd behaviour for 7.10 and restored old behaviour for 6.00 --- source-code/source/plugins/Render/dllmain.cpp | 99 ++++++++++--------- source-code/source/plugins/Render/framework.h | 5 +- 2 files changed, 57 insertions(+), 47 deletions(-) diff --git a/source-code/source/plugins/Render/dllmain.cpp b/source-code/source/plugins/Render/dllmain.cpp index df181d6..3b1fcaf 100644 --- a/source-code/source/plugins/Render/dllmain.cpp +++ b/source-code/source/plugins/Render/dllmain.cpp @@ -135,8 +135,8 @@ __int64 hookedParseParameters(int a1, __int64* a2) case 600: *resolutionType_600 = 15; break; - default: - *resolutionType_710 = 15; + //default: + // *resolutionType_710 = 15; } // Return to the original function switch (game_version) @@ -144,8 +144,8 @@ __int64 hookedParseParameters(int a1, __int64* a2) case 600: return divaParseParameters_600(a1, a2); break; - default: - return divaParseParameters_710(a1, a2); + //default: + // return divaParseParameters_710(a1, a2); } } @@ -231,6 +231,40 @@ __int64 __fastcall limiterFuncLight(__int64 a1) } } +#define WRITE_MEMORY_INT(address, data) \ +{ \ +DWORD oldProtect, bck; \ +VirtualProtect((BYTE*)(address), 4, PAGE_EXECUTE_READWRITE, &oldProtect); \ +*((int*)(address)) = (data); \ +VirtualProtect((BYTE*)(address), 4, oldProtect, &bck); \ +} + +void __fastcall hookedInitRender(int ssaa, int hd_res, int ss_alpha_mask, __int8 npr) { + if (nIntRes) + { + const __int64 widthAddress = 0x0000000140EDA8B0 + 0x0C; + const __int64 heightAddress = 0x0000000140EDA8B0 + 0x10; + const __int64 intWidthAddress = 0x0000000140EDA8D8 + 0x0C; + const __int64 intHeightAddress = 0x0000000140EDA8D8 + 0x10; + + int originalWidth = *(int*)widthAddress; + int originalHeight = *(int*)heightAddress; + int originalIntWidth = *(int*)intWidthAddress; + int originalIntHeight = *(int*)intHeightAddress; + WRITE_MEMORY_INT(widthAddress, nIntResWidth); + WRITE_MEMORY_INT(heightAddress, nIntResHeight); + WRITE_MEMORY_INT(intWidthAddress, nIntResWidth); + WRITE_MEMORY_INT(intHeightAddress, nIntResHeight); + divaInitRender_710(ssaa, hd_res, ss_alpha_mask, npr); + WRITE_MEMORY_INT(widthAddress, originalWidth); + WRITE_MEMORY_INT(heightAddress, originalHeight); + WRITE_MEMORY_INT(intWidthAddress, originalIntWidth); + WRITE_MEMORY_INT(intHeightAddress, originalIntHeight); + } + else + divaInitRender_710(ssaa, hd_res, ss_alpha_mask, npr); +} + __int64 __fastcall hookedEngineUpdate(__int64 a1) { if (nFpsLimit < 1) @@ -284,17 +318,17 @@ BOOL APIENTRY DllMain(HMODULE hModule, } DetourTransactionCommit(); - //DetourTransactionBegin(); - //DetourUpdateThread(GetCurrentThread()); - //switch (game_version) - //{ - //case 600: - // DetourAttach(&(PVOID&)divaParseParameters_600, hookedParseParameters); - // break; + switch (game_version) + { + case 600: + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourAttach(&(PVOID&)divaParseParameters_600, hookedParseParameters); + DetourTransactionCommit(); + break; //default: // DetourAttach(&(PVOID&)divaParseParameters_710, hookedParseParameters); - //} - //DetourTransactionCommit(); + } // set sleep time resolution to 2ms or device minimum (whichever's lower) @@ -340,39 +374,14 @@ BOOL APIENTRY DllMain(HMODULE hModule, switch (game_version) { case 600: - { - DWORD oldProtect, bck; - VirtualProtect((BYTE*)0x0000000140980954, 4, PAGE_EXECUTE_READWRITE, &oldProtect); - *((int*)0x0000000140980954) = nIntResWidth; - VirtualProtect((BYTE*)0x0000000140980954, 6, oldProtect, &bck); - } - { - DWORD oldProtect, bck; - VirtualProtect((BYTE*)0x0000000140980958, 4, PAGE_EXECUTE_READWRITE, &oldProtect); - *((int*)0x0000000140980958) = nIntResHeight; - VirtualProtect((BYTE*)0x0000000140980958, 6, oldProtect, &bck); - } - break; + WRITE_MEMORY_INT(0x0000000140980954, nIntResWidth); + WRITE_MEMORY_INT(0x0000000140980958, nIntResWidth); + break; default: - { - DWORD oldProtect, bck; - VirtualProtect((BYTE*)0x00000001409B8B68, 4, PAGE_EXECUTE_READWRITE, &oldProtect); - *((int*)0x00000001409B8B68) = nIntResWidth; - VirtualProtect((BYTE*)0x00000001409B8B68, 6, oldProtect, &bck); - } - { - DWORD oldProtect, bck; - VirtualProtect((BYTE*)0x00000001409B8B6C, 4, PAGE_EXECUTE_READWRITE, &oldProtect); - *((int*)0x00000001409B8B6C) = nIntResHeight; - VirtualProtect((BYTE*)0x00000001409B8B6C, 6, oldProtect, &bck); - } - - //*((int*)0x00000001409B8B6C) = maxHeight; - //*((int*)0x00000001409B8B14) = maxWidth; - //*((int*)0x00000001409B8B18) = maxHeight; - - //*((int*)0x00000001409B8B1C) = maxWidth; // No parameters width? - //*((int*)0x00000001409B8B20) = maxHeight; // No parameters height? + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourAttach(&(PVOID&)divaInitRender_710, hookedInitRender); + DetourTransactionCommit(); } } } diff --git a/source-code/source/plugins/Render/framework.h b/source-code/source/plugins/Render/framework.h index 219cfb5..67f9150 100644 --- a/source-code/source/plugins/Render/framework.h +++ b/source-code/source/plugins/Render/framework.h @@ -6,11 +6,12 @@ #include static int(__cdecl* divaCreateWindow_710)(const char* title, void(__cdecl* exitfunc)(int)) = (int(__cdecl*)(const char* title, void(__cdecl * exitfunc)(int)))0x140194D00; -__int64 (__fastcall* divaParseParameters_710)(int a1, __int64* a2) = (__int64(__fastcall*)(int a1, __int64* a2))0x140193630; +void(__fastcall* divaInitRender_710)(int ssaa, int hd_res, int ss_alpha_mask, __int8 npr) = (void(__fastcall *)(int ssaa, int hd_res, int ss_alpha_mask, __int8 npr))0x0000000140502A10; +//__int64 (__fastcall* divaParseParameters_710)(int a1, __int64* a2) = (__int64(__fastcall*)(int a1, __int64* a2))0x140193630; __int64(__fastcall* divaEngineUpdate_710)(__int64 a1) = (__int64(__fastcall*)(__int64 a1))0x140194CD0; uint8_t* fullScreenFlag_710 = (uint8_t*)0x140EDA5D1; -DWORD* resolutionType_710 = (DWORD*)0x140EDA5D4; +//DWORD* resolutionType_710 = (DWORD*)0x140EDA5D4; static int(__cdecl* divaCreateWindow_600)(const char* title, void(__cdecl* exitfunc)(int)) = (int(__cdecl*)(const char* title, void(__cdecl * exitfunc)(int)))0x14018CD00; From 360305357b0abe2ced5aaa6449c31e199f964899 Mon Sep 17 00:00:00 2001 From: nastys Date: Wed, 20 Mar 2024 22:37:47 +0100 Subject: [PATCH 06/14] Fix lag compensation triggering ConfigChanged every time --- source-code/source/plugins/Launcher/ui.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 1ab4a24..d69e4ce 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -663,7 +663,7 @@ private: System::Windows::Forms::Button^ button_Wiki; this->trackBar_LagCompensation->Size = System::Drawing::Size(500, 90); this->trackBar_LagCompensation->TabIndex = 0; this->trackBar_LagCompensation->TickStyle = System::Windows::Forms::TickStyle::None; - this->trackBar_LagCompensation->ValueChanged += gcnew System::EventHandler(this, &ui::trackBar_LagCompensation_ValueChanged); + this->trackBar_LagCompensation->Scroll += gcnew System::EventHandler(this, &ui::trackBar_LagCompensation_Scroll); // // groupBox_Details // @@ -1205,7 +1205,7 @@ private: String^ GPUIssueText; private: System::Void LinkLabelLinkClickedGPUIssueHandler(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) { SkinnedMessageBox::Show(this, GPUIssueText, "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); } -private: System::Void trackBar_LagCompensation_ValueChanged(System::Object^ sender, System::EventArgs^ e) { +private: System::Void trackBar_LagCompensation_Scroll(System::Object^ sender, System::EventArgs^ e) { *LagCompensationConfigChanged = true; updateLagCompMsec(); @@ -1215,7 +1215,5 @@ private: System::Void tabPage_Resolution_Click(System::Object^ sender, System::E private: System::Void button_Wiki_Click(System::Object^ sender, System::EventArgs^ e) { System::Diagnostics::Process::Start("https://github.com/PDModdingCommunity/PD-Loader/wiki"); } -private: System::Void trackBar_LagCompensation_Scroll(System::Object^ sender, System::EventArgs^ e) { -} }; } From 2c10f27ab05e7dad9709dbd65eed94519be61f1c Mon Sep 17 00:00:00 2001 From: nastys Date: Tue, 26 Mar 2024 00:25:30 +0100 Subject: [PATCH 07/14] DivaGL detection, Ada Lovelace "support" --- source-code/data/plugins/ShaderPatch.ini | 8 +- source-code/data/plugins/config_template.bin | 2 +- source-code/dependencies/GPUModel/GPUModel.h | 7 +- .../source/plugins/Launcher/framework.h | 2 +- source-code/source/plugins/Launcher/ui.h | 237 ++++++++++-------- .../source/plugins/Novidia/src/dllmain.cpp | 7 + .../plugins/ShaderPatch/src/dllmain.cpp | 7 + 7 files changed, 164 insertions(+), 106 deletions(-) diff --git a/source-code/data/plugins/ShaderPatch.ini b/source-code/data/plugins/ShaderPatch.ini index 6a45d15..e83537e 100644 --- a/source-code/data/plugins/ShaderPatch.ini +++ b/source-code/data/plugins/ShaderPatch.ini @@ -37,13 +37,13 @@ Toon_Lines_Improve_Val3=0.75 [Patches] # Compatibility patches: # Star Story (and etc.) stage corruption (Maxwell+) -blinn_per_vert\.0010010[23]00[01]\.fp=arch:GA,TU,GP,GV,GM||cfg:compat||from:TEX tex_col, a_tex_color0, texture\[0\], 2D; ALIAS||to:TEX tex_col, a_tex_color0, texture[0], 2D; MUL tex_col, 1, tex_col; ALIAS +blinn_per_vert\.0010010[23]00[01]\.fp=arch:AD,GA,GV,TU,GP,GM||cfg:compat||from:TEX tex_col, a_tex_color0, texture\[0\], 2D; ALIAS||to:TEX tex_col, a_tex_color0, texture[0], 2D; MUL tex_col, 1, tex_col; ALIAS # Turing shading lines (new patch by samyuu, hopefully ported to here correctly) -.*=arch:GA,TU||cfg:compat||from:SHORT ||to: +.*=arch:AD,GA,GV,TU||cfg:compat||from:SHORT ||to: # Turing NPR cloth noise -cloth_npr1.*=arch:GA,TU||cfg:compat||from:SSG _tmp0.yw, ybr.xxzz;||to:TEMP _tmpForSSG; SGE _tmpForSSG.xz, ybr.xxzz, 0; SUB _tmpForSSG.xz, _tmpForSSG.xxzz, 1; SGT _tmpForSSG.yw, ybr.xxzz, 0; ADD _tmp0.yw, _tmpForSSG.xxzz, _tmpForSSG.yyww; +cloth_npr1.*=arch:AD,GA,GV,TU||cfg:compat||from:SSG _tmp0.yw, ybr.xxzz;||to:TEMP _tmpForSSG; SGE _tmpForSSG.xz, ybr.xxzz, 0; SUB _tmpForSSG.xz, _tmpForSSG.xxzz, 1; SGT _tmpForSSG.yw, ybr.xxzz, 0; ADD _tmp0.yw, _tmpForSSG.xxzz, _tmpForSSG.yyww; # Turing auto-exposure fix by samyuu -stage_blinn.*\.fp=arch:GA,TU||cfg:compat||from:NRMH normal, a_normal;||to:NRM normal, a_normal; +stage_blinn.*\.fp=arch:AD,GA,GV,TU||cfg:compat||from:NRMH normal, a_normal;||to:NRM normal, a_normal; # Lyb's toon shader improvements: cloth_npr1.*=cfg:toon_improve||from:MAD tmp.y, lc.z, 1.2, -0.5;||to:MAD tmp.y, lc.z, , ; diff --git a/source-code/data/plugins/config_template.bin b/source-code/data/plugins/config_template.bin index bf7e73c..7df3d38 100644 --- a/source-code/data/plugins/config_template.bin +++ b/source-code/data/plugins/config_template.bin @@ -7,7 +7,7 @@ Enable=1 [GPU] -# Force GPU model -- -1=auto, 0=Kepler, 1=Maxwell/Pascal, 2=Turing, 3=Ampere +# Force GPU model -- -1=auto, 0=Kepler, 1=Maxwell/Pascal, 2=Turing, 3=Ampere, 4=Ada Lovelace Model=-1 [Launcher] diff --git a/source-code/dependencies/GPUModel/GPUModel.h b/source-code/dependencies/GPUModel/GPUModel.h index 68bc096..d7eaaf5 100644 --- a/source-code/dependencies/GPUModel/GPUModel.h +++ b/source-code/dependencies/GPUModel/GPUModel.h @@ -34,9 +34,9 @@ namespace GPUModel // note that the used GL context may differ std::string getGpuName() { - // detected model can be overridden -- 0: Kepler, 1: Maxwell, 2: Turing, 3: Ampere + // detected model can be overridden -- 0: Kepler, 1: Maxwell, 2: Turing, 3: Ampere, 4: Ada Lovelace int nGPUModel = GetPrivateProfileIntW(L"gpu", L"model", -1, CONFIG_FILE); - if (nGPUModel >= 0 && nGPUModel <= 3) + if (nGPUModel >= 0 && nGPUModel <= 4) { std::string arch; switch (nGPUModel) @@ -53,6 +53,9 @@ namespace GPUModel case 3: arch = "GA000"; break; + case 4: + arch = "AD000"; + break; } printf("[GPUModel] GPU Model override: %s\n", arch.c_str()); diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 82b2963..94c8b3b 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -166,7 +166,7 @@ ConfigOptionBase* internalResolutionArray[] = { }; ConfigOptionBase* graphicsArray[] = { - new DropdownOption(L"model", L"GPU", CONFIG_FILE, L"NVIDIA GPU:", L"Select your NVIDIA GPU's architecture to apply the necessary workarounds.\n\nNOTE: Automatic detection does not currently work on GNU/Linux.", -1, std::vector({ L"Automatic", L"Kepler", L"Maxwell/Pascal", L"Turing", L"Ampere" }), -1), + new DropdownOption(L"model", L"GPU", CONFIG_FILE, L"NVIDIA GPU:", L"Select your NVIDIA GPU's architecture to apply the necessary workarounds.\n\nNOTE: Automatic detection does not currently work on GNU/Linux.", -1, std::vector({ L"Automatic", L"Kepler", L"Maxwell/Pascal", L"Turing", L"Ampere", L"Ada Lovelace"}), -1), new BooleanOption(L"TAA", GRAPHICS_SECTION, CONFIG_FILE, L"TAA", L"Temporal Anti-Aliasing", true, false), new BooleanOption(L"MLAA", GRAPHICS_SECTION, CONFIG_FILE, L"MLAA", L"Morphological Anti-Aliasing", true, false), new DropdownOption(L"MAG", GRAPHICS_SECTION, CONFIG_FILE, L"Filter:", L"Image filter.\n\nBilinear: default filter\nNearest-neighbour: sharpest, but blocky\nSharpen: sharp filter\nCone: smooth filter", 0, std::vector({ L"Bilinear", L"Nearest-neighbour", L"Sharpen", L"Cone" })), diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index d69e4ce..71d6c5f 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -232,131 +232,172 @@ namespace Launcher { int linkStart = this->labelGPU->Text->Length; bool showGpuDialog = false; - if (vendor->Contains("AMD") || vendor->Contains("ATI")) // check OpenGL to get actual GPU being used for vendor check (to get accurate results for iGPU) + + bool hasNovidia = false; + bool novidiaEnabled = false; + + bool hasDivaGL = false; + bool divaGLEnabled = true; + + for (PluginInfo i : AllPlugins) { - bool hasNovidia = false; - for (PluginInfo i : AllPlugins) + if (i.name == L"Novidia") { - if (i.name == L"Novidia") - hasNovidia = true; + hasNovidia = true; + novidiaEnabled = GetIniBool(L"plugins", i.filename.c_str(), 1, CONFIG_FILE); + } + else if (i.name == L"DivaGL") + { + hasDivaGL = true; + divaGLEnabled = GetIniBool(L"plugins", i.filename.c_str(), 1, CONFIG_FILE); } - if (hasNovidia) + if (hasNovidia && hasDivaGL) break; + } + + if (divaGLEnabled) + { + this->labelGPU->Text += L"Rendering provided by DivaGL."; + GPUIssueText = L"Please check DivaGL's requirements to ensure compatibility with your graphics driver."; + this->labelGPU->LinkColor = System::Drawing::Color::HotPink; + } + else + { + if (vendor->Contains("AMD") || vendor->Contains("ATI")) // check OpenGL to get actual GPU being used for vendor check (to get accurate results for iGPU) { - if (wineVersion == "" && (driver_version_major < 21 || (driver_version_major == 21 && driver_version_minor < 6))) + if (hasNovidia) { - if (driver_version_major == 21 && driver_version_minor == 5) + if (novidiaEnabled) { - this->labelGPU->Text += L"Driver may have issues."; - GPUIssueText = L"The graphics driver you're using should be able to play movies without issues, but may crash while loading a song after playing multiple stages in one session.\nIf possible, please install the latest driver from your GPU vendor's website.\nHowever, note that if your GPU is old, you may not be able to install a more recent driver."; + if (wineVersion == "" && (driver_version_major < 21 || (driver_version_major == 21 && driver_version_minor < 6))) + { + if (driver_version_major == 21 && driver_version_minor == 5) + { + this->labelGPU->Text += L"Driver may have issues."; + GPUIssueText = L"The graphics driver you're using should be able to play movies without issues, but may crash while loading a song after playing multiple stages in one session.\nIf possible, please install the latest driver from your GPU vendor's website.\nHowever, note that if your GPU is old, you may not be able to install a more recent driver."; + } + else + { + this->labelGPU->Text += L"Driver has known issues."; + GPUIssueText = L"The graphics driver you're using has known issues. Movies may not play back correctly.\nPlease install the latest driver from your GPU vendor's website."; + showGpuDialog = true; + } + + this->labelGPU->LinkColor = System::Drawing::Color::Orange; + } + else if (wineVersion == "" && (driver_version_major > 22 || (driver_version_major == 22 && driver_version_minor > 6))) + { + this->labelGPU->Text += "Issues: Unsupported GPU driver."; + GPUIssueText = "The graphics driver you're using is too new for Novidia.\nThe game will not run unless you install driver version 22.6.1 or earlier from AMD's website."; + this->labelGPU->LinkColor = System::Drawing::Color::Red; + showGpuDialog = true; + } + else + { + this->labelGPU->Text += "Issues: AMD GPU support is unofficial."; + GPUIssueText = "AMD GPUs are not supported without mods.\nThe PD Loader AMDPack seems to be installed, but please keep in mind that it may have issues."; + this->labelGPU->LinkColor = System::Drawing::Color::Yellow; + } } else { - this->labelGPU->Text += L"Driver has known issues."; - GPUIssueText = L"The graphics driver you're using has known issues. Movies may not play back correctly.\nPlease install the latest driver from your GPU vendor's website."; + this->labelGPU->Text += "Issues: Mods needed for AMD compatibility!"; + GPUIssueText = "AMD GPUs are not supported without mods.\nNovidia is installed, but disabled; please enable it to use your AMD GPU.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel."; + this->labelGPU->LinkColor = System::Drawing::Color::Red; showGpuDialog = true; } - - this->labelGPU->LinkColor = System::Drawing::Color::Orange; } - else if (wineVersion == "" && (driver_version_major > 22 || (driver_version_major == 22 && driver_version_minor > 6))) + else { - this->labelGPU->Text += "Issues: Unsupported GPU driver."; - GPUIssueText = "The graphics driver you're using is too new for Novidia.\nThe game will not run unless you install driver version 22.6.1 or earlier from AMD's website."; + this->labelGPU->Text += "Issues: Mods needed for AMD compatibility!"; + GPUIssueText = "AMD GPUs are not supported without mods.\nEither DivaGL or Novidia is required. Please download either plugin and check its requirements to ensure compatibility with your graphics driver.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel."; this->labelGPU->LinkColor = System::Drawing::Color::Red; showGpuDialog = true; } - else + } + else if (vendor->Contains("NVIDIA")) + { + if (wineVersion == "" && (driver_version_major < 391 || (driver_version_major > 446 && driver_version_major < 460))) { - this->labelGPU->Text += "Issues: AMD GPU support is unofficial."; - GPUIssueText = "AMD GPUs are not supported without mods.\nThe PD Loader AMDPack seems to be installed, but please keep in mind that it may have issues."; - this->labelGPU->LinkColor = System::Drawing::Color::Yellow; - } - } - else - { - this->labelGPU->Text += "Issues: Mods needed for AMD compatibility!"; - GPUIssueText = "AMD GPUs are not supported without mods.\nThe PD Loader AMDPack can be used to make 3D rendering work. Please download it and follow the included instructions.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel."; - this->labelGPU->LinkColor = System::Drawing::Color::Red; - showGpuDialog = true; - } - } - else if (vendor->Contains("NVIDIA")) - { - if (wineVersion == "" && (driver_version_major < 391 || (driver_version_major > 446 && driver_version_major < 460))) - { - this->labelGPU->Text += L"Driver has known issues."; - GPUIssueText = L"The graphics driver you're using has known issues. Please install the latest driver from your GPU vendor's website."; - this->labelGPU->LinkColor = System::Drawing::Color::Orange; - showGpuDialog = true; - } - else if (gpuModel->StartsWith("GA")) // unconfirmed?? - { - this->labelGPU->Text += L"Issues: Ampere GPU detected! Possible noise.\n(Click for more information)"; - GPUIssueText = L"On Ampere GPUs (RTX 30xx), some important character shaders have issues resulting in lines/noise.\nPlease make sure the ShaderPatch plugin is enabled."; - this->labelGPU->LinkColor = System::Drawing::Color::Yellow; - } - else if (gpuModel->StartsWith("TU") || gpuModel->StartsWith("GV")) // let's assume Volta is like Turing for now - { - this->labelGPU->Text += L"Issues: Turing GPU detected! Possible noise.\n(Click for more information)"; - GPUIssueText = L"On Turing GPUs (GTX 16xx/RTX 20xx), some important character shaders have issues resulting in lines/noise.\nPlease make sure the ShaderPatch plugin is enabled."; - this->labelGPU->LinkColor = System::Drawing::Color::Yellow; - } - else if (gpuModel->StartsWith("GM") || gpuModel->StartsWith("GP")) - { - this->labelGPU->Text += L"Issues: May have minor noise on some stages.\n(Click for more information)"; - GPUIssueText = L"On Maxwell GPUs (~GTX 900) and newer, some minor stage shaders create noise.\nPlease make sure the ShaderPatch plugin is enabled."; - this->labelGPU->LinkColor = System::Drawing::Color::Teal; - } - else if (gpuModel->StartsWith("GK")) - { - this->labelGPU->Text += L"Issues: None."; - GPUIssueText = L"Your GPU should have no issues running the game."; - this->labelGPU->LinkColor = System::Drawing::Color::LightBlue; - } - else if (gpuModel->StartsWith("GF")) - { - if (version[0] < '4') - { - this->labelGPU->Text += L"Issues: Driver too old."; - GPUIssueText = L"Your GPU should be able to run the game, but it looks like your OpenGL version is too old.\nA driver update should fix this."; + this->labelGPU->Text += L"Driver has known issues."; + GPUIssueText = L"The graphics driver you're using has known issues. Please install the latest driver from your GPU vendor's website."; this->labelGPU->LinkColor = System::Drawing::Color::Orange; showGpuDialog = true; } - else + else if (gpuModel->StartsWith("AD")) // unconfirmed?? { - this->labelGPU->Text += L"Issues: No known issues."; - GPUIssueText = L"Your GPU should have no issues running the game, but it is older than the GPU the game was originally designed for (GTX 650 Ti).\nThere may be some issues with graphics.\nPlease report any issues so that they can be analysed and potentially fixed."; + this->labelGPU->Text += L"Issues: Ada Lovelace GPU detected! Possible noise.\n(Click for more information)"; + GPUIssueText = L"On Ada Lovelace GPUs (RTX 40xx), some important character shaders have issues resulting in lines/noise.\nPlease make sure the ShaderPatch plugin is enabled."; + this->labelGPU->LinkColor = System::Drawing::Color::Yellow; + } + else if (gpuModel->StartsWith("GA")) // unconfirmed?? + { + this->labelGPU->Text += L"Issues: Ampere GPU detected! Possible noise.\n(Click for more information)"; + GPUIssueText = L"On Ampere GPUs (RTX 30xx), some important character shaders have issues resulting in lines/noise.\nPlease make sure the ShaderPatch plugin is enabled."; + this->labelGPU->LinkColor = System::Drawing::Color::Yellow; + } + else if (gpuModel->StartsWith("TU") || gpuModel->StartsWith("GV")) // let's assume Volta is like Turing for now + { + this->labelGPU->Text += L"Issues: Turing GPU detected! Possible noise.\n(Click for more information)"; + GPUIssueText = L"On Turing GPUs (GTX 16xx/RTX 20xx), some important character shaders have issues resulting in lines/noise.\nPlease make sure the ShaderPatch plugin is enabled."; + this->labelGPU->LinkColor = System::Drawing::Color::Yellow; + } + else if (gpuModel->StartsWith("GM") || gpuModel->StartsWith("GP")) + { + this->labelGPU->Text += L"Issues: May have minor noise on some stages.\n(Click for more information)"; + GPUIssueText = L"On Maxwell GPUs (~GTX 900) and newer, some minor stage shaders create noise.\nPlease make sure the ShaderPatch plugin is enabled."; this->labelGPU->LinkColor = System::Drawing::Color::Teal; } + else if (gpuModel->StartsWith("GK")) + { + this->labelGPU->Text += L"Issues: None."; + GPUIssueText = L"Your GPU should have no issues running the game."; + this->labelGPU->LinkColor = System::Drawing::Color::LightBlue; + } + else if (gpuModel->StartsWith("GF")) + { + if (version[0] < '4') + { + this->labelGPU->Text += L"Issues: Driver too old."; + GPUIssueText = L"Your GPU should be able to run the game, but it looks like your OpenGL version is too old.\nA driver update should fix this."; + this->labelGPU->LinkColor = System::Drawing::Color::Orange; + showGpuDialog = true; + } + else + { + this->labelGPU->Text += L"Issues: No known issues."; + GPUIssueText = L"Your GPU should have no issues running the game, but it is older than the GPU the game was originally designed for (GTX 650 Ti).\nThere may be some issues with graphics.\nPlease report any issues so that they can be analysed and potentially fixed."; + this->labelGPU->LinkColor = System::Drawing::Color::Teal; + } + } + else if (gpuModel->StartsWith("G") || gpuModel->StartsWith("NV") || gpuModel->StartsWith("NB") || gpuModel->StartsWith("N10") || gpuModel->StartsWith("MCP")) + { + this->labelGPU->Text += L"Issues: GPU too old! 3D rendering might be broken.\n(Click for more information)"; + GPUIssueText = L"Your GPU is very old and does not support rendering techniques used by the game.\nYou may be able to play, but graphics will likely have major issues.\nPlease upgrade to a GTX 600 series or later GPU."; + this->labelGPU->LinkColor = System::Drawing::Color::Orange; + showGpuDialog = true; + } + else if (version[0] >= '4' && gpuModel->Length > 0 && !gpuModel->StartsWith("Unk") && !gpuModel->StartsWith("Oth")) + { + this->labelGPU->Text += L"Issues: GPU may be too new.\n(Click for more information)"; + GPUIssueText = L"It looks like your GPU may be too new. Only up to Ampere (RTX 30xx) is currently supported.\nGood news: the game should be capable of running, but shader patches (probably needed) may not support it yet.\nYou will likely see lines/noise on important character shaders and some minor stage shaders.\nPlease report any issues so that ShaderPatch can be updated.\nYou can also try forcing a specific GPU workaround type."; + this->labelGPU->LinkColor = System::Drawing::Color::Orange; + } + else + { + this->labelGPU->Text += L"Issues: Unable to detect GPU architecture.\n(Click for more information)"; + GPUIssueText = L"It looks like you have an NVIDIA GPU, but something went wrong while trying to determine your GPU's architecture (type).\nThis may be a caused by a bug, but it probably indicates potential issues.\nPlease make sure you have a GTX 600 series or later GPU. (GTX 400 series or later should also work)"; + this->labelGPU->LinkColor = System::Drawing::Color::Orange; + showGpuDialog = true; + } } - else if (gpuModel->StartsWith("G") || gpuModel->StartsWith("NV") || gpuModel->StartsWith("NB") || gpuModel->StartsWith("N10") || gpuModel->StartsWith("MCP")) + else //if (gpuModel->Length == 0 || gpuModel->StartsWith("Unk") || gpuModel->StartsWith("Oth")) { - this->labelGPU->Text += L"Issues: GPU too old! 3D rendering might be broken.\n(Click for more information)"; - GPUIssueText = L"Your GPU is very old and does not support rendering techniques used by the game.\nYou may be able to play, but graphics will likely have major issues.\nPlease upgrade to a GTX 600 series or later GPU."; - this->labelGPU->LinkColor = System::Drawing::Color::Orange; + this->labelGPU->Text += L"Issues: UNSUPPORTED GPU!"; + GPUIssueText = L"Your graphics card is not supported. Only NVIDIA GPUs are recommended (though others can be used with mods).\nPlease use a GTX 600 series or later NVIDIA GPU.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel.\n\nOwners of other GPUs may be able to run the game using plugins or mods, such as DivaGL, Novidia, or DivaImGui."; + this->labelGPU->LinkColor = System::Drawing::Color::Red; showGpuDialog = true; } - else if (version[0] >= '4' && gpuModel->Length > 0 && !gpuModel->StartsWith("Unk") && !gpuModel->StartsWith("Oth")) - { - this->labelGPU->Text += L"Issues: GPU may be too new.\n(Click for more information)"; - GPUIssueText = L"It looks like your GPU may be too new. Only up to Ampere (RTX 30xx) is currently supported.\nGood news: the game should be capable of running, but shader patches (probably needed) may not support it yet.\nYou will likely see lines/noise on important character shaders and some minor stage shaders.\nPlease report any issues so that ShaderPatch can be updated.\nYou can also try forcing a specific GPU workaround type."; - this->labelGPU->LinkColor = System::Drawing::Color::Orange; - } - else - { - this->labelGPU->Text += L"Issues: Unable to detect GPU architecture.\n(Click for more information)"; - GPUIssueText = L"It looks like you have an NVIDIA GPU, but something went wrong while trying to determine your GPU's architecture (type).\nThis may be a caused by a bug, but it probably indicates potential issues.\nPlease make sure you have a GTX 600 series or later GPU. (GTX 400 series or later should also work)"; - this->labelGPU->LinkColor = System::Drawing::Color::Orange; - showGpuDialog = true; - } - } - else //if (gpuModel->Length == 0 || gpuModel->StartsWith("Unk") || gpuModel->StartsWith("Oth")) - { - this->labelGPU->Text += L"Issues: UNSUPPORTED GPU!"; - GPUIssueText = L"Your graphics card is not supported. Only NVIDIA GPUs are recommended (though AMD ones can be used with mods).\nPlease use a GTX 600 series or later NVIDIA GPU.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel.\n\nOwners of other GPUs may be able to run the game using plugins or mods, but 3D graphics will probably not work."; - this->labelGPU->LinkColor = System::Drawing::Color::Red; - showGpuDialog = true; } int linkEnd = this->labelGPU->Text->Length - linkStart; @@ -1203,7 +1244,7 @@ private: bool AnyConfigChanged() { private: String^ GPUIssueText; private: System::Void LinkLabelLinkClickedGPUIssueHandler(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) { - SkinnedMessageBox::Show(this, GPUIssueText, "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); + SkinnedMessageBox::Show(this, GPUIssueText, "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Information); } private: System::Void trackBar_LagCompensation_Scroll(System::Object^ sender, System::EventArgs^ e) { *LagCompensationConfigChanged = true; diff --git a/source-code/source/plugins/Novidia/src/dllmain.cpp b/source-code/source/plugins/Novidia/src/dllmain.cpp index 5a60b7b..62f2441 100644 --- a/source-code/source/plugins/Novidia/src/dllmain.cpp +++ b/source-code/source/plugins/Novidia/src/dllmain.cpp @@ -380,6 +380,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv if (ul_reason_for_call == DLL_PROCESS_ATTACH) { + if (GetModuleHandleW(L"DivaGL.dva") != NULL) + { + // detected DivaGL + printf("[Novidia] Detected DivaGL! Quitting!\n"); + return TRUE; + } + loadConfig(); if (!disable_amd_check) diff --git a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp index 24ab6a6..41efe30 100644 --- a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp +++ b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp @@ -294,6 +294,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { + if (GetModuleHandleW(L"DivaGL.dva") != NULL) + { + // detected DivaGL + printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); + return TRUE; + } + // install a thunk to hook InjectCode((void*)0x1405e5991, { 0x48, 0x83, 0xec, 0x28 }); // SUB RSP, 0x28 InjectCode((void*)0x1405e5995, { 0xe8, 0x56, 0xe8, 0xb9, 0xff }); // CALL 0x1401841f0 From b6fc62bbf1e8c1f6a60bf3a8d82a201c4ab4bee6 Mon Sep 17 00:00:00 2001 From: nastys Date: Tue, 26 Mar 2024 20:16:40 +0100 Subject: [PATCH 08/14] Change DivaGL detection method, fix non_nv_name --- source-code/dependencies/GPUModel/GPUModel.h | 2 +- .../source/plugins/Novidia/src/dllmain.cpp | 5 +-- .../source/plugins/Novidia/src/framework.h | 43 ++++++++++++++++++- .../plugins/ShaderPatch/src/dllmain.cpp | 5 +-- .../plugins/ShaderPatch/src/framework.h | 34 +++++++++++++++ 5 files changed, 80 insertions(+), 9 deletions(-) diff --git a/source-code/dependencies/GPUModel/GPUModel.h b/source-code/dependencies/GPUModel/GPUModel.h index d7eaaf5..5cf3772 100644 --- a/source-code/dependencies/GPUModel/GPUModel.h +++ b/source-code/dependencies/GPUModel/GPUModel.h @@ -68,7 +68,7 @@ namespace GPUModel //DWORD dwAttrib = GetFileAttributesW(L"amdgfxinfo64.dll"); //if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) struct stat buffer; // for some reason winapi version wasn't working - if (stat("amdgfxinfo64.dll", &buffer) == 0); + if (stat("amdgfxinfo64.dll", &buffer) == 0) { non_nv_name = "AMD"; } diff --git a/source-code/source/plugins/Novidia/src/dllmain.cpp b/source-code/source/plugins/Novidia/src/dllmain.cpp index 62f2441..582c85b 100644 --- a/source-code/source/plugins/Novidia/src/dllmain.cpp +++ b/source-code/source/plugins/Novidia/src/dllmain.cpp @@ -380,10 +380,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - if (GetModuleHandleW(L"DivaGL.dva") != NULL) + if (hasConflicts()) { - // detected DivaGL - printf("[Novidia] Detected DivaGL! Quitting!\n"); + // detected an incompatible plugin (i.e. DivaGL) return TRUE; } diff --git a/source-code/source/plugins/Novidia/src/framework.h b/source-code/source/plugins/Novidia/src/framework.h index 6162c90..04ad41a 100644 --- a/source-code/source/plugins/Novidia/src/framework.h +++ b/source-code/source/plugins/Novidia/src/framework.h @@ -1,8 +1,13 @@ #pragma once -#include "glStuff.h" +#define WIN32_LEAN_AND_MEAN +#include +#include + #include +#include "glStuff.h" + // use this as a hook to perform initialisation void(__cdecl* glutSetCursor)(int cursor) = *(void(__cdecl**)(int))0x140966068; void(__cdecl* uploadModelTransformBuf)(DWORD* a1, int a2) = (void(__cdecl*)(DWORD * a1, int a2))0x140444fa0; @@ -112,4 +117,38 @@ void InjectCode(void* address, const std::vector data) VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect); memcpy(address, data.data(), byteCount); VirtualProtect(address, byteCount, oldProtect, nullptr); -} \ No newline at end of file +} + + +bool hasConflicts() +{ + HMODULE hModules[1024]; + HANDLE hProcess; + DWORD cbNeeded; + + hProcess = GetCurrentProcess(); + + if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { + for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { + TCHAR szModName[MAX_PATH]; + + if (GetModuleFileNameEx(hProcess, hModules[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { + auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); + if (pNameFunc) { + LPCWSTR name = pNameFunc(); + if (lstrcmpW(name, L"DivaGL") == 0) + { + // detected DivaGL + printf("[Novidia] Detected DivaGL! Quitting!\n"); +#ifdef _DEBUG + MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0); +#endif + return true; + } + } + } + } + } + + return false; +} diff --git a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp index 41efe30..ea2b4f0 100644 --- a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp +++ b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp @@ -294,10 +294,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - if (GetModuleHandleW(L"DivaGL.dva") != NULL) + if (hasConflicts()) { - // detected DivaGL - printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); + // detected an incompatible plugin (i.e. DivaGL) return TRUE; } diff --git a/source-code/source/plugins/ShaderPatch/src/framework.h b/source-code/source/plugins/ShaderPatch/src/framework.h index 69d14b1..d6477d9 100644 --- a/source-code/source/plugins/ShaderPatch/src/framework.h +++ b/source-code/source/plugins/ShaderPatch/src/framework.h @@ -1,6 +1,7 @@ #pragma once #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include +#include #include #include #include @@ -127,3 +128,36 @@ LPCWSTR DATA_FILE = DATA_FILE_STRING.c_str(); std::wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\ShaderPatchConfig.ini"; LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); + +bool hasConflicts() +{ + HMODULE hModules[1024]; + HANDLE hProcess; + DWORD cbNeeded; + + hProcess = GetCurrentProcess(); + + if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { + for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { + TCHAR szModName[MAX_PATH]; + + if (GetModuleFileNameEx(hProcess, hModules[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { + auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); + if (pNameFunc) { + LPCWSTR name = pNameFunc(); + if (lstrcmpW(name, L"DivaGL") == 0) + { + // detected DivaGL + printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); +#ifdef _DEBUG + MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0); +#endif + return true; + } + } + } + } + } + + return false; +} From eb6964d0b9669a745bfb6b61e5562aab5d4e16c9 Mon Sep 17 00:00:00 2001 From: nastys Date: Fri, 29 Mar 2024 05:40:08 +0100 Subject: [PATCH 09/14] Launcher DivaGL detection fixes --- source-code/source/plugins/Launcher/ui.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 71d6c5f..785724c 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -198,8 +198,12 @@ namespace Launcher { String^ vendor = gcnew String((char*)glGetString(GL_VENDOR)); vendor = vendor->Replace(" Corporation", ""); // this is useless.. remove it to help ensure the GPU type line fits String^ renderer = gcnew String((char*)glGetString(GL_RENDERER)); + renderer = renderer->Replace("Apple ", ""); // "Apple Apple M1" -> "Apple M1" String^ version = gcnew String((char*)glGetString(GL_VERSION)); - version = version->Replace(" Profile Context", ""); // we don't need this, either + version = version->Replace(" Profile Context", "") // we don't need this, either + // misleading - the Metal layer always provides 2.1 as well as 4.1 Core (with the forwards compatiblity bit) + // even though the GLUT context is technically 2.1, inform the user that 4.1 fwcompat is supported (in case they want to use mods) + ->Replace("2.1 Metal", "2.1/4.1 (forward-compatible) Metal"); String^ gpuModel = gcnew String(GPUModel::getGpuName().c_str()); @@ -237,7 +241,7 @@ namespace Launcher { bool novidiaEnabled = false; bool hasDivaGL = false; - bool divaGLEnabled = true; + bool divaGLEnabled = false; for (PluginInfo i : AllPlugins) { @@ -288,7 +292,7 @@ namespace Launcher { else if (wineVersion == "" && (driver_version_major > 22 || (driver_version_major == 22 && driver_version_minor > 6))) { this->labelGPU->Text += "Issues: Unsupported GPU driver."; - GPUIssueText = "The graphics driver you're using is too new for Novidia.\nThe game will not run unless you install driver version 22.6.1 or earlier from AMD's website."; + GPUIssueText = "The graphics driver you're using is too new for Novidia.\nThe game will not run unless you install driver version 22.6.1 or earlier from AMD's website.\n\nAlternatively, you can try mods such as DivaGL."; this->labelGPU->LinkColor = System::Drawing::Color::Red; showGpuDialog = true; } @@ -302,11 +306,19 @@ namespace Launcher { else { this->labelGPU->Text += "Issues: Mods needed for AMD compatibility!"; - GPUIssueText = "AMD GPUs are not supported without mods.\nNovidia is installed, but disabled; please enable it to use your AMD GPU.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel."; + GPUIssueText = "AMD GPUs are not supported without mods.\n" + + (hasDivaGL ? "DivaGL/" : "") + "Novidia is installed, but disabled; please enable it to use your AMD GPU.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel."; this->labelGPU->LinkColor = System::Drawing::Color::Red; showGpuDialog = true; } } + else if (hasDivaGL) + { + this->labelGPU->Text += "Issues: Mods needed for AMD compatibility!"; + GPUIssueText = "AMD GPUs are not supported without mods.\nDivaGL is installed, but disabled; please enable it to use your AMD GPU.\n\nIf you have a laptop with an NVIDIA GPU and wish to use it instead of the detected GPU, you may need to set diva.exe to use it in Windows settings or NVIDIA Control Panel."; + this->labelGPU->LinkColor = System::Drawing::Color::Red; + showGpuDialog = true; + } else { this->labelGPU->Text += "Issues: Mods needed for AMD compatibility!"; From 232ac31190a6e84a39785fb42e7f891055839ec7 Mon Sep 17 00:00:00 2001 From: nastys Date: Sat, 30 Mar 2024 20:55:53 +0100 Subject: [PATCH 10/14] DivaGL, glut32, and conflict detection in Launcher --- source-code/source/plugins/Launcher/ui.h | 55 ++++++++++++++ .../source/plugins/Novidia/src/framework.h | 70 +++++++++++------- .../plugins/ShaderPatch/src/framework.h | 71 ++++++++++++------- 3 files changed, 144 insertions(+), 52 deletions(-) diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 785724c..9e16741 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -190,6 +190,7 @@ namespace Launcher { updateStyle(); + checkHasInvalidGLUT(); glutInit(&argc, argv); int window = glutCreateWindow("glut"); // a context must be created to use glGetString @@ -1095,10 +1096,64 @@ private: System::Void SaveSettings() { private: System::Void Button_Help_Click(System::Object^ sender, System::EventArgs^ e) { System::Diagnostics::Process::Start("https://github.com/PDModdingCommunity/PD-Loader/wiki"); } +private: System::Boolean hasInvalidGLUT = false; +private: System::Void checkHasInvalidGLUT() +{ + HMODULE glutHm = GetModuleHandleW(L"glut32.dll"); + hasInvalidGLUT = glutHm != NULL && GetProcAddress(glutHm, "__glutGetFCB") == NULL; + + if (hasInvalidGLUT) + { + SkinnedMessageBox::Show(this, "Support for custom versions of \"glut32.dll\" is deprecated and will be removed in future versions of PD Loader.\nPlease restore a valid copy of the original file, then validate your files and make sure \"glut32.dll\" passes.\n\nPlease DO NOT ASK for a copy of the file in our support channels!\nWe cannot provide it to you.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); + } +} +private: System::Boolean hasInvalidSettings() +{ + bool divaGLEnabled = false; + bool novidiaEnabled = false; + bool shaderPatchEnabled = false; + + for (ConfigOptionBase* option : AllPluginOpts) + { + if (lstrcmpW(option->_friendlyName, L"DivaGL") == 0) + { + divaGLEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; + if (divaGLEnabled) + { + if (hasInvalidGLUT) goto divagl_freeglut; + else if (novidiaEnabled) goto divagl_novidia; + else if (shaderPatchEnabled) goto divagl_shaderpatch; + } + } + else if (lstrcmpW(option->_friendlyName, L"Novidia") == 0) + { + novidiaEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; + if (novidiaEnabled && divaGLEnabled) goto divagl_novidia; + } + else if (lstrcmpW(option->_friendlyName, L"ShaderPatch") == 0) + { + shaderPatchEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; + if (shaderPatchEnabled && divaGLEnabled) goto divagl_shaderpatch; + } + } + + return false; + +divagl_freeglut: + SkinnedMessageBox::Show(this, "Plugins: DivaGL does not support custom versions of \"glut32.dll\".\nPlease restore a valid copy of the original file, then validate your files and make sure \"glut32.dll\" passes.\n\nPlease DO NOT ASK for a copy of the file in our support channels!\nWe cannot provide it to you.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); + return true; + +divagl_novidia: +divagl_shaderpatch: + SkinnedMessageBox::Show(this, "Plugins: Novidia and ShaderPatch must be disabled if DivaGL is enabled.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); + return true; +} private: System::Void Button_Launch_Click(System::Object^ sender, System::EventArgs^ e) { //SkinnedMessageBox::Show(this, "It looks like the executable has been tampered with, or the version of the game is not 7.10.\n\nPlease use the \"patches\" folder instead of modifying the executable directly (or disable verification).", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); + if (hasInvalidSettings()) return; + SaveSettings(); if (GetPrivateProfileIntW(LAUNCHER_SECTION, L"use_divahook_bat", FALSE, CONFIG_FILE)) diff --git a/source-code/source/plugins/Novidia/src/framework.h b/source-code/source/plugins/Novidia/src/framework.h index 04ad41a..2a3e735 100644 --- a/source-code/source/plugins/Novidia/src/framework.h +++ b/source-code/source/plugins/Novidia/src/framework.h @@ -1,8 +1,8 @@ #pragma once -#define WIN32_LEAN_AND_MEAN -#include -#include +//#define WIN32_LEAN_AND_MEAN +//#include +//#include #include @@ -119,36 +119,54 @@ void InjectCode(void* address, const std::vector data) VirtualProtect(address, byteCount, oldProtect, nullptr); } +//bool hasConflicts() +//{ +// printf("[Novidia] Checking for conflicts...\n"); +// +// HMODULE* hModules = new HMODULE[USHRT_MAX]; +// HANDLE hProcess; +// DWORD cbNeeded; +// +// hProcess = GetCurrentProcess(); +// +// if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { +// for (unsigned long long i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { +// auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); +// if (pNameFunc) { +// LPCWSTR name = pNameFunc(); +// if (name && lstrcmpW(name, L"DivaGL") == 0) +// { +// // detected DivaGL +// printf("[Novidia] Detected DivaGL! Quitting!\n"); +//#ifdef _DEBUG +// MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0); +//#endif +// delete[] hModules; +// return true; +// } +// } +// } +// } +// +// printf("[Novidia] No conflicts found.\n"); +// delete[] hModules; +// return false; +//} bool hasConflicts() { - HMODULE hModules[1024]; - HANDLE hProcess; - DWORD cbNeeded; + printf("[Novidia] Checking for conflicts...\n"); - hProcess = GetCurrentProcess(); - - if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { - for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { - TCHAR szModName[MAX_PATH]; - - if (GetModuleFileNameEx(hProcess, hModules[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { - auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); - if (pNameFunc) { - LPCWSTR name = pNameFunc(); - if (lstrcmpW(name, L"DivaGL") == 0) - { - // detected DivaGL - printf("[Novidia] Detected DivaGL! Quitting!\n"); + if(GetModuleHandleW(L"DivaGL.dva") != NULL) + { + // detected DivaGL + printf("[Novidia] Detected DivaGL! Quitting!\n"); #ifdef _DEBUG - MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0); + MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0); #endif - return true; - } - } - } - } + return true; } + printf("[Novidia] No conflicts found.\n"); return false; } diff --git a/source-code/source/plugins/ShaderPatch/src/framework.h b/source-code/source/plugins/ShaderPatch/src/framework.h index d6477d9..8a6c624 100644 --- a/source-code/source/plugins/ShaderPatch/src/framework.h +++ b/source-code/source/plugins/ShaderPatch/src/framework.h @@ -1,7 +1,7 @@ #pragma once -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include +//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +//#include +//#include #include #include #include @@ -128,36 +128,55 @@ LPCWSTR DATA_FILE = DATA_FILE_STRING.c_str(); std::wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\ShaderPatchConfig.ini"; LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); +//bool hasConflicts() +//{ +// printf("[ShaderPatch] Checking for conflicts...\n"); +// +// HMODULE* hModules = new HMODULE[USHRT_MAX]; +// HANDLE hProcess; +// DWORD cbNeeded; +// +// hProcess = GetCurrentProcess(); +// +// if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { +// for (unsigned long long i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { +// auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); +// if (pNameFunc) { +// LPCWSTR name = pNameFunc(); +// if (name && lstrcmpW(name, L"DivaGL") == 0) +// { +// // detected DivaGL +// printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); +//#ifdef _DEBUG +// MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0); +//#endif +// delete[] hModules; +// return true; +// } +// } +// } +// } +// +// printf("[ShaderPatch] No conflicts found.\n"); +// delete[] hModules; +// return false; +//} + bool hasConflicts() { - HMODULE hModules[1024]; - HANDLE hProcess; - DWORD cbNeeded; + printf("[ShaderPatch] Checking for conflicts...\n"); - hProcess = GetCurrentProcess(); - - if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { - for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { - TCHAR szModName[MAX_PATH]; - - if (GetModuleFileNameEx(hProcess, hModules[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { - auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); - if (pNameFunc) { - LPCWSTR name = pNameFunc(); - if (lstrcmpW(name, L"DivaGL") == 0) - { - // detected DivaGL - printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); + if (GetModuleHandleW(L"DivaGL.dva") != NULL) + { + // detected DivaGL + printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); #ifdef _DEBUG - MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0); + MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0); #endif - return true; - } - } - } - } + return true; } + printf("[ShaderPatch] No conflicts found.\n"); return false; } From c6ceb61636a5e3b3584f39fa79576e9ca9dbbb35 Mon Sep 17 00:00:00 2001 From: nastys Date: Sat, 30 Mar 2024 22:14:38 +0100 Subject: [PATCH 11/14] Attempt to fix DivaGL detection code crashing --- source-code/source/plugins/Novidia/src/framework.h | 6 +++--- source-code/source/plugins/ShaderPatch/src/framework.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source-code/source/plugins/Novidia/src/framework.h b/source-code/source/plugins/Novidia/src/framework.h index 2a3e735..14fde8f 100644 --- a/source-code/source/plugins/Novidia/src/framework.h +++ b/source-code/source/plugins/Novidia/src/framework.h @@ -155,18 +155,18 @@ void InjectCode(void* address, const std::vector data) bool hasConflicts() { - printf("[Novidia] Checking for conflicts...\n"); + puts("[Novidia] Checking for conflicts..."); if(GetModuleHandleW(L"DivaGL.dva") != NULL) { // detected DivaGL - printf("[Novidia] Detected DivaGL! Quitting!\n"); + puts("[Novidia] Detected DivaGL! Quitting!"); #ifdef _DEBUG MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0); #endif return true; } - printf("[Novidia] No conflicts found.\n"); + puts("[Novidia] No conflicts found."); return false; } diff --git a/source-code/source/plugins/ShaderPatch/src/framework.h b/source-code/source/plugins/ShaderPatch/src/framework.h index 8a6c624..e5c3f74 100644 --- a/source-code/source/plugins/ShaderPatch/src/framework.h +++ b/source-code/source/plugins/ShaderPatch/src/framework.h @@ -165,18 +165,18 @@ LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); bool hasConflicts() { - printf("[ShaderPatch] Checking for conflicts...\n"); + puts("[ShaderPatch] Checking for conflicts..."); if (GetModuleHandleW(L"DivaGL.dva") != NULL) { // detected DivaGL - printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); + puts("[ShaderPatch] Detected DivaGL! Quitting!"); #ifdef _DEBUG MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0); #endif return true; } - printf("[ShaderPatch] No conflicts found.\n"); + puts("[ShaderPatch] No conflicts found."); return false; } From be29f090f3bb997070e58e3fa13fa3eec24baf1b Mon Sep 17 00:00:00 2001 From: nastys Date: Wed, 10 Apr 2024 20:00:12 +0200 Subject: [PATCH 12/14] Update and move DivaGL plugin conflict checks to launcher --- .../source/plugins/Launcher/ConfigOption.h | 4 +++- .../source/plugins/Launcher/framework.h | 2 +- source-code/source/plugins/Launcher/ui.h | 19 ++++++++++++++----- .../source/plugins/Novidia/src/dllmain.cpp | 6 ------ .../source/plugins/Novidia/src/framework.h | 18 ------------------ .../plugins/ShaderPatch/src/dllmain.cpp | 6 ------ .../plugins/ShaderPatch/src/framework.h | 19 ------------------- 7 files changed, 18 insertions(+), 56 deletions(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 8555aef..6a6d828 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -1087,9 +1087,10 @@ class PluginOption : public ConfigOptionBase { public: bool _defaultVal; + std::wstring _builddate; std::vector _configopts; - PluginOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, bool defaultVal, std::vector configopts) + PluginOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, bool defaultVal, std::vector configopts, std::wstring builddate = L"Unknown") { _iniVarName = iniVarName; _iniSectionName = iniSectionName; @@ -1098,6 +1099,7 @@ public: _description = description; _defaultVal = defaultVal; _configopts = configopts; + _builddate = builddate; } virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip) diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 94c8b3b..f4674d0 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -474,7 +474,7 @@ std::vector GetPluginOptions(std::vector* plugins) for (PluginInfo &pi : *plugins) { - PluginOption* opt = new PluginOption(pi.filename.c_str(), L"plugins", CONFIG_FILE, pi.name.c_str(), pi.description.c_str(), true, pi.configopts); + PluginOption* opt = new PluginOption(pi.filename.c_str(), L"plugins", CONFIG_FILE, pi.name.c_str(), pi.description.c_str(), true, pi.configopts, pi.builddate); outvec.push_back(opt); } diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 9e16741..9150d16 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -1112,8 +1112,9 @@ private: System::Boolean hasInvalidSettings() bool divaGLEnabled = false; bool novidiaEnabled = false; bool shaderPatchEnabled = false; + bool divaImGuiOldEnabled = false; - for (ConfigOptionBase* option : AllPluginOpts) + for (PluginOption* option : AllPluginOpts) { if (lstrcmpW(option->_friendlyName, L"DivaGL") == 0) { @@ -1121,8 +1122,8 @@ private: System::Boolean hasInvalidSettings() if (divaGLEnabled) { if (hasInvalidGLUT) goto divagl_freeglut; - else if (novidiaEnabled) goto divagl_novidia; - else if (shaderPatchEnabled) goto divagl_shaderpatch; + else if (novidiaEnabled || shaderPatchEnabled) goto divagl_novidia; + else if (divaImGuiOldEnabled) goto divagl_divaimguiold; } } else if (lstrcmpW(option->_friendlyName, L"Novidia") == 0) @@ -1133,7 +1134,12 @@ private: System::Boolean hasInvalidSettings() else if (lstrcmpW(option->_friendlyName, L"ShaderPatch") == 0) { shaderPatchEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; - if (shaderPatchEnabled && divaGLEnabled) goto divagl_shaderpatch; + if (shaderPatchEnabled && divaGLEnabled) goto divagl_novidia; + } + else if (lstrcmpW(option->_friendlyName, L"DivaImGui") == 0 && option->_builddate == L"Unknown") + { + divaImGuiOldEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; + if (divaImGuiOldEnabled && divaGLEnabled) goto divagl_divaimguiold; } } @@ -1144,9 +1150,12 @@ divagl_freeglut: return true; divagl_novidia: -divagl_shaderpatch: SkinnedMessageBox::Show(this, "Plugins: Novidia and ShaderPatch must be disabled if DivaGL is enabled.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); return true; + +divagl_divaimguiold: + SkinnedMessageBox::Show(this, "Plugins: Your version of DivaImGui is too old for DivaGL; please either update or disable it.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); + return true; } private: System::Void Button_Launch_Click(System::Object^ sender, System::EventArgs^ e) { diff --git a/source-code/source/plugins/Novidia/src/dllmain.cpp b/source-code/source/plugins/Novidia/src/dllmain.cpp index 582c85b..5a60b7b 100644 --- a/source-code/source/plugins/Novidia/src/dllmain.cpp +++ b/source-code/source/plugins/Novidia/src/dllmain.cpp @@ -380,12 +380,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - if (hasConflicts()) - { - // detected an incompatible plugin (i.e. DivaGL) - return TRUE; - } - loadConfig(); if (!disable_amd_check) diff --git a/source-code/source/plugins/Novidia/src/framework.h b/source-code/source/plugins/Novidia/src/framework.h index 14fde8f..8d764fa 100644 --- a/source-code/source/plugins/Novidia/src/framework.h +++ b/source-code/source/plugins/Novidia/src/framework.h @@ -152,21 +152,3 @@ void InjectCode(void* address, const std::vector data) // delete[] hModules; // return false; //} - -bool hasConflicts() -{ - puts("[Novidia] Checking for conflicts..."); - - if(GetModuleHandleW(L"DivaGL.dva") != NULL) - { - // detected DivaGL - puts("[Novidia] Detected DivaGL! Quitting!"); -#ifdef _DEBUG - MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0); -#endif - return true; - } - - puts("[Novidia] No conflicts found."); - return false; -} diff --git a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp index ea2b4f0..24ab6a6 100644 --- a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp +++ b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp @@ -294,12 +294,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - if (hasConflicts()) - { - // detected an incompatible plugin (i.e. DivaGL) - return TRUE; - } - // install a thunk to hook InjectCode((void*)0x1405e5991, { 0x48, 0x83, 0xec, 0x28 }); // SUB RSP, 0x28 InjectCode((void*)0x1405e5995, { 0xe8, 0x56, 0xe8, 0xb9, 0xff }); // CALL 0x1401841f0 diff --git a/source-code/source/plugins/ShaderPatch/src/framework.h b/source-code/source/plugins/ShaderPatch/src/framework.h index e5c3f74..8e38d50 100644 --- a/source-code/source/plugins/ShaderPatch/src/framework.h +++ b/source-code/source/plugins/ShaderPatch/src/framework.h @@ -161,22 +161,3 @@ LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); // delete[] hModules; // return false; //} - - -bool hasConflicts() -{ - puts("[ShaderPatch] Checking for conflicts..."); - - if (GetModuleHandleW(L"DivaGL.dva") != NULL) - { - // detected DivaGL - puts("[ShaderPatch] Detected DivaGL! Quitting!"); -#ifdef _DEBUG - MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0); -#endif - return true; - } - - puts("[ShaderPatch] No conflicts found."); - return false; -} From 430e650d0d9306f2148be1b2978a7f417a341b1b Mon Sep 17 00:00:00 2001 From: nastys Date: Tue, 23 Apr 2024 19:08:28 +0200 Subject: [PATCH 13/14] Improve GPU checks --- .../source/plugins/Launcher/ConfigOption.h | 2 + .../source/plugins/Launcher/framework.h | 2 +- source-code/source/plugins/Launcher/ui.h | 65 +++++++++++++++++-- 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 6a6d828..739d414 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -609,6 +609,7 @@ public: int _defaultVal; int _indexOffset; std::vector _valueStrings; + System::IntPtr labelHandle; DropdownOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, int defaultVal, std::vector valueStrings, int indexOffset=0) { @@ -628,6 +629,7 @@ public: ComboBox^ combobox = gcnew ComboBox(); label->Text = gcnew String(_friendlyName); + labelHandle = label->Handle; label->Left = left; label->Top = top + 3; label->Width = Col1Width; diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index f4674d0..8d3d1ee 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -166,7 +166,7 @@ ConfigOptionBase* internalResolutionArray[] = { }; ConfigOptionBase* graphicsArray[] = { - new DropdownOption(L"model", L"GPU", CONFIG_FILE, L"NVIDIA GPU:", L"Select your NVIDIA GPU's architecture to apply the necessary workarounds.\n\nNOTE: Automatic detection does not currently work on GNU/Linux.", -1, std::vector({ L"Automatic", L"Kepler", L"Maxwell/Pascal", L"Turing", L"Ampere", L"Ada Lovelace"}), -1), + new DropdownOption(L"model", L"GPU", CONFIG_FILE, L"Nvidia GPU:", L"Select your Nvidia GPU's architecture to apply the necessary workarounds.\n\nNOTE: Automatic detection does not currently work on GNU/Linux.", -1, std::vector({ L"Automatic", L"Kepler", L"Maxwell/Pascal", L"Turing", L"Ampere", L"Ada or newer"}), -1), new BooleanOption(L"TAA", GRAPHICS_SECTION, CONFIG_FILE, L"TAA", L"Temporal Anti-Aliasing", true, false), new BooleanOption(L"MLAA", GRAPHICS_SECTION, CONFIG_FILE, L"MLAA", L"Morphological Anti-Aliasing", true, false), new DropdownOption(L"MAG", GRAPHICS_SECTION, CONFIG_FILE, L"Filter:", L"Image filter.\n\nBilinear: default filter\nNearest-neighbour: sharpest, but blocky\nSharpen: sharp filter\nCone: smooth filter", 0, std::vector({ L"Bilinear", L"Nearest-neighbour", L"Sharpen", L"Cone" })), diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 9150d16..43ae3cc 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -237,6 +237,7 @@ namespace Launcher { int linkStart = this->labelGPU->Text->Length; bool showGpuDialog = false; + bool showGpuTypeWarning = false; bool hasNovidia = false; bool novidiaEnabled = false; @@ -393,15 +394,18 @@ namespace Launcher { else if (version[0] >= '4' && gpuModel->Length > 0 && !gpuModel->StartsWith("Unk") && !gpuModel->StartsWith("Oth")) { this->labelGPU->Text += L"Issues: GPU may be too new.\n(Click for more information)"; - GPUIssueText = L"It looks like your GPU may be too new. Only up to Ampere (RTX 30xx) is currently supported.\nGood news: the game should be capable of running, but shader patches (probably needed) may not support it yet.\nYou will likely see lines/noise on important character shaders and some minor stage shaders.\nPlease report any issues so that ShaderPatch can be updated.\nYou can also try forcing a specific GPU workaround type."; + GPUIssueText = L"It looks like your GPU may be too new. Only up to Ada Lovelace (RTX 40xx) is currently supported.\nYou will likely see lines/noise on important character shaders and some minor stage shaders.\nPlease report any issues so that ShaderPatch can be updated.\n\nTo try to get rid of any artifacts, try selecting a specific GPU architecture in Graphics -> Nvidia GPU (e.g. \"Ada or newer\"), or use DivaGL."; this->labelGPU->LinkColor = System::Drawing::Color::Orange; + showGpuDialog = true; + showGpuTypeWarning = true; } else { this->labelGPU->Text += L"Issues: Unable to detect GPU architecture.\n(Click for more information)"; - GPUIssueText = L"It looks like you have an NVIDIA GPU, but something went wrong while trying to determine your GPU's architecture (type).\nThis may be a caused by a bug, but it probably indicates potential issues.\nPlease make sure you have a GTX 600 series or later GPU. (GTX 400 series or later should also work)"; + GPUIssueText = L"It looks like you have an NVIDIA GPU, but something went wrong while trying to determine your GPU's architecture (type).\nThis may be a caused by a bug, but it probably indicates potential issues.\nPlease make sure you have a GTX 600 series or later GPU. (GTX 400 series or later should also work)\n\nIf the game runs but has artifacts, try selecting a specific GPU architecture in Graphics -> Nvidia GPU (e.g. \"Ada or newer\"), or use DivaGL."; this->labelGPU->LinkColor = System::Drawing::Color::Orange; showGpuDialog = true; + showGpuTypeWarning = true; } } else //if (gpuModel->Length == 0 || gpuModel->StartsWith("Unk") || gpuModel->StartsWith("Oth")) @@ -417,8 +421,24 @@ namespace Launcher { this->labelGPU->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &ui::LinkLabelLinkClickedGPUIssueHandler); this->labelGPU->LinkArea = System::Windows::Forms::LinkArea(linkStart, linkEnd); - if (showGpuDialog && !nNoGPUDialog) - SkinnedMessageBox::Show(this, GPUIssueText + "\n\nYou can disable this message from the options tab.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); + if (!nNoGPUDialog) + { + if (showGpuDialog) + SkinnedMessageBox::Show(this, GPUIssueText + "\n\nYou can disable this message from the Options tab.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); + + if (showGpuTypeWarning) + { + Label^ gpuTypeLabel = ((Label^)Control::FromHandle(((DropdownOption*)(graphicsArray[0]))->labelHandle)); + ComboBox^ gpuTypeCtrl = ((ComboBox^)Control::FromHandle(((DropdownOption*)(graphicsArray[0]))->mainControlHandle)); + gpuTypeLabel->Text = "/!\\ " + gpuTypeLabel->Text; + gpuTypeLabel->BackColor = System::Drawing::Color::Gold; + gpuTypeLabel->ForeColor = System::Drawing::Color::Crimson; + gpuTypeCtrl->Items[0] = "SELECT ONE"; + gpuTypeCtrl->BackColor = System::Drawing::Color::Gold; + gpuTypeCtrl->ForeColor = System::Drawing::Color::Crimson; + gpuTypeCtrl->FlatStyle = System::Windows::Forms::FlatStyle::Flat; + } + } } protected: @@ -1112,6 +1132,7 @@ private: System::Boolean hasInvalidSettings() bool divaGLEnabled = false; bool novidiaEnabled = false; bool shaderPatchEnabled = false; + //bool divaImGuiEnabled = false; bool divaImGuiOldEnabled = false; for (PluginOption* option : AllPluginOpts) @@ -1136,13 +1157,34 @@ private: System::Boolean hasInvalidSettings() shaderPatchEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; if (shaderPatchEnabled && divaGLEnabled) goto divagl_novidia; } - else if (lstrcmpW(option->_friendlyName, L"DivaImGui") == 0 && option->_builddate == L"Unknown") + else if (lstrcmpW(option->_friendlyName, L"DivaImGui") == 0) { - divaImGuiOldEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; - if (divaImGuiOldEnabled && divaGLEnabled) goto divagl_divaimguiold; + //divaImGuiEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; + + if (option->_builddate == L"Unknown") + { + divaImGuiOldEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked; + if (divaImGuiOldEnabled && divaGLEnabled) goto divagl_divaimguiold; + } } } + //if (divaImGuiEnabled) + //{ + // for (ConfigOptionBase* option : graphicsArray) + // { + // if (option->_iniSectionName == GRAPHICS_SECTION && option->_iniVarName == L"2D") + // { + // if (((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked) + // { + // SkinnedMessageBox::Show(this, "Graphics: \"Disable 3D rendering\" must be disabled if DivaImGui is enabled.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); + // return true; + // } + // break; + // } + // } + //} + return false; divagl_freeglut: @@ -1157,10 +1199,19 @@ divagl_divaimguiold: SkinnedMessageBox::Show(this, "Plugins: Your version of DivaImGui is too old for DivaGL; please either update or disable it.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); return true; } +private: System::Boolean warnCheck() +{ + if (((ComboBox^)Control::FromHandle(((DropdownOption*)(graphicsArray[0]))->mainControlHandle))->Text == "SELECT ONE" && + SkinnedMessageBox::Show(this, L"GPU detection has failed and no Nvidia GPU architecture has been selected.\nAs such, characters and stages may exhibit artifacts, such as noisy shadows and stages.\nIf unsure, try all of the options starting from Kepler.\n\nLaunch anyway?", "PD Launcher", MessageBoxButtons::YesNo, MessageBoxIcon::Error) != System::Windows::Forms::DialogResult::OK) + return false; + + return true; +} private: System::Void Button_Launch_Click(System::Object^ sender, System::EventArgs^ e) { //SkinnedMessageBox::Show(this, "It looks like the executable has been tampered with, or the version of the game is not 7.10.\n\nPlease use the \"patches\" folder instead of modifying the executable directly (or disable verification).", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error); + if (!warnCheck()) return; if (hasInvalidSettings()) return; SaveSettings(); From a766413a5d8cc8f9b3b214b116dde8028a4b955e Mon Sep 17 00:00:00 2001 From: korenkonder Date: Wed, 1 May 2024 22:28:30 +0300 Subject: [PATCH 14/14] [TLAC]: Pause patches. Fix of stuff moving 1 frame after pause --- .../source/plugins/TLAC/Components/Pause.cpp | 13 +++++++++++++ source-code/source/plugins/TLAC/Components/Pause.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/source-code/source/plugins/TLAC/Components/Pause.cpp b/source-code/source/plugins/TLAC/Components/Pause.cpp index 4563e07..c6952da 100644 --- a/source-code/source/plugins/TLAC/Components/Pause.cpp +++ b/source-code/source/plugins/TLAC/Components/Pause.cpp @@ -32,9 +32,13 @@ namespace TLAC::Components Pause::menusets Pause::curMenuSet = MENUSET_MAIN; std::chrono::time_point Pause::menuItemMoveTime; std::vector Pause::origAetMovOp; + float_t Pause::origDeltaFrameHistory = 0.0f; + int32_t Pause::origDeltaFrameHistoryInt = 0; uint8_t* Pause::aetMovPatchAddress = (uint8_t*)0x1401703b3; std::vector Pause::origFramespeedOp; uint8_t* Pause::framespeedPatchAddress = (uint8_t*)0x140192D50; + float_t* Pause::deltaFrameHistoryAddress = (float_t*)0x140EDA6C0; + int32_t* Pause::deltaFrameHistoryIntAddress = (int32_t*)0x140EDA6C4; std::vector Pause::origAgeageHairOp; uint8_t* Pause::ageageHairPatchAddress = (uint8_t*)0x14054352c; std::vector Pause::streamPlayStates; @@ -136,6 +140,12 @@ namespace TLAC::Components InjectCode(framespeedPatchAddress, { 0x0f, 0x57, 0xc0, 0xc3 }); // XORPS XMM0,XMM0; RET InjectCode(ageageHairPatchAddress, { 0x0f, 0x57, 0xdb }); // XORPS XMM3,XMM3 + origDeltaFrameHistory = *deltaFrameHistoryAddress; + origDeltaFrameHistoryInt = *deltaFrameHistoryIntAddress; + + *deltaFrameHistoryAddress = 0.0f; + *deltaFrameHistoryIntAddress = 0; + uint64_t audioMixerAddr = *(uint64_t*)(AUDIO_MAIN_CLASS_ADDRESS + 0x70); uint64_t audioStreamsAddress = *(uint64_t*)(audioMixerAddr + 0x18); int nAudioStreams = *(uint64_t*)(audioMixerAddr + 0x20); @@ -279,6 +289,9 @@ namespace TLAC::Components InjectCode(framespeedPatchAddress, origFramespeedOp); InjectCode(ageageHairPatchAddress, origAgeageHairOp); + *deltaFrameHistoryAddress = origDeltaFrameHistory; + *deltaFrameHistoryIntAddress = origDeltaFrameHistoryInt; + uint64_t audioMixerAddr = *(uint64_t*)(AUDIO_MAIN_CLASS_ADDRESS + 0x70); uint64_t audioStreamsAddress = *(uint64_t*)(audioMixerAddr + 0x18); int nAudioStreams = *(uint64_t*)(audioMixerAddr + 0x20); diff --git a/source-code/source/plugins/TLAC/Components/Pause.h b/source-code/source/plugins/TLAC/Components/Pause.h index 429c233..1162ec6 100644 --- a/source-code/source/plugins/TLAC/Components/Pause.h +++ b/source-code/source/plugins/TLAC/Components/Pause.h @@ -47,6 +47,10 @@ namespace TLAC::Components static std::vector origFramespeedOp; static uint8_t* framespeedPatchAddress; + static float_t origDeltaFrameHistory; + static int32_t origDeltaFrameHistoryInt; + static float_t* deltaFrameHistoryAddress; + static int32_t* deltaFrameHistoryIntAddress; static std::vector origAgeageHairOp; static uint8_t* ageageHairPatchAddress;