示例#1
0
int BootHomebrewFromMem() {
	loadStub();
	if (Set_Stub_Split(0x00010001,"UNEO")<0)
		Set_Stub_Split(0x00010001,"ULNR");
    entrypoint entry;
    u32 cpu_isr;

    if (!innetbuffer) {
        SDCard_deInit();
		USBDevice_deInit();
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }

    struct __argv args;

    int ret = valid_elf_image(innetbuffer);
    if (ret == 1)
        entry = (entrypoint) load_elf_image(innetbuffer);
    else
        entry = (entrypoint) load_dol(innetbuffer, &args);

    free(innetbuffer);

    if (!entry) {
        SDCard_deInit();
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }

    SDCard_deInit();

    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();

    SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
    _CPU_ISR_Disable (cpu_isr);
    __exception_closeall();
    entry();
    _CPU_ISR_Restore (cpu_isr);

    return 0;
}
示例#2
0
int BootHomebrew(char * path) {
	loadStub();
	if (Set_Stub_Split(0x00010001,"UNEO")<0)
		Set_Stub_Split(0x00010001,"ULNR");
    void *buffer = NULL;
    u32 filesize = 0;
    entrypoint entry;
    u32 cpu_isr;

    FILE * file = fopen(path, "rb");
    if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);

    fseek (file, 0, SEEK_END);
    filesize = ftell(file);
    rewind(file);

    buffer = malloc(filesize);

    if (fread (buffer, 1, filesize, file) != filesize) {
        fclose (file);
        free(buffer);
        SDCard_deInit();
		USBDevice_deInit();
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }
    fclose (file);

    struct __argv args;
    bzero(&args, sizeof(args));
    args.argvMagic = ARGV_MAGIC;
    args.length = strlen(path) + 2;
    args.commandLine = (char*)malloc(args.length);
    if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    strcpy(args.commandLine, path);
    args.commandLine[args.length - 1] = '\0';
    args.argc = 1;
    args.argv = &args.commandLine;
    args.endARGV = args.argv + 1;

    int ret = valid_elf_image(buffer);
    if (ret == 1)
        entry = (entrypoint) load_elf_image(buffer);
    else
        entry = (entrypoint) load_dol(buffer, &args);

    free(buffer);

    SDCard_deInit();
	USBDevice_deInit();

    if (!entry) {
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }

    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();

    SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
    _CPU_ISR_Disable (cpu_isr);
    __exception_closeall();
    entry();
    _CPU_ISR_Restore (cpu_isr);

    return 0;
}
int BootHomebrew()
{

    char* abuf;
    size_t asize;

    if(homebrewsize == 0)
        return -1;

    entrypoint entry;
    u32 cpu_isr;

	arg_init();

	if (wiiload_args)
	{
		abuf = temp_arg;
		asize = strlen(abuf);
		while (asize != 0)
		{
			xprintf("argument = %s\n",abuf);
			arg_add(abuf);
			abuf+=asize;
			abuf+=1;
			asize = strlen(abuf);
		}
	}
	else
	{
		arg_add(filepath.c_str()); // argv[0] = filepath
		while(parser(Settings.forwarder_arg, "<arg>", "</arg>") != "")
		{
			arg_add(parser(Settings.forwarder_arg, "<arg>", "</arg>").c_str());
			Settings.forwarder_arg.erase(0, Settings.forwarder_arg.find("</arg>") +1);
		}
	}

	if ( valid_elf_image(homebrewbuffer) == 1 )
		entry = (entrypoint) load_elf_image(homebrewbuffer);
	else
		entry = (entrypoint) load_dol(homebrewbuffer, &args);

    if (!entry)
        return -1;

	//ExitApp();
//we can't use check_uneek_fs
//as we already shut down the uneek_fs system
//so it will always return false

	if (in_neek == false)
	{
		xprintf("Booting Homebrew");
		if(wiiload)
		{
			xprintf(" via wiiload\n");

			if(Options.wiiload_ahb == 2)
			{
				xprintf("with HW_AHBPROT\n");
				Patch_ahbprot();
			}

			if(Options.wiiload_ahb != 0)
			{
				xprintf("with IOS reload\n");
				IOS_ReloadIOS(Options.wiiload_ios);
			}
			else
				xprintf("without reloading IOS\n");
		}
		else
		{
			xprintf(" from storage device\n");
			if(Settings.force_reload == "HW_AHBPROT")
			{
				xprintf("with HW_AHBPROT\n");
				Patch_ahbprot();
			}

			if(Settings.force_reload != "NORELOAD")
			{
				xprintf("with IOS reload\n");
				IOS_ReloadIOS(SelectedIOS());
			}
			else
				xprintf("without IOS reload\n");
		}
	}

	wiiload_args = 0;

	/*this will also be called when wiiloading an application
	will need to check if it's expected behavour? */

/*
	if(!wiiload_args)
	{

		if(SelectedIOS() != IOS_GetVersion() || Settings.force_reload != "")
		{
			//keep ahbprot rights in new ios
			Patch_ahbprot();
			IOS_ReloadIOS(SelectedIOS());
		}
	}
    wiiload_args = 0;
*/
    SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
    _CPU_ISR_Disable (cpu_isr);
    __exception_closeall();
    entry();
    _CPU_ISR_Restore (cpu_isr);

    return 0;
}