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 = "-- Explore --" },
44- [MainBrowseSd ] = {.optionUnion = COLORTORGB (COLOR_GREEN ), .name = "Browse SD" },
45- [MainMountSd ] = {.optionUnion = COLORTORGB (COLOR_YELLOW )}, // To mount/unmount the SD
46- [MainBrowseEmmc ] = {.optionUnion = COLORTORGB (COLOR_BLUE ), .name = "Browse EMMC" },
47- [MainBrowseEmummc ] = {.optionUnion = COLORTORGB (COLOR_BLUE ), .name = "Browse EMUMMC" },
48- [MainTools ] = {.optionUnion = COLORTORGB (COLOR_WHITE ) | SKIPBIT , .name = "\n-- Tools --" },
49- [MainPartitionSd ] = {.optionUnion = COLORTORGB (COLOR_ORANGE ), .name = "Partition the sd" },
50- [MainDumpFw ] = {.optionUnion = COLORTORGB (COLOR_BLUE ), .name = "Dump Firmware" },
51- [MainViewKeys ] = {.optionUnion = COLORTORGB (COLOR_YELLOW ), .name = "View dumped keys" },
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 --" },
5267 [MainViewCredits ] = {.optionUnion = COLORTORGB (COLOR_YELLOW ), .name = "Credits" },
5368 [MainExit ] = {.optionUnion = COLORTORGB (COLOR_WHITE ) | SKIPBIT , .name = "\n-- Exit --" },
5469 [MainPowerOff ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Power off" },
5570 [MainRebootRCM ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Reboot to RCM" },
56- [MainRebootNormal ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Reboot normally" },
71+ // [MainRebootNormal] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Reboot normally"},
5772 [MainRebootHekate ] = {.optionUnion = COLORTORGB (COLOR_VIOLET ), .name = "Reboot to bootloader/update.bin" },
58- [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"}
5974};
6075
6176void HandleSD (){
@@ -104,10 +119,7 @@ void ViewKeys(){
104119
105120void ViewCredits (){
106121 gfx_clearscreen ();
107- 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 );
108-
109- if (hidRead ()-> r )
110- 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 );
111123 hidWait ();
112124}
113125
@@ -131,20 +143,119 @@ void MountOrUnmountSD(){
131143 hidWait ();
132144}
133145
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+
134241menuPaths mainMenuPaths [] = {
135- [MainBrowseSd ] = HandleSD ,
136- [MainMountSd ] = MountOrUnmountSD ,
137- [MainBrowseEmmc ] = HandleEMMC ,
138- [MainBrowseEmummc ] = HandleEMUMMC ,
139- [MainPartitionSd ] = FormatSD ,
140- [MainDumpFw ] = DumpSysFw ,
141- [MainViewKeys ] = ViewKeys ,
142- [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,
143254 [MainRebootHekate ] = RebootToHekate ,
144255 [MainRebootRCM ] = reboot_rcm ,
145256 [MainPowerOff ] = power_off ,
146257 [MainViewCredits ] = ViewCredits ,
147- [MainRebootNormal ] = reboot_normal ,
258+ // [MainRebootNormal] = reboot_normal
148259};
149260
150261void EnterMainMenu (){
@@ -153,18 +264,18 @@ void EnterMainMenu(){
153264 if (sd_get_card_removed ())
154265 sd_unmount ();
155266
156- // -- Explore --
157- mainMenuEntries [MainBrowseSd ].hide = !sd_mounted ;
158- mainMenuEntries [MainMountSd ].name = (sd_mounted ) ? "Unmount SD" : "Mount SD" ;
159- 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);
160271
161- // -- Tools --
162- mainMenuEntries [MainPartitionSd ].hide = (!is_sd_inited || sd_get_card_removed ());
163- mainMenuEntries [MainDumpFw ].hide = (!TConf .keysDumped || !sd_mounted );
164- 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;
165276
166- // -- Exit --
167- 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"));
168279 mainMenuEntries [MainRebootHekate ].hide = (!sd_mounted || !FileExists ("sd:/bootloader/update.bin" ));
169280 mainMenuEntries [MainRebootRCM ].hide = h_cfg .t210b01 ;
170281
0 commit comments