1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00
TegraExplorer/scripts/FirmwareDump.te
2021-07-25 17:49:00 +02:00

53 lines
No EOL
1.6 KiB
Text

#REQUIRE KEYS
p=println
pe={pause() exit()}
fwstr={fw=maj.str()+"."+min.str()+"."+pat.str()}
fv={a=readsave("bis:/save/8000000000000120")
b=a.readFile("/meta/imkvdb.arc")
c=["BYTE[]",9,8,0,0,0,0,0,1]
d=b.find(c)
if(d>0){
e=b.slice(d+8,4).project()
ver=(e[3]<<24)|(e[2]<<16)|(e[1]<<8)|(e[0])
pat=((ver>>16)&((1<<4)- 1))
min=((ver>>20)&((1<<6)- 1))
maj=((ver>>26)&((1<<6)- 1))
}.else(){print("Fw not found")pe()}
a=0 fwstr()}
if(mountsys("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}
fv()
sysfw=fw
p("Sys' fw is",fw)
emufw=""
if (emu()){if(!mountemu("SYSTEM")){fv()emufw=fw p("Emu's fw is",fw)}}
op=["Exit","Dump sysmmc"].copy()
if (emufw!=""){op+"Dump emummc"}
p()r=menu(op,0)clear()
if(r==0){exit()}
if(r==1){fw=sysfw if(mountsys("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}}
if(r==2){fw=emufw if(mountemu("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}}
mkdir("sd:/tegraexplorer")
mkdir("sd:/tegraexplorer/Firmware")
bsp="sd:/tegraexplorer/Firmware/"+fw
if(fsexists(bsp)){p("Dir already exists! Press power to replace, any other key to exit") a=pause() if(!a.power){exit()} deldir(bsp)}
mkdir(bsp)
p("Dumping to",bsp)
con=readdir("bis:/Contents/registered")
if(con.result!=0){println("Fail reading dir")pe()}
c=(con.files.len()+con.folders.len()).str()
i=1 f=0 t=timer()
dump={
fi.foreach("x"){
if(f){fp="bis:/Contents/registered/"+x+"/00"}
.else(){fp="bis:/Contents/registered/"+x}
name=x
if(ncatype(fp)==1){name=name- 4+".cnmt.nca"}
color(0x00FF00)
print("\r["+i.str()+"/"+c+"]", x)
if(copyfile(fp,bsp+"/"+name)){println("\nErr during copy")pe()}
i=i+1
}
}
fi=con.files dump()
f=1 fi=con.folders dump()
p("\nDone! Took",timer()-t/1000,"s")pause()