From e748826b852b166b9099362d15de0d70390a518f Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Tue, 16 Jul 2024 20:08:55 +0800 Subject: [PATCH] add scb support --- premake5.lua | 2 + release.bat | 1 + source/MaxPayne3.XboxRainDroplets.cpp | 172 ++++++++---------- ...SplinterCellBlacklist.XboxRainDroplets.cpp | 82 +++++++++ ...SplinterCellBlacklist.XboxRainDroplets.ini | 9 + 5 files changed, 172 insertions(+), 94 deletions(-) create mode 100644 source/SplinterCellBlacklist.XboxRainDroplets.cpp create mode 100644 source/resources/inis/SplinterCellBlacklist.XboxRainDroplets.ini diff --git a/premake5.lua b/premake5.lua index 859d524..f48cb54 100644 --- a/premake5.lua +++ b/premake5.lua @@ -109,6 +109,8 @@ project "MaxPayne2.XboxRainDroplets" setpaths("Z:/WFP/Games/Max Payne/Max Payne 2 The Fall of Max Payne/", "MaxPayne2.exe", "scripts/") project "MaxPayne3.XboxRainDroplets" setpaths("E:/Games/Steam/steamapps/common/Max Payne 3/Max Payne 3/", "MaxPayne3.exe", "plugins/") +project "SplinterCellBlacklist.XboxRainDroplets" + setpaths("Z:/WFP/Games/Splinter Cell/Splinter Cell Blacklist/src/SYSTEM/", "Blacklist_DX11_game.exe", "scripts/") --tests --project "GTA3.XboxRainDroplets" -- setpaths("Z:/WFP/Games/Grand Theft Auto/GTAIII/", "gta3.exe", "scripts/") diff --git a/release.bat b/release.bat index 606eee9..9130fdc 100644 --- a/release.bat +++ b/release.bat @@ -13,6 +13,7 @@ MaxPayne2.XboxRainDroplets MaxPayne3.XboxRainDroplets Driv3r.XboxRainDroplets DriverParallelLines.XboxRainDroplets +SplinterCellBlacklist.XboxRainDroplets ) do ( 7za a -tzip ".\bin\%%x.zip" ".\bin\%%x.asi" ".\bin\%%x.ini" ) diff --git a/source/MaxPayne3.XboxRainDroplets.cpp b/source/MaxPayne3.XboxRainDroplets.cpp index 8b8fb41..03fe8d2 100644 --- a/source/MaxPayne3.XboxRainDroplets.cpp +++ b/source/MaxPayne3.XboxRainDroplets.cpp @@ -3,17 +3,7 @@ #include #include #include - #include "xrd11.h" -#define FUSIONDXHOOK_INCLUDE_D3D9 1 -#define FUSIONDXHOOK_INCLUDE_D3D10 1 -#define FUSIONDXHOOK_INCLUDE_D3D10_1 1 -#define FUSIONDXHOOK_INCLUDE_D3D11 1 -#define FUSIONDXHOOK_USE_SAFETYHOOK 1 -#define DELAYED_BIND 2000ms -#include "FusionDxHook.h" - -//static auto ppDevice = *hook::get_pattern("68 ? ? ? ? 68 ? ? ? ? 8B D7 83 CA 10", 1); void Init() { @@ -21,107 +11,101 @@ void Init() WaterDrops::ms_rainIntensity = 0.0f; - std::thread([]() - { - using namespace std::chrono_literals; - std::this_thread::sleep_for(DELAYED_BIND); - - FusionDxHook::Init(); + static auto ppDevice = *hook::get_pattern("68 ? ? ? ? 68 ? ? ? ? 8B D7 83 CA 10", 1); + static auto ppSwapChain = *hook::get_pattern("A1 ? ? ? ? 8B 08 53 8D 54 24 14 52 50", 1); - //this enables something for next hook to work - auto pattern = hook::pattern("38 1D ? ? ? ? 75 21 E8"); - injector::WriteMemory(pattern.get_first(6), 0xEB, true); + //this enables something for next hook to work + auto pattern = hook::pattern("38 1D ? ? ? ? 75 21 E8"); + injector::WriteMemory(pattern.get_first(6), 0xEB, true); - static bool bAmbientCheck = false; + static bool bAmbientCheck = false; - pattern = hook::pattern("8D 9B ? ? ? ? 8A 08 3A 0A"); - struct AmbientCheckHook - { - void operator()(injector::reg_pack& regs) - { - std::string_view str((char*)regs.eax); - - if (str == "Ambient_RoofCorner_Drip_S" || str == "Ambient_RoofLine_Drip_Long_S" || str == "Ambient_RoofLine_Splash_Long_S") - bAmbientCheck = true; - } - }; injector::MakeInline(pattern.get_first(0), pattern.get_first(6)); - - pattern = hook::pattern("68 ? ? ? ? E8 ? ? ? ? 8B 15 ? ? ? ? 8B 0D ? ? ? ? 8B 04 95 ? ? ? ? 83 C4 08 03 C1"); - static SafetyHookMid shsub_12D4470 = safetyhook::create_mid(*pattern.get_first(1), - [](SafetyHookContext& ctx) + pattern = hook::pattern("8D 9B ? ? ? ? 8A 08 3A 0A"); + struct AmbientCheckHook + { + void operator()(injector::reg_pack& regs) { - #ifdef DEBUG - WaterDrops::ms_rainIntensity = 1.0f; - #endif // DEBUG - WaterDrops::Process(); - WaterDrops::Render(); - WaterDrops::ms_rainIntensity = 0.0f; - }); + std::string_view str((char*)regs.eax); - pattern = hook::pattern("F3 0F 11 6E ? F3 0F 11 46 ? 5E 5B"); - struct CameraHook - { - void operator()(injector::reg_pack& regs) - { - auto right = *(RwV3d*)(regs.esi + 0x20); - auto up = *(RwV3d*)(regs.esi + 0x30); - auto at = *(RwV3d*)(regs.esi + 0x40); - auto pos = *(RwV3d*)(regs.esi + 0x50); - - WaterDrops::right = right; - WaterDrops::up = up; - WaterDrops::at = at; - WaterDrops::pos = pos; - } - }; injector::MakeInline(pattern.get_first(5)); + if (str == "Ambient_RoofCorner_Drip_S" || str == "Ambient_RoofLine_Drip_Long_S" || str == "Ambient_RoofLine_Splash_Long_S") + bAmbientCheck = true; + } + }; injector::MakeInline(pattern.get_first(0), pattern.get_first(6)); - FusionDxHook::D3D9::onEndSceneEvent += [](LPDIRECT3DDEVICE9 pDevice) - { - Sire::Init(Sire::SIRE_RENDERER_DX9, pDevice); - }; + pattern = hook::pattern("A3 ? ? ? ? 8B 16 8B 82 ? ? ? ? 6A 03"); + static auto D3D11CreateDeviceAndSwapChain = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& ctx) + { + auto pSwapChain = *ppSwapChain; + Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); + }); - FusionDxHook::D3D9::onResetEvent += [](LPDIRECT3DDEVICE9 pDevice) - { - WaterDrops::Reset(); - }; + pattern = hook::pattern("A3 ? ? ? ? 8B 06 8B 90 ? ? ? ? 6A 06"); + static auto D3D9CreateDevice = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& ctx) + { + auto pDevice = *ppDevice; + Sire::Init(Sire::SIRE_RENDERER_DX9, pDevice); + }); - //FusionDxHook::D3D10::onPresentEvent += [](IDXGISwapChain* pSwapChain) - //{ - // //Sire::Init(Sire::SIRE_RENDERER_DX10, pSwapChain); - //}; + pattern = hook::pattern("68 ? ? ? ? E8 ? ? ? ? 8B 15 ? ? ? ? 8B 0D ? ? ? ? 8B 04 95 ? ? ? ? 83 C4 08 03 C1"); + static auto shsub_12D4470 = safetyhook::create_mid(*pattern.get_first(1), [](SafetyHookContext& ctx) + { + #ifdef DEBUG + WaterDrops::ms_rainIntensity = 1.0f; + #endif // DEBUG + WaterDrops::Process(); + WaterDrops::Render(); + WaterDrops::ms_rainIntensity = 0.0f; + }); - FusionDxHook::D3D11::onPresentEvent += [](IDXGISwapChain* pSwapChain) + pattern = hook::pattern("F3 0F 11 6E ? F3 0F 11 46 ? 5E 5B"); + struct CameraHook + { + void operator()(injector::reg_pack& regs) { - Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); - }; + auto right = *(RwV3d*)(regs.esi + 0x20); + auto up = *(RwV3d*)(regs.esi + 0x30); + auto at = *(RwV3d*)(regs.esi + 0x40); + auto pos = *(RwV3d*)(regs.esi + 0x50); + + WaterDrops::right = right; + WaterDrops::up = up; + WaterDrops::at = at; + WaterDrops::pos = pos; + } + }; injector::MakeInline(pattern.get_first(5)); + + pattern = hook::pattern("FF D2 8B 06 8B 90 ? ? ? ? 8B CE FF D2 A1 ? ? ? ? 8B 08"); + static auto D3D9onReset = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& ctx) + { + WaterDrops::Reset(); + }); - pattern = hook::pattern("C6 86 ? ? ? ? ? EB 1C 8B 0D ? ? ? ? 57 E8"); - struct InteriornessHook1 + pattern = hook::pattern("C6 86 ? ? ? ? ? EB 1C 8B 0D ? ? ? ? 57 E8"); + struct InteriornessHook1 + { + void operator()(injector::reg_pack& regs) { - void operator()(injector::reg_pack& regs) + *(uint8_t*)(regs.esi + 0x21BD8) = 1; + if (bAmbientCheck) { - *(uint8_t*)(regs.esi + 0x21BD8) = 1; - if (bAmbientCheck) - { - WaterDrops::ms_rainIntensity = 1.0f; - bAmbientCheck = false; - } + WaterDrops::ms_rainIntensity = 1.0f; + bAmbientCheck = false; } - }; injector::MakeInline(pattern.get_first(0), pattern.get_first(7)); + } + }; injector::MakeInline(pattern.get_first(0), pattern.get_first(7)); - pattern = hook::pattern("C6 86 ? ? ? ? ? 85 FF 74 2E 80 BF ? ? ? ? ? 74 1B"); - struct InteriornessHook2 + pattern = hook::pattern("C6 86 ? ? ? ? ? 85 FF 74 2E 80 BF ? ? ? ? ? 74 1B"); + struct InteriornessHook2 + { + void operator()(injector::reg_pack& regs) { - void operator()(injector::reg_pack& regs) - { - *(uint8_t*)(regs.esi + 0x21BD8) = 0; - WaterDrops::ms_rainIntensity = 0.0f; - } - }; injector::MakeInline(pattern.get_first(0), pattern.get_first(7)); + *(uint8_t*)(regs.esi + 0x21BD8) = 0; + WaterDrops::ms_rainIntensity = 0.0f; + } + }; injector::MakeInline(pattern.get_first(0), pattern.get_first(7)); - pattern = hook::pattern("D9 05 ? ? ? ? 8B 10 51"); - WaterDrops::fTimeStep = *pattern.get_first(2); - }).detach(); + pattern = hook::pattern("D9 05 ? ? ? ? 8B 10 51"); + WaterDrops::fTimeStep = *pattern.get_first(2); } extern "C" __declspec(dllexport) void InitializeASI() diff --git a/source/SplinterCellBlacklist.XboxRainDroplets.cpp b/source/SplinterCellBlacklist.XboxRainDroplets.cpp new file mode 100644 index 0000000..22240a3 --- /dev/null +++ b/source/SplinterCellBlacklist.XboxRainDroplets.cpp @@ -0,0 +1,82 @@ +#include +#include +#include +#include +#include +#include "xrd11.h" + +void Init() +{ + WaterDrops::ReadIniSettings(); + + WaterDrops::ms_rainIntensity = 0.0f; + + auto pattern = hook::pattern("E8 ? ? ? ? F3 0F 10 45 ? 56 51 8B CF"); + static auto BeforeUpdateRain = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) + { + //auto right = *(RwV3d*)(regs.ebx + 0x6C); + //auto up = *(RwV3d*)(regs.ebx + 0x7C); + //auto at = *(RwV3d*)(regs.ebx + 0x8C); + //auto pos = *(RwV3d*)(regs.ebx + 0x9C); + // + //WaterDrops::right = right; + //WaterDrops::up = up; + //WaterDrops::at = at; + //WaterDrops::pos = pos; + + WaterDrops::ms_rainIntensity = 0.0f; + }); + + pattern = hook::pattern("F3 0F 11 44 24 ? F3 0F 11 45 ? F3 0F 11 04 24 E8 ? ? ? ? 8B 7D F0 8A 55 0B"); + static auto OnUpdateRain = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) + { + WaterDrops::ms_rainIntensity = 1.0f; + regs.xmm0.f32[0] = 0.0f; // disables original droplets + }); + + pattern = hook::pattern("83 C4 1C 8B CB E8"); + static auto BeforeRenderHUDPrimitives = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) + { + WaterDrops::Process(); + WaterDrops::Render(); + }); + + pattern = hook::pattern("89 85 ? ? ? ? 85 C0 79 07"); + static auto AfterD3D11CreateDeviceAndSwapChain = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) + { + auto pSwapChain = *(IDXGISwapChain**)(regs.edi + 0x330); + + static bool bOnce = false; + if (!bOnce) + { + bOnce = true; + ID3D11Device* pDevice = nullptr; + HRESULT ret = pSwapChain->GetDevice(__uuidof(ID3D11Device), (PVOID*)&pDevice); + ID3D10Multithread* multithread = nullptr; + if (SUCCEEDED(pDevice->QueryInterface(__uuidof(ID3D10Multithread), (void**)&multithread))) { + multithread->SetMultithreadProtected(TRUE); + multithread->Release(); + } + pDevice->Release(); + } + + Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); + }); +} + +extern "C" __declspec(dllexport) void InitializeASI() +{ + std::call_once(CallbackHandler::flag, []() + { + CallbackHandler::RegisterCallback(Init); + }); +} + +BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) +{ + if (reason == DLL_PROCESS_ATTACH) + { + if (!IsUALPresent()) { InitializeASI(); } + } + return TRUE; +} \ No newline at end of file diff --git a/source/resources/inis/SplinterCellBlacklist.XboxRainDroplets.ini b/source/resources/inis/SplinterCellBlacklist.XboxRainDroplets.ini new file mode 100644 index 0000000..6df08c3 --- /dev/null +++ b/source/resources/inis/SplinterCellBlacklist.XboxRainDroplets.ini @@ -0,0 +1,9 @@ +[MAIN] +MinSize = 5 +MaxSize = 16 +MaxDrops = 350 +MaxMovingDrops = 600 +RadialMovement = 1 +EnableGravity = 1 +SpeedAdjuster = 1.0 +MoveStep = 1.0