From 444af18b39015aed172724191a08b1b6d02049e1 Mon Sep 17 00:00:00 2001 From: Milxnor Date: Mon, 19 Jun 2023 10:11:30 -0400 Subject: [PATCH] reboot living up to its name --- .../BuildingGameplayActorSpawnMachine.cpp | 26 +++++++-------- Project Reboot 3.0/FortGameModeAthena.cpp | 33 ++++++++++++++++++- Project Reboot 3.0/FortGameStateAthena.cpp | 8 +++-- Project Reboot 3.0/FortKismetLibrary.cpp | 3 ++ Project Reboot 3.0/FortPlayerController.cpp | 4 +-- .../FortPlayerControllerAthena.cpp | 2 +- Project Reboot 3.0/addresses.cpp | 1 + Project Reboot 3.0/die.h | 10 +++--- Project Reboot 3.0/dllmain.cpp | 11 +------ Project Reboot 3.0/finder.cpp | 6 ++++ Project Reboot 3.0/finder.h | 16 +++++---- Project Reboot 3.0/gui.h | 10 ++++++ Project Reboot 3.0/hooking.h | 13 +++++++- Project Reboot 3.0/log.h | 1 + vendor/memcury.h | 21 +++++++----- 15 files changed, 115 insertions(+), 50 deletions(-) diff --git a/Project Reboot 3.0/BuildingGameplayActorSpawnMachine.cpp b/Project Reboot 3.0/BuildingGameplayActorSpawnMachine.cpp index d63c010..f6bf380 100644 --- a/Project Reboot 3.0/BuildingGameplayActorSpawnMachine.cpp +++ b/Project Reboot 3.0/BuildingGameplayActorSpawnMachine.cpp @@ -27,7 +27,10 @@ void ABuildingGameplayActorSpawnMachine::RebootingDelegateHook(ABuildingGameplay LOG_INFO(LogDev, "RebootingDelegateHook!"); if (!SpawnMachine->GetResurrectLocation()) + { + LOG_WARN(LogRebooting, "Reboot van did not have a resurrection location!"); return; + } LOG_INFO(LogDev, "PlayerIdsForResurrection.Num(): {}", SpawnMachine->GetPlayerIdsForResurrection().Num()); @@ -61,8 +64,6 @@ void ABuildingGameplayActorSpawnMachine::RebootingDelegateHook(ABuildingGameplay } } - LOG_INFO(LogDev, "PlayerController: {}", __int64(PlayerController)); - if (!PlayerController) return; @@ -91,27 +92,24 @@ void ABuildingGameplayActorSpawnMachine::RebootingDelegateHook(ABuildingGameplay if (!StrongResurrectionLocation) return; - // GameMode->RestartPlayerAtPlayerStart(PlayerController, StrongResurrectionLocation); - PlayerState->GetRespawnData()->IsRespawnDataAvailable() = false; PlayerController->SetPlayerIsWaiting(true); - PlayerController->ServerRestartPlayer(); + // PlayerController->ServerRestartPlayer(); - /* static auto PawnClass = FindObject("/Game/Athena/PlayerPawn_Athena.PlayerPawn_Athena_C"); - auto NewPawn = GetWorld()->SpawnActor(PawnClass, StrongResurrectionLocation->GetTransform()); - PlayerController->Possess(NewPawn); */ + bool bEnterSkydiving = false; // TODO get from like curve table iirc idk or the variable + PlayerController->RespawnPlayerAfterDeath(bEnterSkydiving); AFortPlayerPawn* NewPawn = Cast(PlayerController->GetMyFortPawn()); LOG_INFO(LogDev, "NewPawn: {}", __int64(NewPawn)); if (!NewPawn) // Failed to restart player + { + LOG_INFO(LogRebooting, "Failed to restart the player!"); return; - - bool bEnterSkydiving = false; // TODO get from like curve table iirc idk or the variable + } PlayerController->ClientClearDeathNotification(); - // PlayerController->RespawnPlayerAfterDeath(bEnterSkydiving); NewPawn->SetHealth(100); NewPawn->SetMaxHealth(100); @@ -122,6 +120,9 @@ void ABuildingGameplayActorSpawnMachine::RebootingDelegateHook(ABuildingGameplay static auto OnRep_RebootCounterFn = FindObject(L"/Script/FortniteGame.FortPlayerStateAthena.OnRep_RebootCounter"); PlayerState->ProcessEvent(OnRep_RebootCounterFn); + auto OnPlayerPawnResurrectedFn = SpawnMachine->FindFunction("OnPlayerPawnResurrected"); + SpawnMachine->ProcessEvent(OnPlayerPawnResurrectedFn, &NewPawn); + static void (*AddToAlivePlayersOriginal)(AFortGameModeAthena* GameMode, AFortPlayerControllerAthena* Player) = decltype(AddToAlivePlayersOriginal)(Addresses::AddToAlivePlayers); if (AddToAlivePlayersOriginal) @@ -129,9 +130,6 @@ void ABuildingGameplayActorSpawnMachine::RebootingDelegateHook(ABuildingGameplay AddToAlivePlayersOriginal(GameMode, PlayerController); } - auto OnPlayerPawnResurrectedFn = SpawnMachine->FindFunction("OnPlayerPawnResurrected"); - SpawnMachine->ProcessEvent(OnPlayerPawnResurrectedFn, &NewPawn); - bool IsFinalPlayerToBeRebooted = true; if (IsFinalPlayerToBeRebooted) diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 8791ee7..0c2d5e2 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -687,6 +687,35 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game LOG_INFO(LogNet, "WorldLevel {}", GameState->GetWorldLevel()); + if (Globals::AmountOfListens == 1) // we only want to do this one time. + { + if (bEnableRebooting) + { + auto GameSessionDedicatedAthenaPatch = Memcury::Scanner::FindPattern("3B 41 38 7F ? 48 8B D0 48 8B 41 30 4C 39 04 D0 75 ? 48 8D 96", false).Get(); // todo check this sig more + + if (GameSessionDedicatedAthenaPatch) + { + PatchBytes(GameSessionDedicatedAthenaPatch, { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); + } + else + { + auto S19Patch = Memcury::Scanner::FindPattern("74 1A 48 8D 97 ? ? ? ? 49 8B CF E8 ? ? ? ? 88 87 ? ? ? ? E9").Get(); + + if (S19Patch) + { + PatchByte(S19Patch, 0x75); + } + } + + if (bEnableRebooting) + { + HookInstruction(Addresses::RebootingDelegate, (PVOID)ABuildingGameplayActorSpawnMachine::RebootingDelegateHook, "/Script/Engine.PlayerController.SetVirtualJoystickVisibility", ERelativeOffsets::LEA, FindObject("/Script/FortniteGame.Default__BuildingGameplayActorSpawnMachine")); + } + + LOG_INFO(LogDev, "Patched GameSession!"); + } + } + if (auto TeamsArrayContainer = GameState->GetTeamsArrayContainer()) { GET_PLAYLIST(GameState); @@ -700,6 +729,7 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game LOG_INFO(LogDev, "TeamsArrayContainer->TeamsArray.Num() Before: {}", TeamsArrayContainer->TeamsArray.Num()); LOG_INFO(LogDev, "TeamsArrayContainer->SquadsArray.Num() Before: {}", TeamsArrayContainer->SquadsArray.Num()); + /* if (TeamsArrayContainer->TeamsArray.Num() != AllTeamsNum) { LOG_INFO(LogDev, "Filling TeamsArray!"); @@ -713,6 +743,7 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game TeamsArrayContainer->SquadsArray.Free(); TeamsArrayContainer->SquadsArray.AddUninitialized(AllTeamsNum); } + */ for (int i = 0; i < TeamsArrayContainer->TeamsArray.Num(); i++) { @@ -745,7 +776,7 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game { auto CurrentRebootVan = (ABuildingGameplayActorSpawnMachine*)AllRebootVans.at(i); static auto FortPlayerStartClass = FindObject(L"/Script/FortniteGame.FortPlayerStart"); - CurrentRebootVan->GetResurrectLocation() = CurrentRebootVan->GetClosestActor(FortPlayerStartClass, 100); + CurrentRebootVan->GetResurrectLocation() = CurrentRebootVan->GetClosestActor(FortPlayerStartClass, 300); } AllRebootVans.Free(); diff --git a/Project Reboot 3.0/FortGameStateAthena.cpp b/Project Reboot 3.0/FortGameStateAthena.cpp index d4a4be3..5d11db0 100644 --- a/Project Reboot 3.0/FortGameStateAthena.cpp +++ b/Project Reboot 3.0/FortGameStateAthena.cpp @@ -294,7 +294,10 @@ void AFortGameStateAthena::OnRep_PlayersLeft() TeamsArrayContainer* AFortGameStateAthena::GetTeamsArrayContainer() { - if (!bEnableRebooting) // todo (milxnor) remove + // if (!bEnableRebooting) // todo (milxnor) remove when safer + // return nullptr; + + if (Fortnite_Version < 8.0) // I'm pretty sure it got added on 7.40 but idk if it is structured differently. return nullptr; static auto FriendlyFireTypeOffset = GetOffset("FriendlyFireType"); @@ -302,7 +305,8 @@ TeamsArrayContainer* AFortGameStateAthena::GetTeamsArrayContainer() if (Offset == -1) { - Offset = FriendlyFireTypeOffset + 0x5; + static int IncreaseBy = Engine_Version >= 424 ? 0x25 : 0x5; + Offset = FriendlyFireTypeOffset + IncreaseBy; } return Offset != -1 ? (TeamsArrayContainer*)(__int64(this) + Offset) : nullptr; diff --git a/Project Reboot 3.0/FortKismetLibrary.cpp b/Project Reboot 3.0/FortKismetLibrary.cpp index 6ae6083..e569a23 100644 --- a/Project Reboot 3.0/FortKismetLibrary.cpp +++ b/Project Reboot 3.0/FortKismetLibrary.cpp @@ -323,6 +323,9 @@ void UFortKismetLibrary::K2_RemoveItemFromPlayerHook(UObject* Context, FFrame& S LOG_INFO(LogDev, __FUNCTION__); + if(!PlayerController) + return K2_RemoveItemFromPlayerOriginal(Context, Stack, Ret); + auto WorldInventory = PlayerController->GetWorldInventory(); if (!WorldInventory) diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 200cb3f..4601456 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -1424,7 +1424,7 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo LOG_INFO(LogDev, "PlayersLeft: {} IsDBNO: {}", GameState->GetPlayersLeft(), DeadPawn->IsDBNO()); - if (!DeadPawn->IsDBNO()) + if (bHandleDeath && !DeadPawn->IsDBNO()) { if (Fortnite_Version > 1.8 || Fortnite_Version == 1.11) { @@ -1513,7 +1513,7 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo if (CurrentPlayerState->GetPlace() <= 1) { - // bDidSomeoneWin = true; + bDidSomeoneWin = true; break; } } diff --git a/Project Reboot 3.0/FortPlayerControllerAthena.cpp b/Project Reboot 3.0/FortPlayerControllerAthena.cpp index 743a8fd..3a17ae9 100644 --- a/Project Reboot 3.0/FortPlayerControllerAthena.cpp +++ b/Project Reboot 3.0/FortPlayerControllerAthena.cpp @@ -334,7 +334,7 @@ void AFortPlayerControllerAthena::ServerRestartPlayerHook(AFortPlayerControllerA static auto ZoneServerRestartPlayer = __int64(FortPlayerControllerZoneDefault->VFTable[GetFunctionIdxOrPtr(ServerRestartPlayerFn) / 8]); static void (*ZoneServerRestartPlayerOriginal)(AFortPlayerController*) = decltype(ZoneServerRestartPlayerOriginal)(__int64(ZoneServerRestartPlayer)); - LOG_INFO(LogDev, "Call 0x{:x} returning with 0x{:x}!", ZoneServerRestartPlayer - __int64(_ReturnAddress()), __int64(ZoneServerRestartPlayerOriginal) - __int64(GetModuleHandleW(0))); + LOG_INFO(LogDev, "ServerRestartPlayerHook Call 0x{:x} returning with 0x{:x}!", ZoneServerRestartPlayer - __int64(_ReturnAddress()), __int64(ZoneServerRestartPlayerOriginal) - __int64(GetModuleHandleW(0))); return ZoneServerRestartPlayerOriginal(Controller); } diff --git a/Project Reboot 3.0/addresses.cpp b/Project Reboot 3.0/addresses.cpp index f67b70d..e505a04 100644 --- a/Project Reboot 3.0/addresses.cpp +++ b/Project Reboot 3.0/addresses.cpp @@ -579,6 +579,7 @@ std::vector Addresses::GetFunctionsToNull() if (std::floor(Fortnite_Version) == 17) { toNull.push_back(Memcury::Scanner::FindPattern("48 8B C4 48 89 70 08 48 89 78 10 55 41 54 41 55 41 56 41 57 48 8D 68 A1 48 81 EC ? ? ? ? 45 33 ED").Get()); // collectgarbage + toNull.push_back(Memcury::Scanner::FindPattern("48 8B C4 48 89 58 08 48 89 70 10 48 89 78 18 4C 89 60 20 55 41 56 41 57 48 8B EC 48 83 EC 60 4D 8B F9 41 8A F0 4C 8B F2 48 8B F9 45 32 E4").Get()); // No Reserve } if (Engine_Version == 500) diff --git a/Project Reboot 3.0/die.h b/Project Reboot 3.0/die.h index 998cd02..1bca3cf 100644 --- a/Project Reboot 3.0/die.h +++ b/Project Reboot 3.0/die.h @@ -7,11 +7,10 @@ #include "KismetStringLibrary.h" #include "DataTableFunctionLibrary.h" #include "FortPlaysetItemDefinition.h" -#include "gui.h" static inline void (*SetZoneToIndexOriginal)(AFortGameModeAthena* GameModeAthena, int OverridePhaseMaybeIDFK); -static void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int OverridePhaseMaybeIDFK) +static inline void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int OverridePhaseMaybeIDFK) { static auto ZoneDurationsOffset = Fortnite_Version >= 15 && Fortnite_Version < 18 ? 0x258 : std::floor(Fortnite_Version) >= 18 ? 0x248 @@ -103,7 +102,7 @@ static void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int Override if (!FortGameData) FortGameData = FindObject(L"/Game/Balance/AthenaGameData.AthenaGameData"); - LOG_INFO(LogDev, "FortGameData: {}", FortGameData ? FortGameData->GetFullName() : "InvalidObject"); + // LOG_INFO(LogDev, "FortGameData: {}", FortGameData ? FortGameData->GetFullName() : "InvalidObject"); auto ShrinkTimeFName = UKismetStringLibrary::Conv_StringToName(L"Default.SafeZone.ShrinkTime"); auto HoldTimeFName = UKismetStringLibrary::Conv_StringToName(L"Default.SafeZone.WaitTime"); @@ -130,6 +129,7 @@ static void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int Override ZoneHoldDurations.at(i) = FortGameData->GetValueOfKey(FortGameData->GetKey(HoldTimeFName, i)); } + /* for (int i = 0; i < ZoneDurations.Num(); i++) { LOG_INFO(LogZone, "Move [{}] {}", i, ZoneDurations.at(i)); @@ -139,6 +139,8 @@ static void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int Override { LOG_INFO(LogZone, "Hold [{}] {}", i, ZoneHoldDurations.at(i)); } + + */ } LOG_INFO(LogZone, "SafeZonePhase: {}", GameModeAthena->Get(SafeZonePhaseOffset)); @@ -167,7 +169,7 @@ static void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int Override SafeZoneIndicator->Get(SafeZoneFinishShrinkTimeOffset) = SafeZoneIndicator->Get(SafeZoneStartShrinkTimeOffset) + ZoneDuration; } -void ProcessEventHook(UObject* Object, UFunction* Function, void* Parameters) +static inline void ProcessEventHook(UObject* Object, UFunction* Function, void* Parameters) { if (!Object || !Function) return; diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index d099dd1..f5aa9c2 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -368,6 +368,7 @@ DWORD WINAPI Main(LPVOID) Addresses::SetupVersion(); NumElementsPerChunk = std::floor(Fortnite_Version) >= 5 && Fortnite_Version <= 6 ? 0x10400 : 0x10000; // Idk what version tbh + bEnableRebooting = Addresses::RebootingDelegate && Addresses::FinishResurrection; Offsets::FindAll(); // We have to do this before because FindCantBuild uses FortAIController.CreateBuildingActor Offsets::Print(); @@ -568,12 +569,6 @@ DWORD WINAPI Main(LPVOID) VirtualProtect((PVOID)func, 1, dwProtection, &dwTemp); } - if (bEnableRebooting) - { - auto GameSessionDedicatedAthenaPatch = Memcury::Scanner::FindPattern("3B 41 38 7F ? 48 8B D0 48 8B 41 30 4C 39 04 D0 75 ? 48 8D 96").Get(); // todo check this sig more - PatchBytes(GameSessionDedicatedAthenaPatch, { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); - } - if (Fortnite_Version != 22.4) { auto matchmaking = Memcury::Scanner::FindPattern("83 BD ? ? ? ? 01 7F 18 49 8D 4D D8 48 8B D6 E8 ? ? ? ? 48", false).Get(); @@ -683,10 +678,6 @@ DWORD WINAPI Main(LPVOID) // HookInstruction(Addresses::UpdateTrackedAttributesLea, (PVOID)AFortPlayerControllerAthena::UpdateTrackedAttributesHook, "/Script/Engine.PlayerController.EnableCheats", ERelativeOffsets::LEA, FortPlayerControllerAthenaDefault); // HookInstruction(Addresses::CombinePickupLea, (PVOID)AFortPickup::CombinePickupHook, "/Script/Engine.PlayerController.SetVirtualJoystickVisibility", ERelativeOffsets::LEA, FortPlayerControllerAthenaDefault); - if (bEnableRebooting) - { - HookInstruction(Addresses::RebootingDelegate, (PVOID)ABuildingGameplayActorSpawnMachine::RebootingDelegateHook, "/Script/Engine.PlayerController.SetVirtualJoystickVisibility", ERelativeOffsets::LEA, FindObject("/Script/FortniteGame.Default__BuildingGameplayActorSpawnMachine")); - } if (Fortnite_Version == 13.40) { diff --git a/Project Reboot 3.0/finder.cpp b/Project Reboot 3.0/finder.cpp index 36eb5d8..4a2184e 100644 --- a/Project Reboot 3.0/finder.cpp +++ b/Project Reboot 3.0/finder.cpp @@ -18,6 +18,12 @@ uint64 FindGetPlayerViewpoint() FailedToSpawnPawnAddr = FailedToSpawnPawnStrRefAddr - i; break; } + + if (*(uint8_t*)(uint8_t*)(FailedToSpawnPawnStrRefAddr - i) == 0x48 && *(uint8_t*)(uint8_t*)(FailedToSpawnPawnStrRefAddr - i + 1) == 0x89 && *(uint8_t*)(uint8_t*)(FailedToSpawnPawnStrRefAddr - i + 2) == 0x5C) + { + FailedToSpawnPawnAddr = FailedToSpawnPawnStrRefAddr - i; + break; + } } if (!FailedToSpawnPawnAddr) diff --git a/Project Reboot 3.0/finder.h b/Project Reboot 3.0/finder.h index 9a9ffb4..81c8c4c 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -171,14 +171,13 @@ static inline uint64 FindAddToAlivePlayers() static inline uint64 FindFinishResurrection() { - auto Addrr = FindFunctionCall(L"OnResurrectionCompleted"); + uintptr_t Addrr = Engine_Version >= 427 ? FindNameRef(L"OnResurrectionCompleted") : FindFunctionCall(L"OnResurrectionCompleted"); // Call is inlined if (!Addrr) return 0; - auto addr = Memcury::Scanner::FindPattern("40 53 48 83 EC 20 0F B6 81 ? ? ? ? 83 C2 03 48 8B D9 3B D0 0F 85").Get(); - - return addr; + // auto addr = Memcury::Scanner::FindPattern("40 53 48 83 EC 20 0F B6 81 ? ? ? ? 83 C2 03 48 8B D9 3B D0 0F 85").Get(); + // return addr; LOG_INFO(LogDev, "WTF: 0x{:x}", Addrr - __int64(GetModuleHandleW(0))); @@ -188,6 +187,11 @@ static inline uint64 FindFinishResurrection() { return Addrr - i; } + + if (*(uint8_t*)(uint8_t*)(Addrr - i) == 0x48 && *(uint8_t*)(uint8_t*)(Addrr - i + 1) == 0x89 && *(uint8_t*)(uint8_t*)(Addrr - i + 2) == 0x5C) + { + return Addrr - i; + } } return 0; @@ -654,8 +658,8 @@ static inline uint64 FindSpecConstructor() if (Engine_Version == 427) return Memcury::Scanner::FindPattern("80 61 31 FE 41 83 C9 FF 80 61 29 F0 48 8B 44 24 ? 48 89 41").Get(); - // if (Engine_Version == 500) - // return Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 83 CD FF").Get(); + if (Engine_Version == 500) + return Memcury::Scanner::FindPattern("4C 8B C9 48 8B 44 24 ? 83 C9 FF 41 80 61 ? ? 41 80 61 ? ? 49 89 41 20 33 C0 41 88 41 30 49 89 41").Get(); return 0; } diff --git a/Project Reboot 3.0/gui.h b/Project Reboot 3.0/gui.h index b9ddef8..18d5438 100644 --- a/Project Reboot 3.0/gui.h +++ b/Project Reboot 3.0/gui.h @@ -40,6 +40,7 @@ #include "FortAthenaMutator_Heist.h" #include "BGA.h" #include "vendingmachine.h" +#include "die.h" #define GAME_TAB 1 #define PLAYERS_TAB 2 @@ -61,6 +62,7 @@ #define LOADOUT_PLAYERTAB 4 #define FUN_PLAYERTAB 5 +extern inline bool bHandleDeath = true; extern inline bool bUseCustomMap = false; extern inline std::string CustomMapName = ""; extern inline int AmountToSubtractIndex = 1; @@ -783,8 +785,12 @@ static inline void MainUI() if (SafeZoneIndicator) { + SetZoneToIndexHook(GameMode, -1); + UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startshrinksafezone", nullptr); SafeZoneIndicator->SkipShrinkSafeZone(); + + /* UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startshrinksafezone", nullptr); SafeZoneIndicator->SkipShrinkSafeZone(); @@ -821,6 +827,8 @@ static inline void MainUI() Sleep(1000); SafeZoneIndicator->SkipShrinkSafeZone(); } + + */ } else { @@ -1152,8 +1160,10 @@ static inline void MainUI() static std::string ClassNameToDump; static std::string FunctionNameToDump; + ImGui::Checkbox("Handle Death", &bHandleDeath); ImGui::Checkbox("Fill Vending Machines", &Globals::bFillVendingMachines); ImGui::Checkbox("Enable Bot Tick", &bEnableBotTick); + ImGui::Checkbox("Enable Rebooting", &bEnableRebooting); ImGui::Checkbox("Enable Combine Pickup", &bEnableCombinePickup); ImGui::InputInt("Amount To Subtract Index", &AmountToSubtractIndex); ImGui::InputText("Class Name to mess with", &ClassNameToDump); diff --git a/Project Reboot 3.0/hooking.h b/Project Reboot 3.0/hooking.h index de6481f..a274e88 100644 --- a/Project Reboot 3.0/hooking.h +++ b/Project Reboot 3.0/hooking.h @@ -20,6 +20,17 @@ struct FunctionHooks static inline std::vector AllFunctionHooks; +inline void PatchByte(uint64 addr, uint8_t byte) +{ + DWORD dwProtection; + VirtualProtect((PVOID)addr, 1, PAGE_EXECUTE_READWRITE, &dwProtection); + + *(uint8_t*)addr = byte; + + DWORD dwTemp; + VirtualProtect((PVOID)addr, 1, dwProtection, &dwTemp); +} + inline void PatchBytes(uint64 addr, const std::vector& Bytes) { if (!addr) @@ -27,7 +38,7 @@ inline void PatchBytes(uint64 addr, const std::vector& Bytes) for (int i = 0; i < Bytes.size(); i++) { - *(uint8_t*)(addr + i) = Bytes.at(i); + PatchByte(addr + i, Bytes.at(i)); } } diff --git a/Project Reboot 3.0/log.h b/Project Reboot 3.0/log.h index b00c963..6e4290c 100644 --- a/Project Reboot 3.0/log.h +++ b/Project Reboot 3.0/log.h @@ -85,6 +85,7 @@ inline void InitLogger() MakeLogger("LogBots"); MakeLogger("LogCosmetics"); MakeLogger("LogMatchmaker"); + MakeLogger("LogRebooting"); } #define LOG_DEBUG(loggerName, ...) \ diff --git a/vendor/memcury.h b/vendor/memcury.h index bbcc2e7..bd14498 100644 --- a/vendor/memcury.h +++ b/vendor/memcury.h @@ -1417,8 +1417,7 @@ VirtualProtect(&VTable[Idx], 8, dwProtection, &dwTemp); } - // Finds a string ref, then goes searches xref of the function that it's in and returns that address. - inline uintptr_t FindFunctionCall(const wchar_t* Name, const std::vector& Bytes = std::vector{ 0x48, 0x89, 0x5C }, int skip = 0) // credit ender & me + inline uintptr_t FindNameRef(const wchar_t* Name, int skip = 0, bool bWarnStringNotFound = true) { auto StringRef = Memcury::Scanner::FindStringRef(Name, true, skip); @@ -1429,14 +1428,18 @@ auto PtrRef = Memcury::Scanner::FindPointerRef(FunctionPtr); - /* if (!PtrRef.Get() || PtrRef.Get() == __int64(FunctionPtr)) - { - std::wstring NameWStr = std::wstring(Name); - LOG_WARN(LogMemory, "Failed to find pointer reference for {}", std::string(NameWStr.begin(), NameWStr.end())); - return 0; - } */ + return PtrRef.Get(); + } - return PtrRef.ScanFor(Bytes, false).Get(); + // Finds a string ref, then goes searches xref of the function that it's in and returns that address. + inline uintptr_t FindFunctionCall(const wchar_t* Name, const std::vector& Bytes = std::vector{ 0x48, 0x89, 0x5C }, int skip = 0, bool bWarnStringNotFound = true) // credit ender & me + { + auto NameRef = FindNameRef(Name, skip, bWarnStringNotFound); + + if (!NameRef) + return 0; + + return Memcury::Scanner(NameRef).ScanFor(Bytes, false).Get(); } inline bool IsNullSub(uint64 Addr)