Skip to content

Commit b87e574

Browse files
author
Calvin Fuchs
committed
Changed sourcecode for CPR
1 parent dc74e50 commit b87e574

4 files changed

Lines changed: 173 additions & 60 deletions

File tree

source/fs/fscopy.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,16 @@ ErrCode_t FolderDelete(const char *path){
168168
ret = FolderDelete(temp);
169169
}
170170
else {
171-
gfx_puts_limit(fs[i].name, (YLEFT - x) / 16 - 10);
172-
BoxRestOfScreen();
171+
// gfx_puts_limit(fs[i].name, (YLEFT - x) / 16 - 10);
172+
// BoxRestOfScreen();
173173
res = f_unlink(temp);
174174
if (res){
175175
ret = newErrCode(res);
176176
}
177-
gfx_con_setpos(x, y);
177+
// gfx_con_setpos(x, y);
178+
178179
}
180+
gfx_printf("Deleted: %s \n", temp);
179181
free(temp);
180182
}
181183
}

source/gfx/gfxutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void gfx_printTopInfo() {
1313
bq24193_get_property(BQ24193_ChargeStatus, &current_charge_status);
1414
SETCOLOR(COLOR_DEFAULT, COLOR_WHITE);
1515
gfx_con_setpos(0, 0);
16-
gfx_printf("Tegraexplorer %d.%d.%d | Battery: %d%% %c\n", LP_VER_MJ, LP_VER_MN, LP_VER_BF, battery >> 8, ((current_charge_status) ? 129 : 32));
16+
gfx_printf("CPR %d.%d.%d | Battery: %d%% %c\n", LP_VER_MJ, LP_VER_MN, LP_VER_BF, battery >> 8, ((current_charge_status) ? 129 : 32));
1717
RESETCOLOR;
1818
}
1919

source/main.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,25 @@ void ipl_main()
291291

292292
gfx_clearscreen();
293293

294-
int res = -1;
294+
// int res = -1;
295295

296296

297-
if (btn_read() & BTN_VOL_DOWN || DumpKeys())
298-
res = GetKeysFromFile("sd:/switch/prod.keys");
297+
// if (btn_read() & BTN_VOL_DOWN || DumpKeys())
298+
// res = GetKeysFromFile("sd:/switch/prod.keys");
299299

300-
TConf.keysDumped = (res > 0) ? 0 : 1;
300+
// TConf.keysDumped = (res > 0) ? 0 : 1;
301301

302-
if (res > 0)
303-
DrawError(newErrCode(TE_ERR_KEYDUMP_FAIL));
302+
// if (res > 0)
303+
// DrawError(newErrCode(TE_ERR_KEYDUMP_FAIL));
304304

305-
if (TConf.keysDumped)
306-
SetKeySlots();
305+
// if (TConf.keysDumped)
306+
// SetKeySlots();
307307

308-
if (res == 0)
309-
hidWait();
308+
// if (res == 0)
309+
// hidWait();
310310

311-
if (FileExists("sd:/startup.te"))
312-
RunScript("sd:/", newFSEntry("startup.te"));
311+
// if (FileExists("sd:/startup.te"))
312+
// RunScript("sd:/", newFSEntry("startup.te"));
313313

314314
EnterMainMenu();
315315

source/tegraexplorer/mainmenu.c

Lines changed: 155 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,59 @@
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+
2125
extern hekate_config h_cfg;
2226

2327
enum {
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

4251
MenuEntry_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

6176
void HandleSD(){
@@ -104,10 +119,7 @@ void ViewKeys(){
104119

105120
void 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+
134241
menuPaths 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

150261
void 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

Comments
 (0)