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

Protection and made various code improvements. #206

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ file(GLOB_RECURSE SRC_FILES
"${SRC_DIR}/**.cpp"
)
set(DEPS_DIR "${PROJECT_SOURCE_DIR}/deps")
#compile faster
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

add_library(${PROJECT_NAME} MODULE ${SRC_FILES})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 23)
Expand Down
2 changes: 1 addition & 1 deletion src/core/frontend/manager/Category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace YimMenu
if (m_Length.has_value())
return m_Length.value();

m_Length = std::max(ImGui::CalcTextSize(m_Name.c_str()).x + 25.0f, 75.0f);
m_Length = static_cast<int>(std::max(ImGui::CalcTextSize(m_Name.c_str()).x + 25.0f, 75.0f));
return m_Length.value();
}
}
1 change: 1 addition & 0 deletions src/core/hooking/Hooking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace YimMenu
BaseHook::Add<Hooks::Protections::HandleCloneSync>(new DetourHook("HandleCloneSync", Pointers.HandleCloneSync, Hooks::Protections::HandleCloneSync));
BaseHook::Add<Hooks::Protections::GetCloneCreateResponse>(new DetourHook("GetCloneCreateResponse", Pointers.GetCloneCreateResponse, Hooks::Protections::GetCloneCreateResponse));
BaseHook::Add<Hooks::Protections::CanApplyData>(new DetourHook("CanApplyData", Pointers.CanApplyData, Hooks::Protections::CanApplyData));
BaseHook::Add<Hooks::Protections::PhysicCrash>(new DetourHook("PhysicCrash", Pointers.PhysicCrash, Hooks::Protections::PhysicCrash));
BaseHook::Add<Hooks::Protections::ResetSyncNodes>(new DetourHook("ResetSyncNodes", Pointers.ResetSyncNodes, Hooks::Protections::ResetSyncNodes));
BaseHook::Add<Hooks::Protections::HandleScriptedGameEvent>(new DetourHook("HandleScriptedGameEvent", Pointers.HandleScriptedGameEvent, Hooks::Protections::HandleScriptedGameEvent));
BaseHook::Add<Hooks::Protections::AddObjectToCreationQueue>(new DetourHook("AddObjectToCreationQueue", Pointers.AddObjectToCreationQueue, Hooks::Protections::AddObjectToCreationQueue));
Expand Down
2 changes: 1 addition & 1 deletion src/game/frontend/items/ListCommandItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace YimMenu
m_SelectedItem = "";

auto size = ImGui::CalcTextSize(largest_string);
m_ItemWidth = size.x + 25.0f;
m_ItemWidth = static_cast<int>(size.x + 25.0f);
}

