move code to hooks (incomplete)

This commit is contained in:
Jenny White 2018-04-29 09:07:53 +03:00
parent 9285fdc28e
commit 22c8a56cfb
23 changed files with 1012 additions and 1120 deletions

View File

@ -323,7 +323,7 @@ free(logname);*/
hooks::vstd.Set((void *) g_pUniformStream);
hooks::vstd.HookMethod(HOOK_ARGS(RandomInt));
hooks::vstd.Apply();
hooks::panel.Set(g_IPanel);
hooks::panel.HookMethod(hooked_methods::methods::PaintTraverse,
offsets::PaintTraverse(), &hooked_methods::original::PaintTraverse);

View File

@ -5,7 +5,6 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/FireGameEvent.cpp"
"${CMAKE_CURRENT_LIST_DIR}/GetFriendPersonaName.cpp"
"${CMAKE_CURRENT_LIST_DIR}/GetUserCmd.cpp"
"${CMAKE_CURRENT_LIST_DIR}/IN_KeyEvent.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LevelInit.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LevelShutdown.cpp"
"${CMAKE_CURRENT_LIST_DIR}/nographics.cpp"

View File

@ -17,105 +17,12 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time,
CUserCmd *cmd)
{
return original::CreateMove(this_, input_sample_time, cmd);
}
}
class CMoveData;
namespace engine_prediction
{
void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
{
if (!ent)
return;
typedef void (*SetupMoveFn)(IPrediction *, IClientEntity *, CUserCmd *,
class IMoveHelper *, CMoveData *);
typedef void (*FinishMoveFn)(IPrediction *, IClientEntity *, CUserCmd *,
CMoveData *);
void **predictionVtable = *((void ***) g_IPrediction);
SetupMoveFn oSetupMove =
(SetupMoveFn)(*(unsigned *) (predictionVtable + 19));
FinishMoveFn oFinishMove =
(FinishMoveFn)(*(unsigned *) (predictionVtable + 20));
// CMoveData *pMoveData = (CMoveData*)(sharedobj::client->lmap->l_addr +
// 0x1F69C0C); CMoveData movedata {};
char object[165];
CMoveData *pMoveData = (CMoveData *) object;
float frameTime = g_GlobalVars->frametime;
float curTime = g_GlobalVars->curtime;
CUserCmd defaultCmd;
if (ucmd == NULL)
{
ucmd = &defaultCmd;
}
NET_VAR(ent, 4188, CUserCmd *) = ucmd;
g_GlobalVars->curtime =
g_GlobalVars->interval_per_tick * NET_INT(ent, netvar.nTickBase);
g_GlobalVars->frametime = g_GlobalVars->interval_per_tick;
*g_PredictionRandomSeed =
MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF;
g_IGameMovement->StartTrackPredictionErrors(
reinterpret_cast<CBasePlayer *>(ent));
oSetupMove(g_IPrediction, ent, ucmd, NULL, pMoveData);
g_IGameMovement->ProcessMovement(reinterpret_cast<CBasePlayer *>(ent),
pMoveData);
oFinishMove(g_IPrediction, ent, ucmd, pMoveData);
g_IGameMovement->FinishTrackPredictionErrors(
reinterpret_cast<CBasePlayer *>(ent));
NET_VAR(ent, 4188, CUserCmd *) = nullptr;
g_GlobalVars->frametime = frameTime;
g_GlobalVars->curtime = curTime;
return;
}
/*float o_curtime;
float o_frametime;
void Start() {
g_IGameMovement->StartTrackPredictionErrors((CBasePlayer*)(RAW_ENT(LOCAL_E)));
IClientEntity* player = RAW_ENT(LOCAL_E);
// CPredictableId::ResetInstanceCounters();
*(reinterpret_cast<CUserCmd*>(reinterpret_cast<uintptr_t>(player) + 1047)) =
g_pUserCmd; o_curtime = g_GlobalVars->curtime; o_frametime =
g_GlobalVars->frametime; *g_PredictionRandomSeed =
MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF; g_GlobalVars->curtime
= CE_INT(LOCAL_E, netvar.nTickBase) * g_GlobalVars->interval_per_tick;
g_GlobalVars->frametime = g_GlobalVars->interval_per_tick;
CMoveData data;
}
void End() {
*g_PredictionRandomSeed = -1;
g_GlobalVars->curtime = o_curtime;
g_GlobalVars->frametime = o_frametime;
}*/
}
bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
{
uintptr_t **fp;
__asm__("mov %%ebp, %0" : "=r"(fp));
bSendPackets = reinterpret_cast<bool *>(**fp - 8);
g_Settings.is_create_move = true;
static CreateMove_t original_method =
(CreateMove_t) hooks::clientmode.GetMethod(offsets::CreateMove());
bool time_replaced, ret, speedapplied;
float curtime_old, servertime, speed, yaw;
Vector vsilent, ang;
@ -132,7 +39,7 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
}
}
ret = original_method(thisptr, inputSample, cmd);
ret = original::CreateMove(this_, input_sample_time, cmd);
PROF_SECTION(CreateMove);
@ -249,7 +156,7 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
{
logging::Info("Trying to change CLASS");
g_IEngine->ExecuteClientCmd(
format("join_class ", joinclass.GetString()).c_str());
format("join_class ", joinclass.GetString()).c_str());
}
team_joining_state = 0;
}
@ -471,7 +378,7 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
speedapplied = false;
if (roll_speedhack &&
g_IInputSystem->IsButtonDown(
(ButtonCode_t)((int) roll_speedhack)) &&
(ButtonCode_t)((int) roll_speedhack)) &&
!(cmd->buttons & IN_ATTACK))
{
speed = cmd->forwardmove;
@ -531,3 +438,94 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
g_Settings.is_create_move = false;
return ret;
}
}
class CMoveData;
namespace engine_prediction
{
void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
{
if (!ent)
return;
typedef void (*SetupMoveFn)(IPrediction *, IClientEntity *, CUserCmd *,
class IMoveHelper *, CMoveData *);
typedef void (*FinishMoveFn)(IPrediction *, IClientEntity *, CUserCmd *,
CMoveData *);
void **predictionVtable = *((void ***) g_IPrediction);
SetupMoveFn oSetupMove =
(SetupMoveFn)(*(unsigned *) (predictionVtable + 19));
FinishMoveFn oFinishMove =
(FinishMoveFn)(*(unsigned *) (predictionVtable + 20));
// CMoveData *pMoveData = (CMoveData*)(sharedobj::client->lmap->l_addr +
// 0x1F69C0C); CMoveData movedata {};
char object[165];
CMoveData *pMoveData = (CMoveData *) object;
float frameTime = g_GlobalVars->frametime;
float curTime = g_GlobalVars->curtime;
CUserCmd defaultCmd;
if (ucmd == NULL)
{
ucmd = &defaultCmd;
}
NET_VAR(ent, 4188, CUserCmd *) = ucmd;
g_GlobalVars->curtime =
g_GlobalVars->interval_per_tick * NET_INT(ent, netvar.nTickBase);
g_GlobalVars->frametime = g_GlobalVars->interval_per_tick;
*g_PredictionRandomSeed =
MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF;
g_IGameMovement->StartTrackPredictionErrors(
reinterpret_cast<CBasePlayer *>(ent));
oSetupMove(g_IPrediction, ent, ucmd, NULL, pMoveData);
g_IGameMovement->ProcessMovement(reinterpret_cast<CBasePlayer *>(ent),
pMoveData);
oFinishMove(g_IPrediction, ent, ucmd, pMoveData);
g_IGameMovement->FinishTrackPredictionErrors(
reinterpret_cast<CBasePlayer *>(ent));
NET_VAR(ent, 4188, CUserCmd *) = nullptr;
g_GlobalVars->frametime = frameTime;
g_GlobalVars->curtime = curTime;
return;
}
/*float o_curtime;
float o_frametime;
void Start() {
g_IGameMovement->StartTrackPredictionErrors((CBasePlayer*)(RAW_ENT(LOCAL_E)));
IClientEntity* player = RAW_ENT(LOCAL_E);
// CPredictableId::ResetInstanceCounters();
*(reinterpret_cast<CUserCmd*>(reinterpret_cast<uintptr_t>(player) + 1047)) =
g_pUserCmd; o_curtime = g_GlobalVars->curtime; o_frametime =
g_GlobalVars->frametime; *g_PredictionRandomSeed =
MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF; g_GlobalVars->curtime
= CE_INT(LOCAL_E, netvar.nTickBase) * g_GlobalVars->interval_per_tick;
g_GlobalVars->frametime = g_GlobalVars->interval_per_tick;
CMoveData data;
}
void End() {
*g_PredictionRandomSeed = -1;
g_GlobalVars->curtime = o_curtime;
g_GlobalVars->frametime = o_frametime;
}*/
}
bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
{
}

