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 1 commit
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 @@ -42,6 +42,7 @@ namespace YimMenu
BaseHook::Add<Hooks::Protections::HandleCloneCreate>(new DetourHook("HandleCloneCreate", Pointers.HandleCloneCreate, Hooks::Protections::HandleCloneCreate));
BaseHook::Add<Hooks::Protections::HandleCloneSync>(new DetourHook("HandleCloneSync", Pointers.HandleCloneSync, Hooks::Protections::HandleCloneSync));
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
5 changes: 5 additions & 0 deletions src/game/frontend/submenus/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ 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"}};

#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
1 change: 1 addition & 0 deletions src/game/hooks/Hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ namespace YimMenu::Hooks
extern bool ReceiveArrayUpdate(void* array, CNetGamePlayer* sender, rage::datBitBuffer* buffer, int size, int16_t cycle);
extern void* CreatePoolItem(PoolUtils<Entity>* pool);
extern int HandleCloneRemove(void* mgr, CNetGamePlayer* sender, CNetGamePlayer* target, uint16_t objectId, int ownershipToken, bool unk);
extern __int64 PhysicCrash(__int64 a1, unsigned int a2, int* a3); // Don't really know what to call it. Lets go with PhysicCrash
Sys0xdbg marked this conversation as resolved.
Show resolved Hide resolved
}

namespace Voice
Expand Down
27 changes: 27 additions & 0 deletions src/game/hooks/Protections/PhysicCrash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#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
#include "game/backend/Protections.hpp"
Sys0xdbg marked this conversation as resolved.
Show resolved Hide resolved


namespace YimMenu::Hooks
{
// This not only prevents certain crashes but also helps block lag from some objects. Maybe we should call it LodCrash
Rxann marked this conversation as resolved.
Show resolved Hide resolved
__int64 Protections::PhysicCrash(__int64 a1, unsigned int a2, int* a3)
Sys0xdbg marked this conversation as resolved.
Show resolved Hide resolved
{
unsigned int v11; // esi
__int64 v9; // rbx
Sys0xdbg marked this conversation as resolved.
Show resolved Hide resolved

v9 = *(unsigned long long*)(a1 + 40) + 80i64 * a2;
Sys0xdbg marked this conversation as resolved.
Show resolved Hide resolved
if (v9)
{
v11 = *(unsigned __int16*)(v9 + 72);
Sys0xdbg marked this conversation as resolved.
Show resolved Hide resolved
if (v11 > 1000)
{
return 0;
}
}

return BaseHook::Get<Protections::PhysicCrash, DetourHook<decltype(&Protections::PhysicCrash)>>()->Original()(a1, a2, a3);
}
}
10 changes: 2 additions & 8 deletions src/game/hooks/Protections/ShouldBlockSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ namespace
break;
}
}

static const std::unordered_set<uint32_t> g_CrashObjects = {0xD1641E60, 0x6927D266};
/* {mp_a_c_elk_01} model does not crash & our new hook already avoids crash from {s_chuckwagonawning01b} but lets keep it for notifications.*/
Rxann marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -284,13 +284,7 @@ namespace
{
case "CPedCreationNode"_J:
{
// this is a really bad protection, but it works
auto& data = node->GetData<CPedCreationData>();
if (data.m_ModelHash == "CS_MP_BOUNTYHUNTER"_J)
{
SyncCrashBlocked("unknown ped crash");
return true;
}

if (data.m_ModelHash && !STREAMING::IS_MODEL_A_PED(data.m_ModelHash))
{
Expand Down
5 changes: 5 additions & 0 deletions src/game/pointers/Pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ namespace YimMenu
PackCloneCreate = ptr.Sub(0x34).As<PVOID>();
});

constexpr auto physicCrashPtrn = Pattern<"48 8B C4 48 89 58 08 48 89 70 10 48 89 78 18 4C 89 70 20 55 48 8D 68 E8 48 81 EC ? ? ? ? 0F 28 1D ? ? ? ? 0F 57 D2">("PhysicCrash");
scanner.Add(physicCrashPtrn, [this](PointerCalculator ptr) {
PhysicCrash = ptr.As<PVOID>();
});

if (!scanner.Scan())
{
LOG(FATAL) << "Some patterns could not be found, unloading.";
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 @@ -146,6 +146,7 @@ namespace YimMenu
PVOID ReceiveArrayUpdate;

PVOID CreatePoolItem;
PVOID PhysicCrash;


// Player Stuff
Expand Down
Loading