1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-09 13:41:45 +00:00
TegraExplorer/scripts/FirmwareDump.te
2023-10-11 11:16:43 +02:00

58 lines
No EOL
1.6 KiB
Text

#REQUIRE KEYS
#REQUIRE SD
p=println
pe={pause() exit()}
fwstr={fw=maj.str()+"."+min.str()+"."+pat.str()}
fv={a=readsave("bis:/save/8000000000000120")
b=a.read("/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()}
op=["Exit","Dump sysmmc"].copy()
if (emu()){op+"Dump emummc"}
p()r=menu(op,0)clear()
if(r==0){exit()}
if(r==1){if(mountsys("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}}
if(r==2){if(mountemu("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}}
clear()
fv()
p("Found firmware",fw)
p("Press Power or A to dump firmware, any other key to exit")
a = pause()
if (!a.a) {exit()}
clear()
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()