View File

@ -11,6 +11,245 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type,
bf_read &buffer)
{
if (retrun && gitgud.test_and_set(10000))
{
PrintChat("\x07%06X%s\x01: %s", 0xe05938, lastname.c_str(),
lastfilter.c_str());
retrun = false;
}
int loop_index, s, i, j;
char *data, c;
static const DispatchUserMessage_t original =
(DispatchUserMessage_t) hooks::client.GetMethod(
offsets::DispatchUserMessage());
if (type == 4)
{
loop_index = 0;
s = buf.GetNumBytesLeft();
if (s < 256)
{
data = (char *) alloca(s);
for (i = 0; i < s; i++)
data[i] = buf.ReadByte();
j = 0;
std::string name;
std::string message;
for (i = 0; i < 3; i++)
{
while ((c = data[j++]) && (loop_index < 128))
{
loop_index++;
if (clean_chat)
if ((c == '\n' || c == '\r') && (i == 1 || i == 2))
data[j - 1] = '*';
if (i == 1)
name.push_back(c);
if (i == 2)
message.push_back(c);
}
}
if (chat_filter_enabled && data[0] != LOCAL_E->m_IDX)
{
if (!strcmp(chat_filter.GetString(), ""))
{
std::string tmp = {};
std::string tmp2 = {};
int iii = 0;
player_info_s info;
g_IEngine->GetPlayerInfo(LOCAL_E->m_IDX, &info);
std::string name1 = info.name;
std::vector<std::string> name2{};
std::vector<std::string> name3{};
std::string claz = {};
switch (g_pLocalPlayer->clazz)
{
case tf_scout:
claz = "scout";
break;
case tf_soldier:
claz = "soldier";
break;
case tf_pyro:
claz = "pyro";
break;
case tf_demoman:
claz = "demo";
break;
case tf_engineer:
claz = "engi";
break;
case tf_heavy:
claz = "heavy";
break;
case tf_medic:
claz = "med";
break;
case tf_sniper:
claz = "sniper";
break;
case tf_spy:
claz = "spy";
break;
default:
break;
}
for (char i : name1)
{
if (iii == 2)
{
iii = 0;
tmp += i;
name2.push_back(tmp);
tmp = "";
}
else if (iii < 2)
{
iii++;
tmp += i;
}
}
iii = 0;
for (char i : name1)
{
if (iii == 3)
{
iii = 0;
tmp += i;
name3.push_back(tmp2);
tmp2 = "";
}
else if (iii < 3)
{
iii++;
tmp2 += i;
}
}
if (tmp.size() > 2)
name2.push_back(tmp);
if (tmp2.size() > 2)
name3.push_back(tmp2);
iii = 0;
std::vector<std::string> res = {
"skid", "script", "cheat", "hak", "hac", "f1",
"hax", "vac", "ban", "lmao", "bot", "report",
"cat", "insta", "revv", "brass", "kick", claz
};
for (auto i : name2)
{
boost::to_lower(i);
res.push_back(i);
}
for (auto i : name3)
{
boost::to_lower(i);
res.push_back(i);
}
std::string message2 = message;
boost::to_lower(message2);
boost::replace_all(message2, "4", "a");
boost::replace_all(message2, "3", "e");
boost::replace_all(message2, "0", "o");
boost::replace_all(message2, "6", "g");
boost::replace_all(message2, "5", "s");
boost::replace_all(message2, "7", "t");
for (auto filter : res)
{
if (retrun)
break;
if (boost::contains(message2, filter))
{
if (clear == "")
{
for (int i = 0; i < 120; i++)
clear += "\n";
}
*bSendPackets = true;
chat_stack::Say(". " + clear, true);
retrun = true;
lastfilter = format(filter);
lastname = format(name);
}
}
}
else if (data[0] != LOCAL_E->m_IDX)
{
std::string input = chat_filter.GetString();
boost::to_lower(input);
std::string message2 = message;
std::vector<std::string> result{};
boost::split(result, input, boost::is_any_of(","));
boost::replace_all(message2, "4", "a");
boost::replace_all(message2, "3", "e");
boost::replace_all(message2, "0", "o");
boost::replace_all(message2, "6", "g");
boost::replace_all(message2, "5", "s");
boost::replace_all(message2, "7", "t");
for (auto filter : result)
{
if (retrun)
break;
if (boost::contains(message2, filter))
{
if (clear == "")
{
clear = "";
for (int i = 0; i < 120; i++)
clear += "\n";
}
*bSendPackets = true;
chat_stack::Say(". " + clear, true);
retrun = true;
lastfilter = format(filter);
lastname = format(name);
}
}
}
}
if (sendmsg.test_and_set(300000) &&
hacks::shared::antiaim::communicate)
chat_stack::Say("!!meow");
if (crypt_chat)
{
if (message.find("!!") == 0)
{
if (ucccccp::validate(message))
{
if (ucccccp::decrypt(message) == "meow" &&
hacks::shared::antiaim::communicate &&
data[0] != LOCAL_E->m_IDX &&
playerlist::AccessData(ENTITY(data[0])).state !=
playerlist::k_EState::CAT)
{
playerlist::AccessData(ENTITY(data[0])).state =
playerlist::k_EState::CAT;
chat_stack::Say("!!meow");
}
PrintChat("\x07%06X%s\x01: %s", 0xe05938, name.c_str(),
ucccccp::decrypt(message).c_str());
}
}
}
chatlog::LogMessage(data[0], message);
buf = bf_read(data, s);
buf.Seek(0);
}
}
if (dispatch_log)
{
logging::Info("D> %i", type);
std::ostringstream str{};
while (buf.GetNumBytesLeft())
{
unsigned char byte = buf.ReadByte();
str << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(byte) << ' ';
}
logging::Info("MESSAGE %d, DATA = [ %s ]", type, str.str().c_str());
buf.Seek(0);
}
votelogger::user_message(buf, type);
return original::DispatchUserMessage(this_, type, buffer);
}
}

View File

@ -10,6 +10,20 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(FireGameEvent, void, void *this_, IGameEvent *event)
{
return original::FireGameEvent(this_, event);
const char *name = event->GetName();
if (name)
{
if (event_log)
{
if (!strcmp(name, "player_connect_client") ||
!strcmp(name, "player_disconnect") ||
!strcmp(name, "player_team"))
{
return;
}
}
// hacks::tf2::killstreak::fire_event(event);
}
original::FireGameEvent(this_, event);
}
}

View File

@ -11,6 +11,49 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(GetFriendPersonaName, const char *, ISteamFriends *this_,
CSteamID steam_id)
{
static const GetFriendPersonaName_t original =
(GetFriendPersonaName_t) hooks::steamfriends.GetMethod(
offsets::GetFriendPersonaName());
#if ENABLE_IPC
if (ipc::peer)
{
static std::string namestr(ipc_name.GetString());
namestr.assign(ipc_name.GetString());
if (namestr.length() > 3)
{
ReplaceString(namestr, "%%", std::to_string(ipc::peer->client_id));
return namestr.c_str();
}
}
#endif
// Check User settings if namesteal is allowed
if (namesteal && steamID == g_ISteamUser->GetSteamID())
{
// We dont want to steal names while not in-game as there are no targets
// to steal from. We want to be on a team as well to get teammates names
if (g_IEngine->IsInGame() && g_pLocalPlayer->team)
{
// Check if we have a username to steal, func automaticly steals a
// name in it.
if (StolenName())
{
// Return the name that has changed from the func above
return format(stolen_name, "\x0F").c_str();
}
}
}
if ((strlen(force_name.GetString()) > 1) &&
steamID == g_ISteamUser->GetSteamID())
{
return force_name_newlined;
}
return original::GetFriendPersonaName(this_, steam_id);
}
}

View File

