[Android Studio] fontaipi:
Hi first thanks for your guide,

I'm trying to enable -usb-passthrough on Windows and I got an error running your script.

OS : Windows 11

Emulator : Pixel 5 - API 31

adb root - OK

❯ .\rootAVD.bat C:\PROGRA~2\Android\android-sdk\system-images\android-31\default\x86_64\ramdisk.img PATCHFSTAB GetUSBHPmodZ
[*] Set Directorys
[-] Test if ADB SHELL is working
[-] ADB connectoin possible
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[*] looking for Magisk installer Zip
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] C:\Users\pfontaine\workspace\rootAVD\Magisk.zip: 1 file pushed, 0 skipped. 37.9 MB/s (17930822 bytes in 0.452s)
[*] create Backup File
Access is denied.
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] C:\PROGRA~2\Android\android-sdk\system-images\android-31\default\x86_64\ramdisk.img: 1 file pushed, 0 skipped. 181.9 MB/s (4106161 bytes in 0.022s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 129.9 MB/s (7847625 bytes in 0.058s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in a ranchu emulator shell
[-] Api Level Arch Detect
[-] Device Platform is x64 only
[-] Device SDK API: 31
[-] First API Level: 31
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Checking available Magisk Versions
wget: short read, have only 30
[?] Choose a Magisk Version to install and make it local
[!] (s)how all available Magisk Versions
[1] local stable 'cc79a96f'(24307) (ENTER)
[2] stable 24.3
[3] canary cc79a96f(24307)
[4] alpha a32c4561-alpha(24307)
3
[-] You choose Magisk alpha Version cc79a96f(24307)
[*] Deleting local Magisk 'cc79a96f'(24307)
[*] Downloading Magisk alpha cc79a96f(24307)
wget: got bad TLS record (len:2019) while expecting encrypted data
03 03 40 18 00 00 00 00 00 00 04 82 05 ab a3 12 fb f2 f0 ec ec b0 bf 82 37 31 50 56 bd 4f 09 9c 36 d0 13 39 b5 7f e0 ec 85 f8 00 a7 e1 33 ad 07 64 8c 73 39 7d da d8 8d 41 bb 7d 0c 4b 1a 48 da d5 d0 7e b7 06 6a 79 9a 2a 9b d9 d2 55 9e ea 3b b5 24 c3 15 f1 92 bd 72 f3 aa e4 a3 76 04 5d 24 c7 b1 f6
wget: connection closed prematurely
[!] Error while downloading Magisk alpha cc79a96f(24307)
[-] patching it together
[!] Downloading Magisk alpha cc79a96f(24307) complete!
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[*] Downloading USB HOST Permissions Module Zip
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk cc79a96f(24307) Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[-] copy all x86_64 files from /data/data/com.android.shell/Magisk/lib/x86_64 to /data/data/com.android.shell/Magisk
[*] Detecting ramdisk.img compression
[!] Ramdisk.img uses lz4_legacy compression
[-] taken from shakalaca's MagiskOnEmulator/process.sh
[*] executing ramdisk splitting / extraction / repacking
[-] API level greater then 30
[*] Check if we need to repack ramdisk before patching ..
[*] After decompressing ramdisk.img, magiskboot will work
Detected format: [lz4_legacy]
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=1
[-] Magisk patched boot image detected
[-] Constructing environment - PAY ATTENTION to the AVDs Screen
[!] we are root
su: invalid uid/gid '-c'
[!] not root yet
[!] Couldn't construct environment
[!] Double Check Root Access
[!] Re-Run Script with clean ramdisk.img and try again
[!] aborting the script

Any ideas ?