Skip to content

Commit

Permalink
Move patterns to IDA script, easier to update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamashi committed Feb 15, 2022
1 parent 11640f9 commit 5295574
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 86 deletions.
42 changes: 40 additions & 2 deletions ida/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,44 @@ def get_groups() -> List[Group]:
Item(name='Resize', pattern='44 88 4C 24 20 44 89 44 24 18 89 54 24 10 89 4C', expected=1)
]),
Group(name='CRenderNode_Present', functions=[
Item(name='DoInternal', pattern='48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 30 8B 01 41 8B F8 4C 8B 35', expected=1)
])
Item(name='DoInternal', pattern='48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 30 8B 01 41 8B F8 4C 8B 35', expected=1)
]),
Group(name='CScript', functions=[
Item(name='RunPureScript', pattern='40 55 48 81 EC D0 00 00 00 48 8D 6C 24 40 8B', expected=1),
Item(name='CreateFunction', pattern='48 89 5C 24 08 57 48 83 EC 40 8B F9 48 8D 54 24 30 48 8B 0D ? ? ? ? 41 B8 B8 00 00 00', expected=1),
Item(name='Log', pattern='40 53 48 83 EC ? 48 8D 4C 24 20 48 8B DA E8 ? ? ? ? 33 D2 48 8D 4C 24 40 E8', expected=1),
Item(name='LogChannel', pattern='40 53 48 83 EC ? 48 8D 4C 24 20 48 8B DA E8 ? ? ? ? 33 D2 48 8D 4C 24 40 E8', expected=1),
Item(name='TDBIDConstructorDerive', pattern='40 53 48 83 EC 30 33 C0 4C 89 44 24 20 48 8B DA', expected=1),
Item(name='ProcessRunningState', pattern='40 53 48 83 EC 20 48 8B 0D ? ? ? ? 48 8B DA E8 ? ? ? ? 84 C0', expected=1),
Item(name='TweakDBLoad', pattern='48 89 5C 24 10 48 89 7C 24 18 4C 89 74 24 20 55 48 8B EC 48 83 EC 70 48', expected=1)
]),
Group(name='CWinapi', functions=[
Item(name='ClipToCenter', pattern='48 89 5C 24 08 57 48 83 EC 30 48 8B 99 ? 01 00 00 48 8B F9 FF', expected=1)
]),
Group(name='gameIGameSystem', functions=[
Item(name='Constructor', pattern='48 8B D9 E8 ? ? ? ? 48 8D 05 ? ? ? ? 48 C7 43 40 00 00 00 00', expected=2, index=0),
Item(name='Initialize', pattern='48 89 5C 24 18 48 89 6C 24 20 57 48 83 EC 30 48 8B 42 78', expected=1),
Item(name='UnInitialize', pattern='40 53 48 83 EC 20 48 8B D9 E8 ? ? ? ? 33 C0 48 89 43 50 48 89 43 48', expected=1),
Item(name='Spawn', pattern='FF 90 A8 01 00 00 48 8B 00 4C 8D 85 80 00 00 00', expected=1),
Item(name='Despawn', pattern='40 55 53 56 57 41 55 41 56 41 57 48 8B EC 48 83 EC 50', expected=1),
Item(name='SpawnCallback', pattern='41 57 48 83 EC 70 48 8B E9 4C 8B FA', expected=1)
]),
Group(name='CPhotoMode', functions=[
Item(name='SetRecordID', pattern='48 89 5C 24 08 48 89 74 24 18 55 57 41 56 48 8D 6C 24 B9 48 81 EC 90 00 00 00 48 8B F9', expected=1)
]),
Group(name='CPatches', functions=[
Item(name='BoundaryTeleport', pattern='48 8B C4 55 53 41 54 48 8D A8 78', expected=1),
Item(name='IntroMovie', pattern='48 89 5C 24 08 57 48 83 EC 20 48 8B 44 24 50 48 8B D9 48 89 41 08', expected=1),
Item(name='Vignette', pattern='48 8B 41 30 48 83 78 68 00 74', expected=1),
Item(name='IsFinal', pattern='48 BB 87 C9 B1 63 33 01 15 75', expected=1),
Item(name='CanDebugTeleport', pattern='48 BB C3 63 E3 32 7C A2 3C C1', expected=1),
Item(name='MinimapFlicker', pattern='83 79 2C 00 48 8B F2 4C', expected=1),
Item(name='OptionsInit', pattern='48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 40 48 8B F1 48 8D 4C 24 20 E8', expected=1),
Item(name='RemovePedestrians', pattern='3B D8 0F 4E C3 8B D8 85 DB 0F 8E', expected=1),
Item(name='SkipStartScreen', pattern='48 BB E6 F8 A5 A3 36 56 4E A7 C6 85 B0 ? ? ? 01', expected=1),
Item(name='AmdSMT', pattern='75 2D 33 C9 B8 01 00 00 00 0F A2 8B C8 C1 F9 08', expected=1)
]),
Group(name='CGame', functions=[
Item(name='Main', pattern='40 55 57 41 57 48 81 EC', expected=1)
]),
]
5 changes: 2 additions & 3 deletions src/overlay/Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,9 @@ BOOL Overlay::ClipToCenter(RED4ext::CGameEngine::UnkC0* apThis)