@ -10,6 +10,30 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *this_, int sequence_number)
{
return original::GetUserCmd(this_, sequence_number);
CUserCmd *def = original::GetUserCmd(this_, sequence_number);
int oldcmd;
INetChannel *ch;
if (command_number_mod.find(def->command_number) !=
command_number_mod.end() && def != nullptr)
{
// logging::Info("Replacing command %i with %i", def->command_number,
// command_number_mod[def->command_number]);
oldcmd = def->command_number;
def->command_number = command_number_mod[def->command_number];
def->random_seed =
MD5_PseudoRandom(unsigned(def->command_number)) &
0x7fffffff;
command_number_mod.erase(command_number_mod.find(oldcmd));
*(int *) ((unsigned) g_IBaseClientState +
offsets::lastoutgoingcommand()) = def->command_number - 1;
ch =
(INetChannel *) g_IEngine
->GetNetChannelInfo(); //*(INetChannel**)((unsigned)g_IBaseClientState
//+ offsets::m_NetChannel());
*(int *) ((unsigned) ch + offsets::m_nOutSequenceNr()) =
def->command_number - 1;
}
return def;
}
}

View File

@ -10,6 +10,45 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name)
{
return original::LevelInit(this_, name);
playerlist::Save();
votelogger::antikick_ticks = 0;
hacks::shared::lagexploit::bcalled = false;
#if ENABLE_VISUALS
typedef bool *(*LoadNamedSkys_Fn)(const char *);
uintptr_t addr = gSignatures.GetEngineSignature(
"55 89 E5 57 31 FF 56 8D B5 ? ? ? ? 53 81 EC 6C 01 00 00");
static LoadNamedSkys_Fn LoadNamedSkys = LoadNamedSkys_Fn(addr);
bool succ;
logging::Info("Going to load the skybox");
#ifdef __clang__
asm("movl %1, %%edi; push skynum[(int) skybox_changer]; call %%edi; mov "
"%%eax, %0; add %%esp, 4h"
: "=r"(succ)
: "r"(LoadNamedSkys));
#else
succ = LoadNamedSkys(skynum[(int) skybox_changer]);
#endif
logging::Info("Loaded Skybox: %s", succ ? "true" : "false");
ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday");
if (halloween_mode)
holiday->SetValue(2);
else if (holiday->m_nValue == 2)
holiday->SetValue(2);
#endif
g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec");
hacks::shared::aimbot::Reset();
chat_stack::Reset();
hacks::shared::anticheat::ResetEverything();
original::LevelInit(this_, name);
hacks::shared::walkbot::OnLevelInit();
#if ENABLE_IPC
if (ipc::peer)
{
ipc::peer->memory->peer_user_data[ipc::peer->client_id].ts_connected =
time(nullptr);
}
#endif
}
}

View File

@ -10,6 +10,19 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_)
{
need_name_change = true;
playerlist::Save();
g_Settings.bInvalid = true;
hacks::shared::aimbot::Reset();
chat_stack::Reset();
hacks::shared::anticheat::ResetEverything();
#if ENABLE_IPC
if (ipc::peer)
{
ipc::peer->memory->peer_user_data[ipc::peer->client_id]
.ts_disconnected = time(nullptr);
}
#endif
return original::LevelShutdown(this_);
}
}

View File

@ -14,18 +14,6 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode)
{
return original::Paint(this_, mode);
}
}
static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1",
"Cursor fix");
void Paint_hook(IEngineVGui *_this, PaintMode_t mode)
{
static const Paint_t original = (Paint_t) hooks::enginevgui.GetMethod(
offsets::PlatformOffset(14, offsets::undefined, offsets::undefined));
if (!g_IEngine->IsInGame())
g_Settings.bInvalid = true;
@ -70,7 +58,7 @@ void Paint_hook(IEngineVGui *_this, PaintMode_t mode)
// logging::Info("executing %s",
// hack::command_stack().top().c_str());
g_IEngine->ClientCmd_Unrestricted(
hack::command_stack().top().c_str());
hack::command_stack().top().c_str());
hack::command_stack().pop();
}
}
@ -97,5 +85,9 @@ void Paint_hook(IEngineVGui *_this, PaintMode_t mode)
#endif
}
original(_this, mode);
return original::Paint(this_, mode);
}
}
static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1",
"Cursor fix");

View File

@ -32,139 +32,5 @@ CatVar
void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
{
static const PaintTraverse_t original =
(PaintTraverse_t) hooks::panel.GetMethod(offsets::PaintTraverse());
static bool textures_loaded = false;
static unsigned long panel_focus = 0;
static unsigned long panel_scope = 0;
static unsigned long panel_top = 0;
static bool cur, draw_flag = false;
static bool call_default = true;
static ConVar *software_cursor = g_ICvar->FindVar("cl_software_cursor");
static const char *name;
static std::string name_s, name_stripped, reason_stripped;
#if ENABLE_VISUALS
if (!textures_loaded)
{
textures_loaded = true;
#ifndef FEATURE_RADAR_DISABLED
hacks::tf::radar::Init();
#endif
}
#endif
if (pure_bypass)
{
if (!pure_addr)
{
pure_addr = *reinterpret_cast<void ***>(
gSignatures.GetEngineSignature(
"A1 ? ? ? ? 85 C0 74 ? C7 44 24 ? ? ? ? ? 89 04 24") +
1);
}
if (*pure_addr)
pure_orig = *pure_addr;
*pure_addr = (void *) 0;
}
else if (pure_orig)
{
*pure_addr = pure_orig;
pure_orig = (void *) 0;
}
call_default = true;
if (cathook && panel_scope && no_zoom && vp == panel_scope)
call_default = false;
if (software_cursor_mode)
{
cur = software_cursor->GetBool();
switch ((int) software_cursor_mode)
{
case 1:
if (!software_cursor->GetBool())
software_cursor->SetValue(1);
break;
case 2:
if (software_cursor->GetBool())
software_cursor->SetValue(0);
break;
#if ENABLE_GUI
/*
case 3:
if (cur != g_pGUI->Visible()) {
software_cursor->SetValue(g_pGUI->Visible());
}
break;
case 4:
if (cur == g_pGUI->Visible()) {
software_cursor->SetValue(!g_pGUI->Visible());
}
*/
#endif
}
}
if (call_default)
original(_this, vp, fr, ar);
// To avoid threading problems.
PROF_SECTION(PT_total);
if (vp == panel_top)
draw_flag = true;
if (!cathook)
return;
if (!panel_top)
{
name = g_IPanel->GetName(vp);
if (strlen(name) > 4)
{
if (name[0] == 'M' && name[3] == 'S')
{
panel_top = vp;
}
}
}
if (!panel_focus)
{
name = g_IPanel->GetName(vp);
if (strlen(name) > 5)
{
if (name[0] == 'F' && name[5] == 'O')
{
panel_focus = vp;
}
}
}
if (!panel_scope)
{
name = g_IPanel->GetName(vp);
if (!strcmp(name, "HudScope"))
{
panel_scope = vp;
}
}
if (!g_IEngine->IsInGame())
{
g_Settings.bInvalid = true;
}
if (vp != panel_focus)
return;
g_IPanel->SetTopmostPopup(panel_focus, true);
if (!draw_flag)
return;
draw_flag = false;
if (disable_visuals)
return;
if (clean_screenshots && g_IEngine->IsTakingScreenshot())
return;
#if ENABLE_GUI
g_pGUI->Update();
#endif
PROF_SECTION(PT_active);
draw::UpdateWTS();
}

View File

