From 6b84d6cd865811c3f979fb31bdfe09b9c705b5c0 Mon Sep 17 00:00:00 2001 From: Jeff <57104907+JeffVi@users.noreply.github.com> Date: Sun, 26 May 2024 16:23:12 +0200 Subject: [PATCH 1/2] Keep DeviceSettings when running a system wipe --- scripts/SystemWipe.te | 48 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/scripts/SystemWipe.te b/scripts/SystemWipe.te index 0dcc799..087d753 100644 --- a/scripts/SystemWipe.te +++ b/scripts/SystemWipe.te @@ -1,5 +1,5 @@ #REQUIRE KEYS -is=["8000000000000120","8000000000000000"] +is=["8000000000000120","8000000000000053","8000000000000000"] p=println pr=print pe={pause() exit()} @@ -97,14 +97,21 @@ 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...") -s=getfilesize("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,0x02,0x00,0x00,0x00].copy() # 0x02 imens + +# 120 save +s=getfilesize("bis:/save/"+is[0]) s1=s&0xFF s2=(s>>8)&0xFF s3=(s>>16)&0xFF s4=(s>>24)&0xFF -idb=["BYTE[]",0x49,0x4D,0x4B,0x56,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x49,0x4D,0x45,0x4E,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00].copy() +idb.addrange(imen) idb.addrange(ba0) idb.addrange(ba0) idb.addrange(ba0) @@ -128,13 +135,46 @@ idb.addrange(ba0) idb.addrange(ba0) idb.addrange(ba0) idb.addrange(ba0) -idxs=readsave("bis:/save/"+is[1]) + +# 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!\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)} From 51e8efc6a5c051c1a19580503beb6b5caebd057b Mon Sep 17 00:00:00 2001 From: Jeff <57104907+JeffVi@users.noreply.github.com> Date: Mon, 27 May 2024 20:36:57 +0200 Subject: [PATCH 2/2] Add a check if 120 or 053 is missing --- scripts/SystemWipe.te | 171 ++++++++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 73 deletions(-) diff --git a/scripts/SystemWipe.te b/scripts/SystemWipe.te index 087d753..427f253 100644 --- a/scripts/SystemWipe.te +++ b/scripts/SystemWipe.te @@ -98,84 +98,109 @@ 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...") -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] +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,0x02,0x00,0x00,0x00].copy() # 0x02 imens + idb=["BYTE[]",0x49,0x4D,0x4B,0x56,0x00,0x00,0x00,0x00].copy() # imkv -# 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) + skip53 = !fsexists("bis:/save/"+is[1]) -# 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) + if(skip53) + { + idb.add(0x01) # 0x01 imen + pr("053 save not found!!! Skip indexing it...") + }.else() + { + idb.add(0x02) # 0x02 imens + } -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 + idb.add(0x00) + idb.add(0x00) + idb.add(0x00) -pr("Done!\nDeleting user dirs...")ud=["Album","Contents","save","saveMeta","temp"] + # 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")