diff --git a/ios_mcp/source/menu.c b/ios_mcp/source/menu.c index 395503d..ff3d77e 100644 --- a/ios_mcp/source/menu.c +++ b/ios_mcp/source/menu.c @@ -25,6 +25,7 @@ #include "netconf.h" #include "mcp_misc.h" +#include #include #include @@ -212,6 +213,28 @@ void waitButtonInput(void) } } +void print_error(int index, const char *msg) +{ + gfx_set_font_color(COLOR_ERROR); + gfx_print(16, index, GfxPrintFlag_ClearBG, msg); + setNotificationLED(NOTIF_LED_RED, 0); + waitButtonInput(); + setNotificationLED(NOTIF_LED_PURPLE, 0); +} + +void printf_error(int index, const char *format, ...) +{ + va_list args; + va_start(args, format); + + char buffer[0x100]; + + vsnprintf(buffer, sizeof(buffer), format, args); + va_end(args); + + print_error(index, buffer); +} + /** * Initialize the network configuration. * @param index [in/out] Starting (and ending) Y position. @@ -224,9 +247,7 @@ int initNetconf(uint32_t* index) int res = netconf_init(); if (res <= 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, *index, 0, "Failed to initialize netconf: %x", res); - waitButtonInput(); + printf_error(*index, "Failed to initialize netconf: %x", res); return res; } @@ -251,9 +272,7 @@ int initNetconf(uint32_t* index) *index += CHAR_SIZE_DRC_Y; if (interface == 0xff) { - gfx_set_font_color(COLOR_ERROR); - gfx_print(16, *index, 0, "No network connection!"); - waitButtonInput(); + print_error(*index, "No network connection!"); return 1; } @@ -263,9 +282,7 @@ int initNetconf(uint32_t* index) uint8_t ip_address[4]; res = netconf_get_assigned_address(interface, (uint32_t*) ip_address); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, *index, 0, "Failed to get IP address: %x", res); - waitButtonInput(); + printf_error(*index, "Failed to get IP address: %x", res); return res; } @@ -275,9 +292,7 @@ int initNetconf(uint32_t* index) res = socketInit(); if (res <= 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, *index, 0, "Failed to initialize socketlib: %x", res); - waitButtonInput(); + printf_error(*index, "Failed to initialize socketlib: %x", res); return res; } diff --git a/ios_mcp/source/menu.h b/ios_mcp/source/menu.h index 8742d2e..d69a28e 100644 --- a/ios_mcp/source/menu.h +++ b/ios_mcp/source/menu.h @@ -69,6 +69,12 @@ int drawMenu(const char* title, const Menu* menu, size_t count, */ void waitButtonInput(void); +/** + * Print an error message in red and indicate it on the LED + */ +void print_error(int index, const char *msg); +void printf_error(int index, const char *format, ...); + /** * Initialize the network configuration. * @param index [in/out] Starting (and ending) Y position. diff --git a/ios_mcp/source/options/DebugSystemRegion.c b/ios_mcp/source/options/DebugSystemRegion.c index 05ccc2f..2f988a5 100644 --- a/ios_mcp/source/options/DebugSystemRegion.c +++ b/ios_mcp/source/options/DebugSystemRegion.c @@ -37,9 +37,7 @@ void option_DebugSystemRegion(void) int productArea_id, gameRegion; int res = getRegionInfo(&productArea_id, &gameRegion); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to get the system region code: %x", res); - waitButtonInput(); + printf_error(index, "Failed to get the system region code: %x", res); return; } @@ -125,17 +123,17 @@ void option_DebugSystemRegion(void) } // Show the errors. - gfx_set_font_color(COLOR_ERROR); if (menu_count == 0 || menu_productArea_id < 0) { - gfx_print(16, index, 0, "Could not find a Wii U Menu title installed on this system."); - waitButtonInput(); + print_error(index, "Could not find a Wii U Menu title installed on this system."); return; - } else if (menu_count > 1) { - gfx_print(16, index, 0, "Multiple Wii U Menus were found. Someone dun goofed..."); - waitButtonInput(); + } + + if (menu_count > 1) { + print_error(index, "Multiple Wii U Menus were found. Someone dun goofed..."); return; } + gfx_set_font_color(COLOR_ERROR); if (!menu_matches_region) { gfx_printf(16, index, 0, "The %s region does not match the installed Wii U Menu.", "system"); index += CHAR_SIZE_DRC_Y + 4; @@ -164,9 +162,7 @@ void option_DebugSystemRegion(void) // Attempt to set the region code. int mcpHandle = IOS_Open("/dev/mcp", 0); if (mcpHandle < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "IOS_Open(\"/dev/mcp\") failed: %x", mcpHandle); - waitButtonInput(); + printf_error(index, "IOS_Open(\"/dev/mcp\") failed: %x", mcpHandle); return; } @@ -174,9 +170,7 @@ void option_DebugSystemRegion(void) res = MCP_GetSysProdSettings(mcpHandle, &sysProdSettings); if (res < 0) { IOS_Close(mcpHandle); - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "MCP_GetSysProdSettings() failed: %x", res); - waitButtonInput(); + printf_error(index, "MCP_GetSysProdSettings() failed: %x", res); return; } @@ -187,12 +181,11 @@ void option_DebugSystemRegion(void) res = MCP_SetSysProdSettings(mcpHandle, &sysProdSettings); IOS_Close(mcpHandle); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "MCP_SetSysProdSettings() failed: %x", res); - } else { - gfx_set_font_color(COLOR_SUCCESS); - gfx_printf(16, index, 0, "System region set to %s successfully.", menu_region_str); + printf_error(index, "MCP_SetSysProdSettings() failed: %x", res); + return; } + gfx_set_font_color(COLOR_SUCCESS); + gfx_printf(16, index, 0, "System region set to %s successfully.", menu_region_str); waitButtonInput(); } diff --git a/ios_mcp/source/options/DumpOtpAndSeeprom.c b/ios_mcp/source/options/DumpOtpAndSeeprom.c index c8c7fde..71d4c2f 100644 --- a/ios_mcp/source/options/DumpOtpAndSeeprom.c +++ b/ios_mcp/source/options/DumpOtpAndSeeprom.c @@ -41,17 +41,13 @@ int read_otp_seeprom(void *buf, int index) int res = IOS_ReadOTP(0, otp, 0x400); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to read OTP: %x", res); - waitButtonInput(); + printf_error(index, "Failed to read OTP: %x", res); return res; } res = EEPROM_Read(0, 0x100, seeprom); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to read EEPROM: %x", res); - waitButtonInput(); + printf_error(index, "Failed to read EEPROM: %x", res); return res; } @@ -82,20 +78,16 @@ static int write_file_to_sd(uint32_t *index, int fsaHandle, const char *filename int fileHandle; int res = FSA_OpenFile(fsaHandle, path, "w", &fileHandle); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, *index, 0, "Failed to create %s: %x", filename, res); + printf_error(*index, "Failed to create %s: %x", filename, res); *index += CHAR_SIZE_DRC_Y + 4; - waitButtonInput(); return res; } res = FSA_WriteFile(fsaHandle, buf, 1, size, fileHandle, 0); FSA_CloseFile(fsaHandle, fileHandle); if (res != size) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, *index, 0, "Failed to write %s: %x", filename, res); + printf_error(*index, "Failed to write %s: %x", filename, res); *index += CHAR_SIZE_DRC_Y + 4; - waitButtonInput(); return res; } @@ -106,13 +98,12 @@ void option_DumpOtpAndSeeprom(void) { gfx_clear(COLOR_BACKGROUND); drawTopBar("Dumping OTP + SEEPROM..."); + setNotificationLED(NOTIF_LED_RED_BLINKING, 0); uint32_t index = 16 + 8 + 2 + 8; void* dataBuffer = IOS_HeapAllocAligned(CROSS_PROCESS_HEAP_ID, 0x400, 0x40); if (!dataBuffer) { - gfx_set_font_color(COLOR_ERROR); - gfx_print(16, index, 0, "Out of memory!"); - waitButtonInput(); + print_error(index, "Out of memory!"); return; } @@ -123,11 +114,8 @@ void option_DumpOtpAndSeeprom(void) int res = IOS_ReadOTP(0, dataBuffer, 0x400); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to read OTP: %x", res); - waitButtonInput(); - IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); + printf_error(index, "Failed to read OTP: %x", res); return; } @@ -144,11 +132,8 @@ void option_DumpOtpAndSeeprom(void) res = EEPROM_Read(0, 0x100, (uint16_t*) dataBuffer); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to read EEPROM: %x", res); - waitButtonInput(); - IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); + printf_error(index, "Failed to read EEPROM: %x", res); return; } @@ -160,6 +145,7 @@ void option_DumpOtpAndSeeprom(void) /** All done! **/ + setNotificationLED(NOTIF_LED_PURPLE, 0); gfx_set_font_color(COLOR_SUCCESS); gfx_print(16, index, 0, "Done!"); waitButtonInput(); diff --git a/ios_mcp/source/options/DumpSyslogs.c b/ios_mcp/source/options/DumpSyslogs.c index d4f617e..79464e5 100644 --- a/ios_mcp/source/options/DumpSyslogs.c +++ b/ios_mcp/source/options/DumpSyslogs.c @@ -10,6 +10,7 @@ void option_DumpSyslogs(void) gfx_clear(COLOR_BACKGROUND); drawTopBar("Dumping Syslogs..."); + setNotificationLED(NOTIF_LED_RED_BLINKING, 0); uint32_t index = 16 + 8 + 2 + 8; gfx_print(16, index, 0, "Creating 'logs' directory..."); @@ -17,9 +18,7 @@ void option_DumpSyslogs(void) int res = FSA_MakeDir(fsaHandle, "/vol/storage_recovsd/logs", 0x600); if ((res < 0) && !(res == -0x30016)) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to create directory: %x", res); - waitButtonInput(); + printf_error(index, "Failed to create directory: %x", res); return; } @@ -29,9 +28,7 @@ void option_DumpSyslogs(void) int dir_handle; res = FSA_OpenDir(fsaHandle, "/vol/system/logs", &dir_handle); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to open system logs: %x", res); - waitButtonInput(); + printf_error(index, "Failed to open system logs: %x", res); return; } @@ -50,16 +47,14 @@ void option_DumpSyslogs(void) res = copy_file(fsaHandle, src_path, dst_path); if (res < 0) { - index += CHAR_SIZE_DRC_Y + 4; - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, GfxPrintFlag_ClearBG, "Failed to copy %s: %x", dir_entry.name, res); - waitButtonInput(); - FSA_CloseDir(fsaHandle, dir_handle); + index += CHAR_SIZE_DRC_Y + 4; + printf_error(index, "Failed to copy %s: %x", dir_entry.name, res); return; } } + setNotificationLED(NOTIF_LED_PURPLE, 0); index += CHAR_SIZE_DRC_Y + 4; gfx_set_font_color(COLOR_SUCCESS); gfx_print(16, index, 0, "Done!"); diff --git a/ios_mcp/source/options/InstallWUP.c b/ios_mcp/source/options/InstallWUP.c index 4961243..300af73 100644 --- a/ios_mcp/source/options/InstallWUP.c +++ b/ios_mcp/source/options/InstallWUP.c @@ -4,11 +4,13 @@ #include "gfx.h" #include "mcp_install.h" #include "imports.h" +#include "utils.h" void option_InstallWUP(void) { gfx_clear(COLOR_BACKGROUND); drawTopBar("Installing WUP"); + setNotificationLED(NOTIF_LED_RED_BLINKING, 0); uint32_t index = 16 + 8 + 2 + 8; gfx_print(16, index, 0, "Make sure to place a valid signed WUP directly in 'sd:/install'"); @@ -16,9 +18,7 @@ void option_InstallWUP(void) int mcpHandle = IOS_Open("/dev/mcp", 0); if (mcpHandle < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to open /dev/mcp: %x", mcpHandle); - waitButtonInput(); + printf_error(index, "Failed to open /dev/mcp: %x", mcpHandle); return; } @@ -28,11 +28,8 @@ void option_InstallWUP(void) MCPInstallInfo info; int res = MCP_InstallGetInfo(mcpHandle, "/vol/storage_recovsd/install", &info); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to get install info: %x", res); - waitButtonInput(); - IOS_Close(mcpHandle); + printf_error(index, "Failed to get install info: %x", res); return; } @@ -43,34 +40,26 @@ void option_InstallWUP(void) // only install to NAND res = MCP_InstallSetTargetDevice(mcpHandle, 0); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "MCP_InstallSetTargetDevice: %x", res); - waitButtonInput(); - IOS_Close(mcpHandle); + printf_error(index, "MCP_InstallSetTargetDevice: %x", res); return; } res = MCP_InstallSetTargetUsb(mcpHandle, 0); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "MCP_InstallSetTargetUsb: %x", res); - waitButtonInput(); - IOS_Close(mcpHandle); + printf_error(index, "MCP_InstallSetTargetUsb: %x", res); return; } // TODO: async installations res = MCP_InstallTitle(mcpHandle, "/vol/storage_recovsd/install"); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to install: %x", res); - waitButtonInput(); - IOS_Close(mcpHandle); + printf_error(index, "Failed to install: %x", res); return; } + setNotificationLED(NOTIF_LED_PURPLE, 0); gfx_set_font_color(COLOR_SUCCESS); gfx_print(16, index, 0, "Done!"); waitButtonInput(); diff --git a/ios_mcp/source/options/LoadNetConf.c b/ios_mcp/source/options/LoadNetConf.c index 7791f90..e34926a 100644 --- a/ios_mcp/source/options/LoadNetConf.c +++ b/ios_mcp/source/options/LoadNetConf.c @@ -78,9 +78,7 @@ void option_LoadNetConf(void) int res = netconf_init(); if (res <= 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to initialize netconf: %x", res); - waitButtonInput(); + printf_error(index, "Failed to initialize netconf: %x", res); return; } @@ -90,30 +88,22 @@ void option_LoadNetConf(void) int cfgHandle; res = FSA_OpenFile(fsaHandle, "/vol/storage_recovsd/network.cfg", "r", &cfgHandle); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to open network.cfg: %x", res); - waitButtonInput(); + printf_error(index, "Failed to open network.cfg: %x", res); return; } FSStat stat; res = FSA_StatFile(fsaHandle, cfgHandle, &stat); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to stat file: %x", res); - waitButtonInput(); - FSA_CloseFile(fsaHandle, cfgHandle); + printf_error(index, "Failed to stat file: %x", res); return; } char* cfgBuffer = (char*) IOS_HeapAllocAligned(CROSS_PROCESS_HEAP_ID, stat.size + 1, 0x40); if (!cfgBuffer) { - gfx_set_font_color(COLOR_ERROR); - gfx_print(16, index, 0, "Out of memory!"); - waitButtonInput(); - FSA_CloseFile(fsaHandle, cfgHandle); + print_error(index, "Out of memory!"); return; } @@ -121,12 +111,9 @@ void option_LoadNetConf(void) res = FSA_ReadFile(fsaHandle, cfgBuffer, 1, stat.size, cfgHandle, 0); if (res != stat.size) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to read file: %x", res); - waitButtonInput(); - IOS_HeapFree(CROSS_PROCESS_HEAP_ID, cfgBuffer); FSA_CloseFile(fsaHandle, cfgHandle); + printf_error(index, "Failed to read file: %x", res); return; } @@ -166,12 +153,9 @@ void option_LoadNetConf(void) res = netconf_set_running(&cfg); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to apply configuration: %x", res); - waitButtonInput(); - IOS_HeapFree(CROSS_PROCESS_HEAP_ID, cfgBuffer); FSA_CloseFile(fsaHandle, cfgHandle); + printf_error(index, "Failed to apply configuration: %x", res); return; } diff --git a/ios_mcp/source/options/PairDRC.c b/ios_mcp/source/options/PairDRC.c index 6860c96..943f15c 100644 --- a/ios_mcp/source/options/PairDRC.c +++ b/ios_mcp/source/options/PairDRC.c @@ -20,6 +20,7 @@ #include "ccr.h" #include "gfx.h" #include "menu.h" +#include "utils.h" #include #include @@ -31,15 +32,13 @@ void option_PairDRC(void) { gfx_clear(COLOR_BACKGROUND); drawTopBar("Pairing Gamepad..."); + setNotificationLED(NOTIF_LED_RED_BLINKING, 0); uint32_t index = 16 + 8 + 2 + 8; int res = CCRCDCSetup(); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "CCRCDCSetup() failed: %x", res); - - waitButtonInput(); + printf_error(index, "CCRCDCSetup() failed: %x", res); return; } @@ -49,10 +48,7 @@ void option_PairDRC(void) uint8_t pincode[4]; res = CCRSysGetPincode(pincode); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to get pincode: %x", res); - - waitButtonInput(); + printf_error(index, "Failed to get pincode: %x", res); return; } @@ -93,10 +89,7 @@ void option_PairDRC(void) res = CCRSysStartPairing(CCR_DEST_DRC0, timeout, pincode); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "Failed to start pairing: %x", res); - - waitButtonInput(); + printf_error(index, "Failed to start pairing: %x", res); return; } @@ -104,12 +97,8 @@ void option_PairDRC(void) while (timeout--) { res = CCRCDCWpsStatus(&status); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, GfxPrintFlag_ClearBG, "Failed to get status: %x", res); - CCRCDCWpsStop(); - - waitButtonInput(); + printf_error(index, "Failed to get status: %x", res); return; } @@ -130,14 +119,13 @@ void option_PairDRC(void) } if (status != 0 || timeout <= 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, GfxPrintFlag_ClearBG, "Failed to pair GamePad: %lx", status); - CCRCDCWpsStop(); - } else { - gfx_set_font_color(COLOR_SUCCESS); - gfx_print(16, index, GfxPrintFlag_ClearBG, "Paired GamePad"); + printf_error(index, "Failed to pair GamePad: %lx", res); + return; } + setNotificationLED(NOTIF_LED_PURPLE, 0); + gfx_set_font_color(COLOR_SUCCESS); + gfx_print(16, index, GfxPrintFlag_ClearBG, "Paired GamePad"); waitButtonInput(); } diff --git a/ios_mcp/source/options/SubmitSystemData.c b/ios_mcp/source/options/SubmitSystemData.c index a5b143a..dea4c02 100644 --- a/ios_mcp/source/options/SubmitSystemData.c +++ b/ios_mcp/source/options/SubmitSystemData.c @@ -203,9 +203,7 @@ void option_SubmitSystemData(void) #define DATA_BUFFER_SIZE 0xA00 uint8_t* dataBuffer = IOS_HeapAllocAligned(CROSS_PROCESS_HEAP_ID, DATA_BUFFER_SIZE, 0x40); if (!dataBuffer) { - gfx_set_font_color(COLOR_ERROR); - gfx_print(16, index, 0, "Out of memory!"); - waitButtonInput(); + print_error(index, "Out of memory!"); return; } if (read_otp_seeprom(dataBuffer, index) != 0) { @@ -337,28 +335,22 @@ void option_SubmitSystemData(void) uint8_t aes128_key[16]; res = IOSC_GenerateRand(aes128_key, sizeof(aes128_key)); if (res != 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "IOSC_GenerateRand() failed: %d", res); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "IOSC_GenerateRand() failed: %d", res); return; } uint8_t* const encKey = (uint8_t*)dataBuffer + 0x600; res = rsa2048_encrypt_aes128_key(encKey, RSA2048_BUF_SIZE, aes128_key, sizeof(aes128_key)); if (res != 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "rsa2048_encrypt_aes128_key() failed: %d", res); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "rsa2048_encrypt_aes128_key() failed: %d", res); return; } IOSCSecretKeyHandle aesHandle; res = IOSC_CreateObject(&aesHandle, 0, 0); // IOSU uses 0,0 for AES if (res != 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "IOSC_CreateObject() failed: %d", res); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "IOSC_CreateObject() failed: %d", res); return; } @@ -369,22 +361,18 @@ void option_SubmitSystemData(void) memset(iv, 0, sizeof(iv)); res = IOSC_ImportSecretKey(aesHandle, 0, 0, 0, NULL, 0, iv, sizeof(iv), aes128_key, sizeof(aes128_key)); if (res != 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "IOSC_ImportSecretKey() failed: %d", res); IOSC_DeleteObject(aesHandle); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "IOSC_ImportSecretKey() failed: %d", res); return; } // Encrypt the POST data using AES-128. res = IOSC_Encrypt(aesHandle, iv, sizeof(iv), (uint8_t*)pdh, sizeof(*pdh), (uint8_t*)pdh, sizeof(*pdh)); if (res != 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "IOSC_Encrypt() failed: %d", res); IOSC_DeleteObject(aesHandle); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "IOSC_Encrypt() failed: %d", res); return; } IOSC_DeleteObject(aesHandle); @@ -394,26 +382,22 @@ void option_SubmitSystemData(void) if (res != 0) { // An error occurred while initializing netconf. IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "Failed to initialize netconf: %d", res); return; } int httpSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (httpSocket < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "socket() failed: %d", httpSocket); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "socket() failed: %d", httpSocket); return; } // Look up the domain name. struct hostent* h = gethostbyname(SYSDATA_HOST_NAME); if (!h || !h->h_addr) { - gfx_set_font_color(COLOR_ERROR); - gfx_print(16, index, 0, "gethostbyname() failed; is your DNS server working?"); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + print_error(index, "gethostbyname() failed; is your DNS server working?"); return; } @@ -426,11 +410,9 @@ void option_SubmitSystemData(void) res = connect(httpSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(16, index, 0, "connect() failed: %d", res); closesocket(httpSocket); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + printf_error(index, "connect() failed: %d", res); return; } @@ -461,10 +443,8 @@ void option_SubmitSystemData(void) ok = true; } while (0); if (!ok) { - gfx_set_font_color(COLOR_ERROR); - gfx_print(status_xpos, index, 0, "Failed to send HTTP request."); IOS_HeapFree(CROSS_PROCESS_HEAP_ID, dataBuffer); - waitButtonInput(); + print_error(index, "Failed to send HTTP request."); return; } diff --git a/ios_mcp/source/options/SystemInformation.c b/ios_mcp/source/options/SystemInformation.c index 63b5828..03d60b3 100644 --- a/ios_mcp/source/options/SystemInformation.c +++ b/ios_mcp/source/options/SystemInformation.c @@ -82,9 +82,7 @@ void option_SystemInformation(void) // 0x600-0x7FF: misc for version.bin void *dataBuffer = IOS_HeapAllocAligned(CROSS_PROCESS_HEAP_ID, 0x800, 0x40); if (!dataBuffer) { - gfx_set_font_color(COLOR_ERROR); - gfx_print(x_pos, y_pos, 0, "Out of memory!"); - waitButtonInput(); + print_error(y_pos, "Out of memory!"); return; } if (read_otp_seeprom(dataBuffer, y_pos) != 0) { @@ -258,9 +256,7 @@ void option_SystemInformation(void) // Read info about IOS-FS' memory devices res = MDReadInfo(); if (res < 0) { - gfx_set_font_color(COLOR_ERROR); - gfx_printf(x_pos, y_pos, 0, "Failed to read memory device info: %x", res); - waitButtonInput(); + printf_error(y_pos, "Failed to read memory device info: %x", res); return; }