@ -11,6 +11,90 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &message,
bool force_reliable, bool voice)
{
size_t say_idx, say_team_idx;
int offset;
std::string newlines;
NET_StringCmd stringcmd;
// This is a INetChannel hook - it SHOULDN'T be static because netchannel
// changes.
const SendNetMsg_t original =
(SendNetMsg_t) hooks::netchannel.GetMethod(offsets::SendNetMsg());
// net_StringCmd
if (msg.GetType() == 4 && (newlines_msg || crypt_chat))
{
std::string str(msg.ToString());
say_idx = str.find("net_StringCmd: \"say \"");
say_team_idx = str.find("net_StringCmd: \"say_team \"");
if (!say_idx || !say_team_idx)
{
offset = say_idx ? 26 : 21;
bool crpt = false;
if (crypt_chat)
{
std::string msg(str.substr(offset));
msg = msg.substr(0, msg.length() - 2);
if (msg.find("!!") == 0)
{
msg = ucccccp::encrypt(msg.substr(2));
str = str.substr(0, offset) + msg + "\"\"";
crpt = true;
}
}
if (!crpt && newlines_msg)
{
// TODO move out? update in a value change callback?
newlines = std::string((int) newlines_msg, '\n');
str.insert(offset, newlines);
}
str = str.substr(16, str.length() - 17);
// if (queue_messages && !chat_stack::CanSend()) {
stringcmd.m_szCommand = str.c_str();
return original(_this, stringcmd, bForceReliable, bVoice);
//}
}
}
static ConVar *sv_player_usercommand_timeout =
g_ICvar->FindVar("sv_player_usercommand_timeout");
static float lastcmd = 0.0f;
if (lastcmd > g_GlobalVars->absoluteframetime)
{
lastcmd = g_GlobalVars->absoluteframetime;
}
if (airstuck.KeyDown() && !g_Settings.bInvalid)
{
if (CE_GOOD(LOCAL_E))
{
if (lastcmd + sv_player_usercommand_timeout->GetFloat() - 0.1f <
g_GlobalVars->curtime)
{
if (msg.GetType() == clc_Move)
return false;
}
else
{
lastcmd = g_GlobalVars->absoluteframetime;
}
}
}
if (log_sent && msg.GetType() != 3 && msg.GetType() != 9)
{
logging::Info("=> %s [%i] %s", msg.GetName(), msg.GetType(),
msg.ToString());
unsigned char buf[4096];
bf_write buffer("cathook_debug_buffer", buf, 4096);
logging::Info("Writing %i", msg.WriteToBuffer(buffer));
std::string bytes = "";
constexpr char h2c[] = "0123456789abcdef";
for (int i = 0; i < buffer.GetNumBytesWritten(); i++)
{
// bytes += format(h2c[(buf[i] & 0xF0) >> 4], h2c[(buf[i] & 0xF)], '
// ');
bytes += format((unsigned short) buf[i], ' ');
}
logging::Info("%i bytes => %s", buffer.GetNumBytesWritten(),
bytes.c_str());
}
return original::SendNetMsg(this_, message, force_reliable, voice);
}
}

View File

@ -10,6 +10,33 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason)
{
return original::Shutdown(this_, reason);
g_Settings.bInvalid = true;
// This is a INetChannel hook - it SHOULDN'T be static because netchannel
// changes.
logging::Info("Disconnect: %s", reason);
if (strstr(reason, "banned"))
{
if (die_if_vac)
{
logging::Info("VAC banned");
*(int *) 0 = 0;
exit(1);
}
}
#if ENABLE_IPC
ipc::UpdateServerAddress(true);
#endif
if (cathook && (disconnect_reason.convar_parent->m_StringLength > 3) &&
strstr(reason, "user"))
{
original::Shutdown(this_, disconnect_reason_newlined);
}
else
{
original::Shutdown(this_, reason);
}
if (hacks::shared::autojoin::auto_queue)
tfmm::queue_start();
}
}

View File

