Skip to content

Commit

Permalink
Fixed compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nullifiedcat committed Feb 24, 2017
1 parent 8b639c1 commit 9de57b1
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1168214098." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.965909756" name="Linux GCC" nonInternalBuilderId="cdt.managedbuild.target.gnu.builder.exe.debug" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1799148153" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder buildPath="${workspace_loc:/cathook}/TF2" id="cdt.managedbuild.target.gnu.builder.exe.debug.1383099376" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<builder buildPath="${workspace_loc:/cathook}" id="cdt.managedbuild.target.gnu.builder.exe.debug.1383099376" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.782611349" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.883030293" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.908662295" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "source-sdk-2013"]
path = source-sdk-2013
url = https://github.com/ValveSoftware/source-sdk-2013
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Disclaimer
I know that the style sucks. There is a lot of design errors and cancerous patterns. Most of the code was intended to be *temporary*.
I know that the style sucks. There is a lot of design errors and cancerous patterns. Most of the code was intended to be *temporary*.

# Compilation
`make`

# Injection
`sudo ./attach-backtrace` if you want to see backtrace after the game crashes.
37 changes: 37 additions & 0 deletions attach
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

line=`pidof hl2_linux`
arr=($line)
inst=$1
if [ $# == 0 ]; then
inst=0
fi

if [ ${#arr[@]} == 0 ]; then
echo tf2 isn\'t running!
exit
fi

if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
echo wrong index!
exit
fi

echo Running instances: ${arr[@]}
echo Attaching to ${arr[$1]}

if grep -q $(realpath libcathook.so) /proc/${arr[$1]}/maps; then
echo already loaded
exit
fi

echo loading $(realpath libcathook.so) to ${arr[$1]}
gdb -n -q -batch \
-ex "attach ${arr[$1]}" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$(realpath libcathook.so)\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "detach" \
-ex "quit"

40 changes: 40 additions & 0 deletions attach-backtrace
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

line=`pidof hl2_linux`
arr=($line)
inst=$1
if [ $# == 0 ]; then
inst=0
fi

if [ ${#arr[@]} == 0 ]; then
echo tf2 isn\'t running!
exit
fi

if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
echo wrong index!
exit
fi

proc=${arr[$inst]}

echo Running instances: ${arr[@]}
echo Attaching to $proc

sudo ./detach $inst libcathook.so

if grep -q $(realpath libcathook.so) /proc/$proc/maps; then
echo already loaded
exit
fi

echo loading $(realpath libcathook.so) to $proc
gdb -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$(realpath libcathook.so)\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "continue" \
-ex "backtrace"
37 changes: 37 additions & 0 deletions detach
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

line=`pidof hl2_linux`
arr=($line)
inst=$1
if [ $# == 0 ]; then
inst=0
fi

if [ ${#arr[@]} == 0 ]; then
echo tf2 isn\'t running!
exit
fi

if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
echo wrong index!
exit
fi

echo Running instances: ${arr[@]}
echo Detaching from ${arr[$1]}

if grep -q $(realpath libcathook.so) /proc/${arr[$1]}/maps; then
gdb -n -q -batch \
-ex "attach ${arr[$1]}" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "set \$dlclose = (int(*)(void*)) dlclose" \
-ex "set \$library = \$dlopen(\"$(realpath libcathook.so)\", 6)" \
-ex "print \$library" \
-ex "call \$dlclose(\$library)" \
-ex "call \$dlclose(\$library)" \
-ex "detach" \
-ex "quit"
echo "Detached"
else
echo "not found!"
fi
7 changes: 4 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
CC=g++
CFLAGS=-std=gnu++11 -D_POSIX=1 -DRAD_TELEMETRY_DISABLED -DLINUX=1 -D_LINUX=1 -DPOSIX=1 -DGNUC=1 -DNO_MALLOC_OVERRIDE -O3 -w -c -shared -Wall -Wno-unknown-pragmas -fmessage-length=0 -m32 -fvisibility=hidden -fPIC
SDKFOLDER=source-sdk-2013/mp/src
CFLAGS+=-D__DRM_HWID_0='$(HWID_0)' -D__DRM_HWID_1='$(HWID_1)' -D__DRM_HWID_2='$(HWID_2)' -D__DRM_HWID_3='$(HWID_3)' -D__DRM_NAME='"$(DRM_NAME)"' -D__DRM_EXPIRES='$(DRM_EXPIRES)' -DCATHOOK_BUILD_NUMBER='"$(COUNTER)"'
CINCLUDES=-I../../ssdk/public -I../../ssdk/mathlib -I../../ssdk/common -I../../ssdk/public/tier1 -I../../ssdk/public/tier0
CINCLUDES=-I$(SDKFOLDER)/public -I$(SDKFOLDER)/mathlib -I$(SDKFOLDER)/common -I$(SDKFOLDER)/public/tier1 -I$(SDKFOLDER)/public/tier0
LDFLAGS=-m32 -fno-gnu-unique -D_GLIBCXX_USE_CXX11_ABI=0 -shared
LDLIBS=-Bstatic -lvstdlib -lstdc++ -lc -ltier0
OBJ_DIR := obj
Expand All @@ -23,7 +24,7 @@ OBJECTS := $(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(patsubst %.cpp,%.o,$(SOURCES))

.PHONY: clean directories

all: clean directories cathook
all: directories cathook

directories:
mkdir -p bin
Expand All @@ -45,7 +46,7 @@ $(OBJECTS):
$(CC) $(CFLAGS) $(CINCLUDES) $(patsubst %.o,%.cpp,$(patsubst $(OBJ_DIR)/%,$(SRC_DIR)/%,$@)) -o $@

cathook: $(OBJECTS)
LIBRARY_PATH=/home/cat/cathook/tf2-internal/cathook/lib $(CC) -o $(BIN_DIR)/$(OUT_NAME) $(LDFLAGS) $(LDLIBS) $(OBJECTS)
LIBRARY_PATH=lib $(CC) -o $(BIN_DIR)/$(OUT_NAME) $(LDFLAGS) $(LDLIBS) $(OBJECTS)
strip --strip-all $(BIN_DIR)/$(OUT_NAME)

clean:
Expand Down
4 changes: 4 additions & 0 deletions reattach
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sudo ./detach $1
sudo ./attach $1
1 change: 1 addition & 0 deletions source-sdk-2013
Submodule source-sdk-2013 added at 0d8dce
2 changes: 0 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
#include "hacks/hacklist.h"
#include "glowobjects.h"

#include "drm.h"

#include "sdk.h"

#define TF2C (g_AppID == 243750)
Expand Down
67 changes: 0 additions & 67 deletions src/drm.h

This file was deleted.

6 changes: 0 additions & 6 deletions src/hack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "common.h"
#include "sharedobj.h"
#include "hooks.h"
#include "hwid.h"
#include "netmessage.h"
#include "targeting/ITargetSystem.h"
#include "profiler.h"
Expand Down Expand Up @@ -105,14 +104,9 @@ void hack::Initialize() {
logging::Initialize();
srand(time(0));
prctl(PR_SET_DUMPABLE,0,42,42,42);
hwid::unpack_strings();
hwid::read_hwid_fstab();
hwid::read_hwid_machineid();
hwid::compute_result();
sharedobj::LoadAllSharedObjects();
g_pszTFPath = tf_path_from_maps();
interfaces::CreateInterfaces();
DRM_ENFORCE;
CDumper dumper;
dumper.SaveDump();
ClientClass* cc = interfaces::baseClient->GetAllClasses();
Expand Down
2 changes: 1 addition & 1 deletion src/hacks/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#include "../hack.h"
#include "../common.h"
#include <checksum_md5.h>
#include "../sdk.h"
#include <checksum_md5.h>
#include "../hooks/hookedmethods.h"
#include "../netmessage.h"
#include "../copypasted/CSignature.h"
Expand Down
4 changes: 1 addition & 3 deletions src/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ void SetCVarInterface(ICvar* iface);
#include <vector>
#include "aftercheaders.h"

#include "fixsdk.h"
#include <tier1/convar.h>
#include <inputsystem/ButtonCode.h>
#include "sdk.h"

//typedef void ( *FnCommandCallback_t )( const CCommand &command );

Expand Down
2 changes: 0 additions & 2 deletions src/hooks/others.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "../common.h"
#include "../netmessage.h"
#include "../hack.h"
#include "../hwid.h"
#include "hookedmethods.h"

bool CanPacket_hook(void* thisptr) {
Expand Down Expand Up @@ -134,7 +133,6 @@ bool DispatchUserMessage_hook(void* thisptr, int type, bf_read& buf) {
void LevelInit_hook(void* thisptr, const char* newmap) {
((LevelInit_t*) hooks::hkClientMode->GetMethod(hooks::offLevelInit))(thisptr, newmap);
interfaces::engineClient->ExecuteClientCmd("exec cat_matchexec");
DRM_ENFORCE;
LEVEL_INIT(Aimbot);
LEVEL_INIT(Airstuck);
LEVEL_INIT(AntiAim);
Expand Down
Loading

0 comments on commit 9de57b1

Please sign in to comment.