ImGui::SetNextItemWidth(m_ItemWidth.value());
Expand Down
8 changes: 7 additions & 1 deletion src/game/frontend/submenus/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,13 @@ namespace YimMenu::Submenus
static const char* iconBuf = "";
infoSpoofingGroup->AddItem(std::make_shared<ImGuiItem>([=] {
static std::map<std::string, std::string> colors = {{"", "None"}, {"~e~", "Red"}, {"~f~", "Off White"}, {"~p~", "White"}, {"~o~", "Yellow"}, {"~q~", "Pure White"}, {"~d~", "Orange"}, {"~m~", "Light Grey"}, {"~t~", "Grey"}, {"~v~", "Black"}, {"~pa~", "Blue"}, {"~t1~", "Purple"}, {"~t2~", "Orange"}, {"~t3~", "Teal"}, {"~t4~", "Light Yellow"}, {"~t5~", "Pink"}, {"~t6~", "Green"}, {"~t7~", "Dark Blue"}};
static std::map<const char*, std::string> icons = {{"", "None"}, {"\u2211", "Rockstar Icon"}};

#pragma warning(push)
#pragma warning(disable : 4566)
static std::map<const char*, std::string> icons = {{"", "None"}, {"∑", "Rockstar Icon"}};
#pragma warning(pop)


ImGui::Text("Spoofed data will not appear locally, and will only be visible when joining a new session,\n or when a player joins you");

ImGui::Text("Name");
Expand Down
3 changes: 3 additions & 0 deletions src/game/hooks/Hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ namespace YimMenu::Hooks
extern bool ReceiveArrayUpdate(void* array, CNetGamePlayer* sender, rage::datBitBuffer* buffer, int size, int16_t cycle);
extern void* CreatePoolItem(rage::fwBasePool* pool, int size);
extern int HandleCloneRemove(void* mgr, CNetGamePlayer* sender, CNetGamePlayer* target, uint16_t objectId, int ownershipToken, bool unk);

extern int64_t PhysicCrash(int64_t a1, unsigned int a2, int* a3);

extern void SetTreeErrored(rage::netSyncTree* tree, bool errored);
extern void PhysicsHandleLassoAttachment(void* inst, void* attachment);
extern void DecideConnectionMethod(void* _this, void* a2);
Expand Down
25 changes: 25 additions & 0 deletions src/game/hooks/Protections/PhysicCrash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "core/hooking/DetourHook.hpp"
#include "game/hooks/Hooks.hpp"
#include "game/pointers/Pointers.hpp"
Sys0xdbg marked this conversation as resolved.
Show resolved Hide resolved


namespace YimMenu::Hooks
{
int64_t Protections::PhysicCrash(int64_t a1, unsigned int a2, int* a3)
{
unsigned int v11; // esi
int64_t v9; // rbx

v9 = *(uint64_t*)(a1 + 40) + 80i64 * a2;
if (v9)
{
v11 = *(uint16_t*)(v9 + 72);
if (v11 > 1000)
{
return 0;
}
}

return BaseHook::Get<Protections::PhysicCrash, DetourHook<decltype(&Protections::PhysicCrash)>>()->Original()(a1, a2, a3);
}
}
4 changes: 3 additions & 1 deletion src/game/hooks/Protections/ShouldBlockSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ namespace
{
using namespace YimMenu;

static const std::unordered_set<uint32_t> g_CrashObjects = {0xD1641E60, 0x6927D266};
static const std::unordered_set<uint32_t> g_CrashObjects = {"s_chuckwagonawning01b"_J};

static const std::unordered_set<uint32_t> g_FishModels = {
"A_C_Crawfish_01"_J,
"A_C_FishBluegil_01_ms"_J,
Expand Down Expand Up @@ -210,6 +211,7 @@ namespace
case "CPedCreationNode"_J:
{
auto& data = node->GetData<CPedCreationData>();

if (data.m_ModelHash && !STREAMING::IS_MODEL_A_PED(data.m_ModelHash))
{
LOGF(SYNC, WARNING, "Blocking invalid ped creation model 0x{:X} from {}", data.m_ModelHash, Protections::GetSyncingPlayer().GetName());
Expand Down
8 changes: 8 additions & 0 deletions src/game/pointers/Pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,19 @@ namespace YimMenu
PackCloneCreate = ptr.Sub(0x34).As<PVOID>();
});


constexpr auto physicCrashPtrn = Pattern<"E8 ?? ?? ?? ?? EB 67 48 8B 41 20">("PhysicCrash");
scanner.Add(physicCrashPtrn, [this](PointerCalculator ptr) {
PhysicCrash = ptr.Add(1).Rip().As<PVOID>();
});


constexpr auto writeSyncTreePtrn = Pattern<"0F 84 A4 00 00 00 48 8B 07 45 8B C4">("WriteSyncTree");
scanner.Add(writeSyncTreePtrn, [this](PointerCalculator ptr) {
WriteSyncTree = ptr.Sub(0x79).As<PVOID>();
});


constexpr auto shouldUseNodeCachePtrn = Pattern<"83 FA 20 75 03">("ShouldUseNodeCache");
scanner.Add(shouldUseNodeCachePtrn, [this](PointerCalculator ptr) {
ShouldUseNodeCache = ptr.As<PVOID>();
Expand Down
1 change: 1 addition & 0 deletions src/game/pointers/Pointers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ namespace YimMenu
PVOID SerializeServerRPC;
PVOID ReceiveArrayUpdate;
PVOID CreatePoolItem;
PVOID PhysicCrash;


// Player Stuff
Expand Down