Add reload option to loader

Automatically if loaded
This commit is contained in:
8dcc 2023-07-21 06:25:11 +02:00
parent 8216613d11
commit b76e33d526
1 changed files with 34 additions and 10 deletions

View File

@ -3,16 +3,40 @@
pid=$(pidof "hl_linux")
libpath=$(realpath "libhlcheat.so")
# Used to echo the command. For debugging.
#set -x
if grep -q "$libpath" "/proc/$pid/maps"; then
echo -e "hl-cheat already loaded. Reloading...\n";
# 0x2 -> RTLD_NOW
# 0x6 -> RTLD_LAZY | RTLD_NOLOAD
# For more info on the 3 mid lines, see self_unload() in main.c
sudo gdb -n -q -batch \
-ex "attach $pid" \
-ex "set \$dlopen = (void* (*)(char*, int))dlopen" \
-ex "set \$dlclose = (int (*)(void*))dlclose" \
-ex "set \$dlerror = (char* (*)(void))dlerror" \
\
-ex "set \$self = \$dlopen(\"$libpath\", 6)" \
-ex "call \$dlclose(\$self)" \
-ex "call \$dlclose(\$self)" \
\
-ex "call \$dlopen(\"$libpath\", 2)" \
-ex "call \$dlerror()" \
-ex "detach" \
-ex "quit"
else
sudo gdb -n -q -batch \
-ex "attach $pid" \
-ex "set \$dlopen = (void* (*)(char*, int))dlopen" \
-ex "set \$dlclose = (int (*)(void*))dlclose" \
-ex "set \$dlerror = (char* (*)(void))dlerror" \
-ex "call \$dlopen(\"$libpath\", 2)" \
-ex "call \$dlerror()" \
-ex "detach" \
-ex "quit"
fi
# -ex "set \$dlclose = (int (*)(void*))dlclose" \
set +x
echo -e "\nDone."