actually fix bot crashes (fr this time)
This commit is contained in:
parent
329a0fafe8
commit
e098cb9c06
57
preload-gdb
Executable file
57
preload-gdb
Executable file
@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ $EUID == 0 ]; then
|
||||
echo "This script must not be run as root"
|
||||
exit
|
||||
fi
|
||||
[[ ! -z "$SUDO_USER" ]] && RUNUSER=$SUDO_USER || RUNUSER=$LOGNAME
|
||||
line=$(pgrep -u $RUNUSER hl2_linux)
|
||||
arr=($line)
|
||||
|
||||
if [ ${#arr[@]} != 0 ]; then
|
||||
echo TF2 Already Running!
|
||||
exit
|
||||
fi
|
||||
|
||||
line=$(pgrep -u $RUNUSER steam)
|
||||
arr=($line)
|
||||
|
||||
if [ ${#arr[@]} == 0 ]; then
|
||||
echo Steam not running! Starting it.
|
||||
steam > /dev/null 2>&1 &
|
||||
sleep 30
|
||||
echo Done starting Steam
|
||||
fi
|
||||
|
||||
FILENAME="/tmp/.gl$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 6)"
|
||||
|
||||
cp "bin/libcathook.so" "$FILENAME"
|
||||
|
||||
echo "Preloading cathook as $FILENAME!"
|
||||
TF2_PATH=$(realpath ~/.steam/steam/steamapps/common/Team\ Fortress\ 2/)
|
||||
pushd "$TF2_PATH"
|
||||
LD_PRELOAD="$FILENAME" LD_LIBRARY_PATH="$TF2_PATH/bin" "$TF2_PATH/hl2_linux" -game tf &
|
||||
echo "Game preloading!"
|
||||
popd;
|
||||
sleep 10;
|
||||
|
||||
line=$(pgrep -u $RUNUSER hl2_linux)
|
||||
arr=($line)
|
||||
|
||||
if [ $# == 1 ]; then
|
||||
proc=$1
|
||||
else
|
||||
if [ ${#arr[@]} == 0 ]; then
|
||||
echo TF2 isn\'t running!
|
||||
exit
|
||||
fi
|
||||
proc=${arr[0]}
|
||||
fi
|
||||
|
||||
gdbbin="gdb"
|
||||
sudo $gdbbin -n -q \
|
||||
-ex "attach $proc" \
|
||||
-ex "continue" \
|
||||
|
||||
sleep 3;
|
||||
rm "$FILENAME"
|
@ -15,7 +15,7 @@ void *dlopen(const char *__file, int __mode) __THROWNL
|
||||
logging::Info("Intercepted launcher.so");
|
||||
logging::Info("Waiting for cathook to load Launcher symbols...");
|
||||
while (sharedobj::launcher().lmap == nullptr)
|
||||
usleep(1);
|
||||
usleep(10);
|
||||
logging::Info("Loaded Launcher symbols");
|
||||
static uintptr_t launcher_sig = gSignatures.GetLauncherSignature("55 89 E5 56 53 8D 9D ? ? ? ? 81 EC A0 00 00 00");
|
||||
static BytePatch LauncherBytePatch = BytePatch(launcher_sig, { 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3 });
|
||||
|
@ -62,21 +62,24 @@ static CatCommand RemoveNullhook("debug_material_hook_clear", "Debug", []() { Re
|
||||
static settings::Boolean debug_framerate("debug.framerate", "false");
|
||||
static float framerate = 0.0f;
|
||||
static Timer send_timer{};
|
||||
static InitRoutine init_nographics([]() {
|
||||
static InitRoutine init_nographics(
|
||||
[]()
|
||||
{
|
||||
#if ENABLE_TEXTMODE
|
||||
NullHook();
|
||||
NullHook();
|
||||
#endif
|
||||
EC::Register(
|
||||
EC::Paint,
|
||||
[]() {
|
||||
if (!*debug_framerate)
|
||||
return;
|
||||
framerate = 0.9 * framerate + (1.0 - 0.9) * g_GlobalVars->absoluteframetime;
|
||||
if (send_timer.test_and_set(1000))
|
||||
logging::Info("FPS: %f", 1.0f / framerate);
|
||||
},
|
||||
"material_cm");
|
||||
});
|
||||
EC::Register(
|
||||
EC::Paint,
|
||||
[]()
|
||||
{
|
||||
if (!*debug_framerate)
|
||||
return;
|
||||
framerate = 0.9 * framerate + (1.0 - 0.9) * g_GlobalVars->absoluteframetime;
|
||||
if (send_timer.test_and_set(1000))
|
||||
logging::Info("FPS: %f", 1.0f / framerate);
|
||||
},
|
||||
"material_cm");
|
||||
});
|
||||
static bool blacklist_file(const char *&filename)
|
||||
{
|
||||
const static char *blacklist[] = { ".ani", ".wav", ".mp3", ".vvd", ".vtx", ".vtf", ".vfe", ".cache" /*, ".pcf"*/ };
|
||||
@ -271,65 +274,71 @@ static void UnHookFs()
|
||||
}
|
||||
|
||||
#if ENABLE_TEXTMODE
|
||||
static InitRoutineEarly nullify_textmode([]() {
|
||||
// SDL_CreateWindow has a "flag" parameter. We simply give it HIDDEN as a flag
|
||||
// 0x8 = SDL_HIDDEN
|
||||
static BytePatch patch1(gSignatures.GetLauncherSignature, "C7 43 ? ? ? ? ? C7 44 24 ? ? ? ? ? C7 44 24", 0xb, { 0x8 });
|
||||
static InitRoutineEarly nullify_textmode(
|
||||
[]()
|
||||
{
|
||||
// SDL_CreateWindow has a "flag" parameter. We simply give it HIDDEN as a flag
|
||||
// 0x8 = SDL_HIDDEN
|
||||
static BytePatch patch1(gSignatures.GetLauncherSignature, "C7 43 ? ? ? ? ? C7 44 24 ? ? ? ? ? C7 44 24", 0xb, { 0x8 });
|
||||
|
||||
// all are the same size so use same patch for all
|
||||
std::vector<unsigned char> patch_arr = { 0x90, 0x90, 0x90, 0x90, 0x90 };
|
||||
// all are the same size so use same patch for all
|
||||
std::vector<unsigned char> patch_arr = { 0x90, 0x90, 0x90, 0x90, 0x90 };
|
||||
|
||||
// Hide the SDL window
|
||||
static BytePatch patch2(gSignatures.GetLauncherSignature, "E8 ? ? ? ? C6 43 25 01 83 C4 5C", 0x0, patch_arr);
|
||||
static BytePatch patch3(gSignatures.GetLauncherSignature, "E8 ? ? ? ? 8B 43 14 89 04 24 E8 ? ? ? ? C6 43 25 01 83 C4 1C", 0x0, patch_arr);
|
||||
static BytePatch patch4(gSignatures.GetLauncherSignature, "89 14 24 E8 ? ? ? ? 8B 45 B4", 0x3, patch_arr);
|
||||
// Hide the SDL window
|
||||
static BytePatch patch2(gSignatures.GetLauncherSignature, "E8 ? ? ? ? C6 43 25 01 83 C4 5C", 0x0, patch_arr);
|
||||
static BytePatch patch3(gSignatures.GetLauncherSignature, "E8 ? ? ? ? 8B 43 14 89 04 24 E8 ? ? ? ? C6 43 25 01 83 C4 1C", 0x0, patch_arr);
|
||||
static BytePatch patch4(gSignatures.GetLauncherSignature, "89 14 24 E8 ? ? ? ? 8B 45 B4", 0x3, patch_arr);
|
||||
|
||||
ReduceRamUsage();
|
||||
// CVideoMode_Common::Init SetupStartupGraphic
|
||||
// Make SetupStartupGraphic instantly return
|
||||
auto setup_graphic_addr = e8call_direct(gSignatures.GetEngineSignature("E8 ? ? ? ? 8B 93 ? ? ? ? 85 D2 0F 84")) + 0x18;
|
||||
static BytePatch patch5(setup_graphic_addr, { 0x81, 0xC4, 0x6C, 0x20, 0x00, 0x00, 0x5B, 0x5E, 0x5F, 0x5D, 0xC3 });
|
||||
// CMaterialSystem::SwapBuffers
|
||||
static BytePatch patch6(sharedobj::materialsystem().Pointer(0x3ed90), { 0x31, 0xC0, 0x40, 0xC3 });
|
||||
// V_RenderView
|
||||
static BytePatch patch7(gSignatures.GetEngineSignature, "55 89 E5 56 53 83 C4 80 C7 45 ? 00 00 00 00 A1 ? ? ? ? C7 45 ? 00 00 00 00 85 C0", 0x1d3, { 0x90, 0x90, 0x90, 0x90, 0x90 });
|
||||
ReduceRamUsage();
|
||||
// CVideoMode_Common::Init SetupStartupGraphic
|
||||
// Make SetupStartupGraphic instantly return
|
||||
auto setup_graphic_addr = e8call_direct(gSignatures.GetEngineSignature("E8 ? ? ? ? 8B 93 ? ? ? ? 85 D2 0F 84")) + 0x18;
|
||||
static BytePatch patch5(setup_graphic_addr, { 0x81, 0xC4, 0x6C, 0x20, 0x00, 0x00, 0x5B, 0x5E, 0x5F, 0x5D, 0xC3 });
|
||||
// CMaterialSystem::SwapBuffers
|
||||
static BytePatch patch6(sharedobj::materialsystem().Pointer(0x3ed70), { 0x31, 0xC0, 0x40, 0xC3 });
|
||||
// V_RenderView
|
||||
static BytePatch patch7(gSignatures.GetEngineSignature, "55 89 E5 56 53 83 C4 80 C7 45 ? 00 00 00 00 A1 ? ? ? ? C7 45 ? 00 00 00 00 85 C0", 0x1d3, { 0x90, 0x90, 0x90, 0x90, 0x90 });
|
||||
|
||||
patch1.Patch();
|
||||
patch2.Patch();
|
||||
patch3.Patch();
|
||||
patch4.Patch();
|
||||
patch5.Patch();
|
||||
patch6.Patch();
|
||||
patch7.Patch();
|
||||
});
|
||||
patch1.Patch();
|
||||
patch2.Patch();
|
||||
patch3.Patch();
|
||||
patch4.Patch();
|
||||
patch5.Patch();
|
||||
patch6.Patch();
|
||||
patch7.Patch();
|
||||
});
|
||||
#endif
|
||||
|
||||
static Timer signon_timer;
|
||||
static InitRoutine nullifiy_textmode2([]() {
|
||||
static InitRoutine nullifiy_textmode2(
|
||||
[]()
|
||||
{
|
||||
#if ENABLE_TEXTMODE
|
||||
ReduceRamUsage();
|
||||
ReduceRamUsage();
|
||||
#endif
|
||||
null_graphics.installChangeCallback(
|
||||
[](settings::VariableBase<bool> &, bool after)
|
||||
{
|
||||
if (after)
|
||||
ReduceRamUsage();
|
||||
else
|
||||
UnHookFs();
|
||||
});
|
||||
#if ENABLE_TEXTMODE
|
||||
// Catbots still hit properly, this just makes it easier to Stub stuff not needed in textmode
|
||||
uintptr_t g_bTextMode_ptrptr = gSignatures.GetEngineSignature("A2 ? ? ? ? 8B 43 04") + 0x1;
|
||||
|
||||
BytePatch::mprotectAddr(g_bTextMode_ptrptr, 4, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
BytePatch::mprotectAddr(*(uintptr_t *) g_bTextMode_ptrptr, 4, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
BytePatch::mprotectAddr(**(uintptr_t **) g_bTextMode_ptrptr, 4, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
|
||||
bool *g_bTextMode_ptr = *((bool **) g_bTextMode_ptrptr);
|
||||
*g_bTextMode_ptr = true;
|
||||
// Skip downloading ressources
|
||||
static BytePatch patch1(gSignatures.GetEngineSignature, "0F 85 ? ? ? ? A1 ? ? ? ? 8D 8B ? ? ? ?", 0x1, { 0x81 });
|
||||
patch1.Patch();
|
||||
// CViewRender::Render
|
||||
static BytePatch patch2(gSignatures.GetClientSignature, "55 89 E5 57 56 53 81 EC DC 03 00 00 C7 85 ? ? ? ? 00 00 00 00", 0x0, { 0x31, 0xC0, 0x40, 0xC3 });
|
||||
patch2.Patch();
|
||||
#endif
|
||||
null_graphics.installChangeCallback([](settings::VariableBase<bool> &, bool after) {
|
||||
if (after)
|
||||
ReduceRamUsage();
|
||||
else
|
||||
UnHookFs();
|
||||
});
|
||||
#if ENABLE_TEXTMODE
|
||||
// Catbots still hit properly, this just makes it easier to Stub stuff not needed in textmode
|
||||
uintptr_t g_bTextMode_ptrptr = gSignatures.GetEngineSignature("A2 ? ? ? ? 8B 43 04") + 0x1;
|
||||
|
||||
BytePatch::mprotectAddr(g_bTextMode_ptrptr, 4, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
BytePatch::mprotectAddr(*(uintptr_t *) g_bTextMode_ptrptr, 4, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
BytePatch::mprotectAddr(**(uintptr_t **) g_bTextMode_ptrptr, 4, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
|
||||
bool *g_bTextMode_ptr = *((bool **) g_bTextMode_ptrptr);
|
||||
*g_bTextMode_ptr = true;
|
||||
// Skip downloading ressources
|
||||
static BytePatch patch1(gSignatures.GetEngineSignature, "0F 85 ? ? ? ? A1 ? ? ? ? 8D 8B ? ? ? ?", 0x1, { 0x81 });
|
||||
patch1.Patch();
|
||||
// CViewRender::Render
|
||||
static BytePatch patch2(gSignatures.GetClientSignature, "55 89 E5 57 56 53 81 EC DC 03 00 00 C7 85 ? ? ? ? 00 00 00 00", 0x0, { 0x31, 0xC0, 0x40, 0xC3 });
|
||||
patch2.Patch();
|
||||
#endif
|
||||
});
|
||||
|
Reference in New Issue
Block a user