Created
April 27, 2025 09:00
-
-
Save Howard20181/522f2ff2a8744971b041c9c0c5329d9e to your computer and use it in GitHub Desktop.
Patch boot.img and pull for Magisk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set bootname=%1 | |
set apkname=%2 | |
if not defined bootname ( | |
goto usage | |
) | |
if not defined apkname ( | |
goto usage | |
) | |
if defined bootname ( | |
if exist %bootname% ( | |
adb wait-for-device | |
adb push %bootname% /data/local/tmp/boot.img | |
) else ( | |
echo %bootname% Not Found! | |
goto end | |
) | |
if exist %apkname% ( | |
adb push %apkname% /data/local/tmp/magisk.apk | |
goto patch | |
) else ( | |
echo %apkname% Not Found! | |
goto end | |
) | |
) | |
:patch | |
adb push "%~dp0\patch-boot.sh" /data/local/tmp/ | |
adb shell chmod u+x /data/local/tmp/patch-boot.sh | |
adb shell /data/local/tmp/patch-boot.sh /data/local/tmp/boot.img /data/local/tmp/magisk.apk | |
adb pull /data/local/tmp/new-boot.img | |
adb shell rm /data/local/tmp/new-boot.img | |
goto end | |
:usage | |
echo "Usage <boot image> <apk name>" | |
:end | |
pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
INSTALL_DIR=/data/local/tmp/magisk | |
mkdir -p $INSTALL_DIR | |
cd $INSTALL_DIR || exit 1 | |
MAGISKBIN=/data/adb/magisk | |
MAGISKTMP=/sbin | |
[ -d /sbin ] || MAGISKTMP=/debug_ramdisk | |
if [ ! -f "$2" ]; then | |
echo "No magisk apk found" | |
exit 1 | |
fi | |
ABI=$(getprop ro.product.cpu.abi) | |
for file in busybox magiskpolicy magiskboot magiskinit magisk init-ld; do | |
rm -f "$INSTALL_DIR/$file" | |
unzip -d $INSTALL_DIR -oj "$2" "lib/$ABI/lib$file.so" | |
mv $INSTALL_DIR/lib$file.so $INSTALL_DIR/$file | |
chmod 755 "$INSTALL_DIR/$file" | |
done | |
for file in util_functions.sh boot_patch.sh stub.apk; do | |
rm -f "$INSTALL_DIR/$file" | |
unzip -d $INSTALL_DIR -oj "$2" "assets/$file" | |
chmod 755 "$INSTALL_DIR/$file" | |
done | |
rm -rf "${INSTALL_DIR:?}/chromeos" | |
mkdir -p "$INSTALL_DIR/chromeos" | |
for file in futility kernel_data_key.vbprivk kernel.keyblock; do | |
unzip -d "$INSTALL_DIR/chromeos" -oj "$2" "assets/chromeos/$file" | |
chmod 755 "$INSTALL_DIR/chromeos/$file" | |
done | |
rm "$2" | |
. ./util_functions.sh | |
get_flags | |
api_level_arch_detect | |
if [ -n "$(getprop ro.boot.vbmeta.device)" ] || [ -n "$(getprop ro.boot.vbmeta.size)" ]; then | |
PATCHVBMETAFLAG=false | |
elif getprop ro.product.ab_ota_partitions | grep -wq vbmeta; then | |
PATCHVBMETAFLAG=false | |
else | |
PATCHVBMETAFLAG=true | |
fi | |
LEGACYSAR=false | |
grep ' / ' /proc/mounts | grep -q '/dev/root' && LEGACYSAR=true | |
SOURCEDMODE=true | |
. ./boot_patch.sh | |
mv ./new-boot.img /data/local/tmp/ | |
./magiskboot cleanup | |
cd /data/local/tmp | |
rm "$1" "$0" | |
rm -rf "${INSTALL_DIR:?}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment