void xyzzy_get_keys() { int i; FILE *fp = NULL; bool xyzzy_device = select_device(); if (xyzzy_device) { char path[16] = {0}; sprintf(path, "%s:/keys.txt", device == 1 ? "sd" : "usb"); fp = fopen(path, "w"); if (!fp) { printf("\n\t- Unable to open keys.txt for writing."); printf("\n\t- Sorry, not writing keys to %s.", device == 1 ? "card" : "USB device"); if (device == 1) Close_SD(); if (device == 2) Close_USB(); sleep(2); } } resetscreen(); printheadline(); printf("Getting keys...\n\n"); /* This is where the magic begins */ /* Access to the SEEPROM will be disabled in we're running under vWii */ print_all_keys(stdout, vWii); if (fp) { print_all_keys(fp, vWii); /* This will create a hexdump of the device.cert in the selected device */ char devcert[0x200]; memset(devcert, 42, 0x200); i = ES_GetDeviceCert((u8*)devcert); if (i) { printf("\n\nES_GetDeviceCert returned %d.\n\n", i); } else { fprintf(fp, "\nDevice cert:\n"); hexdump(fp, devcert, 0x180); } fclose(fp); if (device == 1) Close_SD(); if (device == 2) Close_USB(); } }
s32 Settings_Menu() { s32 ret = 0; u32 pressed; int i, selection = 0; char *menu_opt[3] = { "Device menu", "Update application", "Reload to another IOS (device remount required)" }; while(true) { resetscreen(); printheadline(); printf("Select an option. Press B to go back to the menu.\n\n"); for (i = 0; i <= 2; i++) { printf("%s %s\n", ((selection == i) ? ARROW : " "), menu_opt[i]); } pressed = DetectInput(DI_BUTTONS_DOWN); if (pressed == WPAD_BUTTON_UP) { if (selection > 0) selection--; } if (pressed == WPAD_BUTTON_DOWN) { if (selection < 2) selection++; } if (pressed == WPAD_BUTTON_A) { switch (selection) { case 0: /* Device menu */ ret = Device_Menu(true); break; case 1: /* Update application */ UpdateYABDM(launch_path); break; case 2: /* IOS reload */ ret = ios_selectionmenu(249); if (ret > 0) { if (ret != IOS_GetVersion()) { /* Unmount devices */ ISFS_Deinitialize(); Unmount_Devices(); KeepAccessRightsAndReload(ret, true); /* Remount devices */ ISFS_Initialize(); ret = Mount_Devices(); if (ret != -2) logfile_header(); } else { printf("\t- IOS reload aborted (IOS%ld is already loaded).", ret); waitforbuttonpress(); } } else if (ret == 0) { printf("\t- Proceeding without IOS reload..."); waitforbuttonpress(); } break; default: break; } break; } if (pressed == WPAD_BUTTON_B) break; } return ret; }
s32 ios_selectionmenu(s32 default_ios) { u32 pressed, i, ioscount, selection = 0; s32 *list = get_ioslist(&ioscount); if (list == 0) return -1; for (i = 0; i < ioscount; i++) { /* Default to default_ios if found, else the loaded IOS */ if (list[i] == default_ios) { selection = i; break; } if (list[i] == IOS_GetVersion()) selection = i; } resetscreen(); printheadline(); s32 ios; while (true) { printf("\x1b[%d;%dH", 5, 0); // move console cursor to y/x printf("Select the IOS version to use: \b\b\b\b\b\b"); set_highlight(true); printf("IOS%ld", list[selection]); set_highlight(false); printf("\n\nPress LEFT/RIGHT to change IOS version."); printf("\nPress A button to load the selected IOS."); printf("\nPress B to continue without IOS Reload."); printf("\nPress HOME or Start to exit.\n\n"); pressed = DetectInput(DI_BUTTONS_DOWN); if (pressed == WPAD_BUTTON_LEFT) { if (selection > 0) { selection--; } else { selection = ioscount - 1; } } if (pressed == WPAD_BUTTON_RIGHT) { if (selection < ioscount -1) { selection++; } else { selection = 0; } } if (pressed == WPAD_BUTTON_A) { ios = list[selection]; break; } if (pressed == WPAD_BUTTON_B) { ios = 0; break; } if (pressed == WPAD_BUTTON_HOME) { ios = -2; break; } } free(list); return ios; }
int Device_Menu(bool swap) { u32 pressed; int i, selection = 0; char *dev_opt[2] = { "SD Card", "USB Storage" }; while(true) { resetscreen(); printheadline(); printf("Current device: %s.\n\n", DEVICE(1)); printf("Select the new output device. "); printf("%s.\n\n", (swap ? "Press B to swap/remount the storage devices" : "Device swapping is not allowed")); for (i = 0; i <= 1; i++) { printf("%s %s %s\n", ((selection == i) ? ARROW : " "), dev_opt[i], (((i == 0 && SDmnt) || (i == 1 && USBmnt)) ? "(available)" : "(not available)")); } pressed = DetectInput(DI_BUTTONS_DOWN); if (pressed == WPAD_BUTTON_UP) { if (selection > 0) selection--; } if (pressed == WPAD_BUTTON_DOWN) { if (selection < 1) selection++; } if (pressed == WPAD_BUTTON_A) { /* Do not exit this screen if the user attempts to select an unavailable storage device */ if ((selection == 0 && SDmnt) || (selection == 1 && USBmnt)) { /* Detect if the selected device is being already used */ if ((selection == 0 && !isSD) || (selection == 1 && isSD)) { /* Do the magic */ isSD ^= 1; if (debug_file) { fclose(debug_file); logfile_header(); logfile("Device changed from %s to %s.\r\n\r\n", (selection == 0 ? "USB" : "SD"), DEVICE(1)); } } return 0; } } if (pressed == WPAD_BUTTON_B) { if (swap) break; } } resetscreen(); printheadline(); Unmount_Devices(); printf("Swap the current storage devices if you want to use different ones.\n"); printf("Press A when you're done to mount them.\n"); printf("Otherwise, you can just remount the devices already connected."); while(true) { pressed = DetectInput(DI_BUTTONS_DOWN); if (pressed == WPAD_BUTTON_A) break; } /* If the currently running IOS is a Waninkoko/d2x cIOS, we have to reload it before we can retry the USB ports */ s32 ios = IOS_GetVersion(); if (ios >= 200 && !IsHermesIOS(ios)) { /* Unmount NAND */ ISFS_Deinitialize(); /* Do our thing */ KeepAccessRightsAndReload(ios, false); /* Remount NAND */ ISFS_Initialize(); } int ret = Mount_Devices(); if (ret < 0) return ret; logfile_header(); return 0; }
int main(int argc, char* argv[]) { __exception_setreload(10); int i, ret; Init_Console(); printf("\x1b[%u;%um", 37, false); PAD_Init(); WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); printheadline(); ret = ahbprot_menu(); if (ret < 0) { ret = ios_selectionmenu(236); if (ret > 0) { printf("\t- Reloading to IOS%d... ", ret); WPAD_Shutdown(); IOS_ReloadIOS(ret); sleep(2); PAD_Init(); WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); printf("done.\n\n"); } else if (ret == 0) { printf("\t- Proceeding without IOS reload...\n\n"); } else { Reboot(); } } resetscreen(); printheadline(); /* Initialize NAND FS */ ISFS_Initialize(); /* Do our stuff */ char path[ISFS_MAXPATH]; char *filenames[10] = { "misc.bin", "nwc24dl.bin", "nwc24fl.bin", "nwc24fls.bin", "nwc24msg.cbk", "nwc24msg.cfg", \ "mbox/wc24recv.ctl", "mbox/wc24recv.mbx", "mbox/wc24send.ctl", "mbox/wc24send.mbx" }; for (i = 0; i < 10; i++) { snprintf(path, MAX_CHARACTERS(path), "/shared2/wc24/%s", filenames[i]); printf("%u. Deleting \"%s\"... ", i + 1, path); ret = ISFS_Delete(path); if (ret < 0) { switch (ret) { case -1: case -102: printf("\n\t- Error: Permission denied!"); break; case -2: case -105: printf("\n\t- Error: File exists!"); break; case -4: case -101: printf("\n\t- Error: Invalid argument!"); break; case -6: case -106: printf("\n\t- Error: File not found!"); break; case -8: case -118: printf("\n\t- Error: Resource busy!"); break; case -12: case -103: case -114: printf("\n\t- Error: NAND ECC failure!"); break; case -22: printf("\n\t- Error: Memory allocation failed during request!"); break; case -107: case -109: printf("\n\t- Error: Too many files open!"); break; case -108: printf("\n\t- Error: Memory full!"); break; case -110: printf("\n\t- Error: Path name is too long!"); break; case -111: printf("\n\t- Error: File already open!"); break; case -115: printf("\n\t- Error: Directory not empty!"); break; case -116: printf("\n\t- Error: Max directory depth exceeded!"); break; default: printf("\n\t- FATAL / UNKNOWN ERROR!!!"); } printf(" (ret = %d)\n\n", ret); if (ret <= -119) break; } else { printf("OK!\n\n"); } usleep(2000000); // 2 seconds } /* Unmount NAND FS and exit */ ISFS_Deinitialize(); Reboot(); return 0; }
int main(int argc, char* argv[]) { int ret; u32 pressed; u32 pressedGC; Init_Console(); printf("\x1b[%u;%um", 37, false); PAD_Init(); WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); printheadline(); ret = *((int *)MAGIC1); if (ret == MAGIC2) { ret = *((int *)MAGIC3); if (ret == MAGIC4) { ret = *((int *)MAGIC3 + 1); printf("\nSo this now makes %d times you've tried to rerun me, pirate.\n", ret); printf("I told you before, you need to try harder than that.\n\n"); printf("Keep trying and I'll give you a hint...\n\n"); if (ret > 5) { printf("You're persistent aren't you? Here's a hint:\nShow me that you don't pirate all of your Wii games.\n\n"); } if (ret > 10) { printf("You're really persistent! The hint means to play a game normally in your Wii.\n"); printf("There are other ways around the trap too, but figure them out yourself.\n"); } ret++; } else { ret = 2; printf("\nSo you tell me you're a pirate and you expect that running\n"); printf("the application a second time is enough for me to forgive you?\n"); printf("You're going to have to try something harder than that, mate.\n"); *((int *)MAGIC3) = MAGIC4; } *((int *)MAGIC3 + 1) = ret; sleep(ret*2); printf("\nPress any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); } printf("WARNING: If you are not connected to the Internet, this app might crash.\n"); printf("If you get a DSI error, rerun the app and be a little quicker.\n\n"); printf("\nThis Application will install IOS236 onto your Wii.\n"); printf("It relies on the fact that you launched this app with.\n"); printf("the AHBPROT flags set, so you must be using HBC 1.07 or\n"); printf("later.\n"); printf("\nIOS236 is a patched IOS36 v3351 and this app can be used\n"); printf("instead of the Trucha Bug Restorer, upon which the app\n"); printf("was based.\n"); printf("\nThis application should work on all Wii firmwares 4.3 and below,\n"); printf("and as long as the HBC supports AHBPROT, it should work on newer\n"); printf("firmwares too. It is safe to use this application to reinstall\n"); printf("IOS236 or replace a different IOS236.\n"); printf("\nThanks, in no particular order, go to Wiipower, oggzee, Team Twiizers,\n"); printf("tona, Joseph Jordan and anybody else who has code included in\n"); printf("the app. The app was quite a simple job, built upon their\n"); printf("actual real work.\n"); /*printf("\nPlease Wait...\n"); time_t t = time(NULL) + 7; while (time(NULL) < t) { WPAD_ScanPads(); PAD_ScanPads(); if(WPAD_ButtonsDown(0) || PAD_ButtonsDown(0)) { printf("Don't be impatient, press any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); } }*/ printf("Press 1 or Start to start the application...\n"); waitforbuttonpress(&pressed, &pressedGC); if (pressed != WPAD_BUTTON_1 && pressedGC != PAD_BUTTON_START) { printf("Other button pressed, press any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); } printf("Performing Step 1\n"); printf("Patching IOS\n"); if (!IOSPATCH_Apply()) { printf("Unable to initialise the initial patches.\n"); printf("This either means you didn't follow the download\n"); printf("and launching instructions correctly, or your IOS\n"); printf("is not vulnerable for an unknown reason.\n"); printf("Perhaps you need to update the Homebrew Channel (HBC).\n"); printf("Installation cannot continue. Press any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); } printf("IOS patched\n"); printf("About to install IOS236\n"); ret = Install_patched_IOS(36, IOS36version, true, true, true, true, 236, 65535, false); if (ret < 0) { printf("IOS236 Install failed. Press any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); } printf("\nStep 1 Complete!\n"); printf("\nStep 2 is an alteration that is only needed if you plan\n"); printf("to play games you don't own the original disc for.\n"); printf("Do you need this alteration?\n\n"); printf("Press the 1 or X button if you want to play pirated games.\n"); printf("Press the 2 or Y button if you have no need for piracy.\n"); char found = 0; while(!found) { waitforbuttonpress(&pressed, &pressedGC); if (pressed == WPAD_BUTTON_1 || pressedGC == PAD_BUTTON_X) { found = 1; } if (pressed == WPAD_BUTTON_2 || pressedGC == PAD_BUTTON_Y) { found = 2; } } if (found == 1) { printf("\nPerforming Step 2\n"); ISFS_Initialize(); Uninstall_DeleteTicket(1, 236); Uninstall_DeleteTitle(1, 236); ISFS_Deinitialize(); *((int *)MAGIC1) = MAGIC2; printf("\nStep 2 Complete!\n"); printf("\nStep 2 was to delete IOS236. You will need\n"); printf("to install it again.\n\n"); printf("Shame on you for being a pirate!\n"); printf("Sorry if you were just curious or not paying\n"); printf("attention, but you need to learn to be careful.\n\n"); printf("While I can't stop you from lying next time,\n"); printf("I can at least have the satisfaction that I've\n"); printf("wasted some of your time.\n"); printf("\nSeriously, though. Developers do deserve to be paid\n"); printf("to provide you with entertainment. At least consider\n"); printf("buying any game that you play a lot, or that you enjoy\n"); printf("enough to finish.\n"); printf("\nOh, and just be glad I didn't delete your HBC ;)\n"); sleep(10); printf("Press any button to exit\n"); waitforbuttonpress(NULL, NULL); Reboot(); } printf("IOS236 Installation is complete!\n"); printf("Press any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); return 0; }