-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ChaosMod: Add Model Spawn Bypass (#3620)
Allows all models to be spawned (e.g. LOD models).
- Loading branch information
1 parent
690c323
commit f504863
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |