sdl_hooks, (compiles)

This commit is contained in:
Jenny White 2018-04-29 10:43:11 +03:00
parent 1c253f12af
commit f996c7777c
22 changed files with 271 additions and 316 deletions

View File

@ -14,12 +14,16 @@ extern CatVar no_zoom;
extern CatVar clean_screenshots;
extern CatVar disable_visuals;
extern CatVar disconnect_reason;
extern CatVar crypt_chat;
extern CatVar minigun_jump;
extern CatVar nolerp;
extern CatVar joinclass;
extern CatVar jointeam;
extern CatVar fakelag_amount;
extern CatVar serverlag_amount;
extern CatVar debug_projectiles;
extern CatVar semiauto;
extern CatVar engine_pred;
#if ENABLE_VISUALS
extern int spectator_target;
#endif
extern SDL_Window *sdl_current_window;
void DoSDLHooking();
void DoSDLUnhooking();
#endif

View File

@ -7,6 +7,8 @@
#pragma once
#include <string>
namespace chatlog
{

View File

@ -6,7 +6,8 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/drawmgr.hpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectChams.hpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectGlow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp")
"${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp"
"${CMAKE_CURRENT_LIST_DIR}/SDLHooks.hpp")
if(EnableGUI)
add_subdirectory(menu)

View File

@ -0,0 +1,18 @@
/*
Created by Jenny White on 29.04.18.
Copyright (c) 2018 nullworks. All rights reserved.
*/
#pragma once
struct SDL_Window;
namespace sdl_hooks
{
extern SDL_Window *window;
void applySdlHooks();
void cleanSdlHooks();
}

View File

@ -26,4 +26,9 @@ CatVar serverlag_amount(
CatVar semiauto(CV_INT, "semiauto", "0", "Semiauto");
CatVar servercrash(CV_SWITCH, "servercrash", "0", "crash servers",
"Crash servers by spamming signon net messages");
bool *bSendPackets;
bool *bSendPackets;
CatVar crypt_chat(
CV_SWITCH, "chat_crypto", "1", "Crypto chat",
"Start message with !! and it will be only visible to cathook users");

View File

@ -5,6 +5,7 @@
* Author: nullifiedcat
*/
#include <visual/SDLHooks.hpp>
#include "hack.hpp"
#include "common.hpp"
@ -312,7 +313,7 @@ free(logname);*/
hooks::clientmode4.Apply();
hooks::client.Set(g_IBaseClient);
hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage);
hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage));
#if ENABLE_VISUALS
hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify));
hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent));
@ -403,7 +404,7 @@ free(logname);*/
}
logging::Info("SSE enabled..");
#endif
DoSDLHooking();
sdl_hooks::applySdlHooks();
logging::Info("SDL hooking done");
g_IGameEventManager->AddListener(&adv_event_listener, false);
@ -453,7 +454,7 @@ void hack::Shutdown()
hack::shutdown = true;
playerlist::Save();
#if ENABLE_VISUALS
DoSDLUnhooking();
sdl_hooks::cleanSdlHooks();
#endif
logging::Info("Unregistering convars..");
ConVar_Unregister();

View File

@ -10,8 +10,6 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/nographics.cpp"
"${CMAKE_CURRENT_LIST_DIR}/others.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Paint.cpp"
"${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp"
"${CMAKE_CURRENT_LIST_DIR}/sdl.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SendNetMsg.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Shutdown.cpp")

View File

@ -7,11 +7,73 @@
#include "common.hpp"
#include "hack.hpp"
#include "MiscTemporary.hpp"
#include <link.h>
#include "HookedMethods.hpp"
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;
}
}
namespace hooked_methods
{
@ -440,64 +502,6 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time,
}
}
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;
@ -523,9 +527,3 @@ void End() {
g_GlobalVars->curtime = o_curtime;
g_GlobalVars->frametime = o_frametime;
}*/
}
bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
{
}

View File

@ -6,6 +6,7 @@
#include <chatlog.hpp>
#include <ucccccp.hpp>
#include <boost/algorithm/string.hpp>
#include <MiscTemporary.hpp>
#include "HookedMethods.hpp"
static bool retrun = false;
@ -20,9 +21,6 @@ static CatVar chat_filter(CV_STRING, "chat_censor", "", "Censor words",
"said, seperate with commas");
static CatVar chat_filter_enabled(CV_SWITCH, "chat_censor_enabled", "0",
"Enable censor", "Censor Words in chat");
static CatVar crypt_chat(
CV_SWITCH, "chat_crypto", "1", "Crypto chat",
"Start message with !! and it will be only visible to cathook users");
std::string clear = "";
std::string lastfilter{};
std::string lastname{};

View File

@ -5,16 +5,110 @@
#include "HookedMethods.hpp"
static CatVar ipc_name(CV_STRING, "name_ipc", "", "IPC Name");
CatEnum namesteal_enum({ "OFF", "PASSIVE", "ACTIVE" });
CatVar namesteal(namesteal_enum, "name_stealer", "0", "Name Stealer",
"Attemt to steal your teammates names. Usefull for avoiding "
"kicks\nPassive only changes when the name stolen is no "
"longer the best name to use\nActive Attemps to change the "
"name whenever possible");
static std::string stolen_name;
// Func to get a new entity to steal name from and returns true if a target has
// been found
bool StolenName()
{
// Array to store potential namestealer targets with a bookkeeper to tell
// how full it is
int potential_targets[32];
int potential_targets_length = 0;
// Go through entities looking for potential targets
for (int i = 1; i < HIGHEST_ENTITY; i++)
{
CachedEntity *ent = ENTITY(i);
// Check if ent is a good target
if (!ent)
continue;
if (ent == LOCAL_E)
continue;
if (!ent->m_Type == ENTITY_PLAYER)
continue;
if (ent->m_bEnemy)
continue;
// Check if name is current one
player_info_s info;
if (g_IEngine->GetPlayerInfo(ent->m_IDX, &info))
{
// If our name is the same as current, than change it
if (std::string(info.name) == stolen_name)
{
// Since we found the ent we stole our name from and it is still
// good, if user settings are passive, then we return true and
// dont alter our name
if ((int) namesteal == 1)
{
return true;
// Otherwise we continue to change our name to something
// else
}
else
continue;
}
// a ent without a name is no ent we need, contine for a different
// one
}
else
continue;
// Save the ent to our array
potential_targets[potential_targets_length] = i;
potential_targets_length++;
// With our maximum amount of players reached, dont search for anymore
if (potential_targets_length >= 32)
break;
}
// Checks to prevent crashes
if (potential_targets_length == 0)
return false;
// Get random number that we can use with our array
int target_random_num =
floor(RandFloatRange(0, potential_targets_length - 0.1F));
// Get a idx from our random array position
int new_target = potential_targets[target_random_num];
// Grab username of user
player_info_s info;
if (g_IEngine->GetPlayerInfo(new_target, &info))
{
// If our name is the same as current, than change it and return true
stolen_name = std::string(info.name);
return true;
}
// Didnt get playerinfo
return false;
}
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)
{
@ -29,7 +123,7 @@ DEFINE_HOOKED_METHOD(GetFriendPersonaName, const char *, ISteamFriends *this_,
#endif
// Check User settings if namesteal is allowed
if (namesteal && steamID == g_ISteamUser->GetSteamID())
if (namesteal && steam_id == g_ISteamUser->GetSteamID())
{
// We dont want to steal names while not in-game as there are no targets
@ -49,7 +143,7 @@ DEFINE_HOOKED_METHOD(GetFriendPersonaName, const char *, ISteamFriends *this_,
}
if ((strlen(force_name.GetString()) > 1) &&
steamID == g_ISteamUser->GetSteamID())
steam_id == g_ISteamUser->GetSteamID())
{
return force_name_newlined;

View File

@ -1,19 +0,0 @@
/*
* PaintTraverse.cpp
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/
#include "common.hpp"
#if ENABLE_GUI
#include "GUI.h"
#endif
void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
{
}

View File

@ -4,12 +4,21 @@
*/
#include <ucccccp.hpp>
#include <MiscTemporary.hpp>
#include "HookedMethods.hpp"
static CatVar newlines_msg(CV_INT, "chat_newlines", "0", "Prefix newlines",
"Add # newlines before each your message", 0, 24);
static CatVar log_sent(CV_SWITCH, "debug_log_sent_messages", "0",
"Log sent messages");
static CatVar airstuck(CV_KEY, "airstuck", "0", "Airstuck", "");
namespace hooked_methods
{
DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &message,
DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &msg,
bool force_reliable, bool voice)
{
size_t say_idx, say_team_idx;
@ -47,7 +56,7 @@ DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &message,
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);
return original::SendNetMsg(this_, stringcmd, force_reliable, voice);
//}
}
}
@ -92,6 +101,6 @@ DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &message,
logging::Info("%i bytes => %s", buffer.GetNumBytesWritten(),
bytes.c_str());
}
return original::SendNetMsg(this_, message, force_reliable, voice);
return original::SendNetMsg(this_, msg, force_reliable, voice);
}
}

