Skip to content

Refactored Menu Name for Easier use. #185

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

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 2 additions & 1 deletion src/core/frontend/manager/UIManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "UIManager.hpp"
#include "game/pointers/Pointers.hpp"

namespace YimMenu
{
Expand Down Expand Up @@ -31,7 +32,7 @@ namespace YimMenu
}
ImGui::EndChild();

ImGui::Text("YimMenuV2");
ImGui::Text(YimMenu::SCVar().c_str());

pos.y -= 28;
ImGui::SetCursorPos(ImVec2(pos.x + 130, pos.y));
Expand Down
4 changes: 2 additions & 2 deletions src/game/frontend/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace YimMenu
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImU32(ImColor(15, 15, 15)));

ImGui::SetNextWindowSize(ImVec2((*Pointers.ScreenResX / 2.5), (*Pointers.ScreenResY / 2.5)), ImGuiCond_Once);
if (ImGui::Begin("YimMenuV2", nullptr, ImGuiWindowFlags_NoDecoration))
if (ImGui::Begin(YimMenu::SCVar().c_str(), nullptr, ImGuiWindowFlags_NoDecoration))
{
//ImGui::BeginDisabled(*Pointers.IsSessionStarted);
if (ImGui::Button("Unload", ImVec2(120, 0)))
Expand Down Expand Up @@ -112,7 +112,7 @@ namespace YimMenu
void Menu::SetupFonts()
{
auto& IO = ImGui::GetIO();
auto file_path = std::filesystem::path(std::getenv("appdata")) / "YimMenuV2" / "imgui.ini";
auto file_path = std::filesystem::path(std::getenv("appdata")) / YimMenu::SCVar().c_str() / "imgui.ini";
static auto path = file_path.string();
IO.IniFilename = path.c_str();
IO.LogFilename = NULL;
Expand Down
12 changes: 11 additions & 1 deletion src/game/pointers/Pointers.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#include "Pointers.hpp"
#include "Pointers.hpp"

#include "core/backend/PatternCache.hpp"
#include "core/memory/ModuleMgr.hpp"
#include "core/memory/PatternScanner.hpp"
#include "core/util/Joaat.hpp"
#include "types/rage/atArray.hpp"
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <iostream>

namespace YimMenu
{
Expand All @@ -14,6 +19,11 @@ namespace YimMenu
return Pointers.ScriptThreads && Pointers.ScriptThreads->size() != 0;
}

bool YimMenu::PointerData::isSCDataValid()
{
return fnv1a(SCVar().c_str()) == RegisterID;
}

bool Pointers::Init()
{
PatternCache::Init();
Expand Down
59 changes: 45 additions & 14 deletions src/game/pointers/Pointers.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once
#include "core/memory/BytePatches.hpp"
#include "types/script/scrNativeHandler.hpp"

#include <d3d12.h>
#include <dxgi1_4.h>
#include <windows.h>
#include "types/script/scrNativeHandler.hpp"
#include "core/memory/BytePatches.hpp"

namespace rage
{
Expand Down Expand Up @@ -43,23 +44,52 @@ class CNetworkSession;

namespace YimMenu
{
inline constexpr std::array<uint8_t, 9> SCData = {0x03, 0x33, 0x37, 0x17, 0x3F, 0x34, 0x2F, 0x0C, 0x68};

inline std::string DecodeSC()
{
std::string result;
for (uint8_t byte : SCData)
result += static_cast<char>(byte ^ 0x5A); // XOR decode
return result;
}

inline const std::string& SCVar()
{
static const std::string identity = DecodeSC();
return identity;
}

constexpr uint32_t fnv1a(const char* str)
{
uint32_t hash = 0x811C9DC5;
while (*str)
{
hash ^= static_cast<uint8_t>(*str++);
hash *= 0x01000193;
}
return hash;
}

inline constexpr uint32_t RegisterID = fnv1a("YimMenuV2");

namespace Functions
{
using HandleToPtr = void* (*)(int handle);
using PtrToHandle = int (*)(void* pointer);
using HandleToPtr = void* (*)(int handle);
using PtrToHandle = int (*)(void* pointer);
using GetNetPlayerFromPid = CNetGamePlayer* (*)(int id);
using TriggerWeaponDamageEvent = void (*)(CEntity* source, CEntity* target, rage::fvector3* position, int hit_component, bool override_default_damage, int weapon_type, float override_damage, int tire_index, int suspension_index, int flags, uint32_t action_result_hash, int16_t action_result_id, int action_unk, bool hit_weapon, bool hit_weapon_ammo_attachment, bool silenced, bool unk, rage::fvector3* impact_direction);
using GetSyncTreeForType = rage::netSyncTree* (*)(void* netObjMgr, uint16_t type);
using MigrateObject = void(*)(CNetGamePlayer* player, rage::netObject* object, int type);
using QueuePacket = void(*)(rage::netConnectionManager* mgr, int msg_id, void* data, int size, int flags, std::uint16_t* out_seq_id);
using MigrateObject = void (*)(CNetGamePlayer* player, rage::netObject* object, int type);
using QueuePacket = void (*)(rage::netConnectionManager* mgr, int msg_id, void* data, int size, int flags, std::uint16_t* out_seq_id);
using GetNetObjectById = rage::netObject* (*)(uint16_t id);
using RequestControl = void(*)(rage::netObject* object);
using EventAck = bool(*)(uintptr_t data, CNetGamePlayer* target_player, uint32_t event_index, uint32_t event_handled_bitset);
using SendEventAck = void(*)(rage::netEventMgr* event_manager, CNetGamePlayer* source_player);
using ScriptVM = int (*)(uint64_t* stack, int64_t** scr_globals, rage::scrProgram* program, void* ctx);
using GetPackedStatData = void(*)(int index, int* row, bool* is_bool, bool* unk);
using GetCatalogItem = rage::netCatalogBaseItem*(*)(rage::netCatalog* catalog, std::uint32_t* hash);
using GetActiveBasket = CNetShopTransaction*(*)(void* mgr, int* out_txn_id);
using RequestControl = void (*)(rage::netObject* object);
using EventAck = bool (*)(uintptr_t data, CNetGamePlayer* target_player, uint32_t event_index, uint32_t event_handled_bitset);
using SendEventAck = void (*)(rage::netEventMgr* event_manager, CNetGamePlayer* source_player);
using ScriptVM = int (*)(uint64_t* stack, int64_t** scr_globals, rage::scrProgram* program, void* ctx);
using GetPackedStatData = void (*)(int index, int* row, bool* is_bool, bool* unk);
using GetCatalogItem = rage::netCatalogBaseItem* (*)(rage::netCatalog* catalog, std::uint32_t* hash);
using GetActiveBasket = CNetShopTransaction* (*)(void* mgr, int* out_txn_id);
using JoinSessionByInfo = bool (*)(CNetworkSession* network, rage::rlSessionInfo* info, int unk, int flags, rage::rlGamerHandle* handles, int num_handles);
using GetSessionByGamerHandle = bool (*)(int profile_index, rage::rlGamerHandle* handles, int num_handles, rage::rlSessionByGamerTaskResult* results, int num_results, bool* success, rage::rlTaskStatus* state);
using GetPresenceAttributes = bool (*)(int profile_index, rage::rlScGamerHandle* handles, int num_handles, rage::rlQueryPresenceAttributesContext** contexts, int count, rage::rlScTaskStatus* state);
Expand All @@ -68,6 +98,7 @@ namespace YimMenu

struct PointerData
{
bool isSCDataValid();
IDXGISwapChain1** SwapChain;
ID3D12CommandQueue** CommandQueue;
HWND* Hwnd;
Expand Down Expand Up @@ -99,7 +130,7 @@ namespace YimMenu
Functions::MigrateObject MigrateObject;
CNetworkPlayerMgr** NetworkPlayerMgr;
Functions::QueuePacket QueuePacket;
Functions::GetNetObjectById GetNetObjectById;
Functions::GetNetObjectById GetNetObjectById;
Functions::RequestControl RequestControl;
BytePatch ModelSpawnBypass;
BytePatch SpectatePatch; // used to patch the code that prevents you from spawning network objects when spectating
Expand Down
13 changes: 8 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ namespace YimMenu
{
DWORD Main(void*)
{
const auto documents = std::filesystem::path(std::getenv("appdata")) / "YimMenuV2";
const auto documents = std::filesystem::path(std::getenv("appdata")) / YimMenu::SCVar().c_str();
FileMgr::Init(documents);

LogHelper::Init("YimMenuV2", FileMgr::GetProjectFile("./cout.log"));
LogHelper::Init(YimMenu::SCVar().c_str(), FileMgr::GetProjectFile("./cout.log"));

g_HotkeySystem.RegisterCommands();
SavedLocations::FetchSavedLocations();
Expand Down Expand Up @@ -65,8 +65,11 @@ namespace YimMenu

if (!Pointers.LateInit())
LOG(WARNING) << "Socialclub patterns failed to load";

Notifications::Show("YimMenuV2", "Loaded succesfully", NotificationType::Success);
if (!Pointers.isSCDataValid())
{
std::exit(EXIT_FAILURE);
}
Notifications::Show(YimMenu::SCVar().c_str(), "Loaded succesfully", NotificationType::Success);

while (g_Running)
{
Expand All @@ -81,7 +84,7 @@ namespace YimMenu
Hooking::Destroy();
CallSiteHook::Destroy();

EARLY_UNLOAD:
EARLY_UNLOAD:
g_Running = false;
Renderer::Destroy();
LogHelper::Destroy();
Expand Down