static void UnmountPartitions(int device) { char mount[11]; int i; for (i = 0; i < MAX_DEVICES; i++) { switch (part[device][i].type) { case T_FAT: part[device][i].type = 0; sprintf(mount, "%s:", part[device][i].mount); fatUnmount(mount); break; case T_NTFS: part[device][i].type = 0; ntfsUnmount(part[device][i].mount, false); break; case T_EXT2: part[device][i].type = 0; ext2Unmount(part[device][i].mount); break; case T_ISO9660: part[device][i].type = 0; sprintf(mount, "%s:", part[device][i].mount); ISO9660_Unmount(mount); break; } part[device][i].name[0] = 0; part[device][i].mount[0] = 0; part[device][i].sector = 0; part[device][i].interface = NULL; } }
/*************************************************************************** * MountDVD * * return 0 on error, 1 on success ***************************************************************************/ static int MountDVD(void) { GUI_MsgBoxOpen("Information", "Mounting DVD ...",1); /* check if DVD is already mounted */ if (dvd_mounted) { /* unmount DVD */ ISO9660_Unmount("dvd:"); dvd_mounted = 0; } /* check if disc is found */ if(!dvd->isInserted()) { GUI_WaitPrompt("Error","No Disc inserted !"); return 0; } /* mount DVD */ if(!ISO9660_Mount("dvd",dvd)) { GUI_WaitPrompt("Error","Disc can not be read !"); return 0; } /* DVD is mounted */ dvd_mounted = 1; GUI_MsgBoxClose(); return 1; }
void unmountDevice () { if (inuse != NULL) { if (matchStr(inuse->root, "dvd")) { ISO9660_Unmount(); } else { fatUnmount(inuse->root); } inuse = NULL; } }
/**************************************************************************** * MountDVD() * * Tests if a ISO9660 DVD is inserted and available, and mounts it ***************************************************************************/ bool MountDVD(bool silent) { bool mounted = false; int retry = 1; if(unmountRequired[DEVICE_DVD]) { unmountRequired[DEVICE_DVD] = false; ISO9660_Unmount("dvd:"); } while(retry) { ShowAction("Loading DVD..."); if(!dvd->isInserted()) { if(silent) break; retry = ErrorPromptRetry("No disc inserted!"); } else if(!ISO9660_Mount("dvd", dvd)) { if(silent) break; retry = ErrorPromptRetry("Unrecognized DVD format."); } else { mounted = true; break; } } CancelAction(); isMounted[DEVICE_DVD] = mounted; return mounted; }
void ProcessArgs(int argc, char **argv, int boothbdirect) { int i; s32 retval; u32 bootcode = launchcode & ~(0xff<<24);//Mask out the high 8-bits of launchcode, since that's used for options etc. char *path = (char*)0x900FFF00; void (*entry)() = (void*)0x80001800; u64 nandboot_titleid; YellHttp_Ctx *ctx; int use_wc24http = 0; u32 index; FILE *fdol; struct stat dolstats; if(!fatInitDefault())printf("FAT init failed.\n"); printf("Processing args...\n"); #ifndef WIILOADAPPDEBUG if(argc && !boothbdirect) { sscanf(argv[0], "%016llx", &nandboot_titleid); if(curtitleid!=nandboot_titleid) { printf("Current titleID and titleID from NANDBOOTINFO don't match: %016llx %s\n", curtitleid, argv[0]); argc = 0; } } #endif if(argc) { if(boothbdirect)launchcode = 1; if(launchcode & BIT(24))use_wc24http = 1; switch(bootcode) { case 1://Boot homebrew if(argc<2)break; if(!boothbdirect)printf("Booting homebrew from: %s\n", argv[1]); memcpy((void*)0x80001800, loader_bin, loader_bin_size); memset(path, 0, 256); if(!boothbdirect) { if(strncmp(argv[1], "http", 4)==0) { if(!use_wc24http) { printf("Using libyellhttp to download: %s\n", argv[1]); memset(localip, 0, 16); memset(netmask, 0, 16); memset(gateway, 0, 16); printf("Initializing network...\n"); retval = if_config (localip, netmask, gateway, true); if(retval<0) { printf("Network init failed: %d\n", retval); break; } ctx = YellHttp_InitCtx(); if(ctx==NULL) { printf("Failed to init/alloc http ctx.\n"); break; } printf("Downloading %s...\n", argv[1]); if(launchcode & BIT(26)) { WC24_MountWC24DlVFF(); chdir("wc24dl.vff:/"); } retval = YellHttp_ExecRequest(ctx, argv[1]); YellHttp_FreeCtx(ctx); if(retval<0) { memset(errstr, 0, 256); YellHttp_GetErrorStr(retval, errstr, 256); printf("retval = %d str: %s", retval, errstr); break; } for(i=strlen(argv[1])-1; i>0; i--) { if(argv[1][i]=='/')break; } i++; if(launchcode & BIT(26))strncpy(path, "wc24dl.vff:", 255); strncat(path, &argv[1][i], 255); } else { printf("Using WC24 to download: %s\n", argv[1]); printf("Creating record+entry...\n"); retval = WC24_CreateRecord(&myrec, &myent, 0, 0, 0x4842, WC24_TYPE_TITLEDATA, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB, 0x3c, 0x5a0, 0, argv[1], VFFPATH "boot.dol"); if(retval<0) { printf("WC24_CreateRecord returned %d\n", retval); WC24_Shutdown(); break; } index = retval; printf("Downloading...\n"); retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)index, 0x0); if(retval<0) { printf("KD_Download returned %d\n", retval); WC24_DeleteRecord(index); WC24_Shutdown(); break; } printf("Deleting record+entry...\n"); WC24_DeleteRecord(index); printf("Mounting VFF...\n"); retval = WC24_MountWC24DlVFF(); if(retval<0) { printf("WC24_MountWC24DlVFF returned %d\n", retval); WC24_Shutdown(); break; } printf("Reading wc24dl.vff:/" VFFPATH "boot.dol...\n"); fdol = fopen("wc24dl.vff:/" VFFPATH "boot.dol", "r"); if(fdol==NULL) { printf("Failed to open wc24dl.vff:/" VFFPATH "boot.dol\n"); } else { stat("wc24dl.vff:/" VFFPATH "boot.dol", &dolstats); dol_size = dolstats.st_size; fread((void*)0x90100000, 1, dolstats.st_size, fdol); fclose(fdol); unlink("wc24dl.vff:/" VFFPATH "boot.dol"); DCFlushRange((void*)0x90100000, dolstats.st_size); } printf("Unmounting VFF...\n"); VFF_Unmount("wc24dl.vff"); memset(path, 0, 256); boothbdirect = 1; WII_SetNANDBootInfoLaunchcode(0); } } else { strncpy(path, argv[1], 255); } if(!use_wc24http) { if(strncmp(path, "dvd", 3)==0) { DI_Init(); if(!ISO9660_Mount()) { printf("Failed to mount DVD ISO9660.\n"); DI_Close(); break; } } stat(path, &dolstats); dol_size = dolstats.st_size; fdol = fopen(path, "r"); if(fdol==NULL) { printf("Dol doesn't exist: %s\n", argv[1]); break; } else { fread((void*)0x90100000, 1, dol_size, fdol); DCFlushRange((void*)0x90100000, dol_size); fclose(fdol); } memset(path, 0, 256); if(strncmp(path, "dvd", 3)==0) { ISO9660_Unmount(); DI_Close(); } if(launchcode & BIT(26)) { unlink(path); VFF_Unmount("wc24dl.vff"); } } } SetDolArgv((void*)0x90100000, dol_size, argc, argv); DCFlushRange((void*)0x80001800, loader_bin_size); DCFlushRange(path, 256); if(!boothbdirect)WII_SetNANDBootInfoLaunchcode(0); if(!boothbdirect) { printf("Booting: %s\n", path); } else { printf("Booting homebrew directly from RAM buffer.\n"); } WC24_Shutdown(); WPAD_Shutdown(); FlushLog(); //IOS_ReloadIOS(36); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); entry(); break; case 2://Boot game disc memcpy((void*)0x80001800, loader_bin, loader_bin_size); memset(path, 0, 256); memcpy((void*)0x90100000, tinyload_dol, tinyload_dol_size); DCFlushRange((void*)0x80001800, loader_bin_size); DCFlushRange(path, 256); DCFlushRange((void*)0x90100000, tinyload_dol_size); WII_SetNANDBootInfoLaunchcode(0); WC24_Shutdown(); WPAD_Shutdown(); printf("Booting game disc.\n"); FlushLog(); entry(); break; default: break; } } printf("Invalid launchcode or argc: %x %x\n", launchcode, argc); #ifdef DEBUG printf("Press A to contine.\n"); while(1) { WPAD_ScanPads(); if(WPAD_ButtonsDown(0) & WPAD_BUTTON_A)break; VIDEO_WaitVSync(); } #endif printf("Shutting down...\n"); printf("Shutting down WC24...\n"); if(launchcode & BIT(26))VFF_Unmount("wc24dl.vff"); WC24_Shutdown(); FlushLog(); WPAD_Shutdown(); WII_Shutdown(); }