Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Model Spawn Bypass #3620

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChaosMod/ChaosMod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
<ClCompile Include="Main.cpp" />
<ClCompile Include="Memory\Hooks\AudioClearnessHook.cpp" />
<ClCompile Include="Memory\Hooks\ApplyChangeSetEntryHook.cpp" />
<ClCompile Include="Memory\Hooks\ModelSpawnBypass.cpp" />
<ClCompile Include="Memory\Hooks\PresentHook.cpp" />
<ClCompile Include="Memory\Hooks\ScriptThreadRunHook.cpp" />
<ClCompile Include="Memory\Hooks\HandleToEntityStructHook.cpp" />
Expand Down
40 changes: 40 additions & 0 deletions ChaosMod/Memory/Hooks/ModelSpawnBypass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <stdafx.h>

#include "Memory/Hooks/Hook.h"

static DWORD64 ms_ModelSpawnPatchAddr = 0;
static std::array<BYTE, 24> ms_ModelSpawnPatchOrigBytes;

static bool OnHook()
{
Handle handle = Memory::FindPattern("48 85 C0 0F 84 ? ? ? ? 8B 48 50");
if (!handle.IsValid())
{
LOG("ModelSpawnBypass: Failed to patch model spawn bypass!");

return false;
}
else
{
ms_ModelSpawnPatchAddr = handle.Addr();
memcpy_s(ms_ModelSpawnPatchOrigBytes.data(), ms_ModelSpawnPatchOrigBytes.size(),
reinterpret_cast<void *>(ms_ModelSpawnPatchAddr), 24);

Memory::Write<BYTE>(reinterpret_cast<BYTE *>(ms_ModelSpawnPatchAddr), 0x90, 24);

LOG("ModelSpawnBypass: Applied model spawn bypass patch!");

return true;
}
}

static void OnCleanup()
{
if (ms_ModelSpawnPatchAddr)
{
memcpy_s(reinterpret_cast<void *>(ms_ModelSpawnPatchAddr), 24, ms_ModelSpawnPatchOrigBytes.data(),
ms_ModelSpawnPatchOrigBytes.size());
}
}

static RegisterHook registerHookBypass(OnHook, OnCleanup, "_ModelSpawnBypass");