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

Basic online compatibility and a lot of other stuff #24

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
75fb179
feat(invoker): add an invoker
Aug 25, 2023
7813441
feat(debug): add entrypoint dumper
Aug 25, 2023
c7e92b7
finishing touches
Aug 26, 2023
298f2a6
Merge branch 'YimMenu:master' into master
maybegreat48 Aug 26, 2023
bccf1a9
feat(settings): add settings
Sep 10, 2023
d6c572b
feat(anticheat_bypass): hook SendMetric
Sep 12, 2023
4debc4a
feat(menu): basic online support
Sep 17, 2023
e64aec7
feat(vc): add voice chat override
Sep 23, 2023
1728dd0
feat(gui): GUI refactor
Sep 24, 2023
7f7a78f
fix: fix hotkeys
Sep 24, 2023
f48b465
feat(protections): add a basic remote TP protection (untested)
Sep 29, 2023
da81ae2
fix: rewrite gadget protection
Sep 30, 2023
cb455c5
fix: don't zero out entity ptr
Sep 30, 2023
182a9c2
feat(protections): basic sync protections
Oct 2, 2023
d1cef45
feat(protections): improve protections
Oct 7, 2023
340050c
Merge
Oct 7, 2023
31284af
Merge with master
Oct 8, 2023
c6f7f42
fix(renderer): add font support for Vulkan renderer
Oct 8, 2023
a6ec5cb
feat(protections): improve protections
Oct 8, 2023
88be623
feat: more protections
Oct 9, 2023
0627b38
feat(players): add a player service
Oct 9, 2023
896de5e
finishing touches
Oct 9, 2023
afd56c9
Merge branch 'master' of https://github.com/maybegreat48/HorseMenu in…
Oct 9, 2023
c9c4c4b
Merge
Oct 9, 2023
a520703
fix merge
Oct 9, 2023
867267b
fix: code review fixes
Oct 10, 2023
61c6acd
Added tp to waypoint
DayibBaba Oct 11, 2023
c7eed1e
Notification service & some features
DayibBaba Oct 11, 2023
4740146
Added expiry bar to notifications
DayibBaba Oct 11, 2023
a2ed69d
feat(protections): add an object model mismatch check
Oct 12, 2023
6420422
Merge DayibBaba's branch
Oct 12, 2023
8f11723
Merge Marcezsa's patch
Oct 12, 2023
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
9 changes: 7 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@
"unordered_set": "cpp",
"valarray": "cpp",
"variant": "cpp",
"xtree": "cpp"
"xtree": "cpp",
"codecvt": "cpp",
"coroutine": "cpp",
"resumable": "cpp",
"stack": "cpp"
},
"C_Cpp.default.configurationProvider": "maxmitti.cmake-tools-fork"
"C_Cpp.default.configurationProvider": "maxmitti.cmake-tools-fork",
"C_Cpp.errorSquiggles": "disabled"
}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ target_include_directories(${PROJECT_NAME} PRIVATE
"${SRC_DIR}"
"${imgui_SOURCE_DIR}"
"${minhook_SOURCE_DIR}/include"
"${minhook_SOURCE_DIR}/src/hde"
"${rdr_classes_SOURCE_DIR}"
"${vulkan_SOURCE_DIR}/include"
)

message(STATUS "Setting up linked libraries")
target_link_libraries(${PROJECT_NAME} PRIVATE AsyncLogger imgui minhook nlohmann_json::nlohmann_json "${DEPS_DIR}/vulkan-1.lib")
target_link_libraries(${PROJECT_NAME} PRIVATE AsyncLogger imgui minhook nlohmann_json::nlohmann_json dbghelp "${DEPS_DIR}/vulkan-1.lib")
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 6bf009fae77419a9a1e249ddb711987422cf9822
GIT_TAG 0132075d1c6a88066ce6f6225f168a49e76a51a3
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
1 change: 1 addition & 0 deletions src/common.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX

#include <AsyncLogger/Logger.hpp>
#include <MinHook.h>
Expand Down
25 changes: 23 additions & 2 deletions src/core/commands/BoolCommand.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "BoolCommand.hpp"
#include "game/backend/FiberPool.hpp" // TODO: game import in core

