Skip to content

Commit

Permalink
Merge branch 'master' into recreate-a-playerdatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxann authored Jun 25, 2024
2 parents e05cfe7 + 8025d4f commit 518c4af
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmake/rdr-classes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(FetchContent)
FetchContent_Declare(
rdr_classes
GIT_REPOSITORY https://github.com/YimMenu/RDR-Classes.git
GIT_TAG 79b0389bcfc7a616290ec3ec97ce4fa6a574d0ed
GIT_TAG 70091e27d2e0e515f0e34cb1983ab965421dab0e
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
2 changes: 2 additions & 0 deletions src/core/hooking/Hooking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace YimMenu
BaseHook::Add<Hooks::Protections::ReceiveNetMessage>(new DetourHook("ReceiveNetMessage", Pointers.ReceiveNetMessage, Hooks::Protections::ReceiveNetMessage));
BaseHook::Add<Hooks::Protections::HandlePresenceEvent>(new DetourHook("HandlePresenceEvent", Pointers.HandlePresenceEvent, Hooks::Protections::HandlePresenceEvent));
BaseHook::Add<Hooks::Protections::PPostMessage>(new DetourHook("PostMessage", Pointers.PostPresenceMessage, Hooks::Protections::PPostMessage));
BaseHook::Add<Hooks::Protections::SerializeServerRPC>(new DetourHook("SerializeServerRPC", Pointers.SerializeServerRPC, Hooks::Protections::SerializeServerRPC));
BaseHook::Add<Hooks::Protections::ReceiveServerMessage>(new DetourHook("ReceiveServerMessage", Pointers.ReceiveServerMessage, Hooks::Protections::ReceiveServerMessage));

BaseHook::Add<Hooks::Voice::EnumerateAudioDevices>(new DetourHook("EnumerateAudioDevices", Pointers.EnumerateAudioDevices, Hooks::Voice::EnumerateAudioDevices));
BaseHook::Add<Hooks::Voice::DirectSoundCaptureCreate>(new DetourHook("DirectSoundCaptureCreate", Pointers.DirectSoundCaptureCreate, Hooks::Voice::DirectSoundCaptureCreate));
Expand Down
1 change: 0 additions & 1 deletion src/game/frontend/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace YimMenu
UIManager::AddSubmenu(std::make_shared<Submenus::Players>());
UIManager::AddSubmenu(std::make_shared<Submenus::World>());
UIManager::AddSubmenu(std::make_shared<Submenus::Settings>());
// Wierd glitch causes menu to crash when clicking debug
UIManager::AddSubmenu(std::make_shared<Submenus::Debug>());

Renderer::AddRendererCallBack(
Expand Down
1 change: 1 addition & 0 deletions src/game/frontend/submenus/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ namespace YimMenu::Submenus
});
}
}));
debug->AddItem(std::make_shared<BoolCommandItem>("logservermessages"_J));
AddCategory(std::move(debug));
}
}
1 change: 1 addition & 0 deletions src/game/frontend/submenus/Self.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace YimMenu::Submenus

globalsGroup->AddItem(std::make_shared<BoolCommandItem>("drunk"_J));
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("superpunch"_J));
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("unlimiteditems"_J));


toolsGroup->AddItem(std::make_shared<CommandItem>("suicide"_J));
Expand Down
5 changes: 5 additions & 0 deletions src/game/hooks/Hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace rage
};
#pragma pack(pop)
class rlGamerInfo;
class ServerMsg;
class ServerMsgData;
class ServerRPCSerializer;
}
class CNetGamePlayer;
enum class NetEventType;
Expand Down Expand Up @@ -100,6 +103,8 @@ namespace YimMenu::Hooks
extern bool ReceiveNetMessage(void* netConnectionManager, void* a2, rage::InFrame* frame);
extern bool HandlePresenceEvent(uint64_t a1, rage::rlGamerInfo* gamerInfo, unsigned int sender, const char** payload, const char* channel);
extern bool PPostMessage(int localGamerIndex, rage::rlGamerInfo* recipients, int numRecipients, const char* msg, unsigned int ttlSeconds);
extern bool SerializeServerRPC(rage::ServerRPCSerializer* ser, void* a2, const char* message, void* def, void* structure, const char* rpc_guid, void* a7);
extern bool ReceiveServerMessage(void* a1, rage::ServerMsg* a2); // doesn't receive all messages
}

namespace Voice
Expand Down
44 changes: 44 additions & 0 deletions src/game/hooks/Protections/ServerMessages.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "core/commands/BoolCommand.hpp"
#include "core/hooking/DetourHook.hpp"
#include "game/hooks/Hooks.hpp"
#include "util/Joaat.hpp"
#include "util/StrToHex.hpp"

