1818#include "../utils/utils.h"
1919#include "../config.h"
2020
21+ #include "../fs/readers/folderReader.h"
22+ #include "../fs/fstypes.h"
23+ #include "../fs/fscopy.h"
24+
2125extern hekate_config h_cfg ;
2226
2327enum {
2428 MainExplore = 0 ,
25- MainBrowseSd ,
26- MainMountSd ,
27- MainBrowseEmmc ,
28- MainBrowseEmummc ,
29- MainTools ,
30- MainPartitionSd ,
31- MainDumpFw ,
32- MainViewKeys ,
29+ DeleteBootFlags ,
30+ DeleteThemes ,
31+ FixClingWrap ,
32+ FixAll ,
33+ MainOther ,
34+ // MainBrowseSd,
35+ // MainMountSd,
36+ // MainBrowseEmmc,
37+ // MainBrowseEmummc,
38+ // MainTools,
39+ // MainPartitionSd,
40+ // MainDumpFw,
41+ // MainViewKeys,
3342 MainViewCredits ,
3443 MainExit ,
3544 MainPowerOff ,
3645 MainRebootRCM ,
37- MainRebootNormal ,
46+ // MainRebootNormal,
3847 MainRebootHekate ,
39- MainRebootAMS
48+ // MainRebootAMS,
4049};
4150
4251MenuEntry_t mainMenuEntries [] = {
43- [MainExplore ] = {.optionUnion = COLORTORGB (COLOR_WHITE ) | SKIPBIT , .name = "-- Main --" },
44- [MainBrowseSd ] = {.optionUnion = COLORTORGB (COLOR_GREEN ), .name = "Fix common Issues" },
52+ [MainExplore ] = {.optionUnion = COLORTORGB (COLOR_WHITE ) | SKIPBIT , .name = "-- Tools --" },
53+ [DeleteBootFlags ] = {.optionUnion = COLORTORGB (COLOR_GREEN ), .name = "Delete boot2.flags" },
54+ [DeleteThemes ] = {.optionUnion = COLORTORGB (COLOR_GREEN ), .name = "Delete installed themes" },
55+ [FixClingWrap ] = {.optionUnion = COLORTORGB (COLOR_GREEN ), .name = "Fix ClingWrap" },
56+ [FixAll ] = {.optionUnion = COLORTORGB (COLOR_GREEN ), .name = "Try everything" },
57+
58+ // [MainBrowseSd] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Browse SD"},
59+ // [MainMountSd] = {.optionUnion = COLORTORGB(COLOR_YELLOW)}, // To mount/unmount the SD
60+ // [MainBrowseEmmc] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Browse EMMC"},
61+ // [MainBrowseEmummc] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Browse EMUMMC"},
62+ // [MainTools] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Tools --"},
63+ // [MainPartitionSd] = {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Partition the sd"},
64+ // [MainDumpFw] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Dump Firmware"},
65+ // [MainViewKeys] = {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "View dumped keys"},
66+ [MainOther ] = {.optionUnion = COLORTORGB (COLOR_WHITE ) | SKIPBIT , .name = "\n-- Other --" },
4567 [MainViewCredits ] = {.optionUnion = COLORTORGB (COLOR_YELLOW ), .name = "Credits" },
4668 [MainExit ] = {.optionUnion = COLORTORGB (COLOR_WHITE ) | SKIPBIT , .name = "\n-- Exit --" },
4769 [MainPowerOff ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Power off" },
4870 [MainRebootRCM ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Reboot to RCM" },
49- [MainRebootNormal ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Reboot normally" },
71+ // [MainRebootNormal] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Reboot normally"},
5072 [MainRebootHekate ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Reboot to bootloader/update.bin" },
51- [MainRebootAMS ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Reboot to atmosphere/reboot_payload.bin" }
73+ // [MainRebootAMS] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Reboot to atmosphere/reboot_payload.bin"}
5274};
5375
5476void HandleSD (){
@@ -59,7 +81,7 @@ void HandleSD(){
5981 hidWait ();
6082 }
6183 else
62- FileExplorer ("sd:/atmosphere/contents " );
84+ FileExplorer ("sd:/" );
6385}
6486
6587void HandleEMMC (){
@@ -97,10 +119,7 @@ void ViewKeys(){
97119
98120void ViewCredits (){
99121 gfx_clearscreen ();
100- gfx_printf ("\nTegraexplorer v%d.%d.%d\nBy SuchMemeManySkill\n\nBased on Lockpick_RCM & Hekate, from shchmue & CTCaer\n\n\n" , LP_VER_MJ , LP_VER_MN , LP_VER_BF );
101-
102- if (hidRead ()-> r )
103- gfx_printf ("%k\"I'm not even sure if it works\" - meme" , COLOR_ORANGE );
122+ gfx_printf ("\nCommon Problem Resolver v%d.%d.%d\nBy Team Neptune\n\nBased on TegraExplorer by SuchMemeManySkill,\nLockpick_RCM & Hekate, from shchmue & CTCaer\n\n\n" , LP_VER_MJ , LP_VER_MN , LP_VER_BF );
104123 hidWait ();
105124}
106125
@@ -124,20 +143,119 @@ void MountOrUnmountSD(){
124143 hidWait ();
125144}
126145
146+
147+ void DeleteFileSimple (char * thing ){
148+ //char *thing = CombinePaths(path, entry.name);
149+ int res = f_unlink (thing );
150+ if (res )
151+ DrawError (newErrCode (res ));
152+ free (thing );
153+ }
154+
155+ void deleteBootFlags (){
156+ gfx_clearscreen ();
157+ char * storedPath = CpyStr ("sd:/atmosphere/contents" );
158+ int readRes = 0 ;
159+ Vector_t fileVec = ReadFolder (storedPath , & readRes );
160+ if (readRes ){
161+ clearFileVector (& fileVec );
162+ DrawError (newErrCode (readRes ));
163+ } else {
164+ vecDefArray (FSEntry_t * , fsEntries , fileVec );
165+ for (int i = 0 ; i < fileVec .count ; i ++ ){
166+
167+ char * suf = "/flags/boot2.flag" ;
168+ char * flagPath = CombinePaths (storedPath , fsEntries [i ].name );
169+ flagPath = CombinePaths (flagPath , suf );
170+
171+ if (FileExists (flagPath )) {
172+ gfx_printf ("Deleting: %s\n" , flagPath );
173+ DeleteFileSimple (flagPath );
174+ }
175+ free (flagPath );
176+ }
177+ }
178+ gfx_printf ("\n\n Done, press a key to proceed." );
179+ hidWait ();
180+ }
181+
182+ void deleteTheme (char * basePath , char * folderId ){
183+ char * path = CombinePaths (basePath , folderId );
184+ if (FileExists (path )) {
185+ gfx_printf ("-- Theme found: %s\n" , path );
186+ FolderDelete (path );
187+ }
188+ free (path );
189+ }
190+
191+ void deleteInstalledThemes (){
192+ gfx_clearscreen ();
193+ deleteTheme ("sd:/atmosphere/contents" , "0100000000001000" );
194+ deleteTheme ("sd:/atmosphere/contents" , "0100000000001007" );
195+ deleteTheme ("sd:/atmosphere/contents" , "0100000000001013" );
196+
197+ gfx_printf ("\n\n Done, press a key to proceed." );
198+ hidWait ();
199+ }
200+
201+ void fixClingWrap (){
202+ gfx_clearscreen ();
203+ char * bpath = CpyStr ("sd:/_b0otloader" );
204+ char * bopath = CpyStr ("sd:/bootloader" );
205+ char * kpath = CpyStr ("sd:/atmosphere/_k1ps" );
206+ char * kopath = CpyStr ("sd:/atmosphere/kips" );
207+
208+ if (FileExists (bpath )) {
209+ if (FileExists (bopath )) {
210+ FolderDelete (bopath );
211+ }
212+ int res = f_rename (bpath , bopath );
213+ if (res ){
214+ DrawError (newErrCode (res ));
215+ }
216+ gfx_printf ("-- Fixed Bootloader\n" );
217+ }
218+
219+ if (FileExists (kpath )) {
220+ if (FileExists (kopath )) {
221+ FolderDelete (kopath );
222+ }
223+ int res = f_rename (bpath , kopath );
224+ if (res ){
225+ DrawError (newErrCode (res ));
226+ }
227+ gfx_printf ("-- Fixed kips\n" );
228+ }
229+
230+ gfx_printf ("\n\n Done, press a key to proceed." );
231+ hidWait ();
232+ }
233+
234+ void fixAll (){
235+ gfx_clearscreen ();
236+ deleteBootFlags ();
237+ deleteInstalledThemes ();
238+ fixClingWrap ();
239+ }
240+
127241menuPaths mainMenuPaths [] = {
128- [MainBrowseSd ] = HandleSD ,
129- [MainMountSd ] = MountOrUnmountSD ,
130- [MainBrowseEmmc ] = HandleEMMC ,
131- [MainBrowseEmummc ] = HandleEMUMMC ,
132- [MainPartitionSd ] = FormatSD ,
133- [MainDumpFw ] = DumpSysFw ,
134- [MainViewKeys ] = ViewKeys ,
135- [MainRebootAMS ] = RebootToAMS ,
242+ [DeleteBootFlags ] = deleteBootFlags ,
243+ [DeleteThemes ] = deleteInstalledThemes ,
244+ [FixClingWrap ] = fixClingWrap ,
245+ [FixAll ] = fixAll ,
246+ // [MainBrowseSd] = HandleSD,
247+ // [MainMountSd] = MountOrUnmountSD,
248+ // [MainBrowseEmmc] = HandleEMMC,
249+ // [MainBrowseEmummc] = HandleEMUMMC,
250+ // [MainPartitionSd] = FormatSD,
251+ // [MainDumpFw] = DumpSysFw,
252+ // [MainViewKeys] = ViewKeys,
253+ // [MainRebootAMS] = RebootToAMS,
136254 [MainRebootHekate ] = RebootToHekate ,
137255 [MainRebootRCM ] = reboot_rcm ,
138256 [MainPowerOff ] = power_off ,
139257 [MainViewCredits ] = ViewCredits ,
140- [MainRebootNormal ] = reboot_normal ,
258+ // [MainRebootNormal] = reboot_normal
141259};
142260
143261void EnterMainMenu (){
@@ -146,18 +264,18 @@ void EnterMainMenu(){
146264 if (sd_get_card_removed ())
147265 sd_unmount ();
148266
149- // -- Explore --
150- mainMenuEntries [MainBrowseSd ].hide = !sd_mounted ;
151- mainMenuEntries [MainMountSd ].name = (sd_mounted ) ? "Unmount SD" : "Mount SD" ;
152- mainMenuEntries [MainBrowseEmummc ].hide = (!emu_cfg .enabled || !sd_mounted );
267+ // // -- Explore --
268+ // mainMenuEntries[MainBrowseSd].hide = !sd_mounted;
269+ // mainMenuEntries[MainMountSd].name = (sd_mounted) ? "Unmount SD" : "Mount SD";
270+ // mainMenuEntries[MainBrowseEmummc].hide = (!emu_cfg.enabled || !sd_mounted);
153271
154- // -- Tools --
155- mainMenuEntries [MainPartitionSd ].hide = (!is_sd_inited || sd_get_card_removed ());
156- mainMenuEntries [MainDumpFw ].hide = (!TConf .keysDumped || !sd_mounted );
157- mainMenuEntries [MainViewKeys ].hide = !TConf .keysDumped ;
272+ // // -- Tools --
273+ // mainMenuEntries[MainPartitionSd].hide = (!is_sd_inited || sd_get_card_removed());
274+ // mainMenuEntries[MainDumpFw].hide = (!TConf.keysDumped || !sd_mounted);
275+ // mainMenuEntries[MainViewKeys].hide = !TConf.keysDumped;
158276
159- // -- Exit --
160- mainMenuEntries [MainRebootAMS ].hide = (!sd_mounted || !FileExists ("sd:/atmosphere/reboot_payload.bin" ));
277+ // // -- Exit --
278+ // mainMenuEntries[MainRebootAMS].hide = (!sd_mounted || !FileExists("sd:/atmosphere/reboot_payload.bin"));
161279 mainMenuEntries [MainRebootHekate ].hide = (!sd_mounted || !FileExists ("sd:/bootloader/update.bin" ));
162280 mainMenuEntries [MainRebootRCM ].hide = h_cfg .t210b01 ;
163281
@@ -170,4 +288,3 @@ void EnterMainMenu(){
170288 mainMenuPaths [res ]();
171289 }
172290}
173-
0 commit comments