这是用于提取我卡住的 MTK android boot.img 的批处理脚本的一部分,由 DEV 共享。
正如标题所说,我自己是一个 AHK 新手,被循环卡住了,%boot_size% & cpio没有提取到rmdisk文件夹......
set /A N=0
:loop
FOR /F %%G IN (bin\off2.txt) DO (
if !N!==1 (
set /A ofs1=%%G
set /A N+=1
)
if !N!==3 (
set /A ofs2=%%G
set /A N+=1
)
if !N!==5 (
set /A ofs3=%%G+4
set /A N+=1
)
if `%%G` EQU `offset` (
set /A N+=1
)
)
FOR %%i IN (%1) DO ( set /A boot_size=%%~Zi )
md %~N1
bin\sfk166.exe partcopy %1 -fromto 0x0 %ofs1% %~N1\kernel_header -yes
bin\sfk166.exe partcopy %1 -fromto %ofs1% %ofs2% %~N1\kernel -yes
bin\sfk166.exe partcopy %1 -fromto %ofs2% %ofs3% %~N1\ram_header -yes
bin\sfk166.exe partcopy %1 -fromto %ofs3% %boot_size% %~N1\ram_disk.gz -yes
bin\7z.exe -tgzip x -y %~N1\ram_disk.gz -o%~N1 >nul
md %~N1\rmdisk
cd %~N1
cd rmdisk
%~dp0bin\cpio.exe -i <../ram_disk
任何帮助是极大的赞赏... ;-)
TIA
@MCL感谢 您的回复。脚本的第一部分就像直接翻译,所以它只是工作...... :-P
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
RunWait, %comspec% /c %A_ScriptDir%\bin\sfk166.exe hexfind %A_ScriptDir%\recovery.img -pat -bin /88168858/ -case>%A_ScriptDir%\bin\offset.txt, , min
RunWait, %comspec% /c %A_ScriptDir%\bin\sfk166.exe hexfind %A_ScriptDir%\recovery.img -pat -bin /FFFFFFFF1F8B08/ -case>>%A_ScriptDir%\bin\offset.txt , , min
RunWait, %comspec% /c %A_ScriptDir%\bin\sfk166.exe find %A_ScriptDir%\bin\offset.txt -pat offset>%A_ScriptDir%\bin\off2.txt, , min
RunWait, %comspec% /c %A_ScriptDir%\bin\sfk166.exe replace %A_ScriptDir%\bin\off2.txt -binary /20/0A/ -yes, , min
FileRemoveDir, %A_ScriptDir%/recovery ;to make sure old failed extracted folder is deleted
FileCreateDir, %A_ScriptDir%/recovery