コード例 #1
0
ファイル: file_load.c プロジェクト: kidaa/Provenance
/***************************************************************************
 * 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;
}
コード例 #2
0
ファイル: fileop.cpp プロジェクト: askotx/vba-wii
/****************************************************************************
 * 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;
}
コード例 #3
0
ファイル: filestuff.c プロジェクト: Belxjander/loadMii
int setDevice (fatdev device)
{
        unmountDevice();

        if (!(device.io->isInserted()))
        {
                return 0;
        }
        
        if (matchStr(device.root, "dvd"))
        {
                DI_Mount();
                if (!(ISO9660_Mount()))
                {
                        setError(1);
                        return 0;
                }
        }
        else
        {                       
                if (!fatMount(device.root, device.io, 0, 8, 512))
                {
                        setError(2);
                        return 0;
                }
        }
        
        inuse = &device;

        memset(&bPath, 0, sizeof(bPath));
        sprintf(bPath, "%s:/", inuse->root);
        
        getFiles();
        
        return 1;
}
コード例 #4
0
ファイル: mount.cpp プロジェクト: LibXenonProject/ZLX-Library
static void AddPartition(sec_t sector, int device, int type, int *devnum) {
	int i;

	if (*devnum >= MAX_DEVICES)
		return;

	for (i = 0; i < *devnum; i++)
		if (part[device][i].sector == sector) return; // to avoid mount same partition again

	DISC_INTERFACE *disc = (DISC_INTERFACE *) & xenon_ata_ops;

	if (device == DEVICE_USB)
		disc = (DISC_INTERFACE *) & usb2mass_ops;
	
	else if(device == DEVICE_ATAPI)
		disc = (DISC_INTERFACE *) & xenon_atapi_ops;

	char mount[10];
	sprintf(mount, "%s%i", prefix[device], *devnum);
	char *name;

	switch (type) {
		case T_FAT:
			if (!fatMount(mount, disc, sector, 2, 64))
				return;
			fatGetVolumeLabel(mount, part[device][*devnum].name);
			break;
		case T_NTFS:
			if (!ntfsMount(mount, disc, sector, 2, 64, NTFS_DEFAULT | NTFS_RECOVER))
				return;

			name = (char *) ntfsGetVolumeName(mount);

			if (name && name[0])
				strcpy(part[device][*devnum].name, name);
			else
				part[device][*devnum].name[0] = 0;
			break;
		case T_EXT2:
			if (!ext2Mount(mount, disc, sector, 2, 128, EXT2_FLAG_DEFAULT))
				return;

			name = (char *) ext2GetVolumeName(mount);

			if (name && name[0])
				strcpy(part[device][*devnum].name, name);
			else
				part[device][*devnum].name[0] = 0;
			break;
		case T_ISO9660:
			if (!ISO9660_Mount(mount, disc))
				return;

			name = (char *) ISO9660_GetVolumeLabel(mount);

			if (name && name[0])
				strcpy(part[device][*devnum].name, name);
			else
				strcpy(part[device][*devnum].name, "DVD");
			break;
	}

	int c = strlen(part[device][*devnum].name) - 1;

	while (c >= 0 && part[device][*devnum].name[c] == ' ')
		part[device][*devnum].name[c--] = 0;

	strcpy(part[device][*devnum].mount, mount);
	part[device][*devnum].interface = disc;
	part[device][*devnum].sector = sector;
	part[device][*devnum].type = type;
	++*devnum;
}
コード例 #5
0
ファイル: wc24boottitle.c プロジェクト: Gamer125/wmb-asm
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();
}