1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-09 13:41:45 +00:00
TegraExplorer/scripts/SystemWipe.te
2024-05-27 20:36:57 +02:00

207 lines
No EOL
4.6 KiB
Text

#REQUIRE KEYS
is=["8000000000000120","8000000000000053","8000000000000000"]
p=println
pr=print
pe={pause() exit()}
p("System wiper\n")
op=["Exit","Wipe sysmmc"].copy()
if (emu()){op+"Wipe emummc"}
r=menu(op,0)clear()
if(r==0){exit()}
if(r==1){
mount=mountsys
selected_target = "sysmmc"
}
if(r==2){
mount=mountemu
selected_target = "emummc"
}
if(mount("SYSTEM")){p("Mount failed!")pe()}
clear()
border = {
setpixels(0,0,1279,19,border_color)
setpixels(0,700,1279,719,border_color)
setpixels(0,20,19,699,border_color)
setpixels(1260,20,1279,699,border_color)
}
i = 20
x_pos = 10
y_pos = 8
["WARNING!!!",
"",
"Do you really want to wipe your system?",
"This will remove:",
"- Your Save Data",
"- Your Game Data",
"- Your User Data",
"- (Some) System Calibration Data"
"",
"This script includes wiping some calibration data.",
"Among other uses, this data is used for battery calibration.",
"This is especially problematic for lite systems,",
" as it makes the system initialize with unsafe",
" battery calibration values!",
"",
"Restoring an emmc backup is always preferable over wiping.",
"Please only use this as a last resort.",
"This script is intended to be used in aid of unbricking.",
"",
"Pull requests to fix the calibration issue are welcome",
"https://github.com/suchmememanyskill/TegraExplorer"].foreach("line")
{
printpos(x_pos, y_pos)
y_pos = y_pos + 1
print(line)
}
time = 10000
y_pos = y_pos + 4
while (i > 0)
{
i = i - 1
if (i % 2 == 0){
border_color = 0xFF0000
}.else() {
border_color = 0x000000
}
border()
sleep(500)
time = time - 500
printpos(x_pos, y_pos)
print("Waiting for", time / 1000, "seconds")
}
printpos(x_pos, y_pos)
print("Ready to wipe", selected_target, " ")
y_pos = y_pos + 1
printpos(x_pos, y_pos)
print("Press the power button to wipe, any other key to exit")
result = pause(0x70F000F)
if (!result.power)
{
exit()
}
clear()
color(0xFF0000)
pr("Deleting system saves... ")
f=readdir("bis:/save")
if(f.folders.len()!=0){p("Folders in save dir???")pe()}
f.files.foreach("x"){if(!is.contains(x)){if(delfile("bis:/save/"+x)){p("File deletion failed: ", x)pe()}}}
pr("Done!\nSetting up indexer save...")
if(fsexists("bis:/save/"+is[0]))
{
ba0=["BYTE[]",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
ba120=["BYTE[]",0x20,0x01,0x00,0x00,0x00,0x00,0x00,0x80]
ba53=["BYTE[]",0x53,0x00,0x00,0x00,0x00,0x00,0x00,0x80]
imen=["BYTE[]",0x49,0x4D,0x45,0x4E,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00]
idb=["BYTE[]",0x49,0x4D,0x4B,0x56,0x00,0x00,0x00,0x00].copy() # imkv
skip53 = !fsexists("bis:/save/"+is[1])
if(skip53)
{
idb.add(0x01) # 0x01 imen
pr("053 save not found!!! Skip indexing it...")
}.else()
{
idb.add(0x02) # 0x02 imens
}
idb.add(0x00)
idb.add(0x00)
idb.add(0x00)
# 120 save
s=getfilesize("bis:/save/"+is[0])
s1=s&0xFF
s2=(s>>8)&0xFF
s3=(s>>16)&0xFF
s4=(s>>24)&0xFF
idb.addrange(imen)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba120)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba120)
idb.add(s1)
idb.add(s2)
idb.add(s3)
idb.add(s4)
idb.add(0x00)
idb.add(0x00)
idb.add(0x00)
idb.add(0x00)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
if(!skip53)
{
# 53 save
s=getfilesize("bis:/save/"+is[1])
s1=s&0xFF
s2=(s>>8)&0xFF
s3=(s>>16)&0xFF
s4=(s>>24)&0xFF
idb.addrange(imen)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba53)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba53)
idb.add(s1)
idb.add(s2)
idb.add(s3)
idb.add(s4)
idb.add(0x00)
idb.add(0x00)
idb.add(0x00)
idb.add(0x00)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
idb.addrange(ba0)
}
idxs=readsave("bis:/save/"+is[2])
if(idxs.resize("/imkvdb.arc",idb.len())){p("imkvdb resize failed")pe()}
if(idxs.write("/imkvdb.arc",idb)){p("imkvdb write failed")pe()}
if(idxs.resize("/lastPublishedId",ba0.len())){p("lastPublishedId resize failed")pe()}
if(idxs.write("/lastPublishedId",ba0)){p("lastPublishedId write failed")pe()}
if(idxs.commit()){p("Indexer save commit failed")pe()}
idxs=0
pr("Done!")
}.else()
{
pr("120 save not found!!! Skip editing indexer save!!!")
}
pr("\nDeleting user dirs...")ud=["Album","Contents","save","saveMeta","temp"]
if(mount("USER")){p("Mount failed!")pe()}
ud.foreach("x"){pr("\n"+x,"")if(deldir("bis:/"+x)){p("Dir deletion failed")pe()}mkdir("bis:/"+x)}
mkdir("bis:/Contents/placehld")mkdir("bis:/Contents/registered")
color(0x00FF00)p("\n\nDone!")pause()