namespace YimMenu
{
Expand All @@ -12,6 +13,16 @@ namespace YimMenu
SetState(!m_State);
}

void BoolCommand::SaveState(nlohmann::json& value)
{
value = m_State;
}

void BoolCommand::LoadState(nlohmann::json& value)
{
m_State = value;
}

bool BoolCommand::GetState()
{
return m_State;
Expand All @@ -20,10 +31,20 @@ namespace YimMenu
void BoolCommand::SetState(bool state)
{
if (state && !m_State)
OnEnable();
FiberPool::Push([this] {
OnEnable();
});
else if (!state && m_State)
OnDisable();
FiberPool::Push([this] {
OnDisable();
});

m_State = state;
MarkDirty();
}

void BoolCommand::Shutdown()
{
OnDisable();
}
}
3 changes: 3 additions & 0 deletions src/core/commands/BoolCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ namespace YimMenu
virtual void OnEnable(){};
virtual void OnDisable(){};
virtual void OnCall() override;
virtual void SaveState(nlohmann::json& value) override;
virtual void LoadState(nlohmann::json& value) override;

bool m_State = false;

public:
BoolCommand(std::string name, std::string label, std::string description);
bool GetState();
void SetState(bool state);
void Shutdown();
};
}
5 changes: 5 additions & 0 deletions src/core/commands/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ namespace YimMenu
{
OnCall();
}

void Command::MarkDirty()
{
Commands::MarkDirty();
}
}
5 changes: 4 additions & 1 deletion src/core/commands/Command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ namespace YimMenu

protected:
virtual void OnCall() = 0;

void MarkDirty();

public:
Command(std::string name, std::string label, std::string description, int num_args = 0);
void Call();

virtual void SaveState(nlohmann::json& value){};
virtual void LoadState(nlohmann::json& value){};

