Skip to content

Commit dbfd436

Browse files
authored
feat: Data hash spoofing. (#364)
* feat: Add data hash spoofing. feat: LogCurrentSessionInfo To be deleted. * chore: Remove logcurrentsessioninfo. * chore(PackOrderHook): Move to SpoofDataHash. * chore: Update getDLCHashPtrn to support new version. * chore: Update to 889.15. I hope this is correct... * chore: Remove unused include. * chore: Update data hash to latest. --------- Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
1 parent c4849db commit dbfd436

9 files changed

Lines changed: 123 additions & 3 deletions

File tree

src/core/hooking/Hooking.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace YimMenu
4040
BaseHook::Add<Hooks::Spoofing::WriteSyncTree>(new DetourHook("WriteSyncTree", Pointers.WriteSyncTree, Hooks::Spoofing::WriteSyncTree));
4141

4242
BaseHook::Add<Hooks::Network::GetPoolType>(new DetourHook("GetPoolType", Pointers.GetPoolType, Hooks::Network::GetPoolType));
43+
BaseHook::Add<Hooks::Network::GetDLCHash>(new DetourHook("GetDLCHash", Pointers.GetDLCHash, Hooks::Network::GetDLCHash));
4344

4445
BaseHook::Add<Hooks::Matchmaking::MatchmakingAdvertise>(new DetourHook("MatchmakingAdvertise", Pointers.MatchmakingAdvertise, Hooks::Matchmaking::MatchmakingAdvertise));
4546
BaseHook::Add<Hooks::Matchmaking::MatchmakingSessionDetailSendResponse>(new DetourHook("MatchmakingSessionDetailSendResponse", Pointers.MatchmakingSessionDetailSendResponse, Hooks::Matchmaking::MatchmakingSessionDetailSendResponse));

src/game/backend/AnticheatBypass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "game/gta/Natives.hpp"
88
#include "types/rage/gameSkeleton.hpp"
99
#include "types/anticheat/CAnticheatContext.hpp"
10-
#include "types/game_files/CGameDataHash.hpp"
1110

1211
using FnGetVersion = int (*)();
1312
using FnLocalSaves = bool (*)();
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#include "core/commands/BoolCommand.hpp"
2+
#include "core/hooking/DetourHook.hpp"
3+
#include "game/backend/NativeHooks.hpp"
4+
#include "game/gta/Natives.hpp"
5+
#include "game/hooks/Hooks.hpp"
6+
#include "game/pointers/Pointers.hpp"
7+
#include "types/game_files/CGameDataHash.hpp"
8+
9+
namespace YimMenu::Features
10+
{
11+
class DumpDataHash : public Command
12+
{
13+
using Command::Command;
14+
15+
virtual void OnCall() override
16+
{
17+
auto log = LOG(VERBOSE);
18+
log << "DLC Hash: "
19+
<< BaseHook::Get<Hooks::Network::GetDLCHash, DetourHook<decltype(&Hooks::Network::GetDLCHash)>>()->Original()(
20+
*Pointers.DLCManager,
21+
0)
22+
<< "\n";
23+
if (auto hashes = Pointers.GameDataHash)
24+
{
25+
log << "validHashes = {" << "\n";
26+
for (int i = 0; i < hashes->m_Data.size(); i++)
27+
log << hashes->m_Data[i].getData() << ", // " << i << "\n";
28+
log << "};";
29+
}
30+
}
31+
};
32+
static DumpDataHash _DumpDataHash{"dumpdatahash", "Dump Data Hash", "Dumps the current data hash into the console"};
33+
34+
static void PackOrderHook(rage::scrNativeCallContext* ctx);
35+
class SpoofDataHash : public BoolCommand
36+
{
37+
using BoolCommand::BoolCommand;
38+
39+
std::array<std::uint32_t, 16> origHashes;
40+
41+
virtual void OnEnable() override
42+
{
43+
NativeHooks::AddHook(NativeHooks::ALL_SCRIPTS, NativeIndex::GET_EVER_HAD_BAD_PACK_ORDER, &PackOrderHook);
44+
45+
constexpr std::array<std::uint32_t, 16> validHashes = {
46+
1222354255, // 0
47+
1017, // 1
48+
2008403316, // 2
49+
472, // 3
50+
0, // 4
51+
0, // 5
52+
1061472380, // 6
53+
0, // 7
54+
0, // 8
55+
1731098795, // 9
56+
234493012, // 10
57+
19919, // 11
58+
4002619495, // 12
59+
307143837, // 13
60+
2941593772, // 14
61+
200299391, // 15
62+
};
63+
if (auto hashes = Pointers.GameDataHash)
64+
{
65+
for (int i = 0; i < hashes->m_Data.size(); i++)
66+
origHashes[i] = hashes->m_Data[i];
67+
68+
for (int i = 0; i < validHashes.size(); i++)
69+
hashes->m_Data[i] = validHashes[i];
70+
}
71+
}
72+
73+
virtual void OnDisable() override
74+
{
75+
if (auto hashes = Pointers.GameDataHash)
76+
{
77+
for (int i = 0; i < origHashes.size(); i++)
78+
hashes->m_Data[i] = origHashes[i];
79+
}
80+
}
81+
};
82+
83+
static SpoofDataHash _SpoofDataHash{"spoofdatahash", "Spoof Data Hash", "Allows you to join players with rpf mods (or a half installed game)."};
84+
85+
static void PackOrderHook(rage::scrNativeCallContext* ctx)
86+
{
87+
return ctx->SetReturnValue(FALSE);
88+
}
89+
}
90+
91+
namespace YimMenu::Hooks
92+
{
93+
uint32_t Network::GetDLCHash(void* manager, uint32_t seed)
94+
{
95+
if (YimMenu::Features::_SpoofDataHash.GetState())
96+
return 2784221708;
97+
98+
return BaseHook::Get<Network::GetDLCHash, DetourHook<decltype(&Network::GetDLCHash)>>()->Original()(manager, seed);
99+
}
100+
}

src/game/frontend/submenus/Debug/Misc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ namespace YimMenu::Submenus
5858
}
5959
}));
6060

