Skip to content

Commit

Permalink
refactor: replaced with a matching reverse structure(nlohmann#18)
Browse files Browse the repository at this point in the history
- fixed the handling function in the vehicle(nlohmann#11)
- fixed weapon adjustable parameters(nlohmann#9)
most of the functionality seems to have broken down and is currently just trying to get through compilation
  • Loading branch information
Bela Proinsias authored and core committed Sep 26, 2024
1 parent 9fb53d6 commit bfdff70
Show file tree
Hide file tree
Showing 48 changed files with 3,005 additions and 2,895 deletions.
13 changes: 8 additions & 5 deletions PrivateMenu/src/UI/components/playerInfoComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "../src/menu/submenus/main/settingsMenu.h"
#include "menu\submenus\main\sessionMenu.h"
#include "menu/submenus/main/miscMenu.h"
Expand Down Expand Up @@ -743,9 +743,12 @@ bool GetNameFromHandle(SPlayer& player) {
String GetPlayerIP(SPlayer& player) {
if (player.m_id == GetLocalPlayer().m_id) return "255.255.255.255";
if (player.m_isEvolveUserBlock) return "Impulse Block";
CNetworkPlayerManager* playerManager = ReClass::GetNetworkPlayerManager();
BYTE* ExternalIP = reinterpret_cast<BYTE*>(&playerManager->m_players[player.m_id]->PlayerInfo->ExternalIP);
return va("%d.%d.%d.%d - P: %d", *(ExternalIP + 3), *(ExternalIP + 2), *(ExternalIP + 1), *ExternalIP, 6672);

rage::rlGamerInfo* ExternalIP = ReClass::GetNetworkPlayerManager()->m_net_players[player.m_id].get_net_data();
return va("%d.%d.%d.%d - P: %d", ExternalIP->m_external_ip.m_field1, ExternalIP->m_external_ip.m_field2, ExternalIP->m_external_ip.m_field3, ExternalIP->m_external_ip.m_field4, ExternalIP->m_external_port);
//&playerManager->m_player_list->m_player_info;
//BYTE* ExternalIP = reinterpret_cast<BYTE*>(&playerManager->m_player_list[player.m_id]->m_player_info->m_net_player_data->m_external_ip);
//return va("%d.%d.%d.%d - P: %d", *(ExternalIP + 3), *(ExternalIP + 2), *(ExternalIP + 1), *ExternalIP, 6672)
}

String GetPlayerStance(SPlayer& player) {
Expand Down Expand Up @@ -850,7 +853,7 @@ void UIPlayerInfoComponent::render() {
} else if (StreamerModeMenuVars::vars.StreamerMode || SettingsMenuVars::vars.hideplayerrids) {
drawInfo(m_half, m_half, 11, strRockstarID.Get(), "Blocked");
} else {
drawInfo(m_half, m_half, 11, strRockstarID.Get(), va("%i", ped->PlayerInfo->RockstarID));
drawInfo(m_half, m_half, 11, strRockstarID.Get(), va("%i", ped->m_player_info->m_net_player_data.m_gamer_handle.m_rockstar_id));
}
} else drawInfo(m_half, m_half, 11, strRockstarID.Get(), strUnknown.Get());

Expand Down
62 changes: 31 additions & 31 deletions PrivateMenu/src/UI/components/vehicleComponent.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once
#pragma execution_character_set("utf-8")
#include "menu/submenus/main/spawn/spawnVehicleMenu.h"

Expand Down Expand Up @@ -28,40 +28,40 @@ class UIVehicleComponent : public UIComponent {
GetRenderer()->DrawRect(xPos, yPos, GetRenderer()->m_lineWidth * 2, GetRenderer()->m_lineWidth * 2, GetRenderer()->m_cOutline);
}

String ClassIdToString(int id) {
String ClassIdToString(eVehicleClass id) {
switch (id)
{
case 0: return "Compacts";
case 1: return "Sedans";
case 2: return "SUVs";
case 3: return "Coupes";
case 4: return "Muscle";
case 5: return "Sports Classics";
case 6: return "Sports";
case 7: return "Super";
case 8: return "Motorcycles";
case 9: return "Off-road";
case 10: return "Industrial";
case 11: return "Utility";
case 12: return "Vans";
case 13: return "Cycles";
case 14: return "Boats";
case 15: return "Helicopters";
case 16: return "Planes";
case 17: return "Service";
case 18: return "Emergency";
case 19: return "Military";
case 20: return "Commercial";
case 21: return "Trains";
case 22: return "Open-Wheel";
case eVehicleClass::VC_COMPACT: return "Compacts";
case eVehicleClass::VC_SEDAN: return "Sedans";
case eVehicleClass::VC_SUV: return "SUVs";
case eVehicleClass::VC_COUPE: return "Coupes";
case eVehicleClass::VC_MUSCLE: return "Muscle";
case eVehicleClass::VC_SPORT_CLASSIC: return "Sports Classics";
case eVehicleClass::VC_SPORT: return "Sports";
case eVehicleClass::VC_SUPER: return "Super";
case eVehicleClass::VC_MOTORCYCLE: return "Motorcycles";
case eVehicleClass::VC_OFF_ROAD: return "Off-road";
case eVehicleClass::VC_INDUSTRIAL: return "Industrial";
case eVehicleClass::VC_UTILITY: return "Utility";
case eVehicleClass::VC_VAN: return "Vans";
case eVehicleClass::VC_CYCLE: return "Cycles";
case eVehicleClass::VC_BOAT: return "Boats";
case eVehicleClass::VC_HELICOPTER: return "Helicopters";
case eVehicleClass::VC_PLANE: return "Planes";
case eVehicleClass::VC_SERVICE: return "Service";
case eVehicleClass::VC_EMERGENCY: return "Emergency";
case eVehicleClass::VC_MILITARY: return "Military";
case eVehicleClass::VC_COMMERCIAL: return "Commercial";
case eVehicleClass::VC_RAIL: return "Trains";
case eVehicleClass::VC_OPEN_WHEEL: return "Open-Wheel";
default: return "NULL";
}
}

void DrawVehicleImage(Hash model) {
int index = 0xFFFF;

CVehicleModelInfo1290* modelInfo = (CVehicleModelInfo1290*)Backend::GetModelInfo(model, &index);
CVehicleModelInfo* modelInfo = (CVehicleModelInfo*)Backend::GetModelInfo(model, &index);

auto vit = std::find(VehicleImages.begin(), VehicleImages.end(), model);
if (vit != VehicleImages.end()) GetRenderer()->DrawSprite({ vit->dict, vit->imgName }, m_parent->m_position.x, m_parent->m_position.y - 0.030f, 0.187f, 0.165f, 0, { 255, 255, 255, 255 });
Expand All @@ -71,14 +71,14 @@ class UIVehicleComponent : public UIComponent {
if (modelInfo) {
float half = 0.187f / 2;
float whole = 0.187f;
drawInfo(0, half, 6, "Make", va("%s", HUD::GetFilenameForAudioConversation(modelInfo->m_manufacturerName)));
drawInfo(0, half, 6, "Make", va("%s", HUD::GetFilenameForAudioConversation(modelInfo->m_name)));
drawInfo(half, half, 6, "Name", va(HUD::GetFilenameForAudioConversation(VEHICLE::GetDisplayNameFromVehicleModel(model))));
drawInfo(half, half, 7, "Acceleration", va("%.1f", VEHICLE::GetVehicleModelAcceleration(model)));
drawInfo(0, half, 7, "Max Speed", va("%.0fMPH", VEHICLE::GetVehicleModelEstimatedMaxSpeed(model) * 2.4f));
drawInfo(half, half , 8, "Max Traction", va("%.1f", VEHICLE::GetVehicleModelMaxTraction(model)));
drawInfo(0, half, 8, "Max Braking", va("%.1f", VEHICLE::GetVehicleModelMaxBraking(model)));
drawInfo(half, half, 9, "Seats", va("%d", VEHICLE::GetVehicleModelNumberOfSeats(model)));
drawInfo(0, half, 9, "Class & ID", va("%s |ID: %d", ClassIdToString(modelInfo->m_vehicleClass), modelInfo->m_vehicleClass));// TODO: how to display such: "Sports | 6"
drawInfo(0, half, 9, "Class & ID", va("%s |ID: %d", ClassIdToString(modelInfo->m_vehicle_class), modelInfo->m_vehicle_class));// TODO: how to display such: "Sports | 6"

drawMiddleLineTop(6);
drawMiddleLine(6);
Expand All @@ -90,7 +90,7 @@ class UIVehicleComponent : public UIComponent {

void DrawScaleform(Hash model) {
int index = 0xFFFF;
CVehicleModelInfo1290* modelInfo = (CVehicleModelInfo1290*)Backend::GetModelInfo(model, &index);
CVehicleModelInfo* modelInfo = (CVehicleModelInfo*)Backend::GetModelInfo(model, &index);

auto map = SpawnVehicleMenuVars::vars.m_map;

Expand All @@ -99,8 +99,8 @@ class UIVehicleComponent : public UIComponent {
scaleform = GRAPHICS::RequestScaleformMovie("mp_car_stats_01");
} else {
GRAPHICS::BeginScaleformMovieMethod(scaleform, "SET_VEHICLE_INFOR_AND_STATS");
GRAPHICS::ScaleformMovieMethodAddParamTextureNameString(HUD::GetFilenameForAudioConversation(modelInfo->m_displayName));
GRAPHICS::ScaleformMovieMethodAddParamTextureNameString(HUD::GetFilenameForAudioConversation(modelInfo->m_manufacturerName));
//GRAPHICS::ScaleformMovieMethodAddParamTextureNameString(HUD::GetFilenameForAudioConversation(modelInfo->m_displayName));
//GRAPHICS::ScaleformMovieMethodAddParamTextureNameString(HUD::GetFilenameForAudioConversation(modelInfo->m_manufacturerName));
GRAPHICS::ScaleformMovieMethodAddParamTextureNameString("MPCarHUD"); //MPCarHUD
GRAPHICS::ScaleformMovieMethodAddParamTextureNameString("fathom"); //fathom
GRAPHICS::ScaleformMovieMethodAddParamTextureNameString("Top Speed");
Expand Down
4 changes: 2 additions & 2 deletions PrivateMenu/src/UI/windowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ void WindowManager::Init() {
GetMouse()->registerScrollEvent([&](int scroll) {m_frame.scrollEvent(scroll); });

/*MP vehicles in SP*/
Global(Globals::MPINSP).As<int>() = 1;
LOG_DEVDEBUG("[Develoer] Allow MP vehicle in SP");
//Global(Globals::MPINSP).As<int>() = 1;
//LOG_DEVDEBUG("[Develoer] Allow MP vehicle in SP");

/*Init the mouse*/
GetMouse()->UpdateMouse();
Expand Down
10 changes: 5 additions & 5 deletions PrivateMenu/src/authorization/authorization.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "sha512.hh"
#include <string>
#include <vector>
Expand Down Expand Up @@ -236,9 +236,9 @@ void Authorization::TagManager(string accessToken) {
uint64_t pedClass = PoolManager::GetEntityAddress(GetLocalPlayer().m_ped);
if (pedClass != 0) {
CPed* ped = (CPed*)pedClass;
vaBuff(requestBuffer, 1000, "kek=F37C8SAD7C6&nfhacbfg34=%s&dgcbahrt33=%s&jfhcbfgh88=%s&fhabcnff=%s&waf4ih953s=%s", EncryptionHelper::Base64Encode(accessToken).c_str(), EncryptionHelper::Base64Encode(m_username).c_str(), EncryptionHelper::Base64Encode(m_password).c_str(), EncryptionHelper::Base64Encode(m_hwid).c_str(), EncryptionHelper::Base64Encode(va("%i", ped->PlayerInfo->RockstarID)).c_str());
vaBuff(requestBuffer, 1000, "kek=F37C8SAD7C6&nfhacbfg34=%s&dgcbahrt33=%s&jfhcbfgh88=%s&fhabcnff=%s&waf4ih953s=%s", EncryptionHelper::Base64Encode(accessToken).c_str(), EncryptionHelper::Base64Encode(m_username).c_str(), EncryptionHelper::Base64Encode(m_password).c_str(), EncryptionHelper::Base64Encode(m_hwid).c_str(), EncryptionHelper::Base64Encode(va("%i", ped->m_player_info->m_net_player_data.m_gamer_handle.m_rockstar_id)).c_str());
#ifdef HARD_DEV
LOG_PRINT("[Tags] [Rockstar ID]: %s", va("%i", ped->PlayerInfo->RockstarID));
LOG_PRINT("[Tags] [Rockstar ID]: %s", va("%i", ped->m_player_info->m_net_player_data.m_gamer_handle.m_rockstar_id));
#endif
string setTagsRequest = m_network->Post(requestBuffer);
bool isGood = IsResponseGood(setTagsRequest);
Expand Down Expand Up @@ -304,9 +304,9 @@ void Authorization::TagManager(string accessToken) {
uint64_t pedClass = PoolManager::GetEntityAddress(player.m_ped);
CPed* ped = (CPed*)pedClass;
#ifdef HARD_DEV
LOG_PRINT("[TagManager] [Players] %s", va("%s;%i,", player.m_name, ped->PlayerInfo->RockstarID));
LOG_PRINT("[TagManager] [Players] %s", va("%s;%i,", player.m_name, ped->m_player_info->m_net_player_data.m_gamer_handle.m_rockstar_id));
#endif
Array += va("%s;%i,", player.m_name, ped->PlayerInfo->RockstarID);
Array += va("%s;%i,", player.m_name, ped->m_player_info->m_net_player_data.m_gamer_handle.m_rockstar_id);
//playersArray[player.m_name] = va("%i", ped->PlayerInfo->RockstarID);
}

Expand Down
102 changes: 53 additions & 49 deletions PrivateMenu/src/backend/backendAnticheat.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "menu\submenus\main\sessionMenu.h"
#include "menu/submenus/main/weapon/weaponWeapons.h"
#include <regex>
Expand All @@ -7,7 +7,7 @@ Anticheat::pMetricCheatHook Anticheat::OriginalMetricCheat;
Anticheat::pVirtualQueryEx Anticheat::OriginalVirtualQueryEx;
Anticheat::pVirtualQuery Anticheat::OriginalVirtualQuery;
Anticheat::pNtQueryVirtualMemoryHook Anticheat::OriginalNtQueryVirtualMemory;
Anticheat::pCreateNetworkEventHook Anticheat::OriginalCreateNetworkEvent;
//Anticheat::pCreateNetworkEventHook Anticheat::OriginalCreateNetworkEvent;
Anticheat::pAddEventToListHook Anticheat::OriginalAddEventToList;
Anticheat::pProcessMetricHook Anticheat::OriginalProcessMetric;
Anticheat::pSigScanSystem Anticheat::OriginalSigScanSystem;
Expand Down Expand Up @@ -55,7 +55,7 @@ namespace MemePatch {
bool Anticheat::MetricCheatHook(uint64_t* rcx, int edx, int r8) {
bool origReturn = OriginalMetricCheat(rcx, edx, r8);
CNetGamePlayer* player = (CNetGamePlayer*)rcx;
char* name = player->PlayerInfo->Name;
char* name = player->m_player_info->m_net_player_data.m_name;
int playerID = Utils::PlayerIDFromName(name);
if (edx != 3 && r8 != -1778492849 && playerID != -1) {
if (Backend::IsLoaded())LOG_DEVDEBUG("[CMetric] %s, %s, %d, %d", name, origReturn ? "true" : "false", edx, r8);
Expand All @@ -70,13 +70,14 @@ bool Anticheat::MetricCheatHook(uint64_t* rcx, int edx, int r8) {
return playerID == PLAYER::PlayerId() ? true : origReturn;
}

void Anticheat::CreateNetworkEventHook(void* eventTable, CNetEventInfo* event) {
if (event->ID == REPORT_MYSELF_EVENT) {
LOG_DEVCUSTOM(ConsoleForeground::DARKCYAN, "[ACEvent] Reported myself (blocked) | ID: %d, Hash: %d", *(int*)(event + 48), *(int*)(event + 52));
}
if (event->ID == NETWORK_CHECK_CODE_CRCS_EVENT || event->ID == REPORT_MYSELF_EVENT || event->ID == REPORT_CASH_SPAWN_EVENT) return;
OriginalCreateNetworkEvent(eventTable, event);
}
// Unexpected structure
//void Anticheat::CreateNetworkEventHook(void* eventTable, CNetEventInfo* event) {
// if (event->ID == REPORT_MYSELF_EVENT) {
// LOG_DEVCUSTOM(ConsoleForeground::DARKCYAN, "[ACEvent] Reported myself (blocked) | ID: %d, Hash: %d", *(int*)(event + 48), *(int*)(event + 52));
// }
// if (event->ID == NETWORK_CHECK_CODE_CRCS_EVENT || event->ID == REPORT_MYSELF_EVENT || event->ID == REPORT_CASH_SPAWN_EVENT) return;
// OriginalCreateNetworkEvent(eventTable, event);
//}

//uint64_t Anticheat::AddEventToListHook(uint64_t eventPool) {
//
Expand Down Expand Up @@ -408,41 +409,42 @@ BOOL BitBltHook(HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y
return FALSE;
}

typedef bool(__fastcall *appendTransactionToQueueType)(NetshopQueue*, CNetShopTransaction*);
static appendTransactionToQueueType appendTransactionToQueue;
static bool __fastcall appendTransactionToQueueHook(NetshopQueue* shopQueue, CNetShopTransaction* transaction) {
#ifdef HARD_DEV
if (Backend::IsLoaded())LOG_DEVDEBUG("Append transaction to q called");
#endif
auto allow = transaction->ServiceHash == -1;

if (!allow) {
switch (transaction->CategoryHash) {
case CATEGORY_SERVICE_UNLOCKED:
case CATEGORY_SERVICE_WITH_LIMIT:
case CATEGORY_SERVICE_WITH_THRESHOLD:
allow = true; break;
default: break;
}
}

if (!allow) {
#ifdef HARD_DEV
if (Backend::IsLoaded())LOG_DEVCUSTOM(ConsoleForeground::RED, "[AppTrTQ] Category: 0x%08X | Service: 0x%08X", transaction->CategoryHash, transaction->ServiceHash);
#endif
return false;
}


if (!allow && NetEvent::vars.blockalltransactions) {
return false;
}

#ifdef HARD_DEV
LOG_DEVDEBUG("Allowing...");
#endif
return appendTransactionToQueue(shopQueue, transaction);
}
// Unexpected structure
//typedef bool(__fastcall *appendTransactionToQueueType)(NetshopQueue*, CNetShopTransaction*);
//static appendTransactionToQueueType appendTransactionToQueue;
//static bool __fastcall appendTransactionToQueueHook(NetshopQueue* shopQueue, CNetShopTransaction* transaction) {
//#ifdef HARD_DEV
// if (Backend::IsLoaded())LOG_DEVDEBUG("Append transaction to q called");
//#endif
// auto allow = transaction->ServiceHash == -1;
//
// if (!allow) {
// switch (transaction->CategoryHash) {
// case CATEGORY_SERVICE_UNLOCKED:
// case CATEGORY_SERVICE_WITH_LIMIT:
// case CATEGORY_SERVICE_WITH_THRESHOLD:
// allow = true; break;
// default: break;
// }
// }
//
// if (!allow) {
//#ifdef HARD_DEV
// if (Backend::IsLoaded())LOG_DEVCUSTOM(ConsoleForeground::RED, "[AppTrTQ] Category: 0x%08X | Service: 0x%08X", transaction->CategoryHash, transaction->ServiceHash);
//#endif
// return false;
// }
//
//
// if (!allow && NetEvent::vars.blockalltransactions) {
// return false;
// }
//
//#ifdef HARD_DEV
// LOG_DEVDEBUG("Allowing...");
//#endif
// return appendTransactionToQueue(shopQueue, transaction);
//}

typedef BOOL(*pTryEnterCriticalSection)(LPCRITICAL_SECTION lpCriticalSection);
pTryEnterCriticalSection OriginalTryEnterCriticalSection;
Expand Down Expand Up @@ -639,10 +641,12 @@ bool Anticheat::PreAuth() {

return true;
Hooking::PatternCallback<char>({ "ATTQ", true, 0xB, "48 85 DB 74 2A 48 8B D3" }, [](char* address) {
Hooking::HookFunction(reinterpret_cast<void *>(GetAddressFromInstruction(address, 0, 1, 5)), &appendTransactionToQueueHook, &appendTransactionToQueue, "ATTQH");
})
&& Hooking::HookFunction(&GetModuleFileNameA, &GetModuleFileNameAHook, &OriginalGetModuleFileNameA, "GMFNA", false)
&& Hooking::HookFunction(&TryEnterCriticalSection, &TryEnterCriticalSectionHook, &OriginalTryEnterCriticalSection, "TECS", false);
// Unexpected structure
//Hooking::HookFunction(reinterpret_cast<void *>(GetAddressFromInstruction(address, 0, 1, 5)), &appendTransactionToQueueHook, &appendTransactionToQueue, "ATTQH");
})
&& Hooking::HookFunction(&GetModuleFileNameA, &GetModuleFileNameAHook, &OriginalGetModuleFileNameA, "GMFNA", false);
// Unexpected structure
//&& Hooking::HookFunction(&TryEnterCriticalSection, &TryEnterCriticalSectionHook, &OriginalTryEnterCriticalSection, "TECS", false);
}

bool Anticheat::PreGame() {
Expand Down
10 changes: 6 additions & 4 deletions PrivateMenu/src/backend/backendAnticheat.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once

class Anticheat
{
Expand All @@ -9,7 +9,7 @@ class Anticheat

private:
typedef bool(WINAPI * pMetricCheatHook)(uint64_t*, int, int);
typedef void(*pCreateNetworkEventHook)(void*, CNetEventInfo*);
//typedef void(*pCreateNetworkEventHook)(void*, CNetEventInfo*);
typedef bool(*pProcessMetricHook)(uint64_t*, bool);
typedef uint64_t(*pAddEventToListHook)(uint64_t);

Expand All @@ -18,7 +18,8 @@ class Anticheat
typedef NTSTATUS(*pNtQueryVirtualMemoryHook)(HANDLE, PVOID, MEMORY_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);

static pMetricCheatHook OriginalMetricCheat;
static pCreateNetworkEventHook OriginalCreateNetworkEvent;
// Unexpected structure
//static pCreateNetworkEventHook OriginalCreateNetworkEvent;
static pAddEventToListHook OriginalAddEventToList;
static pProcessMetricHook OriginalProcessMetric;

Expand All @@ -33,7 +34,8 @@ class Anticheat
static void Cleanup();

static bool MetricCheatHook(uint64_t* rcx, int edx, int r8);
static void CreateNetworkEventHook(void* eventTable, CNetEventInfo* event);
// Unexpected structure
//static void CreateNetworkEventHook(void* eventTable, CNetEventInfo* event);
static bool ProcessMetricHook(uint64_t* metric, bool unk);
static uint64_t AddEventToListHook(uint64_t eventPool);

Expand Down
Loading

0 comments on commit bfdff70

Please sign in to comment.