#include <network/netServerMessages.hpp>


namespace YimMenu::Features
{
BoolCommand _UnlimitedItems{"unlimiteditems", "Unlimited Items", "Never run out of items in your inventory!"};
BoolCommand _LogServerMessages{"logservermessages", "Log Server Messages", "Log Server Messages"};
}

namespace YimMenu::Hooks
{
bool Protections::ReceiveServerMessage(void* a1, rage::ServerMsg* a2)
{
if (Features::_LogServerMessages.GetState())
{
LOG(INFO) << __FUNCTION__ << ": " << a2->GetName() << ": "
<< hexStr((unsigned char*)a2->GetMsgData()->data, a2->GetMsgData()->size);
}
return BaseHook::Get<ReceiveServerMessage, DetourHook<decltype(&ReceiveServerMessage)>>()->Original()(a1, a2);
}

bool Protections::SerializeServerRPC(rage::ServerRPCSerializer* ser, void* a2, const char* message, void* def, void* structure, const char* rpc_guid, void* a7)
{
// TODO: remove ret variable and just return original instead of storing it
bool ret = BaseHook::Get<SerializeServerRPC, DetourHook<decltype(&SerializeServerRPC)>>()->Original()(ser, a2, message, def, structure, rpc_guid, a7);
if (Features::_LogServerMessages.GetState())
{
LOG(INFO) << __FUNCTION__ << ": " << message << ": " << hexStr((unsigned char*)ser->GetData(), ser->GetSize());
if (rpc_guid)
LOG(INFO) << "RPC Guid"
" = "
<< rpc_guid;
}
if (Joaat(message) == "UseItems"_J && Features::_UnlimitedItems.GetState())
return false;
return ret;
}
}
4 changes: 1 addition & 3 deletions src/game/hooks/Spoofing/SendNetInfoToLobby.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "core/commands/BoolCommand.hpp"
#include "core/commands/Commands.hpp"
#include "core/hooking/DetourHook.hpp"
#include "game/hooks/Hooks.hpp"
#include "game/rdr/Natives.hpp"
Expand All @@ -12,7 +10,7 @@ namespace YimMenu::Hooks
{
bool Spoofing::SendNetInfoToLobby(rage::rlGamerInfo* local_player, int64_t a2, int64_t a3, DWORD* a4)
{
if (!g_SpoofingStorage.spoofed_name.empty())
if (!g_SpoofingStorage.spoofed_name.empty() && !SCRIPTS::IS_LOADING_SCREEN_VISIBLE())
memcpy(local_player->m_Name, g_SpoofingStorage.spoofed_name.c_str(), sizeof(local_player->m_Name));

return BaseHook::Get<Spoofing::SendNetInfoToLobby, DetourHook<decltype(&Spoofing::SendNetInfoToLobby)>>()->Original()(local_player, a2, a3, a4);
Expand Down
10 changes: 10 additions & 0 deletions src/game/pointers/Pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ namespace YimMenu
FwScriptGuidCreateGuid = ptr.Sub(141).As<uint32_t (*)(void*)>();
});

constexpr auto receiveServerMessagePtrn = Pattern<"48 89 5C 24 08 57 48 83 EC 20 48 8B 02 48 8B F9 48 8B CA 48 8B DA FF 50 ?? 48 8B C8">("ReceiveServerMessage");
scanner.Add(receiveServerMessagePtrn, [this](PointerCalculator ptr) {
ReceiveServerMessage = ptr.As<PVOID>();
});

constexpr auto serializeServerRPCPtrn = Pattern<"48 89 5C 24 08 57 48 83 EC 30 48 8B 44 24 70">("SerializeServerRPC");
scanner.Add(serializeServerRPCPtrn, [this](PointerCalculator ptr) {
SerializeServerRPC = ptr.As<PVOID>();
});

if (!scanner.Scan())
{
LOG(FATAL) << "Some patterns could not be found, unloading.";
Expand Down
2 changes: 2 additions & 0 deletions src/game/pointers/Pointers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ namespace YimMenu
PVOID AddObjectToCreationQueue;
PVOID ReceiveNetMessage;
PVOID SendComplaint;
PVOID ReceiveServerMessage;
PVOID SerializeServerRPC;

// Player Stuff
PVOID PlayerHasJoined;
Expand Down
9 changes: 9 additions & 0 deletions src/util/StrToHex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ namespace YimMenu

return ch - 'a' + 10;
}

inline std::string hexStr(unsigned char* data, int len)
{
std::stringstream ss;
ss << std::hex;
for (int i = 0; i < len; ++i)
ss << std::setw(2) << std::setfill('0') << (int)data[i];
return ss.str();
}
}

0 comments on commit 518c4af

Please sign in to comment.