Merge pull request #18 from no-boot-device/patch-2

update ./attach
This commit is contained in:
nullifiedcat 2017-03-25 19:34:19 +03:00 committed by GitHub
commit 195b70cf0e

15
attach
View File

@ -17,21 +17,24 @@ if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
exit
fi
echo Running instances: ${arr[@]}
echo Attaching to ${arr[$1]}
proc=${arr[$inst]}
if grep -q $(realpath bin/libcathook.so) /proc/${arr[$1]}/maps; then
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
echo loading $(realpath bin/libcathook.so) to ${arr[$1]}
echo loading $(realpath bin/libcathook.so) to $proc
gdb -n -q -batch \
-ex "attach ${arr[$1]}" \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$(realpath bin/libcathook.so)\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "detach" \
-ex "quit"