View File

@ -5,6 +5,8 @@
#include "HookedMethods.hpp"
static CatVar die_if_vac(CV_SWITCH, "die_if_vac", "0", "Die if VAC banned");
namespace hooked_methods
{

View File

@ -12,6 +12,7 @@
#include "chatlog.hpp"
#include "netmessage.hpp"
#include <boost/algorithm/string.hpp>
#include <MiscTemporary.hpp>
#if ENABLE_VISUALS
@ -52,8 +53,6 @@ CatCommand spectate("spectate", "Spectate", [](const CCommand &args) {
#endif
static CatVar log_sent(CV_SWITCH, "debug_log_sent_messages", "0",
"Log sent messages");
static CatCommand plus_use_action_slot_item_server(
"+cat_use_action_slot_item_server", "use_action_slot_item_server", []() {
@ -69,117 +68,17 @@ static CatCommand minus_use_action_slot_item_server(
g_IEngine->ServerCmdKeyValues(kv);
});
static CatVar newlines_msg(CV_INT, "chat_newlines", "0", "Prefix newlines",
"Add # newlines before each your message", 0, 24);
// TODO replace \\n with \n
// TODO name \\n = \n
// static CatVar queue_messages(CV_SWITCH, "chat_queue", "0", "Queue messages",
// "Use this if you want to use spam/killsay and still be able to chat normally
// (without having your msgs eaten by valve cooldown)");
static CatVar airstuck(CV_KEY, "airstuck", "0", "Airstuck", "");
static CatVar server_crash_key(CV_KEY, "crash_server", "0", "Server crash key",
"hold key and wait...");
static CatVar die_if_vac(CV_SWITCH, "die_if_vac", "0", "Die if VAC banned");
CatEnum namesteal_enum({ "OFF", "PASSIVE", "ACTIVE" });
CatVar namesteal(namesteal_enum, "name_stealer", "0", "Name Stealer",
"Attemt to steal your teammates names. Usefull for avoiding "
"kicks\nPassive only changes when the name stolen is no "
"longer the best name to use\nActive Attemps to change the "
"name whenever possible");
static std::string stolen_name;
// Func to get a new entity to steal name from and returns true if a target has
// been found
bool StolenName()
{
// Array to store potential namestealer targets with a bookkeeper to tell
// how full it is
int potential_targets[32];
int potential_targets_length = 0;
// Go through entities looking for potential targets
for (int i = 1; i < HIGHEST_ENTITY; i++)
{
CachedEntity *ent = ENTITY(i);
// Check if ent is a good target
if (!ent)
continue;
if (ent == LOCAL_E)
continue;
if (!ent->m_Type == ENTITY_PLAYER)
continue;
if (ent->m_bEnemy)
continue;
// Check if name is current one
player_info_s info;
if (g_IEngine->GetPlayerInfo(ent->m_IDX, &info))
{
// If our name is the same as current, than change it
if (std::string(info.name) == stolen_name)
{
// Since we found the ent we stole our name from and it is still
// good, if user settings are passive, then we return true and
// dont alter our name
if ((int) namesteal == 1)
{
return true;
// Otherwise we continue to change our name to something
// else
}
else
continue;
}
// a ent without a name is no ent we need, contine for a different
// one
}
else
continue;
// Save the ent to our array
potential_targets[potential_targets_length] = i;
potential_targets_length++;
// With our maximum amount of players reached, dont search for anymore
if (potential_targets_length >= 32)
break;
}
// Checks to prevent crashes
if (potential_targets_length == 0)
return false;
// Get random number that we can use with our array
int target_random_num =
floor(RandFloatRange(0, potential_targets_length - 0.1F));
// Get a idx from our random array position
int new_target = potential_targets[target_random_num];
// Grab username of user
player_info_s info;
if (g_IEngine->GetPlayerInfo(new_target, &info))
{
// If our name is the same as current, than change it and return true
stolen_name = std::string(info.name);
return true;
}
// Didnt get playerinfo
return false;
}
static CatVar ipc_name(CV_STRING, "name_ipc", "", "IPC Name");

View File

@ -1,94 +0,0 @@
/*
* sdl.cpp
*
* Created on: May 19, 2017
* Author: nullifiedcat
*/
#include "common.hpp"
#include "hooks/HookedMethods.hpp"
#include "hack.hpp"
#include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h>
#include <SDL2/SDL_events.h>
#include <GL/glew.h>
#include <GL/gl.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
SDL_Window *sdl_current_window{ nullptr };
SDL_GL_SwapWindow_t *SDL_GL_SwapWindow_loc{ nullptr };
SDL_GL_SwapWindow_t SDL_GL_SwapWindow_o{ nullptr };
SDL_PollEvent_t *SDL_PollEvent_loc{ nullptr };
SDL_PollEvent_t SDL_PollEvent_o{ nullptr };
typedef uint32_t (*SDL_GetWindowFlags_t)(SDL_Window *window);
SDL_GetWindowFlags_t *SDL_GetWindowFlags_loc{ nullptr };
SDL_GetWindowFlags_t SDL_GetWindowFlags_o{ nullptr };
uint32_t SDL_GetWindowFlags_hook(SDL_Window *window)
{
uint32_t flags = SDL_GetWindowFlags_o(window);
flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_HIDDEN);
flags |= SDL_WINDOW_SHOWN;
return flags;
}
void SDL_GL_SwapWindow_hook(SDL_Window *window)
{
}
int SDL_PollEvent_hook(SDL_Event *event)
{
int ret = SDL_PollEvent_o(event);
if (ret)
{
logging::Info("event %x %x", event->type, event->common.type);
if (event->type == SDL_WINDOWEVENT)
{
switch (event->window.event)
{
case SDL_WINDOWEVENT_HIDDEN:
logging::Info("Window hidden");
return 0;
case SDL_WINDOWEVENT_MINIMIZED:
logging::Info("Window minimized");
return 0;
}
}
}
return ret;
}
void DoSDLHooking()
{
SDL_GL_SwapWindow_loc = reinterpret_cast<SDL_GL_SwapWindow_t *>(
sharedobj::libsdl().Pointer(0xFD648));
SDL_GL_SwapWindow_o = *SDL_GL_SwapWindow_loc;
*SDL_GL_SwapWindow_loc = SDL_GL_SwapWindow_hook;
// SDL_GetWindowFlags_loc =
// reinterpret_cast<SDL_GetWindowFlags_t*>(sharedobj::libsdl().Pointer(0xFD588));
// SDL_GetWindowFlags_o = *SDL_GetWindowFlags_loc;
// *SDL_GetWindowFlags_loc = SDL_GetWindowFlags_hook;
// SDL_PollEvent_loc =
// reinterpret_cast<SDL_PollEvent_t*>(sharedobj::libsdl().Pointer(0xFCF64));
// SDL_PollEvent_o = *SDL_PollEvent_loc;
// *SDL_PollEvent_loc = SDL_PollEvent_hook;
}
void DoSDLUnhooking()
{
*SDL_GL_SwapWindow_loc = SDL_GL_SwapWindow_o;
// *SDL_GetWindowFlags_loc = SDL_GetWindowFlags_o;
// *SDL_PollEvent_loc = SDL_PollEvent_o;
}

View File

@ -3,6 +3,9 @@
Copyright (c) 2018 nullworks. All rights reserved.
*/
#include <SDL_syswm.h>
#include <MiscTemporary.hpp>
#include <visual/SDLHooks.hpp>
#include "HookedMethods.hpp"
namespace hooked_methods
@ -24,8 +27,8 @@ DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window)
GetWindowWMInfo(window, &wminfo);
init_wminfo = true;
}
if (!sdl_current_window)
sdl_current_window = window;
if (!sdl_hooks::window)
sdl_hooks::window = window;
static bool init{ false };
@ -44,13 +47,11 @@ DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window)
{
PROF_SECTION(SWAPWINDOW_tf2);
SDL_GL_MakeCurrent(window, tf2_sdl);
SDL_GL_SwapWindow_o(window);
original::SDL_GL_SwapWindow(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);
}
}

