AM_CFLAGS= -std=gnu11 -Os -g -fomit-frame-pointer -ffast-math \
-Wpedantic -Wall -Wextra -Wcast-align -Wcast-qual \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op \
- -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls \
+ -Wmissing-include-dirs -Wredundant-decls \
-Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default \
-Wundef -Wno-unused $(THUMBFLAGS) $(SIZE_OPTIMIZATION) $(INCPATHS) $(C9FLAGS) \
- -fshort-wchar -fno-builtin -std=gnu11 -DVERSION=\"$(REVISION)\" \
+ -fshort-wchar -fno-builtin -std=gnu11 -DREVISION=\"$(REVISION)\" \
-DFW_NAME=\"corbenik\" $(PATHARGS)
int cursor_min = -1;
int cursor_max = -1;
int exit = 0;
- int window_size = (TOP_HEIGHT / font_h) - 3;
+
+ // Font height is user-controlled. Realistically, if it's higher than a signed int, that's not my fault.
+ int window_size = (TOP_HEIGHT / (int)font_h) - 3;
int window_top = 0, window_bottom = window_size;
int less_mode = 0;
header("A:Enter B:Back DPAD:Nav Select:Info");
- int i = window_top;
- while (options[i].index != -1) { // -1 Sentinel.
+ for (int i = window_top; options[i].index != -1; ++i) { // -1 Sentinel.
if (i > window_bottom)
break;
- set_cursor(TOP_SCREEN, 0, i-window_top+2);
+ // NOTE - Signed to unsigned conversion here. Again, not an issue.
+ set_cursor(TOP_SCREEN, 0, (unsigned int)(i - window_top + 2) );
if (options[i].allowed == boolean_val || (is_n3ds && options[i].allowed == boolean_val_n3ds)) {
if (cursor_y == i) {
accent_color(TOP_SCREEN, 1);
fprintf(TOP_SCREEN, "%s\x1b[0m", options[i].name);
}
- ++i;
}
uint32_t key = wait_key(1);
clear_disp(TOP_SCREEN);
}
break;
+ default:
+ break;
}
if (cursor_y < cursor_min)
void dump_firm(firm_h** buffer, uint8_t index) {
if (*buffer != NULL) return;
- uint32_t firm_offset = 0x0B130000 + (index % 2) * 0x400000,
- firm_size = 0x00100000; // 1MB, because
+ // NOTE - Cast, because GCC is making assumptions about 'index'.
+ uint32_t firm_offset = (uint32_t)(0x0B130000 + (index % 2) * 0x400000),
+ firm_b_size = 0x00100000; // 1MB, because
- buffer[0] = static_allocate(firm_size);
+ buffer[0] = static_allocate(firm_b_size);
uint8_t ctr[0x10],
cid[0x10],
firm_h* firm = buffer[0];
- if (sdmmc_nand_readsectors(firm_offset / SECTOR_SIZE, firm_size / SECTOR_SIZE, (uint8_t*)firm))
+ if (sdmmc_nand_readsectors(firm_offset / SECTOR_SIZE, firm_b_size / SECTOR_SIZE, (uint8_t*)firm))
abort(" Failed to read NAND!\n");
fprintf(stderr, " Read FIRM%u off NAND.\n", index);
use_aeskey(0x06);
set_ctr(ctr);
- aes(firm, firm, firm_size / AES_BLOCK_SIZE, ctr, AES_CTR_MODE);
+ aes(firm, firm, firm_b_size / AES_BLOCK_SIZE, ctr, AES_CTR_MODE);
fprintf(stderr, " AES decrypted FIRM%u.\n", index);
*p9exefs = (exefs_h *)(p9exheader + 1);
process9->address = p9exheader->sci.textCodeSet.address;
process9->size = (*p9exefs)->fileHeaders[0].size;
- process9->offset = (void *)((*p9exefs) + 1) - (void *)firm;
+ process9->offset = (uint32_t)((*p9exefs) + 1) - (uint32_t)firm;
fprintf(stderr, " Found process9 offset\n");
return 0;
}
break;
case OP_SEEK: // Jump to offset if greater than or equal
code++;
- offset = code[0] + (code[1] << 8) + (code[2] << 16) + (code[3] << 24);
+ offset = (uint32_t)(code[0] + (code[1] << 8) + (code[2] << 16) + (code[3] << 24));
if (debug) {
#ifdef LOADER
log("seek\n");
// { IGNORE_BROKEN_SHIT, "Allow unsafe options", boolean_val, 0, 0 },
// Sentinel.
- { -1, "", "", 0, -1, -1 }, // cursor_min and cursor_max are stored in the last two.
+ { -1, "", "", 0, 0, 0 }, // cursor_min and cursor_max are stored in the last two.
};
extern unsigned int font_w;
{ 0, " Native FIRM: ", "The version of NATIVE_FIRM in use.", not_option, 0, 0},
{ 0, " AGB FIRM: ", "The version of AGB_FIRM in use. This is used to run GBA games.", not_option, 0, 0},
{ 0, " TWL FIRM: ", "The version of TWL_FIRM in use. This is used to run DS games and DSiWare.", not_option, 0, 0},
- { 0, " " FW_NAME ": " VERSION " (" REL ")", FW_NAME "'s version.", not_option, 0, 0},
+ { 0, " " FW_NAME ": " REVISION " (" REL ")", FW_NAME "'s version.", not_option, 0, 0},
{ -1, "", "", not_option, 0, 0 }
};
static int is_setup_info = 0;
{ 0, "Boot Firmware", "Generates caches, patches the firmware, and boots it.\nMake sure to 'Save Configuration' first if any options changed.", break_menu, 0, 0 },
// Sentinel.
- { -1, "", "", 0, -1, -1 }, // cursor_min and cursor_max are stored in the last two.
+ { -1, "", "", 0, 0, 0 }, // cursor_min and cursor_max are stored in the last two.
};
void
/* Not possible to be implemented as bytecode. Hey, can't win em all. */
-PATCH(modules)
+int
+patch_modules()
{
// TODO - load other module cxis here
FILE *f = fopen(PATH_MODULES "/loader.cxi", "r");
// Copy the module into the firm
memcpy(sysmodule, module, module->contentSize * 0x200);
}
- sysmodule = (ncch_h *)((uintptr_t)sysmodule + sysmodule->contentSize * 0x200);
+ sysmodule = (ncch_h *)((uint32_t)sysmodule + sysmodule->contentSize * 0x200);
}
fprintf(stderr, "Module: injected modules.\n");
+/* This code was all nicked from Luma (before the GPL headers were corrected by TuxSH)
+ Someone please remind me to fix this code.*/
+
#include <common.h>
#include <ctr9/io.h>
// This code handles restoration of backdoor
-PATCH(services)
+int
+patch_services()
{
if (svc_offs_init == 0) {
arm11Section1 = (uint8_t *)firm_loc + firm_loc->section[1].offset;
fclose(data);
// memcpy(svc_tab_open, svcbackdoor, sizeof(svcbackdoor));
- svcTable[0x7B] = 0xFFFF0000 + ((uint8_t *)svc_tab_open - (uint8_t *)exceptionsPage);
+ svcTable[0x7B] = 0xFFFF0000 + (uint32_t)((uint8_t *)svc_tab_open - (uint8_t *)exceptionsPage);
svc_tab_open += size;
// TODO - Basically all this needs to move to patcher programs.
-uint32_t wait_key(int sleep);
-
extern int patch_services();
extern int patch_modules();
extern int patch_reboot();
#include <common.h>
void poweroff();
-uint32_t wait_key(int sleep);
void abort(const char* x, ...) {
va_list ap;
}
break;
case 's':
- // Using puts isn't correct here...
+ // FIXME - Substring ANSI colors will screw up hard, so don't do that.
+ // once the color handling is moved to putc as a state machine this
+ // will no longer be an issue.
+
+ // For now, this warning stays.
disable_format = 1; // Disable format strings.
fprintf(channel, va_arg(ap, char *));
disable_format = 0; // Reenable.