diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..1f9e6f84 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,26 @@ +# File responsible for building the cathook "binary package" + +image: "nullworks/cathook-ci-ubuntu:latest" + +variables: + GIT_SUBMODULE_STRATEGY: recursive +stages: + - build + +pages: + script: + # Build cathook + - mkdir build_cathook && pushd build_cathook && cmake .. && make && popd + # Create the "package" containing everything needed + - mkdir package && mv ./bin/libcathook.so ./package/libcathook.so && mv ./data ./package/data && mv ./config_data ./package/config_data && mv ./scripts/binarypackage/install ./package/install && mv ./scripts/binarypackage/attach ./package/attach + # Build a static gdb + - mkdir build_gdb && pushd build_gdb && wget http://ftp.gnu.org/gnu/gdb/gdb-9.1.tar.xz -O gdb.tar.xz && tar xf gdb.tar.xz --strip-components 1 && mkdir build && pushd build && ../configure --prefix=<> --enable-static=yes --enable-inprocess-agent=no CFLAGS="-static -Os -s" CXXFLAGS="-Os -s -static" && make && popd && popd + # Create public directory + - mkdir public && tar -czf ./public/package.tar.gz ./package/ && mv ./build_gdb/build/gdb/gdb ./public/gdb + artifacts: + paths: + - public + expire_in: 1 weeks + stage: build + only: + - stable diff --git a/scripts/binarypackage/attach b/scripts/binarypackage/attach new file mode 100755 index 00000000..55b1f301 --- /dev/null +++ b/scripts/binarypackage/attach @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Error codes: +# 1 Generic +# 2 TF2 not running + +set -e + +[[ ! -z "$SUDO_USER" ]] && RUNUSER="$SUDO_USER" || RUNUSER="$LOGNAME" + +line=$(pgrep -u $RUNUSER hl2_linux || true) +arr=($line) + +if [ $# == 1 ]; then + proc=$1 +else + if [ ${#arr[@]} == 0 ]; then + echo TF2 isn\'t running! + exit 2 + fi + proc=${arr[0]} +fi + +echo Running instances: "${arr[@]}" +echo Attaching to "$proc" + +#sudo ./detach $inst bin/libcathook.so + +#if grep -q "$(realpath bin/libcathook.so)" /proc/"$proc"/maps; then +# echo already loaded +# exit +#fi + +# pBypass for crash dumps being sent +# You may also want to consider using -nobreakpad in your launch options. +mkdir -p /tmp/dumps # Make it as root if it doesnt exist +chown root:root /tmp/dumps # Claim it as root +chmod 000 /tmp/dumps # No permissions + +FILENAME="/tmp/.gl$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 6)" + +cp "libcathook.so" "$FILENAME" + +echo loading "$FILENAME" to "$proc" + + +gdbbin="gdb" +if ! [ -x "$(command -v gdb)" ]; then + gdbbin="../gdb" + chmod +x "$gdbbin" +fi + +$gdbbin -n -q -batch \ + -ex "attach $proc" \ + -ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \ + -ex "call \$dlopen(\"$FILENAME\", 1)" \ + -ex "call dlerror()" \ + -ex 'print (char *) $2' \ + -ex "detach" \ + -ex "quit" + +rm $FILENAME diff --git a/scripts/binarypackage/install b/scripts/binarypackage/install new file mode 100755 index 00000000..3b775d49 --- /dev/null +++ b/scripts/binarypackage/install @@ -0,0 +1,3 @@ +#!/bin/bash +\cp -rf ./data/ ../ +\cp -nr ./config_data/* ../data diff --git a/scripts/binarypackage/readme b/scripts/binarypackage/readme new file mode 100644 index 00000000..76dbe580 --- /dev/null +++ b/scripts/binarypackage/readme @@ -0,0 +1 @@ +Just some scripts used by the "binary" version of cathook available in cathook-gui. Ignore this if you are just using cathook.