View File

@ -6,7 +6,8 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/drawmgr.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectChams.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectGlow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp")
"${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SDLHooks.cpp")
if(EnableGUI)
add_subdirectory(menu)

View File

@ -6,6 +6,7 @@
*/
#include <visual/EffectChams.hpp>
#include <MiscTemporary.hpp>
#include "common.hpp"
// static CatVar chams_experimental(CV_SWITCH, "chams_effect", "0",

View File

@ -6,6 +6,7 @@
*/
#include <visual/EffectGlow.hpp>
#include <MiscTemporary.hpp>
#include "common.hpp"
IMaterialSystem *materials = nullptr;

33
src/visual/SDLHooks.cpp Normal file
View File

@ -0,0 +1,33 @@
/*
Created by Jenny White on 29.04.18.
Copyright (c) 2018 nullworks. All rights reserved.
*/
#include "SDLHooks.hpp"
#include "HookedMethods.hpp"
namespace sdl_hooks
{
SDL_Window *window{ nullptr };
namespace pointers
{
hooked_methods::types::SDL_GL_SwapWindow *SDL_GL_SwapWindow{ nullptr };
}
void applySdlHooks()
{
pointers::SDL_GL_SwapWindow = reinterpret_cast<hooked_methods::types::SDL_GL_SwapWindow *>(sharedobj::libsdl().Pointer(0xFD648));
hooked_methods::original::SDL_GL_SwapWindow = *pointers::SDL_GL_SwapWindow;
*pointers::SDL_GL_SwapWindow = hooked_methods::methods::SDL_GL_SwapWindow;
}
void cleanSdlHooks()
{
*pointers::SDL_GL_SwapWindow = hooked_methods::original::SDL_GL_SwapWindow;
}
}

