mirror of
https://github.com/diamante0018/MW3ServerFreezer.git
synced 2025-04-19 19:52:53 +00:00
Got to a decent point
This commit is contained in:
parent
b9f313af7a
commit
810f743f39
@ -98,11 +98,11 @@ namespace command
|
|||||||
|
|
||||||
if (sync)
|
if (sync)
|
||||||
{
|
{
|
||||||
game::Cmd_ExecuteSingleCommand(0, 0, command.data());
|
game::Cmd_ExecuteSingleCommand(game::LocalClientNum_t::LOCAL_CLIENT_0, 0, command.data());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
game::Cbuf_AddText(0, command.data());
|
game::Cbuf_AddText(game::LocalClientNum_t::LOCAL_CLIENT_0, command.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
|
#include <loader/component_loader.hpp>
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
|
namespace dvar_patches
|
||||||
|
{
|
||||||
|
void dvar_set_from_string_by_name_stub(const char*, const char*)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
class component final : public component_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
utils::hook::call(0x59C0EF, dvar_set_from_string_by_name_stub);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(dvar_patches::component)
|
@ -4,12 +4,13 @@
|
|||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
#include "command.hpp"
|
#include "command.hpp"
|
||||||
|
#include "key_catcher.hpp"
|
||||||
|
|
||||||
namespace exploit
|
namespace exploit
|
||||||
{
|
{
|
||||||
bool exploit = false;
|
bool exploit = false;
|
||||||
|
|
||||||
void cl_netchan_transmit(int a1, unsigned char* data, int size)
|
void cl_netchan_transmit_stub(int a1, unsigned char* data, int size)
|
||||||
{
|
{
|
||||||
if (exploit)
|
if (exploit)
|
||||||
{
|
{
|
||||||
@ -26,11 +27,30 @@ namespace exploit
|
|||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
add_exploit_commands();
|
add_exploit_commands();
|
||||||
|
add_key_hooks();
|
||||||
|
|
||||||
utils::hook::call(0x420E40, cl_netchan_transmit);
|
utils::hook::call(0x420E40, cl_netchan_transmit_stub);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void add_key_hooks()
|
||||||
|
{
|
||||||
|
key_catcher::on_key_press("O", [](const game::LocalClientNum_t&)
|
||||||
|
{
|
||||||
|
command::execute("exploit");
|
||||||
|
});
|
||||||
|
|
||||||
|
key_catcher::on_key_press("L", [](const game::LocalClientNum_t&)
|
||||||
|
{
|
||||||
|
command::execute("undo_exploit");
|
||||||
|
});
|
||||||
|
|
||||||
|
key_catcher::on_key_press("K", [](const game::LocalClientNum_t&)
|
||||||
|
{
|
||||||
|
command::execute("disconnect");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static void add_exploit_commands()
|
static void add_exploit_commands()
|
||||||
{
|
{
|
||||||
command::add("exploit", [](const command::params&)
|
command::add("exploit", [](const command::params&)
|
||||||
|
60
src/component/key_catcher.cpp
Normal file
60
src/component/key_catcher.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
|
#include <loader/component_loader.hpp>
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
|
#include "key_catcher.hpp"
|
||||||
|
|
||||||
|
namespace key_catcher
|
||||||
|
{
|
||||||
|
utils::hook::detour cl_key_event_hook;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::unordered_map<std::string, callback>& get_key_callbacks()
|
||||||
|
{
|
||||||
|
static std::unordered_map<std::string, callback> key_callbacks{};
|
||||||
|
return key_callbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_key_event(game::LocalClientNum_t localClient, int keyID)
|
||||||
|
{
|
||||||
|
auto result = VkKeyScanA(static_cast<CHAR>(keyID));
|
||||||
|
auto VkKey = LOBYTE(result);
|
||||||
|
auto& callbacks = get_key_callbacks();
|
||||||
|
|
||||||
|
for (auto const& i : callbacks)
|
||||||
|
{
|
||||||
|
auto gameVkKey = game::Key_StringToKeynum(i.first.data());
|
||||||
|
if (static_cast<BYTE>(gameVkKey) == VkKey)
|
||||||
|
{
|
||||||
|
i.second(localClient);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_key_press(const std::string& command, const callback& callback)
|
||||||
|
{
|
||||||
|
get_key_callbacks()[command] = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cl_key_event_stub(game::LocalClientNum_t localClient, int keyID, int a3)
|
||||||
|
{
|
||||||
|
handle_key_event(localClient, keyID);
|
||||||
|
|
||||||
|
cl_key_event_hook.invoke<void>(localClient, keyID, a3);
|
||||||
|
}
|
||||||
|
|
||||||
|
class component final : public component_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
cl_key_event_hook.create(0x4CD840, &cl_key_event_stub);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(key_catcher::component)
|
8
src/component/key_catcher.hpp
Normal file
8
src/component/key_catcher.hpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace key_catcher
|
||||||
|
{
|
||||||
|
using callback = std::function<void(game::LocalClientNum_t& localClient)>;
|
||||||
|
|
||||||
|
void on_key_press(const std::string& command, const callback& callback);
|
||||||
|
}
|
75
src/component/network.cpp
Normal file
75
src/component/network.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
|
#include <loader/component_loader.hpp>
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
|
#include "network.hpp"
|
||||||
|
#include "command.hpp"
|
||||||
|
|
||||||
|
namespace network
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::unordered_map<std::string, callback>& get_callbacks()
|
||||||
|
{
|
||||||
|
static std::unordered_map<std::string, callback> network_callbacks{};
|
||||||
|
return network_callbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handle_command(game::netadr_s* address, const char* command, game::msg_t* message)
|
||||||
|
{
|
||||||
|
const auto cmd_string = utils::string::to_lower(command);
|
||||||
|
auto& callbacks = get_callbacks();
|
||||||
|
const auto handler = callbacks.find(cmd_string);
|
||||||
|
|
||||||
|
if (handler == callbacks.end())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto offset = cmd_string.size() + 5;
|
||||||
|
const std::string_view data(message->data + offset, message->cursize - offset);
|
||||||
|
|
||||||
|
handler->second(*address, data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int packet_interception_handler(game::netadr_s* from, const char* command, game::msg_t* message)
|
||||||
|
{
|
||||||
|
if (!handle_command(from, command, message))
|
||||||
|
{
|
||||||
|
return reinterpret_cast<int (*)(game::netadr_s*, const char*, game::msg_t*)>(0x525730)(from, command, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_packet(const std::string& command, const callback& callback)
|
||||||
|
{
|
||||||
|
get_callbacks()[utils::string::to_lower(command)] = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
class component final : public component_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
add_network_commands();
|
||||||
|
|
||||||
|
utils::hook::call(0x5B27E1, packet_interception_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void add_network_commands()
|
||||||
|
{
|
||||||
|
on_packet("naughty_reply", [](const game::netadr_s&, const std::string_view&)
|
||||||
|
{
|
||||||
|
command::execute("dia_quit");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(network::component)
|
8
src/component/network.hpp
Normal file
8
src/component/network.hpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace network
|
||||||
|
{
|
||||||
|
using callback = std::function<void(const game::netadr_s&, const std::string_view&)>;
|
||||||
|
|
||||||
|
void on_packet(const std::string& command, const callback& callback);
|
||||||
|
}
|
28
src/component/remove_hooks.cpp
Normal file
28
src/component/remove_hooks.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
|
#include <loader/component_loader.hpp>
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
|
namespace remove_hooks
|
||||||
|
{
|
||||||
|
class component final : public component_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
remove_tekno_hooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void remove_tekno_hooks()
|
||||||
|
{
|
||||||
|
utils::hook::set<BYTE>(0x4E3D42, 0xE8);
|
||||||
|
utils::hook::set<BYTE>(0x4E3D43, 0xA9);
|
||||||
|
utils::hook::set<BYTE>(0x4E3D44, 0x25);
|
||||||
|
utils::hook::set<BYTE>(0x4E3D45, 0xFE);
|
||||||
|
utils::hook::set<BYTE>(0x4E3D46, 0xFF);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(remove_hooks::component)
|
@ -26,6 +26,16 @@ namespace game
|
|||||||
const char** argv[8];
|
const char** argv[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class LocalClientNum_t
|
||||||
|
{
|
||||||
|
LOCAL_CLIENT_0 = 0,
|
||||||
|
LOCAL_CLIENT_1 = 1,
|
||||||
|
LOCAL_CLIENT_2 = 2,
|
||||||
|
LOCAL_CLIENT_3 = 3,
|
||||||
|
LOCAL_CLIENT_LAST = 3,
|
||||||
|
LOCAL_CLIENT_COUNT = 4
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
NS_CLIENT1 = 0,
|
NS_CLIENT1 = 0,
|
||||||
@ -368,6 +378,46 @@ namespace game
|
|||||||
int remoteControlMove;
|
int remoteControlMove;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum LocSelInputState
|
||||||
|
{
|
||||||
|
LOC_SEL_INPUT_NONE = 0,
|
||||||
|
LOC_SEL_INPUT_CONFIRM = 1,
|
||||||
|
LOC_SEL_INPUT_CANCEL = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
struct field_t
|
||||||
|
{
|
||||||
|
int cursor;
|
||||||
|
int scroll;
|
||||||
|
int drawWidth;
|
||||||
|
int widthInPixels;
|
||||||
|
float charHeight;
|
||||||
|
int fixedSize;
|
||||||
|
char buffer[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct KeyState
|
||||||
|
{
|
||||||
|
int down;
|
||||||
|
int repeats;
|
||||||
|
int binding;
|
||||||
|
const char* bindingCheat;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(field_t) == 280);
|
||||||
|
|
||||||
|
struct PlayerKeyState
|
||||||
|
{
|
||||||
|
field_t chatField;
|
||||||
|
int chat_team;
|
||||||
|
int overstrikeMode;
|
||||||
|
int anyKeyDown;
|
||||||
|
KeyState keys[256];
|
||||||
|
LocSelInputState locSelInputState;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(PlayerKeyState) == 4392);
|
||||||
|
|
||||||
enum EffectiveStance
|
enum EffectiveStance
|
||||||
{
|
{
|
||||||
PM_EFF_STANCE_DEFAULT = 0,
|
PM_EFF_STANCE_DEFAULT = 0,
|
||||||
|
@ -6,10 +6,10 @@ namespace game
|
|||||||
{
|
{
|
||||||
// Functions
|
// Functions
|
||||||
WEAK symbol<const char*(int index)> ConcatArgs{0x539060};
|
WEAK symbol<const char*(int index)> ConcatArgs{0x539060};
|
||||||
WEAK symbol<void(int localClientNum, const char* text)> Cbuf_AddText{0x4C1030};
|
WEAK symbol<void(LocalClientNum_t, const char* text)> Cbuf_AddText{0x4C1030};
|
||||||
WEAK symbol<void(int localClientNum, const char* text)> Cbuf_InsertText{0x429920};
|
WEAK symbol<void(LocalClientNum_t, const char* text)> Cbuf_InsertText{0x429920};
|
||||||
WEAK symbol<void(const char* cmdName, void(), cmd_function_t* cmd)> Cmd_AddCommandInternal{0x537E70};
|
WEAK symbol<void(const char* cmdName, void(), cmd_function_t* cmd)> Cmd_AddCommandInternal{0x537E70};
|
||||||
WEAK symbol<void(int, int, const char* text)> Cmd_ExecuteSingleCommand{0x4EB8F0};
|
WEAK symbol<void(LocalClientNum_t, int, const char* text)> Cmd_ExecuteSingleCommand{0x4EB8F0};
|
||||||
WEAK symbol<void(const char* cmdName)> Cmd_RemoveCommand{0x4EAF30};
|
WEAK symbol<void(const char* cmdName)> Cmd_RemoveCommand{0x4EAF30};
|
||||||
WEAK symbol<const char*(int index)> Cmd_Argv{0x5580E0};
|
WEAK symbol<const char*(int index)> Cmd_Argv{0x5580E0};
|
||||||
|
|
||||||
@ -24,6 +24,8 @@ namespace game
|
|||||||
Dvar_RegisterFloat{0x4A5CF0};
|
Dvar_RegisterFloat{0x4A5CF0};
|
||||||
|
|
||||||
WEAK symbol<int(const char* cmd)> Key_GetBindingForCmd{0x47D300};
|
WEAK symbol<int(const char* cmd)> Key_GetBindingForCmd{0x47D300};
|
||||||
|
WEAK symbol<int(const char* keyAsText)> Key_StringToKeynum{0x50A710}; // Virtual-Key Code
|
||||||
|
WEAK symbol<void(LocalClientNum_t, int, int)> Key_SetBinding{0x50B770};
|
||||||
|
|
||||||
WEAK symbol<void(int arg, char* buffer, int bufferLength)> SV_Cmd_ArgvBuffer{0x4F6B00};
|
WEAK symbol<void(int arg, char* buffer, int bufferLength)> SV_Cmd_ArgvBuffer{0x4F6B00};
|
||||||
|
|
||||||
@ -32,4 +34,5 @@ namespace game
|
|||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
WEAK symbol<CmdArgs> cmd_args{0x1C96850};
|
WEAK symbol<CmdArgs> cmd_args{0x1C96850};
|
||||||
|
WEAK symbol<PlayerKeyState> playerKeys{0xB3A38C};
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
#include "hook.hpp"
|
#include "hook.hpp"
|
||||||
#include "string.hpp"
|
#include "string.hpp"
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
#include "nt.hpp"
|
#include "nt.hpp"
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
#include "nt.hpp"
|
#include "nt.hpp"
|
||||||
|
|
||||||
namespace utils::nt
|
namespace utils::nt
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
#include "signature.hpp"
|
#include "signature.hpp"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
|
||||||
#include "string.hpp"
|
#include "string.hpp"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user