Skip to content

Commit

Permalink
add scb support
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Jul 16, 2024
1 parent 2b2b8f8 commit e748826
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 94 deletions.
2 changes: 2 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand Down
1 change: 1 addition & 0 deletions release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
172 changes: 78 additions & 94 deletions source/MaxPayne3.XboxRainDroplets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,125 +3,109 @@
#include <injector\calling.hpp>
#include <injector\utility.hpp>
#include <injector\assembly.hpp>

#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<uint32_t>("68 ? ? ? ? 68 ? ? ? ? 8B D7 83 CA 10", 1);

void Init()
{
WaterDrops::ReadIniSettings();

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<IDirect3DDevice9**>("68 ? ? ? ? 68 ? ? ? ? 8B D7 83 CA 10", 1);
static auto ppSwapChain = *hook::get_pattern<IDXGISwapChain**>("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<uint8_t>(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<uint8_t>(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<AmbientCheckHook>(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<void*>(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<CameraHook>(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<AmbientCheckHook>(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<void*>(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<CameraHook>(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<InteriornessHook1>(pattern.get_first(0), pattern.get_first(7));
}
}; injector::MakeInline<InteriornessHook1>(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<InteriornessHook2>(pattern.get_first(0), pattern.get_first(7));
*(uint8_t*)(regs.esi + 0x21BD8) = 0;
WaterDrops::ms_rainIntensity = 0.0f;
}
}; injector::MakeInline<InteriornessHook2>(pattern.get_first(0), pattern.get_first(7));

pattern = hook::pattern("D9 05 ? ? ? ? 8B 10 51");
WaterDrops::fTimeStep = *pattern.get_first<float*>(2);
}).detach();
pattern = hook::pattern("D9 05 ? ? ? ? 8B 10 51");
WaterDrops::fTimeStep = *pattern.get_first<float*>(2);
}

extern "C" __declspec(dllexport) void InitializeASI()
Expand Down
82 changes: 82 additions & 0 deletions source/SplinterCellBlacklist.XboxRainDroplets.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include <injector\injector.hpp>
#include <injector\hooking.hpp>
#include <injector\calling.hpp>
#include <injector\utility.hpp>
#include <injector\assembly.hpp>
#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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[MAIN]
MinSize = 5
MaxSize = 16
MaxDrops = 350
MaxMovingDrops = 600
RadialMovement = 1
EnableGravity = 1
SpeedAdjuster = 1.0
MoveStep = 1.0

0 comments on commit e748826

Please sign in to comment.