#!/system/bin/sh

DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"

INJECT="$DIR/Inject"
LIB="$DIR/libgnyx.so"

echo "[+] Current dir: $DIR"
echo "[+] Inject path: $INJECT"
echo "[+] Lib path: $LIB"

if [ ! -f "$INJECT" ]; then
    echo "[-] Inject not found: $INJECT"
    exit 1
fi

if [ ! -f "$LIB" ]; then
    echo "[-] lib not found: $LIB"
    exit 1
fi

chmod 777 "$DIR"
chmod 777 "$INJECT"
chmod 777 "$LIB"

if [ ! -x "$INJECT" ]; then
    echo "[-] Inject is not executable: $INJECT"
    echo "[-] 当前目录可能不允许执行 ELF，比如 /sdcard/Download"
    exit 1
fi

cd "$DIR" || exit 1

echo "[+] Ready"
echo "[+] Use absolute Inject path: $INJECT"
echo "[+] Use absolute Lib path: $LIB"

# 在你有授权的测试环境中，把你自己的合法命令写在这里
# 注意：不要再写 ./Inject，也不要写 ./libgnyx.so
# 应该使用：
# "" ... -lib "$LIB" ...

setenforce 0
$INJECT -pkg com.tencent.tmgp.gnyx -lib $LIB -hide_maps true -hide_solist true
setenforce 1