void Overlay::Hook()
{
const mem::pattern cClipToCenterPattern("48 89 5C 24 08 57 48 83 EC 30 48 8B 99 ? 01 00 00 48 8B F9 FF");
const mem::default_scanner scanner(cClipToCenterPattern);
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CWinapi_ClipToCenter);

uint8_t* pLocation = scanner(m_options.GameImage.TextRegion).as<uint8_t*>();
uint8_t* pLocation = func.GetAddr();

if (pLocation)
{
Expand Down
5 changes: 2 additions & 3 deletions src/patches/DisableBoundaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ void DisableBoundaryTeleportPatch(const Image* apImage)
{
// Disarm the WorldBoundarySystem/Tick function
// Going out of bounds will still play the glitchy-screen effect that normally happens when game teleports you, but the actual teleport won't happen
const mem::pattern cPattern("48 8B C4 55 53 41 54 48 8D A8 78");
const mem::default_scanner cScanner(cPattern);
const auto pLocation = cScanner(apImage->TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_BoundaryTeleport);
const auto pLocation = func.GetAddr();

if (pLocation == nullptr)
{
Expand Down
6 changes: 2 additions & 4 deletions src/patches/DisableIntroMovies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ void* HookInitScriptMemberVariable(void* a1, void* a2, uint64_t a3, uint64_t nam

void DisableIntroMoviesPatch(const Image* apImage)
{
const mem::pattern cPattern("48 89 5C 24 08 57 48 83 EC 20 48 8B 44 24 50 48 8B D9 48 89 41 08");
const mem::default_scanner scanner(cPattern);

RealInitScriptMemberVariable = scanner(apImage->TextRegion).as<TInitScriptMemberVariable*>();
RED4ext::RelocPtr<void> func(CyberEngineTweaks::Addresses::CPatches_IntroMovie);
RealInitScriptMemberVariable = static_cast<TInitScriptMemberVariable*>(func.GetAddr());

if (RealInitScriptMemberVariable == nullptr)
{
Expand Down
6 changes: 2 additions & 4 deletions src/patches/DisableVignette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

void DisableVignettePatch(const Image* apImage)
{
const mem::pattern cPattern("48 8B 41 30 48 83 78 68 00 74");
const mem::default_scanner scanner(cPattern);

const auto pLocation = scanner(apImage->TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_Vignette);
const auto pLocation = func.GetAddr();

if (pLocation == nullptr)
{
Expand Down
11 changes: 4 additions & 7 deletions src/patches/EnableDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,11 @@ void EnableDebugPatch(const Image* apImage)
{
uint8_t* pChecksumLocations[] = { 0, 0 };

const mem::pattern cIsFinalPattern("48 BB 87 C9 B1 63 33 01 15 75");
const mem::pattern cCanDebugTeleportPattern("48 BB C3 63 E3 32 7C A2 3C C1");
RED4ext::RelocPtr<uint8_t> isFinal(CyberEngineTweaks::Addresses::CPatches_IsFinal);
RED4ext::RelocPtr<uint8_t> canDebugTeleport(CyberEngineTweaks::Addresses::CPatches_CanDebugTeleport);

const mem::default_scanner cIsFinalScanner(cIsFinalPattern);
const mem::default_scanner cCanDebugTeleportScanner(cCanDebugTeleportPattern);

pChecksumLocations[0] = cIsFinalScanner(apImage->TextRegion).as<uint8_t*>(); // "IsFinal", helps us find RegisterScriptFunction
pChecksumLocations[1] = cCanDebugTeleportScanner(apImage->TextRegion).as<uint8_t*>(); // "CanDebugTeleport", to find RegisterScriptMemberFunction
pChecksumLocations[0] = isFinal.GetAddr(); // "IsFinal", helps us find RegisterScriptFunction
pChecksumLocations[1] = canDebugTeleport.GetAddr(); // "CanDebugTeleport", to find RegisterScriptMemberFunction

for (int i = 0; i < 2; i++)
{
Expand Down
5 changes: 2 additions & 3 deletions src/patches/MinimapFlicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

void MinimapFlickerPatch(const Image* apImage)
{
const mem::pattern cPattern("83 79 2C 00 48 8B F2 4C");
const mem::default_scanner cScanner(cPattern);
auto pLocation = cScanner(apImage->TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_MinimapFlicker);
uint8_t* pLocation = func.GetAddr();

if (pLocation == nullptr)
{
Expand Down
11 changes: 5 additions & 6 deletions src/patches/OptionsPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ void* HookGameOptionInit(GameOption* apThis)

void OptionsInitHook(const Image* apImage)
{
const mem::pattern cPattern("48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 40 48 8B F1 48 8D 4C 24 20 E8");
const mem::default_scanner cScanner(cPattern);
auto GameOptionInit = cScanner(apImage->TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_OptionsInit);
uint8_t* pLocation = func.GetAddr();

if (GameOptionInit)
if (pLocation)
{
MH_CreateHook(GameOptionInit, &HookGameOptionInit, reinterpret_cast<void**>(&RealGameOptionInit));
MH_EnableHook(GameOptionInit);
MH_CreateHook(pLocation, &HookGameOptionInit, reinterpret_cast<void**>(&RealGameOptionInit));
MH_EnableHook(pLocation);

Log::Info("Hidden options hook: success");
}
Expand Down
6 changes: 2 additions & 4 deletions src/patches/RemovePeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

void RemovePedsPatch(const Image* apImage)
{
const mem::pattern cPattern("3B D8 0F 4E C3 8B D8 85 DB 0F 8E");
const mem::default_scanner scanner(cPattern);

const auto pLocation = scanner(apImage->TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_RemovePedestrians);
uint8_t* pLocation = func.GetAddr();

if(pLocation == nullptr)
{
Expand Down
5 changes: 2 additions & 3 deletions src/patches/SkipStartScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

void StartScreenPatch(const Image* apImage)
{
const mem::pattern cPattern("48 BB E6 F8 A5 A3 36 56 4E A7 C6 85 B0 ?? ?? ?? 01");
const mem::default_scanner cScanner(cPattern);
auto pLocation = cScanner(apImage->TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_SkipStartScreen);
uint8_t* pLocation = func.GetAddr();

if(pLocation == nullptr)
{
Expand Down
5 changes: 2 additions & 3 deletions src/patches/Smt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

void SmtAmdPatch(const Image* apImage)
{
const mem::pattern cPattern("75 2D 33 C9 B8 01 00 00 00 0F A2 8B C8 C1 F9 08");
const mem::default_scanner cScanner(cPattern);
auto pLocation = cScanner(apImage->TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_AmdSMT);
uint8_t* pLocation = func.GetAddr();

if (pLocation == nullptr)
{
Expand Down
46 changes: 45 additions & 1 deletion src/reverse/Addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,57 @@ namespace CyberEngineTweaks::Addresses
{
constexpr uintptr_t ImageBase = 0x140000000;

#pragma region CGame
constexpr uintptr_t CGame_Main = 0x140AD86C0 - ImageBase; // 40 55 57 41 57 48 81 EC, expected: 1, index: 0
#pragma endregion

#pragma region CPatches
constexpr uintptr_t CPatches_BoundaryTeleport = 0x141BBDED0 - ImageBase; // 48 8B C4 55 53 41 54 48 8D A8 78, expected: 1, index: 0
constexpr uintptr_t CPatches_IntroMovie = 0x140222200 - ImageBase; // 48 89 5C 24 08 57 48 83 EC 20 48 8B 44 24 50 48 8B D9 48 89 41 08, expected: 1, index: 0
constexpr uintptr_t CPatches_Vignette = 0x1412233C0 - ImageBase; // 48 8B 41 30 48 83 78 68 00 74, expected: 1, index: 0
constexpr uintptr_t CPatches_IsFinal = 0x14020DDFD - ImageBase; // 48 BB 87 C9 B1 63 33 01 15 75, expected: 1, index: 0
constexpr uintptr_t CPatches_CanDebugTeleport = 0x1426C0756 - ImageBase; // 48 BB C3 63 E3 32 7C A2 3C C1, expected: 1, index: 0
constexpr uintptr_t CPatches_MinimapFlicker = 0x14260AD98 - ImageBase; // 83 79 2C 00 48 8B F2 4C, expected: 1, index: 0
constexpr uintptr_t CPatches_OptionsInit = 0x142C64300 - ImageBase; // 48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 40 48 8B F1 48 8D 4C 24 20 E8, expected: 1, index: 0
constexpr uintptr_t CPatches_RemovePedestrians = 0x141E98965 - ImageBase; // 3B D8 0F 4E C3 8B D8 85 DB 0F 8E, expected: 1, index: 0
constexpr uintptr_t CPatches_SkipStartScreen = 0x142A50634 - ImageBase; // 48 BB E6 F8 A5 A3 36 56 4E A7 C6 85 B0 ? ? ? 01, expected: 1, index: 0
constexpr uintptr_t CPatches_AmdSMT = 0x142C1077B - ImageBase; // 75 2D 33 C9 B8 01 00 00 00 0F A2 8B C8 C1 F9 08, expected: 1, index: 0
#pragma endregion

#pragma region CPhotoMode
constexpr uintptr_t CPhotoMode_SetRecordID = 0x142E287C0 - ImageBase; // 48 89 5C 24 08 48 89 74 24 18 55 57 41 56 48 8D 6C 24 B9 48 81 EC 90 00 00 00 48 8B F9, expected: 1, index: 0
#pragma endregion

#pragma region CRenderGlobal
constexpr uintptr_t CRenderGlobal_InstanceOffset = 0x144C91230 - ImageBase; // 48 8B 05 ? ? ? ? 8B D1 48 8B 88 18 8A 5A 01, expected: 1, index: 0, offset: 3
constexpr uintptr_t CRenderGlobal__DoNotUse_RenderQueueOffset = 0x18BE22C76 - ImageBase; // 4D 8B 0E 49 39 31 0F 84 85 00 00 00 41 39 71 24 74 ? 49 8B 95, expected: 1, index: 0, offset: 0
constexpr uintptr_t CRenderGlobal_Resize = 0x142D41700 - ImageBase; // 44 88 4C 24 20 44 89 44 24 18 89 54 24 10 89 4C, expected: 1, index: 0
#pragma endregion

#pragma region CRenderNode_Present
constexpr uintptr_t CRenderNode_Present_DoInternal = 0x142D439E0 - ImageBase; // 48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 30 8B 01 41 8B F8 4C 8B 35, expected: 1, index: 0
constexpr uintptr_t CRenderNode_Present_DoInternal = 0x142D439E0 - ImageBase; // 48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 30 8B 01 41 8B F8 4C 8B 35, expected: 1, index: 0
#pragma endregion

#pragma region CScript
constexpr uintptr_t CScript_RunPureScript = 0x14022E980 - ImageBase; // 40 55 48 81 EC D0 00 00 00 48 8D 6C 24 40 8B, expected: 1, index: 0
constexpr uintptr_t CScript_CreateFunction = 0x14029CDD0 - ImageBase; // 48 89 5C 24 08 57 48 83 EC 40 8B F9 48 8D 54 24 30 48 8B 0D ? ? ? ? 41 B8 B8 00 00 00, expected: 1, index: 0
constexpr uintptr_t CScript_Log = 0x140210470 - ImageBase; // 40 53 48 83 EC ? 48 8D 4C 24 20 48 8B DA E8 ? ? ? ? 33 D2 48 8D 4C 24 40 E8, expected: 1, index: 0
constexpr uintptr_t CScript_LogChannel = 0x140210470 - ImageBase; // 40 53 48 83 EC ? 48 8D 4C 24 20 48 8B DA E8 ? ? ? ? 33 D2 48 8D 4C 24 40 E8, expected: 1, index: 0
constexpr uintptr_t CScript_TDBIDConstructorDerive = 0x142C5D2B0 - ImageBase; // 40 53 48 83 EC 30 33 C0 4C 89 44 24 20 48 8B DA, expected: 1, index: 0
constexpr uintptr_t CScript_ProcessRunningState = 0x140AD62A0 - ImageBase; // 40 53 48 83 EC 20 48 8B 0D ? ? ? ? 48 8B DA E8 ? ? ? ? 84 C0, expected: 1, index: 0
constexpr uintptr_t CScript_TweakDBLoad = 0x140C43060 - ImageBase; // 48 89 5C 24 10 48 89 7C 24 18 4C 89 74 24 20 55 48 8B EC 48 83 EC 70 48, expected: 1, index: 0
#pragma endregion

#pragma region CWinapi
constexpr uintptr_t CWinapi_ClipToCenter = 0x1407E7DA0 - ImageBase; // 48 89 5C 24 08 57 48 83 EC 30 48 8B 99 ? 01 00 00 48 8B F9 FF, expected: 1, index: 0
#pragma endregion

#pragma region gameIGameSystem
constexpr uintptr_t gameIGameSystem_Constructor = 0x140B4E636 - ImageBase; // 48 8B D9 E8 ? ? ? ? 48 8D 05 ? ? ? ? 48 C7 43 40 00 00 00 00, expected: 2, index: 0
constexpr uintptr_t gameIGameSystem_Initialize = 0x142E2A0F0 - ImageBase; // 48 89 5C 24 18 48 89 6C 24 20 57 48 83 EC 30 48 8B 42 78, expected: 1, index: 0
constexpr uintptr_t gameIGameSystem_UnInitialize = 0x142E28DE0 - ImageBase; // 40 53 48 83 EC 20 48 8B D9 E8 ? ? ? ? 33 C0 48 89 43 50 48 89 43 48, expected: 1, index: 0
constexpr uintptr_t gameIGameSystem_Spawn = 0x142E2B225 - ImageBase; // FF 90 A8 01 00 00 48 8B 00 4C 8D 85 80 00 00 00, expected: 1, index: 0
constexpr uintptr_t gameIGameSystem_Despawn = 0x142E28E80 - ImageBase; // 40 55 53 56 57 41 55 41 56 41 57 48 8B EC 48 83 EC 50, expected: 1, index: 0
constexpr uintptr_t gameIGameSystem_SpawnCallback = 0x14119D70E - ImageBase; // 41 57 48 83 EC 70 48 8B E9 4C 8B FA, expected: 1, index: 0
#pragma endregion
} // namespace CyberEngineTweaks::Addresses
29 changes: 13 additions & 16 deletions src/reverse/RTTIExtender.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#include "RTTIExtender.h"
#include <CET.h>
#include <Image.h>
#include <RED4ext/SharedMutex.hpp>
#include <RED4ext/Scripting/Natives/Generated/Transform.hpp>
#include <RED4ext/Scripting/Natives/Generated/WorldTransform.hpp>
#include <RED4ext/Scripting/Natives/Generated/ent/Entity.hpp>
#include <RED4ext/Scripting/Natives/Generated/ent/EntityID.hpp>


template<typename T>
struct PatternCall
struct GameCall
{
PatternCall(const char* acPattern, const int32_t acOffset = 0)
GameCall(uintptr_t aAddress, const int32_t acOffset = 0)
{
const auto& gameImage = CET::Get().GetOptions().GameImage;
const mem::pattern cPattern(acPattern);
const mem::default_scanner cScanner(cPattern);
const auto* pLocation = cScanner(gameImage.TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> addr(aAddress);
const auto* pLocation = addr.GetAddr();
m_address = pLocation ? reinterpret_cast<T>(pLocation + acOffset) : nullptr;
}

Expand Down Expand Up @@ -127,7 +124,7 @@ struct gameIGameSystem : IUpdatableSystem
{
// expected: 2, index: 0
using TFunc = void (*)(void*);
static PatternCall<TFunc> func("48 8B D9 E8 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 C7 43 40 00 00 00 00", -6);
static GameCall<TFunc> func(CyberEngineTweaks::Addresses::gameIGameSystem_Constructor, -6);
func(apAddress); // gameIGameSystem::ctor()
}

Expand Down Expand Up @@ -234,7 +231,7 @@ struct TEMP_SpawnSettings
{
// Copied from the function photomode uses to spawn 3rd person puppet
using TFunc = void (*)(const RED4ext::TweakDBID&, RED4ext::Handle<RED4ext::IScriptable>&);
static PatternCall<TFunc> func("48 89 5C 24 08 48 89 74 24 18 55 57 41 56 48 8D 6C 24 B9 48 81 EC 90 00 00 00 48 8B F9");
static GameCall<TFunc> func(CyberEngineTweaks::Addresses::CPhotoMode_SetRecordID);

DONOTUSE_recordDBID = acTweakDBID;
func(acTweakDBID, unkB0);
Expand Down Expand Up @@ -269,22 +266,22 @@ struct TEMP_Spawner
void Initialize(RED4ext::GameInstance* apGameInstance)
{
using TFunc = void (*)(TEMP_Spawner*, RED4ext::GameInstance*);
static PatternCall<TFunc> func("48 89 5C 24 18 48 89 6C 24 20 57 48 83 EC 30 48 8B 42 78");
static GameCall<TFunc> func(CyberEngineTweaks::Addresses::gameIGameSystem_Initialize);
func(this, apGameInstance);
}

void UnInitialize()
{
using TFunc = void (*)(TEMP_Spawner*);
static PatternCall<TFunc> func("40 53 48 83 EC 20 48 8B D9 E8 ?? ?? ?? ?? 33 C0 48 89 43 50 48 89 43 48");
static GameCall<TFunc> func(CyberEngineTweaks::Addresses::gameIGameSystem_UnInitialize);
func(this);
}

RED4ext::ent::EntityID Spawn(const RED4ext::CName acEntityPath, TEMP_SpawnSettings& aSettings)
{
// REDSmartPtr<TEMP_PendingEntity::Unk00> TEMP_Spawner::func(this, TEMP_SpawnSettings&, RED4ext::CName&)
using TFunc = void (*)(TEMP_Spawner*, REDSmartPtr<TEMP_PendingEntity::Unk00>*, TEMP_SpawnSettings&, const RED4ext::CName&);
static PatternCall<TFunc> func("FF 90 A8 01 00 00 48 8B 00 4C 8D 85 80 00 00 00", -0x55);
static GameCall<TFunc> func(CyberEngineTweaks::Addresses::gameIGameSystem_Spawn, -0x55);

REDSmartPtr<TEMP_PendingEntity::Unk00> pendingEntity;
func(this, &pendingEntity, aSettings, acEntityPath);
Expand Down Expand Up @@ -325,7 +322,7 @@ struct TEMP_Spawner
void Despawn(RED4ext::Handle<RED4ext::IScriptable> aEntity)
{
using TFunc = void(*)(TEMP_Spawner*, RED4ext::IScriptable*);
static PatternCall<TFunc> func("40 55 53 56 57 41 55 41 56 41 57 48 8B EC 48 83 EC 50");
static GameCall<TFunc> func(CyberEngineTweaks::Addresses::gameIGameSystem_Despawn);
func(this, aEntity.GetPtr());
}
};
Expand Down Expand Up @@ -519,12 +516,12 @@ struct exEntitySpawnerSystem : gameIGameSystem
static void SpawnCallback(TEMP_PendingEntity::Unk00& aUnk)
{
using TFunc = void(*)(RED4ext::IScriptable*, RED4ext::ent::Entity*);
static PatternCall<TFunc> func("41 57 48 83 EC 70 48 8B E9 4C 8B FA", -0x0E);
static GameCall<TFunc> func(CyberEngineTweaks::Addresses::gameIGameSystem_SpawnCallback, -0xE);

struct GameInstance_78_Unk
{
uint8_t unk00[0xD0];
RED4ext::IScriptable* worldRuntimeEntityRegistry;
IScriptable* worldRuntimeEntityRegistry;
};

struct GameInstance_78
Expand Down
Loading

0 comments on commit 5295574

Please sign in to comment.