From 66db5deb2b966f704fb369f8d2ec98986d6c8cbd Mon Sep 17 00:00:00 2001 From: nastys <@> Date: Thu, 7 Oct 2021 23:10:40 +0200 Subject: [PATCH] 2.6.5a: Fix PlayerData, auto-disable DivaMovie if DXVA-HW is available (unless forced - fixes random black backgrounds) --- .../plugins/DivaMovie/DivaMovie.vcxproj | 194 +++++++++--------- .../source/plugins/DivaMovie/dllmain.cpp | 23 ++- .../source/plugins/DivaMovie/framework.h | 151 +++++++------- .../source/plugins/Launcher/framework.h | 10 +- source-code/source/plugins/Launcher/ui.h | 2 +- 5 files changed, 198 insertions(+), 182 deletions(-) diff --git a/source-code/source/plugins/DivaMovie/DivaMovie.vcxproj b/source-code/source/plugins/DivaMovie/DivaMovie.vcxproj index 2c6216a..2e4291d 100644 --- a/source-code/source/plugins/DivaMovie/DivaMovie.vcxproj +++ b/source-code/source/plugins/DivaMovie/DivaMovie.vcxproj @@ -1,98 +1,98 @@ - - - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {1994C586-F73B-4EF2-BA3E-2A0FC3034B1A} - DivaMovie - 10.0 - - - - DynamicLibrary - true - v142 - MultiByte - - - DynamicLibrary - false - v142 - true - MultiByte - - - - - - - - - - - - - - - .dva - - - .dva - - - - Level3 - Disabled - true - true - ..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories) - -d2FH4- %(AdditionalOptions) - - - Console - ..\..\..\dependencies\detours\lib;%(AdditionalLibraryDirectories) - detours.lib;evr.lib;mfplat.lib;mfuuid.lib;strmiids.lib;syelog.lib;%(AdditionalDependencies) - -d2:-FH4- %(AdditionalOptions) - - - - - Level3 - MaxSpeed - true - true - true - true - ..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories) - MultiThreadedDLL - -d2FH4- %(AdditionalOptions) - - - Console - true - true - detours.lib;evr.lib;mfplat.lib;mfuuid.lib;syelog.lib;%(AdditionalDependencies) - ..\..\..\dependencies\detours\lib;%(AdditionalLibraryDirectories) - -d2:-FH4- %(AdditionalOptions) - - - - - - - - - - - - + + + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {1994C586-F73B-4EF2-BA3E-2A0FC3034B1A} + DivaMovie + 10.0 + + + + DynamicLibrary + true + v142 + MultiByte + + + DynamicLibrary + false + v142 + true + MultiByte + + + + + + + + + + + + + + + .dva + + + .dva + + + + Level3 + Disabled + true + true + ..\..\..\dependencies\simpleini;..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories) + -d2FH4- %(AdditionalOptions) + + + Console + ..\..\..\dependencies\detours\lib;%(AdditionalLibraryDirectories) + detours.lib;evr.lib;mfplat.lib;mfuuid.lib;strmiids.lib;syelog.lib;%(AdditionalDependencies) + -d2:-FH4- %(AdditionalOptions) + + + + + Level3 + MaxSpeed + true + true + true + true + ..\..\..\dependencies\simpleini;..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + -d2FH4- %(AdditionalOptions) + + + Console + true + true + detours.lib;evr.lib;mfplat.lib;mfuuid.lib;syelog.lib;%(AdditionalDependencies) + ..\..\..\dependencies\detours\lib;%(AdditionalLibraryDirectories) + -d2:-FH4- %(AdditionalOptions) + + + + + + + + + + + + \ No newline at end of file diff --git a/source-code/source/plugins/DivaMovie/dllmain.cpp b/source-code/source/plugins/DivaMovie/dllmain.cpp index 8634600..e7208dc 100644 --- a/source-code/source/plugins/DivaMovie/dllmain.cpp +++ b/source-code/source/plugins/DivaMovie/dllmain.cpp @@ -10,8 +10,9 @@ #include #include #include +#include -bool forceSoftwareDecoding = false, debug = false; +bool forceSoftwareDecoding = false, forceHardwareDecoding = false, debug = false; IDirect3DDeviceManager9* deviceManager; @@ -146,11 +147,21 @@ VTABLE_HOOK(HRESULT, IMFTransform, ProcessMessage, MFT_MESSAGE_TYPE eMessage, UL if (SUCCEEDED(result)) INSTALL_VTABLE_HOOK(This, ProcessOutput, 25); } - else + else if (!forceHardwareDecoding && eMessage == MFT_MESSAGE_SET_D3D_MANAGER && result == 0) { static bool warn = false; - if(!warn) MessageBoxW(0, L"Your system supports DXVA hardware decoding.\nIt is highly recommended to disable DivaMovie (in Plugins and Patches).", L"DivaMovie", MB_ICONWARNING); - warn = true; + if (!warn) + { + MessageBoxW(0, L"Your system supports DXVA hardware decoding.\nDivaMovie will be disabled.\n\nIt is highly recommended to restart the game now.", L"DivaMovie", MB_ICONWARNING); + + CSimpleIniW ini_reader; + ini_reader.SetUnicode(false); + ini_reader.LoadFile(MASTER_CONFIG_FILE); + ini_reader.SetValue(L"plugins", L"DivaMovie.dva", L"0"); + ini_reader.SaveFile(MASTER_CONFIG_FILE); + + warn = true; + } } return result; } @@ -183,6 +194,7 @@ HOOK(HRESULT, DXVA2CreateDirect3DDeviceManager, PROC_ADDRESS("dxva2.dll", "DXVA2 void loadConfig() { forceSoftwareDecoding = GetPrivateProfileIntW(L"general", L"force_software_decoding", 0, CONFIG_FILE) > 0 ? true : false; + forceHardwareDecoding = GetPrivateProfileIntW(L"general", L"force_hardware_decoding", 0, CONFIG_FILE) > 0 ? true : false; debug = GetPrivateProfileIntW(L"general", L"debug", 0, CONFIG_FILE) > 0 ? true : false; } @@ -200,6 +212,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv PluginConfig::PluginConfigOption config[] = { { PluginConfig::CONFIG_BOOLEAN, new PluginConfig::PluginConfigBooleanData{ L"force_software_decoding", L"general", CONFIG_FILE, L"Force Software Decoding", L"Use software decoding even on systems that support DXVA hardware decoding.", false } }, + { PluginConfig::CONFIG_BOOLEAN, new PluginConfig::PluginConfigBooleanData{ L"force_hardware_decoding", L"general", CONFIG_FILE, L"Force Hardware Decoding", L"Do not disable DivaMovie on systems that support DXVA hardware decoding.", false } }, { PluginConfig::CONFIG_BOOLEAN, new PluginConfig::PluginConfigBooleanData{ L"debug", L"general", CONFIG_FILE, L"Debug", L"Enable PRINT (possibly at the cost of performance).", false } }, }; @@ -210,7 +223,7 @@ extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void) extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void) { - return L"DivaMovie Plugin by Skyth\n\nDivaMovie enables movies on systems that does not support DXVA hardware decoding."; + return L"DivaMovie Plugin by Skyth\n\nDivaMovie enables movies on systems that do not support DXVA hardware decoding."; } extern "C" __declspec(dllexport) PluginConfig::PluginConfigArray GetPluginOptions(void) diff --git a/source-code/source/plugins/DivaMovie/framework.h b/source-code/source/plugins/DivaMovie/framework.h index 076522b..a0708c9 100644 --- a/source-code/source/plugins/DivaMovie/framework.h +++ b/source-code/source/plugins/DivaMovie/framework.h @@ -1,74 +1,77 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN - -#include -#include -#include -#include - -std::wstring ExePath() { - WCHAR buffer[MAX_PATH]; - GetModuleFileNameW(NULL, buffer, MAX_PATH); - return std::wstring(buffer); -} - -std::wstring DirPath() { - std::wstring exepath = ExePath(); - std::wstring::size_type pos = exepath.find_last_of(L"\\/"); - return exepath.substr(0, pos); -} - -std::wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\DivaMovie.ini"; -LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); - -#define PRINT(value, ...) if (debug) printf(value, __VA_ARGS__); - -#define PROC_ADDRESS(libraryName, procName) \ - GetProcAddress(LoadLibrary(TEXT(libraryName)), procName) - -#define SAFE_RELEASE(object) if (object) { object->Release(); object = NULL; } - -#define VTABLE_HOOK(returnType, className, functionName, ...) \ - typedef returnType functionName(className* This, __VA_ARGS__); \ - functionName* original##functionName; \ - returnType implOf##functionName(className* This, __VA_ARGS__) - -#define INSTALL_VTABLE_HOOK(object, functionName, functionIndex) \ - { \ - void** addr = &(*(void***)object)[functionIndex]; \ - if (*addr != implOf##functionName) \ - { \ - PRINT("[DivaMovie] Installing %s hook...\n", #functionName); \ - original##functionName = (functionName*)*addr; \ - DWORD oldProtect; \ - VirtualProtect(addr, sizeof(void*), PAGE_EXECUTE_READWRITE, &oldProtect); \ - *addr = implOf##functionName; \ - VirtualProtect(addr, sizeof(void*), oldProtect, NULL); \ - } \ - } - -#define HOOK(returnType, function, location, ...) \ - typedef returnType function(__VA_ARGS__); \ - function* original##function = (function*)location; \ - returnType implOf##function(__VA_ARGS__) - -#define INSTALL_HOOK(functionName) \ - { \ - PRINT("[DivaMovie] Installing %s hook...\n", #functionName); \ - DetourTransactionBegin(); \ - DetourUpdateThread(GetCurrentThread()); \ - DetourAttach((void**)&original##functionName, implOf##functionName); \ - DetourTransactionCommit(); \ - } - -#define ASSERT(function) \ - if (FAILED(result = (function))) \ - { \ - PRINT("[DivaMovie] %s failed (error code: 0x%08x)\n", #function, (unsigned int)result); \ - goto end; \ - } /*\ - else \ - { \ - PRINT("[DivaMovie] %s succeeded\n", #function); \ - }*/ +#pragma once + +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include + +std::wstring ExePath() { + WCHAR buffer[MAX_PATH]; + GetModuleFileNameW(NULL, buffer, MAX_PATH); + return std::wstring(buffer); +} + +std::wstring DirPath() { + std::wstring exepath = ExePath(); + std::wstring::size_type pos = exepath.find_last_of(L"\\/"); + return exepath.substr(0, pos); +} + +std::wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\DivaMovie.ini"; +LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); + +std::wstring MASTER_CONFIG_FILE_STRING = DirPath() + L"\\plugins\\config.ini"; +LPCWSTR MASTER_CONFIG_FILE = MASTER_CONFIG_FILE_STRING.c_str(); + +#define PRINT(value, ...) if (debug) printf(value, __VA_ARGS__); + +#define PROC_ADDRESS(libraryName, procName) \ + GetProcAddress(LoadLibrary(TEXT(libraryName)), procName) + +#define SAFE_RELEASE(object) if (object) { object->Release(); object = NULL; } + +#define VTABLE_HOOK(returnType, className, functionName, ...) \ + typedef returnType functionName(className* This, __VA_ARGS__); \ + functionName* original##functionName; \ + returnType implOf##functionName(className* This, __VA_ARGS__) + +#define INSTALL_VTABLE_HOOK(object, functionName, functionIndex) \ + { \ + void** addr = &(*(void***)object)[functionIndex]; \ + if (*addr != implOf##functionName) \ + { \ + PRINT("[DivaMovie] Installing %s hook...\n", #functionName); \ + original##functionName = (functionName*)*addr; \ + DWORD oldProtect; \ + VirtualProtect(addr, sizeof(void*), PAGE_EXECUTE_READWRITE, &oldProtect); \ + *addr = implOf##functionName; \ + VirtualProtect(addr, sizeof(void*), oldProtect, NULL); \ + } \ + } + +#define HOOK(returnType, function, location, ...) \ + typedef returnType function(__VA_ARGS__); \ + function* original##function = (function*)location; \ + returnType implOf##function(__VA_ARGS__) + +#define INSTALL_HOOK(functionName) \ + { \ + PRINT("[DivaMovie] Installing %s hook...\n", #functionName); \ + DetourTransactionBegin(); \ + DetourUpdateThread(GetCurrentThread()); \ + DetourAttach((void**)&original##functionName, implOf##functionName); \ + DetourTransactionCommit(); \ + } + +#define ASSERT(function) \ + if (FAILED(result = (function))) \ + { \ + PRINT("[DivaMovie] %s failed (error code: 0x%08x)\n", #function, (unsigned int)result); \ + goto end; \ + } /*\ + else \ + { \ + PRINT("[DivaMovie] %s succeeded\n", #function); \ + }*/ diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index f6fd233..3ff3a8b 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -289,11 +289,11 @@ ConfigOptionBase* playerdataArray[] = { new BooleanOption(L"border_excellent", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Clear Border (Excellent)", L"Shows the clear border for an excellent rating on the progress bar.", true, true), new BooleanOption(L"border_rival", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Clear Border (Rival)", L"Shows the clear border for beating your rival on the progress bar.", false, true), - new BooleanOption(L"use_card", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Use Card", L"Enables IC card. This allows module selection.", false, true), - new BooleanOption(L"module_card_workaround", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Module Selection Workaround", L"Allows module selection without card and tries to improve menu performance.\n(BETA)", true, true), - new BooleanOption(L"use_pv_module_equip ", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Song Specific Modules", L"Allows song-specific module selection.", false, true), - new BooleanOption(L"use_pv_skin_equip ", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Song Specific Skins", L"Allows song-specific skin settings.\nValues stored in skins.ini", false, true), - new BooleanOption(L"use_pv_sfx_equip ", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Song Specific Sound Effects", L"Allows song-specific sound effect settings.\nValues stored in sfx.ini", false, true), + new BooleanOption(L"use_card", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Use Card", L"Enables IC card. This allows module selection.", true, true), + new BooleanOption(L"module_card_workaround", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Fast Module Selection (buggy)", L"Allows module selection without card and tries to improve menu performance.\nKnown to cause issues, especially with song-specific modules.", false, true), + new BooleanOption(L"use_pv_module_equip", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Song Specific Modules", L"Allows song-specific module selection.", true, true), + new BooleanOption(L"use_pv_skin_equip", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Song Specific Skins", L"Allows song-specific skin settings.\nValues stored in skins.ini", true, true), + new BooleanOption(L"use_pv_sfx_equip", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Song Specific Sound Effects", L"Allows song-specific sound effect settings.\nValues stored in sfx.ini", true, true), new BooleanOption(L"gamemode_options", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Game Modifiers", L"Allows use of game mode modifiers (hi-speed, hidden, and sudden).", true, true), }; diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index e2aecd3..1499287 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -224,7 +224,7 @@ namespace Launcher { if (wineVersion != "") { - this->labelGPU->Text = "Wine " + wineVersion + " (at least 4.12.1 is required)\n"; + this->labelGPU->Text = "Wine " + wineVersion + " (remember to disable movies!)\n"; } else this->labelGPU->Text = "GPU Info:\n"; this->labelGPU->Text += vendor + " " + renderer + "\n";