@ -38,83 +38,6 @@ static CatVar no_arms(CV_SWITCH, "no_arms", "0", "No Arms",
static CatVar no_hats(CV_SWITCH, "no_hats", "0", "No Hats",
"Removes non-stock hats");
float last_say = 0.0f;
void DrawModelExecute_hook(IVModelRender *_this, const DrawModelState_t &state,
const ModelRenderInfo_t &info, matrix3x4_t *matrix)
{
static const DrawModelExecute_t original =
(DrawModelExecute_t) hooks::modelrender.GetMethod(
offsets::DrawModelExecute());
static const char *name;
static std::string sname;
static IClientUnknown *unk;
static IClientEntity *ent;
if (!cathook ||
!(spectator_target || no_arms || no_hats ||
(clean_screenshots && g_IEngine->IsTakingScreenshot())))
{
original(_this, state, info, matrix);
return;
}
PROF_SECTION(DrawModelExecute);
if (no_arms || no_hats)
{
if (info.pModel)
{
name = g_IModelInfo->GetModelName(info.pModel);
if (name)
{
sname = name;
if (no_arms && sname.find("arms") != std::string::npos)
{
return;
}
else if (no_hats &&
sname.find("player/items") != std::string::npos)
{
return;
}
}
}
}
unk = info.pRenderable->GetIClientUnknown();
if (unk)
{
ent = unk->GetIClientEntity();
if (ent)
{
if (ent->entindex() == spectator_target)
{
return;
}
}
if (ent && !effect_chams::g_EffectChams.drawing &&
effect_chams::g_EffectChams.ShouldRenderChams(ent))
{
return;
}
}
original(_this, state, info, matrix);
}
int IN_KeyEvent_hook(void *_this, int eventcode, int keynum,
const char *pszCurrentBinding)
{
static const IN_KeyEvent_t original =
(IN_KeyEvent_t) hooks::client.GetMethod(offsets::IN_KeyEvent());
#if ENABLE_GUI
/*
if (g_pGUI->ConsumesKey((ButtonCode_t)keynum) && g_pGUI->Visible()) {
return 0;
}
*/
#endif
return original(_this, eventcode, keynum, pszCurrentBinding);
}
CatVar override_fov_zoomed(CV_FLOAT, "fov_zoomed", "0", "FOV override (zoomed)",
"Overrides FOV with this value when zoomed in "
@ -140,122 +63,8 @@ CatCommand spectate("spectate", "Spectate", [](const CCommand &args) {
}
});
void OverrideView_hook(void *_this, CViewSetup *setup)
{
static const OverrideView_t original =
(OverrideView_t) hooks::clientmode.GetMethod(offsets::OverrideView());
static bool zoomed;
original(_this, setup);
if (!cathook)
return;
if (g_pLocalPlayer->bZoomed && override_fov_zoomed)
{
setup->fov = override_fov_zoomed;
}
else
{
if (override_fov)
{
setup->fov = override_fov;
}
}
if (spectator_target)
{
CachedEntity *spec = ENTITY(spectator_target);
if (CE_GOOD(spec) && !CE_BYTE(spec, netvar.iLifeState))
{
setup->origin =
spec->m_vecOrigin + CE_VECTOR(spec, netvar.vViewOffset);
// why not spectate yourself
if (spec == LOCAL_E)
{
setup->angles =
CE_VAR(spec, netvar.m_angEyeAnglesLocal, QAngle);
}
else
{
setup->angles = CE_VAR(spec, netvar.m_angEyeAngles, QAngle);
}
}
if (g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_SPACE))
{
spectator_target = 0;
}
}
if (freecam)
{
static Vector freecam_origin{ 0 };
static bool freecam_last{ false };
if (freecam.KeyDown())
{
if (not freecam_last)
{
freecam_origin = setup->origin;
}
float sp, sy, cp, cy;
QAngle angle;
Vector forward;
g_IEngine->GetViewAngles(angle);
sy = sinf(DEG2RAD(angle[1]));
cy = cosf(DEG2RAD(angle[1]));
sp = sinf(DEG2RAD(angle[0]));
cp = cosf(DEG2RAD(angle[0]));
forward.x = cp * cy;
forward.y = cp * sy;
forward.z = -sp;
forward *= 4;
freecam_origin += forward;
setup->origin = freecam_origin;
}
freecam_last = freecam.KeyDown();
}
draw::fov = setup->fov;
}
#endif
bool CanPacket_hook(void *_this)
{
const CanPacket_t original =
(CanPacket_t) hooks::netchannel.GetMethod(offsets::CanPacket());
return *bSendPackets && original(_this);
}
CUserCmd *GetUserCmd_hook(IInput *_this, int sequence_number)
{
static const GetUserCmd_t original =
(GetUserCmd_t) hooks::input.GetMethod(offsets::GetUserCmd());
static CUserCmd *def;
static int oldcmd;
static INetChannel *ch;
def = original(_this, sequence_number);
if (def &&
command_number_mod.find(def->command_number) !=
command_number_mod.end())
{
// logging::Info("Replacing command %i with %i", def->command_number,
// command_number_mod[def->command_number]);
oldcmd = def->command_number;
def->command_number = command_number_mod[def->command_number];
def->random_seed =
MD5_PseudoRandom(unsigned(def->command_number)) & 0x7fffffff;
command_number_mod.erase(command_number_mod.find(oldcmd));
*(int *) ((unsigned) g_IBaseClientState +
offsets::lastoutgoingcommand()) = def->command_number - 1;
ch =
(INetChannel *) g_IEngine
->GetNetChannelInfo(); //*(INetChannel**)((unsigned)g_IBaseClientState
//+ offsets::m_NetChannel());
*(int *) ((unsigned) ch + offsets::m_nOutSequenceNr()) =
def->command_number - 1;
}
return def;
}
static CatVar log_sent(CV_SWITCH, "debug_log_sent_messages", "0",
"Log sent messages");
@ -292,132 +101,9 @@ static CatVar chat_filter_enabled(CV_SWITCH, "chat_censor_enabled", "0",
"Enable censor", "Censor Words in chat");
static CatVar server_crash_key(CV_KEY, "crash_server", "0", "Server crash key",
"hold key and wait...");
bool SendNetMsg_hook(void *_this, INetMessage &msg, bool bForceReliable = false,
bool bVoice = false)
{
static size_t say_idx, say_team_idx;
static int offset;
static std::string newlines;
static NET_StringCmd stringcmd;
// This is a INetChannel hook - it SHOULDN'T be static because netchannel
// changes.
const SendNetMsg_t original =
(SendNetMsg_t) hooks::netchannel.GetMethod(offsets::SendNetMsg());
// net_StringCmd
if (msg.GetType() == 4 && (newlines_msg || crypt_chat))
{
std::string str(msg.ToString());
say_idx = str.find("net_StringCmd: \"say \"");
say_team_idx = str.find("net_StringCmd: \"say_team \"");
if (!say_idx || !say_team_idx)
{
offset = say_idx ? 26 : 21;
bool crpt = false;
if (crypt_chat)
{
std::string msg(str.substr(offset));
msg = msg.substr(0, msg.length() - 2);
if (msg.find("!!") == 0)
{
msg = ucccccp::encrypt(msg.substr(2));
str = str.substr(0, offset) + msg + "\"\"";
crpt = true;
}
}
if (!crpt && newlines_msg)
{
// TODO move out? update in a value change callback?
newlines = std::string((int) newlines_msg, '\n');
str.insert(offset, newlines);
}
str = str.substr(16, str.length() - 17);
// if (queue_messages && !chat_stack::CanSend()) {
stringcmd.m_szCommand = str.c_str();
return original(_this, stringcmd, bForceReliable, bVoice);
//}
}
}
static ConVar *sv_player_usercommand_timeout =
g_ICvar->FindVar("sv_player_usercommand_timeout");
static float lastcmd = 0.0f;
if (lastcmd > g_GlobalVars->absoluteframetime)
{
lastcmd = g_GlobalVars->absoluteframetime;
}
if (airstuck.KeyDown() && !g_Settings.bInvalid)
{
if (CE_GOOD(LOCAL_E))
{
if (lastcmd + sv_player_usercommand_timeout->GetFloat() - 0.1f <
g_GlobalVars->curtime)
{
if (msg.GetType() == clc_Move)
return false;
}
else
{
lastcmd = g_GlobalVars->absoluteframetime;
}
}
}
if (log_sent && msg.GetType() != 3 && msg.GetType() != 9)
{
logging::Info("=> %s [%i] %s", msg.GetName(), msg.GetType(),
msg.ToString());
unsigned char buf[4096];
bf_write buffer("cathook_debug_buffer", buf, 4096);
logging::Info("Writing %i", msg.WriteToBuffer(buffer));
std::string bytes = "";
constexpr char h2c[] = "0123456789abcdef";
for (int i = 0; i < buffer.GetNumBytesWritten(); i++)
{
// bytes += format(h2c[(buf[i] & 0xF0) >> 4], h2c[(buf[i] & 0xF)], '
// ');
bytes += format((unsigned short) buf[i], ' ');
}
logging::Info("%i bytes => %s", buffer.GetNumBytesWritten(),
bytes.c_str());
}
return original(_this, msg, bForceReliable, bVoice);
}
static CatVar die_if_vac(CV_SWITCH, "die_if_vac", "0", "Die if VAC banned");
void Shutdown_hook(void *_this, const char *reason)
{
g_Settings.bInvalid = true;
// This is a INetChannel hook - it SHOULDN'T be static because netchannel
// changes.
const Shutdown_t original =
(Shutdown_t) hooks::netchannel.GetMethod(offsets::Shutdown());
logging::Info("Disconnect: %s", reason);
if (strstr(reason, "banned"))
{
if (die_if_vac)
{
logging::Info("VAC banned");
*(int *) 0 = 0;
exit(1);
}
}
#if ENABLE_IPC
ipc::UpdateServerAddress(true);
#endif
if (cathook && (disconnect_reason.convar_parent->m_StringLength > 3) &&
strstr(reason, "user"))
{
original(_this, disconnect_reason_newlined);
}
else
{
original(_this, reason);
}
if (hacks::shared::autojoin::auto_queue)
tfmm::queue_start();
}
static CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles");
CatEnum namesteal_enum({ "OFF", "PASSIVE", "ACTIVE" });
@ -517,201 +203,7 @@ bool StolenName()
static CatVar ipc_name(CV_STRING, "name_ipc", "", "IPC Name");
const char *GetFriendPersonaName_hook(ISteamFriends *_this, CSteamID steamID)
{
static const GetFriendPersonaName_t original =
(GetFriendPersonaName_t) hooks::steamfriends.GetMethod(
offsets::GetFriendPersonaName());
#if ENABLE_IPC
if (ipc::peer)
{
static std::string namestr(ipc_name.GetString());
namestr.assign(ipc_name.GetString());
if (namestr.length() > 3)
{
ReplaceString(namestr, "%%", std::to_string(ipc::peer->client_id));
return namestr.c_str();
}
}
#endif
// Check User settings if namesteal is allowed
if (namesteal && steamID == g_ISteamUser->GetSteamID())
{
// We dont want to steal names while not in-game as there are no targets
// to steal from. We want to be on a team as well to get teammates names
if (g_IEngine->IsInGame() && g_pLocalPlayer->team)
{
// Check if we have a username to steal, func automaticly steals a
// name in it.
if (StolenName())
{
// Return the name that has changed from the func above
return format(stolen_name, "\x0F").c_str();
}
}
}
if ((strlen(force_name.GetString()) > 1) &&
steamID == g_ISteamUser->GetSteamID())
{
return force_name_newlined;
}
return original(_this, steamID);
}
void FireGameEvent_hook(void *_this, IGameEvent *event)
{
static const FireGameEvent_t original =
(FireGameEvent_t) hooks::clientmode4.GetMethod(
offsets::FireGameEvent());
const char *name = event->GetName();
if (name)
{
if (event_log)
{
if (!strcmp(name, "player_connect_client") ||
!strcmp(name, "player_disconnect") ||
!strcmp(name, "player_team"))
{
return;
}
}
// hacks::tf2::killstreak::fire_event(event);
}
original(_this, event);
}
CatVar nightmode(CV_SWITCH, "nightmode", "0", "Enable nightmode", "");
#if ENABLE_VISUALS
void FrameStageNotify_hook(void *_this, int stage)
{
if (nightmode)
{
static int OldNightmode = 0;
if (OldNightmode != (int) nightmode)
{
static ConVar *r_DrawSpecificStaticProp =
g_ICvar->FindVar("r_DrawSpecificStaticProp");
if (!r_DrawSpecificStaticProp)
{
r_DrawSpecificStaticProp =
g_ICvar->FindVar("r_DrawSpecificStaticProp");
return;
}
r_DrawSpecificStaticProp->SetValue(0);
for (MaterialHandle_t i = g_IMaterialSystem->FirstMaterial();
i != g_IMaterialSystem->InvalidMaterial();
i = g_IMaterialSystem->NextMaterial(i))
{
IMaterial *pMaterial = g_IMaterialSystem->GetMaterial(i);
if (!pMaterial)
continue;
if (strstr(pMaterial->GetTextureGroupName(), "World") ||
strstr(pMaterial->GetTextureGroupName(), "StaticProp"))
{
if (nightmode)
if (strstr(pMaterial->GetTextureGroupName(),
"StaticProp"))
pMaterial->ColorModulate(0.3f, 0.3f, 0.3f);
else
pMaterial->ColorModulate(0.05f, 0.05f, 0.05f);
else
pMaterial->ColorModulate(1.0f, 1.0f, 1.0f);
}
}
OldNightmode = nightmode;
}
}
static IClientEntity *ent;
PROF_SECTION(FrameStageNotify_TOTAL);
static const FrameStageNotify_t original =
(FrameStageNotify_t) hooks::client.GetMethod(
offsets::FrameStageNotify());
if (!g_IEngine->IsInGame())
g_Settings.bInvalid = true;
{
PROF_SECTION(FSN_skinchanger);
hacks::tf2::skinchanger::FrameStageNotify(stage);
}
if (resolver && cathook && !g_Settings.bInvalid &&
stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
{
PROF_SECTION(FSN_resolver);
for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++)
{
if (i == g_IEngine->GetLocalPlayer())
continue;
ent = g_IEntityList->GetClientEntity(i);
if (ent && !ent->IsDormant() && !NET_BYTE(ent, netvar.iLifeState))
{
Vector &angles = NET_VECTOR(ent, netvar.m_angEyeAngles);
if (angles.x >= 90)
angles.x = -89;
if (angles.x <= -90)
angles.x = 89;
angles.y = fmod(angles.y + 180.0f, 360.0f);
if (angles.y < 0)
angles.y += 360.0f;
angles.y -= 180.0f;
}
}
}
if (cathook && stage == FRAME_RENDER_START)
{
INetChannel *ch;
ch = (INetChannel *) g_IEngine->GetNetChannelInfo();
if (ch && !hooks::IsHooked((void *) ch))
{
hooks::netchannel.Set(ch);
hooks::netchannel.HookMethod((void *) CanPacket_hook,
offsets::CanPacket());
hooks::netchannel.HookMethod((void *) SendNetMsg_hook,
offsets::SendNetMsg());
hooks::netchannel.HookMethod((void *) Shutdown_hook,
offsets::Shutdown());
hooks::netchannel.Apply();
#if ENABLE_IPC
ipc::UpdateServerAddress();
#endif
}
}
if (cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START)
{
IF_GAME(IsTF())
{
if (CE_GOOD(LOCAL_E) && no_zoom)
RemoveCondition<TFCond_Zoomed>(LOCAL_E);
}
if (force_thirdperson && !g_pLocalPlayer->life_state &&
CE_GOOD(g_pLocalPlayer->entity))
{
CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 1;
}
if (stage == 5 && show_antiaim && g_IInput->CAM_IsThirdPerson())
{
if (CE_GOOD(g_pLocalPlayer->entity))
{
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 4) =
g_Settings.last_angles.x;
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 8) =
g_Settings.last_angles.y;
}
}
}
original(_this, stage);
}
#endif /* TEXTMODE */
static CatVar clean_chat(CV_SWITCH, "clean_chat", "0", "Clean chat",
"Removes newlines from chat");
@ -725,249 +217,6 @@ static bool retrun = false;
static Timer sendmsg{};
static Timer gitgud{};
bool DispatchUserMessage_hook(void *_this, int type, bf_read &buf)
{
if (retrun && gitgud.test_and_set(10000))
{
PrintChat("\x07%06X%s\x01: %s", 0xe05938, lastname.c_str(),
lastfilter.c_str());
retrun = false;
}
int loop_index, s, i, j;
char *data, c;
static const DispatchUserMessage_t original =
(DispatchUserMessage_t) hooks::client.GetMethod(
offsets::DispatchUserMessage());
if (type == 4)
{
loop_index = 0;
s = buf.GetNumBytesLeft();
if (s < 256)
{
data = (char *) alloca(s);
for (i = 0; i < s; i++)
data[i] = buf.ReadByte();
j = 0;
std::string name;
std::string message;
for (i = 0; i < 3; i++)
{
while ((c = data[j++]) && (loop_index < 128))
{
loop_index++;
if (clean_chat)
if ((c == '\n' || c == '\r') && (i == 1 || i == 2))
data[j - 1] = '*';
if (i == 1)
name.push_back(c);
if (i == 2)
message.push_back(c);
}
}
if (chat_filter_enabled && data[0] != LOCAL_E->m_IDX)
{
if (!strcmp(chat_filter.GetString(), ""))
{
std::string tmp = {};
std::string tmp2 = {};
int iii = 0;
player_info_s info;
g_IEngine->GetPlayerInfo(LOCAL_E->m_IDX, &info);
std::string name1 = info.name;
std::vector<std::string> name2{};
std::vector<std::string> name3{};
std::string claz = {};
switch (g_pLocalPlayer->clazz)
{
case tf_scout:
claz = "scout";
break;
case tf_soldier:
claz = "soldier";
break;
case tf_pyro:
claz = "pyro";
break;
case tf_demoman:
claz = "demo";
break;
case tf_engineer:
claz = "engi";
break;
case tf_heavy:
claz = "heavy";
break;
case tf_medic:
claz = "med";
break;
case tf_sniper:
claz = "sniper";
break;
case tf_spy:
claz = "spy";
break;
default:
break;
}
for (char i : name1)
{
if (iii == 2)
{
iii = 0;
tmp += i;
name2.push_back(tmp);
tmp = "";
}
else if (iii < 2)
{
iii++;
tmp += i;
}
}
iii = 0;
for (char i : name1)
{
if (iii == 3)
{
iii = 0;
tmp += i;
name3.push_back(tmp2);
tmp2 = "";
}
else if (iii < 3)
{
iii++;
tmp2 += i;
}
}
if (tmp.size() > 2)
name2.push_back(tmp);
if (tmp2.size() > 2)
name3.push_back(tmp2);
iii = 0;
std::vector<std::string> res = {
"skid", "script", "cheat", "hak", "hac", "f1",
"hax", "vac", "ban", "lmao", "bot", "report",
"cat", "insta", "revv", "brass", "kick", claz
};
for (auto i : name2)
{
boost::to_lower(i);
res.push_back(i);
}
for (auto i : name3)
{
boost::to_lower(i);
res.push_back(i);
}
std::string message2 = message;
boost::to_lower(message2);
boost::replace_all(message2, "4", "a");
boost::replace_all(message2, "3", "e");
boost::replace_all(message2, "0", "o");
boost::replace_all(message2, "6", "g");
boost::replace_all(message2, "5", "s");
boost::replace_all(message2, "7", "t");
for (auto filter : res)
{
if (retrun)
break;
if (boost::contains(message2, filter))
{
if (clear == "")
{
for (int i = 0; i < 120; i++)
clear += "\n";
}
*bSendPackets = true;
chat_stack::Say(". " + clear, true);
retrun = true;
lastfilter = format(filter);
lastname = format(name);
}
}
}
else if (data[0] != LOCAL_E->m_IDX)
{
std::string input = chat_filter.GetString();
boost::to_lower(input);
std::string message2 = message;
std::vector<std::string> result{};
boost::split(result, input, boost::is_any_of(","));
boost::replace_all(message2, "4", "a");
boost::replace_all(message2, "3", "e");
boost::replace_all(message2, "0", "o");
boost::replace_all(message2, "6", "g");
boost::replace_all(message2, "5", "s");
boost::replace_all(message2, "7", "t");
for (auto filter : result)
{
if (retrun)
break;
if (boost::contains(message2, filter))
{
if (clear == "")
{
clear = "";
for (int i = 0; i < 120; i++)
clear += "\n";
}
*bSendPackets = true;
chat_stack::Say(". " + clear, true);
retrun = true;
lastfilter = format(filter);
lastname = format(name);
}
}
}
}
if (sendmsg.test_and_set(300000) &&
hacks::shared::antiaim::communicate)
chat_stack::Say("!!meow");
if (crypt_chat)
{
if (message.find("!!") == 0)
{
if (ucccccp::validate(message))
{
if (ucccccp::decrypt(message) == "meow" &&
hacks::shared::antiaim::communicate &&
data[0] != LOCAL_E->m_IDX &&
playerlist::AccessData(ENTITY(data[0])).state !=
playerlist::k_EState::CAT)
{
playerlist::AccessData(ENTITY(data[0])).state =
playerlist::k_EState::CAT;
chat_stack::Say("!!meow");
}
PrintChat("\x07%06X%s\x01: %s", 0xe05938, name.c_str(),
ucccccp::decrypt(message).c_str());
}
}
}
chatlog::LogMessage(data[0], message);
buf = bf_read(data, s);
buf.Seek(0);
}
}
if (dispatch_log)
{
logging::Info("D> %i", type);
std::ostringstream str{};
while (buf.GetNumBytesLeft())
{
unsigned char byte = buf.ReadByte();
str << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(byte) << ' ';
}
logging::Info("MESSAGE %d, DATA = [ %s ]", type, str.str().c_str());
buf.Seek(0);
}
votelogger::user_message(buf, type);
return original(_this, type, buf);
}
const char *skynum[] = { "sky_tf2_04",
"sky_upward",
"sky_dustbowl_01",
@ -1036,80 +285,3 @@ static CatVar
static CatVar halloween_mode(CV_SWITCH, "halloween_mode", "0",
"Forced Halloween mode",
"forced tf_forced_holiday 2");
void LevelInit_hook(void *_this, const char *newmap)
{
static const LevelInit_t original =
(LevelInit_t) hooks::clientmode.GetMethod(offsets::LevelInit());
playerlist::Save();
votelogger::antikick_ticks = 0;
hacks::shared::lagexploit::bcalled = false;
#if ENABLE_VISUALS
typedef bool *(*LoadNamedSkys_Fn)(const char *);
uintptr_t addr = gSignatures.GetEngineSignature(
"55 89 E5 57 31 FF 56 8D B5 ? ? ? ? 53 81 EC 6C 01 00 00");
static LoadNamedSkys_Fn LoadNamedSkys = LoadNamedSkys_Fn(addr);
bool succ;
logging::Info("Going to load the skybox");
#ifdef __clang__
asm("movl %1, %%edi; push skynum[(int) skybox_changer]; call %%edi; mov "
"%%eax, %0; add %%esp, 4h"
: "=r"(succ)
: "r"(LoadNamedSkys));
#else
succ = LoadNamedSkys(skynum[(int) skybox_changer]);
#endif
logging::Info("Loaded Skybox: %s", succ ? "true" : "false");
ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday");
if (halloween_mode)
holiday->SetValue(2);
else if (holiday->m_nValue == 2)
holiday->SetValue(2);
#endif
g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec");
hacks::shared::aimbot::Reset();
chat_stack::Reset();
hacks::shared::anticheat::ResetEverything();
original(_this, newmap);
hacks::shared::walkbot::OnLevelInit();
#if ENABLE_IPC
if (ipc::peer)
{
ipc::peer->memory->peer_user_data[ipc::peer->client_id].ts_connected =
time(nullptr);
}
#endif
}
void LevelShutdown_hook(void *_this)
{
static const LevelShutdown_t original =
LevelShutdown_t(hooks::clientmode.GetMethod(offsets::LevelShutdown()));
need_name_change = true;
playerlist::Save();
g_Settings.bInvalid = true;
hacks::shared::aimbot::Reset();
chat_stack::Reset();
hacks::shared::anticheat::ResetEverything();
original(_this);
#if ENABLE_IPC
if (ipc::peer)
{
ipc::peer->memory->peer_user_data[ipc::peer->client_id]
.ts_disconnected = time(nullptr);
}
#endif
}
#if ENABLE_VISUALS
int RandomInt_hook(void *_this, int iMinVal, int iMaxVal)
{
static const RandomInt_t original =
RandomInt_t(hooks::vstd.GetMethod(offsets::RandomInt()));
if (medal_flip && iMinVal == 0 && iMaxVal == 9)
return 0;
return original(_this, iMinVal, iMaxVal);
}
#endif

View File

@ -40,46 +40,7 @@ uint32_t SDL_GetWindowFlags_hook(SDL_Window *window)
void SDL_GL_SwapWindow_hook(SDL_Window *window)
{
static SDL_SysWMinfo wminfo;
wminfo.version.major = 2;
wminfo.version.minor = 0;
typedef SDL_bool (*SDL_GetWindowWMInfo_t)(SDL_Window * window,
SDL_SysWMinfo * info);
static SDL_GetWindowWMInfo_t GetWindowWMInfo =
*reinterpret_cast<SDL_GetWindowWMInfo_t *>(
sharedobj::libsdl().Pointer(0xFD4D8));
static bool init_wminfo{ false };
if (!init_wminfo)
{
GetWindowWMInfo(window, &wminfo);
init_wminfo = true;
}
if (!sdl_current_window)
sdl_current_window = window;
static bool init{ false };
static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext();
if (cathook && !disable_visuals)
{
PROF_SECTION(SWAPWINDOW_cathook);
if (not init)
{
draw_api::initialize();
init = true;
}
render_cheat_visuals();
}
{
PROF_SECTION(SWAPWINDOW_tf2);
SDL_GL_MakeCurrent(window, tf2_sdl);
SDL_GL_SwapWindow_o(window);
// glXMakeContextCurrent(wminfo.info.x11.display,
// wminfo.info.x11.window,
// wminfo.info.x11.window, tf2);
// glXSwapBuffers(wminfo.info.x11.display, wminfo.info.x11.window);
}
}
int SDL_PollEvent_hook(SDL_Event *event)

View File

@ -6,4 +6,5 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp"
"${CMAKE_CURRENT_LIST_DIR}/RandomInt.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SDL_GL_SwapWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SDL_PollEvent.cpp")
"${CMAKE_CURRENT_LIST_DIR}/SDL_PollEvent.cpp"
"${CMAKE_CURRENT_LIST_DIR}/IN_KeyEvent.cpp")