View File

@ -12,6 +12,7 @@
#include <GL/glew.h>
#include <GL/gl.h>
#include <visual/SDLHooks.hpp>
#if EXTERNAL_DRAWING
extern "C" {
@ -77,7 +78,7 @@ void initialize()
}
xoverlay_show();
#else
context = SDL_GL_CreateContext(sdl_current_window);
context = SDL_GL_CreateContext(sdl_hooks::window);
glClearColor(1.0, 0.0, 0.0, 0.5);
glewExperimental = GL_TRUE;
glewInit();
@ -159,7 +160,7 @@ void draw_begin()
#if EXTERNAL_DRAWING
xoverlay_draw_begin();
#else
SDL_GL_MakeCurrent(sdl_current_window, context);
SDL_GL_MakeCurrent(sdl_hooks::window, context);
#endif
glez_begin();
}
@ -168,7 +169,7 @@ void draw_end()
{
PROF_SECTION(DRAWEX_draw_end);
glez_end();
SDL_GL_MakeCurrent(sdl_current_window, nullptr);
SDL_GL_MakeCurrent(sdl_hooks::window, nullptr);
#if EXTERNAL_DRAWING
xoverlay_draw_end();
#endif

View File

@ -5,6 +5,7 @@
* Author: nullifiedcat
*/
#include <MiscTemporary.hpp>
#include "common.hpp"
#include "visual/drawing.hpp"
#include "hack.hpp"