const std::string& GetName()
{
return m_Name;
Expand Down
32 changes: 32 additions & 0 deletions src/core/commands/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

namespace YimMenu
{
Commands::Commands() :
IStateSerializer("commands")
{
}

void Commands::AddCommandImpl(Command* command)
{
m_Commands.insert({command->GetHash(), command});
Expand All @@ -27,4 +32,31 @@ namespace YimMenu
return it->second;
return nullptr;
}

void Commands::SaveStateImpl(nlohmann::json& state)
{
for (auto& command : m_Commands)
{
if (!state.contains(command.second->GetName()))
state[command.second->GetName()] = nlohmann::json::object();

command.second->SaveState(state[command.second->GetName()]);
}
}

void Commands::LoadStateImpl(nlohmann::json& state)
{
for (auto& command : m_Commands)
{
if (state.contains(command.second->GetName()))
command.second->LoadState(state[command.second->GetName()]);
}
}

void Commands::ShutdownImpl()
{
for (auto& command : m_LoopedCommands)
if (command->GetState())
command->Shutdown();
}
}
19 changes: 17 additions & 2 deletions src/core/commands/Commands.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#pragma once
#include "util/Joaat.hpp"
#include "core/settings/IStateSerializer.hpp"

namespace YimMenu
{
class Command;
class LoopedCommand;

class Commands
class Commands :
private IStateSerializer
{
private:
std::unordered_map<joaat_t, Command*> m_Commands;
std::vector<LoopedCommand*> m_LoopedCommands;
Commands(){};
Commands();

public:
static void AddCommand(Command* command)
Expand Down Expand Up @@ -46,11 +48,24 @@ namespace YimMenu
return GetInstance().m_LoopedCommands;
}

static void MarkDirty()
{
GetInstance().MarkStateDirty();
}

static void Shutdown()
{
GetInstance().ShutdownImpl();
}

private:
void AddCommandImpl(Command* command);
void AddLoopedCommandImpl(LoopedCommand* command);
void RunLoopedCommandsImpl();
Command* GetCommandImpl(joaat_t hash);
virtual void SaveStateImpl(nlohmann::json& state) override;
virtual void LoadStateImpl(nlohmann::json& state) override;
void ShutdownImpl();

static Commands& GetInstance()
{
Expand Down
69 changes: 38 additions & 31 deletions src/core/commands/HotkeySystem.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
#include "HotkeySystem.hpp"

#include "game/rdr/Natives.hpp"
#include "game/rdr/Natives.hpp" // TODO: game import in core
#include "game/backend/ScriptMgr.hpp"
#include "Commands.hpp"
#include "LoopedCommand.hpp"

// TODO: hotkeys

// TODO: serialization isn't stable

namespace YimMenu
{
HotkeySystem::HotkeySystem() :
IStateSerializer("hotkeys")
{
}

void HotkeySystem::RegisterCommands()
{
auto Commands = Commands::GetCommands();
auto LoopedCommands = Commands::GetLoopedCommands();

for (auto [Hash, Command] : Commands)
{
CommandLink link(false);
CommandLink link;
m_CommandHotkeys.insert(std::make_pair(Command->GetHash(), link));
}

for (auto looped_command : LoopedCommands)
{
CommandLink link(true);
m_CommandHotkeys.insert(std::make_pair(looped_command->GetHash(), link));
}

LOG(INFO) << "Registered " << m_CommandHotkeys.size() << " commands";
}

Expand All @@ -41,7 +37,7 @@ namespace YimMenu
return false;
};

//VK_OEM_CLEAR Is about the limit in terms of virtual key codes
// VK_OEM_CLEAR Is about the limit in terms of virtual key codes
for (int i = 0; i < VK_OEM_CLEAR; i++)
{
if ((GetKeyState(i) & 0x8000) && i != 1 && !IsKeyBlacklisted(i))
Expand All @@ -54,7 +50,8 @@ namespace YimMenu

return false;
}
//Will return the keycode if there are no labels

// Will return the keycode if there are no labels
std::string HotkeySystem::GetHotkeyLabel(int HotkeyModifier)
{
char KeyName[32];
Expand All @@ -66,7 +63,7 @@ namespace YimMenu
return KeyName;
}

//Meant to be called in a loop
// Meant to be called in a loop
void HotkeySystem::CreateHotkey(std::vector<int>& Hotkey)
{
static auto IsKeyUnique = [this](int Key, std::vector<int> List) -> bool {
Expand All @@ -88,6 +85,8 @@ namespace YimMenu
Hotkey.push_back(PressedKey);
}
}

MarkStateDirty();
}

void HotkeySystem::FeatureCommandsHotkeyLoop()
Expand All @@ -109,27 +108,35 @@ namespace YimMenu

if (AllKeysPressed && GetForegroundWindow() == Pointers.Hwnd)
{
if (Link.Looped)
{
auto LoopedCommand_ = Commands::GetCommand<LoopedCommand>(Hash);

if (LoopedCommand_)
LoopedCommand_->SetState(!LoopedCommand_->GetState());

LOG(INFO) << "Hotkey detected for looped command " << LoopedCommand_->GetName();
}
else
auto Command = Commands::GetCommand(Hash);
if (Command)
{
auto Command = Commands::GetCommand(Hash);
if (Command)
{
Command->Call();
LOG(INFO) << "Hotkey detected for command " << Command->GetName();
}
Command->Call();
LOG(INFO) << "Hotkey detected for command " << Command->GetName();
}

ScriptMgr::Yield(100ms);
}
}
}

void HotkeySystem::SaveStateImpl(nlohmann::json& state)
{
for (auto& hotkey : m_CommandHotkeys)
{
if (!hotkey.second.Hotkey.empty())
{
state[std::to_string(hotkey.first).data()] = hotkey.second.Hotkey;
}
}
}

void HotkeySystem::LoadStateImpl(nlohmann::json& state)
{
for (auto& [key, value] : state.items())
{
if (m_CommandHotkeys.contains(std::atoi(key.data())))
m_CommandHotkeys[std::atoi(key.data())].Hotkey = value.get<std::vector<int>>();
}
}
}
Loading