View File

@ -12,6 +12,63 @@ DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_,
const DrawModelState_t &state,
const ModelRenderInfo_t &info, matrix3x4_t *bone)
{
static const DrawModelExecute_t original =
(DrawModelExecute_t) hooks::modelrender.GetMethod(
offsets::DrawModelExecute());
static const char *name;
static std::string sname;
static IClientUnknown *unk;
static IClientEntity *ent;
if (!cathook ||
!(spectator_target || no_arms || no_hats ||
(clean_screenshots && g_IEngine->IsTakingScreenshot())))
{
original(_this, state, info, matrix);
return;
}
PROF_SECTION(DrawModelExecute);
if (no_arms || no_hats)
{
if (info.pModel)
{
name = g_IModelInfo->GetModelName(info.pModel);
if (name)
{
sname = name;
if (no_arms && sname.find("arms") != std::string::npos)
{
return;
}
else if (no_hats &&
sname.find("player/items") != std::string::npos)
{
return;
}
}
}
}
unk = info.pRenderable->GetIClientUnknown();
if (unk)
{
ent = unk->GetIClientEntity();
if (ent)
{
if (ent->entindex() == spectator_target)
{
return;
}
}
if (ent && !effect_chams::g_EffectChams.drawing &&
effect_chams::g_EffectChams.ShouldRenderChams(ent))
{
return;
}
}
return original::DrawModelExecute(this_, state, info, bone);
}
}

