bool readch (s_channelConfig *cc) { s32 ret; char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); Debug ("neek_PLNandInfo [begin]"); ISFS_Initialize (); sprintf (path, "/sneek/nandcfg.ch"); s32 fd; fd = ISFS_Open( path, ISFS_OPEN_READ); ret = -1; if (fd > 0) { ret = ISFS_Read(fd, cc, sizeof(s_channelConfig)); ISFS_Close(fd); } ISFS_Deinitialize (); if (ret >= 0) return true; return false; }
bool LoadPostloaderFromISFS (void) { char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); ISFS_Initialize(); strcpy (path, "/apps/postLoader/boot.dol"); s32 fd = ISFS_Open (path, ISFS_OPEN_READ); if (fd < 0) goto fail; s32 filesize = ISFS_Seek(fd, 0, 2); if (filesize == 0) goto fail; ISFS_Seek (fd, 0, 0); // exeBuffer is already 32bit aligned... should work fine s32 readed = ISFS_Read (fd, exeBuffer, filesize); ISFS_Close (fd); if (readed != filesize) goto fail; return TRUE; fail: ISFS_Deinitialize (); return FALSE; }
void RestoreSneekFolder (void) { s32 fd; int ret; char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); char pathBak[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); Debug ("RestoreSneekFolder [begin]"); ISFS_Initialize (); sprintf (path, "/sneek/nandpath.bin"); ret = ISFS_Delete (path); Debug ("RestoreSneekFolder: delete '%s' = %d", path, ret); sprintf (path, "/sneek/nandcfg.pl"); ret = ISFS_Delete (path); Debug ("RestoreSneekFolder: delete '%s' = %d", path, ret); ret = sprintf (path, "/sneek/nandcfg.ch"); ISFS_Delete (path); Debug ("RestoreSneekFolder: delete '%s' = %d", path, ret); sprintf (path, "/title/00000001/00000002/data/loader.ini"); sprintf (pathBak, "/title/00000001/00000002/data/loader.bak"); fd = ISFS_Open(pathBak, ISFS_OPEN_READ); if (fd > 0) { ISFS_Close(fd); ret = ISFS_Delete (path); Debug ("RestoreSneekFolder: delete '%s' = %d", path, ret); ret = ISFS_Rename (pathBak, path); Debug ("RestoreSneekFolder: rename '%s'->'%s' = %d", pathBak, path, ret); } sprintf (path, "/sneek/nandcfg.bin"); sprintf (pathBak, "/sneek/nandcfg.bak"); fd = ISFS_Open(pathBak, ISFS_OPEN_READ); if (fd > 0) { ISFS_Close(fd); ret = ISFS_Delete (path); Debug ("RestoreSneekFolder: delete '%s' = %d", path, ret); ret = ISFS_Rename (pathBak, path); Debug ("RestoreSneekFolder: rename '%s'->'%s' = %d", pathBak, path, ret); } ISFS_Deinitialize (); Debug ("RestoreSneekFolder [end]"); }
int main(int argc, char **argv) { s32 ret; /* Load Custom IOS */ ret = IOS_ReloadIOS(249); /* Initialize subsystems */ Sys_Init(); /* Set video mode */ Video_SetMode(); /* Initialize console */ Gui_InitConsole(); /* Draw bckground */ Gui_DrawBackground(); /* Initialize Wiimote subsystem */ Wpad_Init(); /* Check for Custom IOS */ if (ret < 0) { printf("[+] ERROR: Could not load Custom IOS! (ret = %d)\n", ret); goto out; } /* Initialize ISFS */ ret = ISFS_Initialize(); if (ret < 0) { printf("[+] ERROR: Could not initialize ISFS! (ret = %d)\n", ret); goto out; } /* Mount ISFS */ ret = ISFS_Mount(); if (ret < 0) { printf("[+] ERROR: Could not mount ISFS! (ret = %d)\n", ret); goto out; } /* Menu loop */ Menu_Loop(); out: /* Restart */ Restart_Wait(); return 0; }
void miscinit(void) { s32 ret; ret = Identify_SU(); printf("\nInitializing file-system driver..."); fflush(stdout); ret = ISFS_Initialize(); if (ret < 0) { printf("\nError! ISFS_Initialize (ret = %d)\n", ret); } else { printf("OK!\n"); } }
void RestoreSM (int nidx) { bool find = FALSE; char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); char pathBack[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); char *sm[] = {"00000088","00000085","0000008b","0000008e","00000098","00000095","0000009b","0000009e"}; s32 smsize; bool issm = FALSE; ISFS_Initialize(); int i; s32 fd; for (i = 0; i < sizeof(sm) / sizeof(char*); i++) { sprintf (path, "%s/title/00000001/00000002/content/%s.app", nandConfig->NandInfo[nidx], sm[i]); sprintf (pathBack, "%s/title/00000001/00000002/content/%s.bak", nandConfig->NandInfo[nidx], sm[i]); fd = ISFS_Open (path, ISFS_OPEN_READ); Debug ("ReplaceNandSystemMenu: checking %s (%d)", sm[i], fd); if (fd < 0) continue; smsize = ISFS_Seek(fd, 0, 2); Debug ("ReplaceNandSystemMenu: sm size %d", smsize); if (smsize > 1000000) // E' piu' grande di 1MB... e' il sistem menu issm = TRUE; ISFS_Close (fd); find = TRUE; break; } if (find && !issm) { // Restore filesistem ISFS_Delete (path); ISFS_Rename (pathBack, path); } ISFS_Deinitialize (); }
void RestorePriiloader (int nidx) { char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); char pathBack[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); ISFS_Initialize(); sprintf (path, "%s/title/00000001/00000002/data/main.bin", nandConfig->NandInfo[nidx]); sprintf (pathBack, "%s/title/00000001/00000002/data/main.bak", nandConfig->NandInfo[nidx]); ISFS_Delete (path); ISFS_Rename (pathBack, path); sprintf (path, "%s/title/00000001/00000002/data/loader.ini", nandConfig->NandInfo[nidx]); sprintf (pathBack, "%s/title/00000001/00000002/data/loader.bak", nandConfig->NandInfo[nidx]); ISFS_Delete (path); ISFS_Rename (pathBack, path); ISFS_Deinitialize (); }
int Playlog_Create(void) { s32 fd = IOS_Open(PLAYRECPATH, IPC_OPEN_RW); if(fd >= 0) { //exists IOS_Close(fd); return 0; } ISFS_Initialize(); //In case the play_rec.dat wasn´t found create one and try again int ret = ISFS_CreateFile(PLAYRECPATH, 0, 3, 3, 3); if(ret >= 0) ISFS_SetAttr(PLAYRECPATH, 0x1000, 1, 0, 3, 3, 3); ISFS_Deinitialize(); return ret; }
int main(int argc, char **argv) { s32 ret; /* Initialize subsystems */ Sys_Init(); /* Set video mode */ Video_SetMode(); /* Initialize ISFS */ ISFS_Initialize(); /* Read config */ Config_Read(); /* Config menu */ ret = SYS_ResetButtonDown(); if (ret) Menu(); /* Draw loading image */ if(loaderCfg.showSplash) Gui_DrawLoading(); /* Execute application */ Loader_Execute(); /* Draw error image */ Gui_DrawError(); /* Sleep */ sleep(RESTART_SECONDS); /* Load System Menu */ Sys_LoadMenu(); return 0; }
int main(int argc, char **argv) { set_new_handler(no_memory); geckoinit = InitGecko(); __exception_setreload(5); SYS_SetArena1Hi(APPLOADER_START); char *gameid = NULL; string dolLoc; //(argv[0] != NULL ? argv[0] : ""); for (int i = 0; i < argc; i++) { if (argv[i] != NULL && strcasestr(argv[i], "ios=") != NULL && strlen(argv[i]) > 4) { while(argv[i][0] && !isdigit(argv[i][0])) argv[i]++; if (atoi(argv[i]) < 254 && atoi(argv[i]) > 0) mainIOS = atoi(argv[i]); } else if (strlen(argv[i]) == 6) { gameid = argv[i]; for (int i=0; i < 5; i++) if (!isalnum(gameid[i])) gameid = NULL; } } gprintf("Loading cIOS: %d\n", mainIOS); ISFS_Initialize(); // Load Custom IOS bool iosOK = loadIOS(mainIOS, false); MEM2_init(52); u8 mainIOSBase = 0; iosOK = iosOK && cIOSInfo::D2X(mainIOS, &mainIOSBase); gprintf("Loaded cIOS: %u has base %u\n", mainIOS, mainIOSBase); // Init video CVideo vid; vid.init(); WIILIGHT_Init(); vid.waitMessage(0.2f); // Init Sys_Init(); Sys_ExitTo(EXIT_TO_HBC); int ret = 0; do { Open_Inputs(); bool deviceAvailable = false; u8 timeout = 0; while(!deviceAvailable && timeout++ != 20) { DeviceHandler::Instance()->MountAll(); sleep(1); for(u8 device = SD; device <= USB8; device++) if(DeviceHandler::Instance()->IsInserted(device)) deviceAvailable = true; } bool dipOK = Disc_Init() >= 0; CMenu menu(vid); menu.init(dolLoc); mainMenu = &menu; if(!deviceAvailable) { menu.error(L"Could not find a device to save configuration files on!"); break; } else if(!iosOK) { menu.error(sfmt("d2x cIOS %i rev6 or later is required", mainIOS)); break; } else if(!dipOK) { menu.error(L"Could not initialize the DIP module!"); break; } else { if (gameid != NULL && strlen(gameid) == 6) menu._directlaunch(gameid); else ret = menu.main(); } vid.cleanup(); if (bootHB) { IOS_ReloadIOS(58); BootHomebrew(); } } while (ret == 1); WifiGecko_Close(); Nand::Instance()->Disable_Emu(); Nand::DestroyInstance(); Sys_Exit(); return 0; };
static int identify(void){ // Identify as our own title void* dvdCert = NULL, * dvdTMD = NULL, * dvdTicket = NULL; unsigned int dvdCertSize, dvdTMDSize, dvdTicketSize, keyid; int ret; if(!customCert){ // If there's no certificate supplied #if 0 // Use the one from the DVD ret = getTitle(&dvdCert, &dvdCertSize, &dvdTMD, &dvdTMDSize, &dvdTicket, &dvdTicketSize); customCert = dvdCert; customCertSize = dvdCertSize; if(ret < 0) return ret; #else return identified = 0; #endif } ret = ES_Identify(customCert, customCertSize, customTMD, customTMDSize, customTicket, customTicketSize, &keyid); if(ret >= 0){ ES_GetTitleID(&titleID); ISFS_Initialize(); // If we haven't identified this title before // we'll need to set some things up char* path = memalign(32, 64);; ES_GetDataDir(titleID, path); strncat(path, "/banner.bin", 64); ret = ISFS_Open(path, 1); if(ret < 0){ // If the banner doesn't exist // Create our banner.bin ret = ISFS_CreateFile(path, 0, 3, 3, 1); if(ret < 0) return 0; ret = ISFS_Open(path, 2); if(ret < 0) return 0; ISFS_Write(ret, customBanner, customBannerSize); ISFS_Close(ret); // Create the N64SAVES directory ES_GetDataDir(titleID, path); strncat(path, "/N64SAVES", 64); ISFS_CreateDir(path, 0, 3, 3, 1); } else ISFS_Close(ret); free(path); return identified = 1; } #if 0 // If that still fails, try to identify from the discs certs if(!dvdCert || !dvdTMD || !dvdTicket) ret = getTitle(&dvdCert, &dvdCertSize, &dvdTMD, &dvdTMDSize, &dvdTicket, &dvdTicketSize); else ret = 0; if(ret >= 0){ ret = ES_Identify(dvdCert, dvdCertSize, dvdTMD, dvdTMDSize, dvdTicket, dvdTicketSize, &keyid); ES_GetTitleID(&titleID); ISFS_Initialize(); return identified = (ret >= 0); } #endif return identified = 0; }
/******************************************************************************** * TitleBrowser- opens a browser with a list of installed Titles * relies on code from any title deleter. *********************************************************************************/ int TitleBrowser(u32 type) { u32 num_titles; u32 titles[100] ATTRIBUTE_ALIGN(32); u32 num_sys_titles; u32 sys_titles[10] ATTRIBUTE_ALIGN(32); s32 ret = -1; int numtitle;//to get rid of a stupid compile wrning //open the database file FILE *f; char path[100]; ISFS_Initialize(); sprintf(path,"%s/config/database.txt",bootDevice); f = fopen(path, "r"); // Get count of titles of our requested type ret = getTitles_TypeCount(type, &num_titles); if (ret < 0) { //printf("\tError! Can't get count of titles! (ret = %d)\n", ret); //exit(1); } // Get titles of our requested type ret = getTitles_Type(type, titles, num_titles); if (ret < 0) { //printf("\tError! Can't get list of titles! (ret = %d)\n", ret); //exit(1); } // Get count of system titles ret = getTitles_TypeCount(0x00010002, &num_sys_titles); if (ret < 0) { //printf("\tError! Can't get count of titles! (ret = %d)\n", ret); //exit(1); } // Get system titles ret = getTitles_Type(0x00010002, sys_titles, num_sys_titles); if (ret < 0) { //printf("\tError! Can't get list of titles! (ret = %d)\n", ret); //exit(1); } //this array will hold all the names for the titles so we only have to get them one time char name[num_titles+num_sys_titles][50]; customOptionList options3(num_titles+num_sys_titles+1); //write the titles on the option browser u32 i = 0; //first add the good stuff while (i < num_titles) { //start from the beginning of the file each loop if (f)rewind(f); //char name[50]; char text[15]; strcpy(name[i],"");//make sure name is empty u8 found=0; //set the title's name, number, ID to text sprintf(text, "%s", titleText(type, titles[i])); //get name from database cause i dont like the ADT function char line[200]; char tmp[50]; snprintf(tmp,50," "); //check if the content.bin is on the SD card for that game //if there is content.bin,then the game is on the SDmenu and not the wii sprintf(line,"SD:/private/wii/title/%s/content.bin",text); if (!checkfile(line)) { if (f) { while (fgets(line, sizeof(line), f)) { if (line[0]== text[0]&& line[1]== text[1]&& line[2]== text[2]) { int j=0; found=1; for (j=0;(line[j+4]!='\0' || j<51);j++) tmp[j]=line[j+4]; snprintf(name[i],sizeof(name[i]),"%s",tmp); //break; } } } if (!found) { if (getName00(name[i], TITLE_ID(type, titles[i]),CONF_GetLanguage()*2)>=0) found=2; if (!found) { if (getNameBN(name[i], TITLE_ID(type, titles[i]))>=0) found=3; if (!found) snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",titles[i]); } } //set the text to the option browser options3.SetName(i, "%s",text); options3.SetValue(i, "%s",name[i]); //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel //move on to the next title } i++; } // now add the crappy system titles while (i < num_titles+num_sys_titles) { //start from the beginning of the file each loop if (f)rewind(f); //char name[50]; char text[15]; strcpy(name[i],"");//make sure name is empty u8 found=0; //set the title's name, number, ID to text sprintf(text, "%s", titleText(0x00010002, sys_titles[i-num_titles])); //get name from database cause i dont like the ADT function char line[200]; char tmp[50]; snprintf(tmp,50," "); //snprintf(name[i],sizeof(name[i]),"Unknown Title"); if (f) { while (fgets(line, sizeof(line), f)) { if (line[0]== text[0]&& line[1]== text[1]&& line[2]== text[2]) { int j=0; found=1; for (j=0;(line[j+4]!='\0' || j<51);j++) tmp[j]=line[j+4]; snprintf(name[i],sizeof(name[i]),"%s",tmp); break; } } } if (!found) { if (getName00(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) found=2; if (!found) { if (getNameBN(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) found=3; if (!found) snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",sys_titles[i-num_titles]); } } //set the text to the option browser options3.SetName(i, "%s",text); options3.SetValue(i, "%s",name[i]); //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel //move on to the next title i++; } if (i == num_titles+num_sys_titles) { options3.SetName(i, " "); options3.SetValue(i, "%s",tr("Wii Settings")); } //we have all the titles we need so close the database and stop poking around in the wii fclose(f); //get rid of our footprints in there Uninstall_FromTitle(TITLE_ID(1, 0)); ISFS_Deinitialize(); bool exit = false; if (IsNetworkInit()) ResumeNetworkWait(); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); // because destroy GuiSound must wait while sound playing is finished, we use a global sound if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); // GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); char imgPath[100]; snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); GuiImageData btnOutline(imgPath, button_dialogue_box_png); snprintf(imgPath, sizeof(imgPath), "%sgamesettings_background.png", CFG.theme_path); GuiImageData settingsbg(imgPath, settings_background_png); GuiTrigger trigA; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); GuiTrigger trigB; trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); GuiText titleTxt(tr("Title Launcher"), 28, (GXColor) {0, 0, 0, 255}); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetPosition(12,40); titleTxt.SetMaxWidth(356, GuiText::SCROLL); GuiImage settingsbackground(&settingsbg); GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); settingsbackgroundbtn.SetPosition(0, 0); settingsbackgroundbtn.SetImage(&settingsbackground); GuiText cancelBtnTxt(tr("Back"), 22, THEME.prompttext); cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); GuiImage cancelBtnImg(&btnOutline); if (Settings.wsprompt == yes) { cancelBtnTxt.SetWidescreen(CFG.widescreen); cancelBtnImg.SetWidescreen(CFG.widescreen); } GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, btnClick2,1); cancelBtn.SetScale(0.9); cancelBtn.SetLabel(&cancelBtnTxt); cancelBtn.SetTrigger(&trigB); u8 scrollbaron = 0; if (num_titles > 9) scrollbaron = 1; GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, num_titles+num_sys_titles>9?1:0, 200); optionBrowser3.SetPosition(0, 90); optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path); GuiImageData wifiImgData(imgPath, Wifi_btn_png); GuiImage wifiImg(&wifiImgData); if (Settings.wsprompt == yes) { wifiImg.SetWidescreen(CFG.widescreen); } GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight()); wifiBtn.SetImage(&wifiImg); wifiBtn.SetPosition(100, 400); wifiBtn.SetEffectGrow(); wifiBtn.SetAlpha(80); wifiBtn.SetTrigger(&trigA); GuiTrigger trigZ; trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); GuiButton screenShotBtn(0,0); screenShotBtn.SetPosition(0,0); screenShotBtn.SetTrigger(&trigZ); HaltGui(); GuiWindow w(screenwidth, screenheight); w.Append(&screenShotBtn); w.Append(&settingsbackgroundbtn); w.Append(&titleTxt); w.Append(&cancelBtn); w.Append(&wifiBtn); w.Append(&optionBrowser3); mainWindow->Append(&w); int tmp=num_titles+num_sys_titles; ResumeGui(); numtitle=num_titles; while (!exit) { VIDEO_WaitVSync(); if (shutdown == 1) Sys_Shutdown(); if (reset == 1) Sys_Reboot(); else if (wifiBtn.GetState() == STATE_CLICKED) { ResumeNetworkWait(); wifiBtn.ResetState(); } if (IsNetworkInit()) { wifiBtn.SetAlpha(255); } ret = optionBrowser3.GetClickedOption(); if (ret > -1) {//if a click happened //char name[50]; char text[15]; if (f)rewind(f); //strcpy(name,"");//make sure name is empty if (ret<numtitle) { //set the title's name, number, ID to text sprintf(text, "%s", titleText(type, titles[ret])); char temp[100]; //prompt to boot selected title snprintf(temp, sizeof(temp), "%s : %s",text,name[ret]); int choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel")); if (choice) {//if they say yes //stop all this stuff before starting the channel CloseXMLDatabase(); ExitGUIThreads(); ShutdownAudio(); StopGX(); WII_Initialize(); WII_LaunchTitle(TITLE_ID(type,titles[ret])); //this really shouldn't be needed because the title will be booted exit = true; break; } else { //if they said no to booting the title ret = -1; optionBrowser3.ResetState(); } } else { //if they clicked a system title if (ret == tmp) { CloseXMLDatabase(); ExitGUIThreads(); ShutdownAudio(); StopGX(); WII_Initialize(); WII_ReturnToSettings(); } else { //set the title's name, number, ID to text sprintf(text, "%s", titleText(0x00010002, sys_titles[ret-num_titles])); char temp[112]; //prompt to boot selected title snprintf(temp, sizeof(temp), tr("%s : %s May not boot correctly if your System Menu is not up to date."),text,name[ret]); int choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel")); if (choice) {//if they say yes //stop all this stuff before starting the channel CloseXMLDatabase(); ExitGUIThreads(); ShutdownAudio(); StopGX(); WII_Initialize(); WII_LaunchTitle(TITLE_ID(0x00010002,sys_titles[ret-num_titles])); //this really shouldn't be needed because the title will be booted exit = true; break; } else { //if they said no to booting the title ret = -1; optionBrowser3.ResetState(); } } } } if(infilesize > 0) { char filesizetxt[50]; char temp[50]; char filepath[100]; // u32 read = 0; //make sure there is a folder for this to be saved in struct stat st; snprintf(filepath, sizeof(filepath), "%s/wad/", bootDevice); if (stat(filepath, &st) != 0) { if (subfoldercreate(filepath) != 1) { WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); } } snprintf(filepath, sizeof(filepath), "%s/wad/tmp.tmp", bootDevice); if (infilesize < MB_SIZE) snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fKB"), infilesize/KB_SIZE); else snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fMB"), infilesize/MB_SIZE); snprintf(temp, sizeof(temp), tr("Load file from: %s ?"), GetIncommingIP()); int choice = WindowPrompt(filesizetxt, temp, tr("OK"), tr("Cancel")); gprintf("\nchoice:%d",choice); if (choice == 1) { u32 read = 0; u8 *temp = NULL; int len = NETWORKBLOCKSIZE; temp = (u8 *) malloc(infilesize); bool error = false; u8 *ptr = temp; gprintf("\nrecieving shit"); while (read < infilesize) { ShowProgress(tr("Receiving file from:"), GetIncommingIP(), NULL, read, infilesize, true); if (infilesize - read < (u32) len) len = infilesize-read; else len = NETWORKBLOCKSIZE; int result = network_read(ptr, len); if (result < 0) { WindowPrompt(tr("Error while transfering data."), 0, tr("OK")); error = true; break; } if (!result) { gprintf("\n!RESULT"); break; } ptr += result; read += result; } ProgressStop(); char filename[101]; char tmptxt[200]; //bool installWad=0; if (!error) { gprintf("\nno error yet"); network_read((u8*) &filename, 100); gprintf("\nfilename: %s",filename); // Do we need to unzip this thing? if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4) { gprintf("\nusing newer wiiload version"); if (uncfilesize != 0) { // if uncfilesize == 0, it's not compressed gprintf("\ntrying to uncompress"); // It's compressed, uncompress u8 *unc = (u8 *) malloc(uncfilesize); uLongf f = uncfilesize; error = uncompress(unc, &f, temp, infilesize) != Z_OK; uncfilesize = f; free(temp); temp = unc; } } if (!error) { sprintf(tmptxt,"%s",filename); //if we got a wad if (strcasestr(tmptxt,".wad")) { FILE *file = fopen(filepath, "wb"); fwrite(temp, 1, (uncfilesize>0?uncfilesize:infilesize), file); fclose(file); sprintf(tmptxt,"%s/wad/%s",bootDevice,filename); if (checkfile(tmptxt))remove(tmptxt); rename(filepath, tmptxt); //check and make sure the wad we just saved is the correct size u32 lSize; file = fopen(tmptxt, "rb"); // obtain file size: fseek (file , 0 , SEEK_END); lSize = ftell (file); rewind (file); if (lSize==(uncfilesize>0?uncfilesize:infilesize)) { gprintf("\nsize is ok"); int pick = WindowPrompt(tr(" Wad Saved as:"), tmptxt, tr("Install"),tr("Uninstall"),tr("Cancel")); //install or uninstall it if (pick==1) { HaltGui(); w.Remove(&titleTxt); w.Remove(&cancelBtn); w.Remove(&wifiBtn); w.Remove(&optionBrowser3); ResumeGui(); Wad_Install(file); HaltGui(); w.Append(&titleTxt); w.Append(&cancelBtn); w.Append(&wifiBtn); w.Append(&optionBrowser3); ResumeGui(); } if (pick==2)Wad_Uninstall(file); } else gprintf("\nBad size"); //close that beast, we're done with it fclose (file); //do we want to keep the file in the wad folder if (WindowPrompt(tr("Delete ?"), tmptxt, tr("Delete"),tr("Keep"))!=0) remove(tmptxt); } else { WindowPrompt(tr("ERROR:"), tr("Not a WAD file."), tr("OK")); } } } if (error || read != infilesize) { WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK")); } if(temp)free(temp); } CloseConnection(); ResumeNetworkWait(); } if (cancelBtn.GetState() == STATE_CLICKED) { //break the loop and end the function exit = true; ret = -10; } else if (screenShotBtn.GetState() == STATE_CLICKED) { gprintf("\n\tscreenShotBtn clicked"); screenShotBtn.ResetState(); ScreenShot(); gprintf("...It's easy, mmmmmmKay"); } } CloseConnection(); if (IsNetworkInit()) HaltNetworkThread(); fclose(f); HaltGui(); mainWindow->Remove(&w); ResumeGui(); return ret; }
s32 what_to_do() { u32 pressed; u32 pressedGC; int selection = 0; int ret; char *optionsstring[3] = { "<Install IOS118 and 118 Channel>", "<Uninstall IOS118 and 118 Channel>", "<Exit>" }; while (true) { Con_ClearLine(); set_highlight(true); printf(optionsstring[selection]); set_highlight(false); waitforbuttonpress(&pressed, &pressedGC); if (pressed == WPAD_BUTTON_LEFT || pressedGC == PAD_BUTTON_LEFT) { if (selection > 0) { selection--; } else { selection =2; } } if (pressed == WPAD_BUTTON_RIGHT || pressedGC == PAD_BUTTON_RIGHT) { if (selection < 2) { selection++; } else { selection = 0; } } if (pressed == WPAD_BUTTON_A || pressedGC == PAD_BUTTON_A) { printf("\n"); if (selection == 0) { printf("About to install IOS118\n"); ret = Install_patched_IOS(36, IOS36version, true, true, true, true, 118, 65535, false); if (ret < 0) { printf("IOS118 Install failed. Press any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); } printf("\nStep 1 Complete!\n"); printf("IOS118 Installation is complete!\n"); install_channel_118(); printf("\nStep 2 Complete!\n"); printf("118Channel Installation is complete!\n"); printf("Press any button to exit...\n"); waitforbuttonpress(NULL, NULL); Reboot(); return 0; } if (selection == 1) { ISFS_Initialize(); Uninstall_DeleteTicket(1, 118); Uninstall_DeleteTitle(1, 118); Uninstall_118Channel_all(); ISFS_Deinitialize(); } if (selection == 2) { Reboot(); } } } }
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; }
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; }
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; }
static int recOpenLib(void){ return (isfsOpen++) ? 0 : ISFS_Initialize(); }