61+
misc->AddItem(std::make_shared<CommandItem>("dumpdatahash"_J));
62+
6163
return misc;
6264
}
6365
}

src/game/frontend/submenus/Network.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "core/frontend/Notifications.hpp"
44
#include "game/frontend/items/Items.hpp"
55
#include "game/frontend/submenus/Network/SavedPlayers.hpp"
6-
#include "game/gta/Network.hpp"
76
#include "game/frontend/submenus/Network/RandomEvents.hpp"
7+
#include "game/gta/Network.hpp"
88

99
namespace YimMenu::Submenus
1010
{
@@ -111,6 +111,7 @@ namespace YimMenu::Submenus
111111
spoofMMRegion->AddItem(std::make_shared<BoolCommandItem>("spoofmmregion"_J, "Spoof Region"));
112112
spoofMMRegion->AddItem(std::make_shared<ConditionalItem>("spoofmmregion"_J, std::make_shared<ListCommandItem>("mmregion"_J, "##mmregion")));
113113
matchmakingGroup->AddItem(std::make_shared<ConditionalItem>("cheaterpool"_J, spoofMMRegion, true));
114+
matchmakingGroup->AddItem(std::make_shared<BoolCommandItem>("spoofdatahash"_J));
114115
spoofing->AddItem(matchmakingGroup);
115116

116117
auto matchmakingSrvGroup = std::make_shared<Group>("Matchmaking (Server)");

src/game/hooks/Hooks.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ namespace YimMenu::Hooks
8787
extern void ReceiveNetMessage(void* a1, rage::netConnectionManager* mgr, rage::netEvent* event);
8888
extern void ReceiveNetGameEvent(Player player, uint16_t event_id, uint32_t event_index, uint32_t event_handled_bits, rage::datBitBuffer& buffer);
8989
extern bool HandleScriptedGameEvent(Player player, CScriptedGameEvent& event);
90+
extern uint32_t GetDLCHash(void* manager, uint32_t seed);
9091
extern int GetPoolType();
9192
}
9293

src/game/pointers/Pointers.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "core/memory/ModuleMgr.hpp"
55
#include "core/memory/PatternScanner.hpp"
66
#include "core/util/Joaat.hpp"
7+
#include "types/network/rlSessionInfo.hpp"
78
#include "types/rage/atArray.hpp"
89

910
namespace YimMenu
@@ -389,6 +390,17 @@ namespace YimMenu
389390
BattlEyeServerProcessPlayerJoin = ptr.Sub(4).Rip().As<PVOID*>()[1];
390391
});
391392

393+
constexpr auto gameDataHashPtrn = Pattern<"48 8D 3D ? ? ? ? 69 C9">("GameDataHash");
394+
scanner.Add(gameDataHashPtrn, [this](PointerCalculator ptr) {
395+
GameDataHash = ptr.Add(3).Rip().As<CGameDataHash*>();
396+
});
397+
398+
constexpr auto getDLCHashPtrn = Pattern<"31 D2 E8 ? ? ? ? 3B 84">("GetDLCHash&DLCManager");
399+
scanner.Add(getDLCHashPtrn, [this](PointerCalculator ptr) {
400+
DLCManager = ptr.Sub(4).Rip().As<void**>();
401+
GetDLCHash = ptr.Add(3).Rip().As<PVOID>();
402+
});
403+
392404
constexpr auto assistedAimShouldReleaseEntityPtrn = Pattern<"80 7F 28 04 75 6A">("AssistedAimShouldReleaseEntity");
393405
scanner.Add(assistedAimShouldReleaseEntityPtrn, [this](PointerCalculator ptr) {
394406
AssistedAimShouldReleaseEntity = ptr.Sub(0xF).As<PVOID>();

src/game/pointers/Pointers.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class PoolEncryption;
4242
class CStatsMgr;
4343
class CNetShopTransaction;
4444
class CNetworkSession;
45+
class CGameDataHash;
4546
class CStatsMpCharacterMappingData;
4647
class CAnticheatContext;
4748

@@ -154,6 +155,9 @@ namespace YimMenu
154155
CStatsMpCharacterMappingData* StatsMpCharacterMappingData;
155156
int* HasGTAPlus;
156157
PVOID BattlEyeServerProcessPlayerJoin;
158+
CGameDataHash* GameDataHash;
159+
void** DLCManager;
160+
PVOID GetDLCHash;
157161
PVOID AssistedAimShouldReleaseEntity;
158162
Functions::AssistedAimFindNewTarget AssistedAimFindNewTarget;
159163
rage::gameSkeleton* GameSkeleton;

src/types/game_files/CGameDataHash.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class CGameDataHash
1010
std::array<rage::Obf32, 16> m_Data;
1111
};
1212
static_assert(sizeof(CGameDataHash) == 0x104);
13-
#pragma pack(pop)
13+
#pragma pack(pop)

0 commit comments

Comments
 (0)