View File

@ -11,6 +11,118 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(FrameStageNotify, void, void *this_,
ClientFrameStage_t stage)
{
if (nightmode)
{
static int OldNightmode = 0;
if (OldNightmode != (int) nightmode)
{
static ConVar *r_DrawSpecificStaticProp =
g_ICvar->FindVar("r_DrawSpecificStaticProp");
if (!r_DrawSpecificStaticProp)
{
r_DrawSpecificStaticProp =
g_ICvar->FindVar("r_DrawSpecificStaticProp");
return;
}
r_DrawSpecificStaticProp->SetValue(0);
for (MaterialHandle_t i = g_IMaterialSystem->FirstMaterial();
i != g_IMaterialSystem->InvalidMaterial();
i = g_IMaterialSystem->NextMaterial(i))
{
IMaterial *pMaterial = g_IMaterialSystem->GetMaterial(i);
if (!pMaterial)
continue;
if (strstr(pMaterial->GetTextureGroupName(), "World") ||
strstr(pMaterial->GetTextureGroupName(), "StaticProp"))
{
if (nightmode)
if (strstr(pMaterial->GetTextureGroupName(),
"StaticProp"))
pMaterial->ColorModulate(0.3f, 0.3f, 0.3f);
else
pMaterial->ColorModulate(0.05f, 0.05f, 0.05f);
else
pMaterial->ColorModulate(1.0f, 1.0f, 1.0f);
}
}
OldNightmode = nightmode;
}
}
static IClientEntity *ent;
PROF_SECTION(FrameStageNotify_TOTAL);
if (!g_IEngine->IsInGame())
g_Settings.bInvalid = true;
{
PROF_SECTION(FSN_skinchanger);
hacks::tf2::skinchanger::FrameStageNotify(stage);
}
if (resolver && cathook && !g_Settings.bInvalid &&
stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
{
PROF_SECTION(FSN_resolver);
for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++)
{
if (i == g_IEngine->GetLocalPlayer())
continue;
ent = g_IEntityList->GetClientEntity(i);
if (ent && !ent->IsDormant() && !NET_BYTE(ent, netvar.iLifeState))
{
Vector &angles = NET_VECTOR(ent, netvar.m_angEyeAngles);
if (angles.x >= 90)
angles.x = -89;
if (angles.x <= -90)
angles.x = 89;
angles.y = fmod(angles.y + 180.0f, 360.0f);
if (angles.y < 0)
angles.y += 360.0f;
angles.y -= 180.0f;
}
}
}
if (cathook && stage == FRAME_RENDER_START)
{
INetChannel *ch;
ch = (INetChannel *) g_IEngine->GetNetChannelInfo();
if (ch && !hooks::IsHooked((void *) ch))
{
hooks::netchannel.Set(ch);
hooks::netchannel.HookMethod(HOOK_ARGS(CanPacket));
hooks::netchannel.HookMethod(HOOK_ARGS(SendNetMsg));
hooks::netchannel.HookMethod(HOOK_ARGS(Shutdown));
hooks::netchannel.Apply();
#if ENABLE_IPC
ipc::UpdateServerAddress();
#endif
}
}
if (cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START)
{
IF_GAME(IsTF())
{
if (CE_GOOD(LOCAL_E) && no_zoom)
RemoveCondition<TFCond_Zoomed>(LOCAL_E);
}
if (force_thirdperson && !g_pLocalPlayer->life_state &&
CE_GOOD(g_pLocalPlayer->entity))
{
CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 1;
}
if (stage == 5 && show_antiaim && g_IInput->CAM_IsThirdPerson())
{
if (CE_GOOD(g_pLocalPlayer->entity))
{
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 4) =
g_Settings.last_angles.x;
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 8) =
g_Settings.last_angles.y;
}
}
}
return original::FrameStageNotify(this_, stage);
}
}

