Skip to content

Commit

Permalink
mp3 run init in a thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Jan 1, 2024
1 parent 224f58c commit ed78e82
Showing 1 changed file with 76 additions and 70 deletions.
146 changes: 76 additions & 70 deletions source/MaxPayne3.XboxRainDroplets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,95 +41,101 @@ void Init()

WaterDrops::ms_rainIntensity = 0.0f;

FusionDxHook::Init();
std::thread([]()
{
using namespace std::chrono_literals;
std::this_thread::sleep_for(DELAYED_BIND);

auto pattern = hook::pattern("83 EC 08 F3 0F 10 05 ? ? ? ? 8D 04 24 50");
jmpaddr = (uint32_t)pattern.get_first();
FusionDxHook::Init();

//this enables something for next hook to work
pattern = hook::pattern("38 1D ? ? ? ? 75 21 E8");
injector::WriteMemory<uint8_t>(pattern.get_first(6), 0xEB, true);
auto pattern = hook::pattern("83 EC 08 F3 0F 10 05 ? ? ? ? 8D 04 24 50");
jmpaddr = (uint32_t)pattern.get_first();

static bool bAmbientCheck = false;
//this enables something for next hook to work
pattern = hook::pattern("38 1D ? ? ? ? 75 21 E8");
injector::WriteMemory<uint8_t>(pattern.get_first(6), 0xEB, true);

pattern = hook::pattern("8D 9B ? ? ? ? 8A 08 3A 0A");
struct test
{
void operator()(injector::reg_pack& regs)
static bool bAmbientCheck = false;

pattern = hook::pattern("8D 9B ? ? ? ? 8A 08 3A 0A");
struct AmbientCheckHook
{
std::string_view str((char*)regs.eax);
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<test>(pattern.get_first(0), pattern.get_first(6));
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");
injector::WriteMemory(pattern.get_first(1), sub_12D4470, true);
pattern = hook::pattern("68 ? ? ? ? E8 ? ? ? ? 8B 15 ? ? ? ? 8B 0D ? ? ? ? 8B 04 95 ? ? ? ? 83 C4 08 03 C1");
injector::WriteMemory(pattern.get_first(1), sub_12D4470, true);

pattern = hook::pattern("F3 0F 11 6E ? F3 0F 11 46 ? 5E 5B");
struct CameraHook
{
void operator()(injector::reg_pack& regs)
pattern = hook::pattern("F3 0F 11 6E ? F3 0F 11 46 ? 5E 5B");
struct CameraHook
{
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));

FusionDxHook::D3D9::onEndSceneEvent += [](LPDIRECT3DDEVICE9 pDevice)
{
Sire::Init(Sire::SIRE_RENDERER_DX9, pDevice);
};
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));

FusionDxHook::D3D9::onResetEvent += [](LPDIRECT3DDEVICE9 pDevice)
{
WaterDrops::Reset();
};
FusionDxHook::D3D9::onEndSceneEvent += [](LPDIRECT3DDEVICE9 pDevice)
{
Sire::Init(Sire::SIRE_RENDERER_DX9, pDevice);
};

FusionDxHook::D3D10::onPresentEvent += [](IDXGISwapChain* pSwapChain)
{
//Sire::Init(Sire::SIRE_RENDERER_DX10, pSwapChain);
};
FusionDxHook::D3D9::onResetEvent += [](LPDIRECT3DDEVICE9 pDevice)
{
WaterDrops::Reset();
};

FusionDxHook::D3D11::onPresentEvent += [](IDXGISwapChain* pSwapChain)
{
Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain);
};
FusionDxHook::D3D10::onPresentEvent += [](IDXGISwapChain* pSwapChain)
{
//Sire::Init(Sire::SIRE_RENDERER_DX10, pSwapChain);
};

pattern = hook::pattern("C6 86 ? ? ? ? ? EB 1C 8B 0D ? ? ? ? 57 E8");
struct InteriornessHook1
{
void operator()(injector::reg_pack& regs)
FusionDxHook::D3D11::onPresentEvent += [](IDXGISwapChain* pSwapChain)
{
*(uint8_t*)(regs.esi + 0x21BD8) = 1;
if (bAmbientCheck)
Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain);
};

pattern = hook::pattern("C6 86 ? ? ? ? ? EB 1C 8B 0D ? ? ? ? 57 E8");
struct InteriornessHook1
{
void operator()(injector::reg_pack& regs)
{
WaterDrops::ms_rainIntensity = 1.0f;
bAmbientCheck = false;
*(uint8_t*)(regs.esi + 0x21BD8) = 1;
if (bAmbientCheck)
{
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
{
void operator()(injector::reg_pack& regs)
pattern = hook::pattern("C6 86 ? ? ? ? ? 85 FF 74 2E 80 BF ? ? ? ? ? 74 1B");
struct InteriornessHook2
{
*(uint8_t*)(regs.esi + 0x21BD8) = 0;
WaterDrops::ms_rainIntensity = 0.0f;
}
}; injector::MakeInline<InteriornessHook2>(pattern.get_first(0), pattern.get_first(7));
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));

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

extern "C" __declspec(dllexport) void InitializeASI()
Expand Down

0 comments on commit ed78e82

Please sign in to comment.