View File

@ -11,6 +11,13 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(IN_KeyEvent, int, void *this_, int eventcode,
ButtonCode_t keynum, const char *binding)
{
#if ENABLE_GUI
/*
if (g_pGUI->ConsumesKey((ButtonCode_t)keynum) && g_pGUI->Visible()) {
return 0;
}
*/
#endif
return original::IN_KeyEvent(this_, eventcode, keynum, binding);
}
}

View File

@ -10,6 +10,74 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(OverrideView, void, void *this_, CViewSetup *setup)
{
return original::OverrideView(this_, setup);
static bool zoomed;
original::OverrideView(this_, setup);
if (!cathook)
return;
if (g_pLocalPlayer->bZoomed && override_fov_zoomed)
{
setup->fov = override_fov_zoomed;
}
else
{
if (override_fov)
{
setup->fov = override_fov;
}
}
if (spectator_target)
{
CachedEntity *spec = ENTITY(spectator_target);
if (CE_GOOD(spec) && !CE_BYTE(spec, netvar.iLifeState))
{
setup->origin =
spec->m_vecOrigin + CE_VECTOR(spec, netvar.vViewOffset);
// why not spectate yourself
if (spec == LOCAL_E)
{
setup->angles =
CE_VAR(spec, netvar.m_angEyeAnglesLocal, QAngle);
}
else
{
setup->angles = CE_VAR(spec, netvar.m_angEyeAngles, QAngle);
}
}
if (g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_SPACE))
{
spectator_target = 0;
}
}
if (freecam)
{
static Vector freecam_origin{ 0 };
static bool freecam_last{ false };
if (freecam.KeyDown())
{
if (not freecam_last)
{
freecam_origin = setup->origin;
}
float sp, sy, cp, cy;
QAngle angle;
Vector forward;
g_IEngine->GetViewAngles(angle);
sy = sinf(DEG2RAD(angle[1]));
cy = cosf(DEG2RAD(angle[1]));
sp = sinf(DEG2RAD(angle[0]));
cp = cosf(DEG2RAD(angle[0]));
forward.x = cp * cy;
forward.y = cp * sy;
forward.z = -sp;
forward *= 4;
freecam_origin += forward;
setup->origin = freecam_origin;
}
freecam_last = freecam.KeyDown();
}
draw::fov = setup->fov;
}
}

View File

@ -11,6 +11,138 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_,
unsigned int panel, bool force, bool allow_force)
{
return original::PaintTraverse(this_, panel, force, allow_force);
static bool textures_loaded = false;
static unsigned long panel_focus = 0;
static unsigned long panel_scope = 0;
static unsigned long panel_top = 0;
static bool cur, draw_flag = false;
static bool call_default = true;
static ConVar *software_cursor = g_ICvar->FindVar("cl_software_cursor");
static const char *name;
static std::string name_s, name_stripped, reason_stripped;
#if ENABLE_VISUALS
if (!textures_loaded)
{
textures_loaded = true;
#ifndef FEATURE_RADAR_DISABLED
hacks::tf::radar::Init();
#endif
}
#endif
if (pure_bypass)
{
if (!pure_addr)
{
pure_addr = *reinterpret_cast<void ***>(
gSignatures.GetEngineSignature(
"A1 ? ? ? ? 85 C0 74 ? C7 44 24 ? ? ? ? ? 89 04 24") +
1);
}
if (*pure_addr)
pure_orig = *pure_addr;
*pure_addr = (void *) 0;
}
else if (pure_orig)
{
*pure_addr = pure_orig;
pure_orig = (void *) 0;
}
call_default = true;
if (cathook && panel_scope && no_zoom && vp == panel_scope)
call_default = false;
if (software_cursor_mode)
{
cur = software_cursor->GetBool();
switch ((int) software_cursor_mode)
{
case 1:
if (!software_cursor->GetBool())
software_cursor->SetValue(1);
break;
case 2:
if (software_cursor->GetBool())
software_cursor->SetValue(0);
break;
#if ENABLE_GUI
/*
case 3:
if (cur != g_pGUI->Visible()) {
software_cursor->SetValue(g_pGUI->Visible());
}
break;
case 4:
if (cur == g_pGUI->Visible()) {
software_cursor->SetValue(!g_pGUI->Visible());
}
*/
#endif
}
}
if (call_default)
original::PaintTraverse(this_, panel, force, allow_force);
// To avoid threading problems.
PROF_SECTION(PT_total);
if (vp == panel_top)
draw_flag = true;
if (!cathook)
return;
if (!panel_top)
{
name = g_IPanel->GetName(vp);
if (strlen(name) > 4)
{
if (name[0] == 'M' && name[3] == 'S')
{
panel_top = vp;
}
}
}
if (!panel_focus)
{
name = g_IPanel->GetName(vp);
if (strlen(name) > 5)
{
if (name[0] == 'F' && name[5] == 'O')
{
panel_focus = vp;
}
}
}
if (!panel_scope)
{
name = g_IPanel->GetName(vp);
if (!strcmp(name, "HudScope"))
{
panel_scope = vp;
}
}
if (!g_IEngine->IsInGame())
{
g_Settings.bInvalid = true;
}
if (vp != panel_focus)
return;
g_IPanel->SetTopmostPopup(panel_focus, true);
if (!draw_flag)
return;
draw_flag = false;
if (disable_visuals)
return;
if (clean_screenshots && g_IEngine->IsTakingScreenshot())
return;
#if ENABLE_GUI
g_pGUI->Update();
#endif
PROF_SECTION(PT_active);
draw::UpdateWTS();
}
}

View File

@ -11,6 +11,9 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(RandomInt, int, IUniformRandomStream *this_, int min,
int max)
{
if (medal_flip && min == 0 && max == 9)
return 0;
return original::RandomInt(this_, min, max);
}
}

View File

@ -10,6 +10,47 @@ namespace hooked_methods
DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window)
{
static SDL_SysWMinfo wminfo;
wminfo.version.major = 2;
wminfo.version.minor = 0;
typedef SDL_bool (*SDL_GetWindowWMInfo_t)(SDL_Window * window,
SDL_SysWMinfo * info);
static SDL_GetWindowWMInfo_t GetWindowWMInfo =
*reinterpret_cast<SDL_GetWindowWMInfo_t *>(
sharedobj::libsdl().Pointer(0xFD4D8));
static bool init_wminfo{ false };
if (!init_wminfo)
{
GetWindowWMInfo(window, &wminfo);
init_wminfo = true;
}
if (!sdl_current_window)
sdl_current_window = window;
static bool init{ false };
static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext();
if (cathook && !disable_visuals)
{
PROF_SECTION(SWAPWINDOW_cathook);
if (not init)
{
draw_api::initialize();
init = true;
}
render_cheat_visuals();
}
{
PROF_SECTION(SWAPWINDOW_tf2);
SDL_GL_MakeCurrent(window, tf2_sdl);
SDL_GL_SwapWindow_o(window);
// glXMakeContextCurrent(wminfo.info.x11.display,
// wminfo.info.x11.window,
// wminfo.info.x11.window, tf2);
// glXSwapBuffers(wminfo.info.x11.display, wminfo.info.x11.window);
}
return original::SDL_GL_SwapWindow(window);
}
}