示例#1
0
bool CheckvWii (void) {
	#ifdef DOLPHIN
	return false;
	#endif
	// Check Device ID
	u32 deviceID = 0;
	ES_GetDeviceID(&deviceID);
	// If it is greater than or equal to 0x20000000 (536870912), then you are running on a Wii U
	return (deviceID >= 536870912);
} // CheckvWii
示例#2
0
void FlushLog()
{
	#ifdef DEBUGPOST
	s32 retval;
	u32 cid = 0;
	YellHttp_Ctx *ctx = YellHttp_InitCtx();
	time_t curtime;
	struct tm *timeconv;

	printf("Flushing log...\n");
	memset(errstr, 0, 256);
	memset(creds, 0, 256);
	strncpy(creds, "wc24boottitle:WC24HAXX", 256);
	YellHttp_SetAuthCb(authentication_callback, creds);
	ctx->server_flags |= YELLHTTP_SRVFLAG_NOCACHE;

	memset(log_name, 0, 256);
	ES_GetDeviceID(&cid);
	curtime = time(NULL);
	timeconv = gmtime(&curtime);
	snprintf(log_name, 255, "%08x_%d-%d-%d_%d-%d-%d", cid, timeconv->tm_mday, timeconv->tm_mon, timeconv->tm_year - 100, timeconv->tm_hour, timeconv->tm_min, timeconv->tm_sec);
	

	formentries[0].numfields = 2;
	formentries[0].fields = formfields;
	formfields[1].value = log_name;
	formentries[0].path = NULL;
	memset(formentries[0].content_type, 0, 512);
	strncpy(formentries[0].content_type, "text/plain", 511);
	formentries[0].data = (unsigned char*)log_buffer;
	formentries[0].data_length = strnlen(log_buffer, 0x4000);

	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);
		YellHttp_FreeCtx(ctx);
		free(log_buffer);
		return;
	}

	printf("Executing ExecRequest...(GET)\n");
	retval = YellHttp_ExecRequest(ctx, "http://192.168.1.33/wc24boottitle/debuglogs/upload.php");
	YellHttp_GetErrorStr(retval, errstr, 256);
	if(retval!=0)
	{
		printf("retval = %d str: %s", retval, errstr);
	}

	retval = YellHttp_EncodePostMIME_MultipartFormData(ctx, formentries, 1);
	YellHttp_GetErrorStr(retval, errstr, 256);
	if(retval!=0)printf("Encode MIME retval = %d str: %s", retval, errstr);
	memset(errstr, 0, 256);

	printf("Executing ExecRequest...(POST)\n");
	retval = YellHttp_ExecRequest(ctx, "http://192.168.1.33/wc24boottitle/debuglogs/upload.php");
	YellHttp_GetErrorStr(retval, errstr, 256);
	if(retval!=0)
	{
		printf("retval = %d str: %s", retval, errstr);
	}

	YellHttp_FreeCtx(ctx);

	free(log_buffer);
	#endif
}
示例#3
0
s32 ProcessWC24(int dlnow)
{
	s32 retval;
	u32 entry_bitmask = 0xf;
	FILE *fdol = NULL, *fver = NULL, *fconfig = NULL;
	int i;
	char *configbuf;
	char *updateinfobuf;
	char *configlines[0x10];
	char *updateinfolines[0x10];
	struct stat dolstats;
	u32 consoleID;
	int dlfreq;
	char **argv;
	#ifdef LAN
	dlfreq = 1;//Set dl frequency to every 2 minutes for LAN, hourly for Internet.
	#else
	dlfreq = 0x3c;
	#endif
	if(dlnow)entry_bitmask = 0xf;

	retval = WC24_CreateWC24DlVFF(0x200000, 0);//2MB
	if(retval<0 && retval!=-105)//Return when VFF creation fails, except when the VFF already exists.
	{
		printf("WC24_CreateWC24DlVFF returned %d\n", retval);
		return retval;
	}
	
	retval = WC24_MountWC24DlVFF();
	if(retval<0)
	{
		printf("WC24_MountWC24DlVFF returned %d\n", retval);
		return retval;
	}
	
	printf("mkdir...\n");
	mkdir("wc24dl.vff:/wc24boottitle", 777);
	printf("done.\n");
	VFF_Unmount("wc24dl.vff");

	retval = ES_GetDeviceID(&consoleID);
	if(retval<0)
	{
		printf("ES_GetDeviceID returned %d\n", retval);
	}
	memset(url_id, 0, 256);
	snprintf(url_id, 255, ".php?cid=%08x", consoleID);

	memset(url, 0, 256);
	snprintf(url, 255, "%swc24boottitle/installer.dol%s", SRVR_BASEURL, url_id);//See the README for note on retrieving server scripts source.
	retval = WC24_FindEntry((u32)curtitleid, "installer.dol", &myent, 1);
	if(retval>=0)
	{
		if(strncmp(myent.url, url, 0xec))
		{
			WC24_DeleteRecord(retval);
			retval = LIBWC24_ENOENT;
		}
		else
		{
			retval = -1;
		}
	}

	if(retval==LIBWC24_ENOENT)//Only create the entry when it doesn't exist. When there's an entry with "installer.dol" for the URL filename but the whole URL doesn't match the one we're going to install, that entry is deleted then we create a new one.
	{
		printf("Creating record+entry for wc24boottitle auto-update installer...\n");
		retval = WC24_CreateRecord(&myrec, &myent, WC24ID, 0, 0x4842, WC24_TYPE_TITLEDATA, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB, dlfreq, 0x5a0, 0, url, VFFPATH "installer.dol");
		if(retval<0)
		{
			printf("WC24_CreateRecord returned %d\n", retval);
			VFF_Unmount("wc24dl.vff");
			return retval;
		}
		entry_bitmask |= BIT(0);
	}

	memset(url, 0, 256);
	snprintf(url, 255, "%swc24boottitle/verinfo%s", SRVR_BASEURL, url_id);
	retval = WC24_FindEntry((u32)curtitleid, "verinfo", &myent, 1);
	if(retval>=0)
	{
		if(strncmp(myent.url, url, 0xec))
		{
			WC24_DeleteRecord(retval);
			retval = LIBWC24_ENOENT;
		}
		else
		{
			retval = -1;
		}
	}

	if(retval==LIBWC24_ENOENT)
	{
		printf("Creating record+entry for wc24boottitle auto-update version info...\n");
		retval = WC24_CreateRecord(&myrec, &myent, WC24ID, 0, 0x4842, WC24_TYPE_TITLEDATA, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB, dlfreq, 0x5a0, 0, url, VFFPATH "verinfo");
		if(retval<0)
		{
			printf("WC24_CreateRecord returned %d\n", retval);
			VFF_Unmount("wc24dl.vff");
			return retval;
		}
		entry_bitmask |= BIT(1);
	}

	memset(url, 0, 256);
	snprintf(url, 255, "%swc24boottitle/bootmailupd%s", SRVR_BASEURL, url_id);
	retval = WC24_FindEntry((u32)curtitleid, "bootmailupd", &myent, 1);
	if(retval>=0)
	{
		if(strncmp(myent.url, url, 0xec))
		{
			WC24_DeleteRecord(retval);
			retval = LIBWC24_ENOENT;
		}
		else
		{
			retval = -1;
		}
	}

	if(retval==LIBWC24_ENOENT)
	{
		printf("Creating record+entry for wc24boottitle auto-update boot mail...\n");
		retval = WC24_CreateRecord(&myrec, &myent, WC24ID, 0, 0x4842, WC24_TYPE_MSGBOARD, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB | WC24_FLAGS_IDLEONLY, dlfreq, 0x5a0, 0, url, NULL);
		if(retval<0)
		{
			printf("WC24_CreateRecord returned %d\n", retval);
			VFF_Unmount("wc24dl.vff");
			return retval;
		}
		entry_bitmask |= BIT(2);
	}

	memset(url, 0, 256);
	snprintf(url, 255, "%swc24boottitle/bootmailbt%s", SRVR_BASEURL, url_id);
	retval = WC24_FindEntry((u32)curtitleid, "bootmailbt", &myent, 1);
	if(retval>=0)
	{
		if(strncmp(myent.url, url, 0xec))
		{
			WC24_DeleteRecord(retval);
			retval = LIBWC24_ENOENT;
		}
		else
		{
			retval = -1;
		}
	}

	if(retval==LIBWC24_ENOENT)
	{
		printf("Creating record+entry for wc24boottitle boot mail...\n");
		retval = WC24_CreateRecord(&myrec, &myent, WC24ID, 0, 0x4842, WC24_TYPE_MSGBOARD, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB | WC24_FLAGS_IDLEONLY, dlfreq, 0x5a0, 0, url, NULL);
		if(retval<0)
		{
			printf("WC24_CreateRecord returned %d\n", retval);
			VFF_Unmount("wc24dl.vff");
			return retval;
		}
		entry_bitmask |= BIT(3);
	}

	memset(url, 0, 256);
	snprintf(url, 255, "%swc24boottitle/changelogmail%s", SRVR_BASEURL, url_id);
	retval = WC24_FindEntry((u32)curtitleid, "changelogmail", &myent, 1);
	if(retval>=0)
	{
		if(strncmp(myent.url, url, 0xec))
		{
			WC24_DeleteRecord(retval);
			retval = LIBWC24_ENOENT;
		}
		else
		{
			retval = -1;
		}
	}

	if(retval==LIBWC24_ENOENT)
	{
		printf("Creating record+entry for wc24boottitle changelog mail...\n");
		retval = WC24_CreateRecord(&myrec, &myent, WC24ID, 0, 0x4842, WC24_TYPE_MSGBOARD, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB, dlfreq, 0x5a0, 0, url, NULL);
		if(retval<0)
		{
			printf("WC24_CreateRecord returned %d\n", retval);
			VFF_Unmount("wc24dl.vff");
			return retval;
		}
		entry_bitmask |= BIT(4);
	}

	if(entry_bitmask)
	{
		printf("New entries were installed, downloading the content immediately...\n");

		if(entry_bitmask & BIT(0))
		{
			memset(url, 0, 256);
			snprintf(url, 255, "%swc24boottitle/installer.dol%s", SRVR_BASEURL, url_id);
			retval = WC24_FindEntry((u32)curtitleid, url, &myent, 0);
			if(retval<0)
			{
				printf("Failed to find entry for wc24boottitle auto-update installer.\n");
			}
			else
			{
				retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)retval, 0x0);
				WC24_ReadEntry(myent.index, &myent);
				if(retval<0)printf("KD_Download for wc24boottitle auto-update installer entry failed: %d\n", retval);
				if(myent.error_code!=0 && myent.error_code!=WC24_EHTTP304)printf("WC24 error code: %d\n", myent.error_code);
				printf("cnt_nextdl: %x\n", (u32)myent.cnt_nextdl);
			}
		}

		if(entry_bitmask & BIT(1))
		{
			memset(url, 0, 256);
			snprintf(url, 255, "%swc24boottitle/verinfo%s", SRVR_BASEURL, url_id);
			retval = WC24_FindEntry((u32)curtitleid, url, &myent, 0);
			if(retval<0)
			{
				printf("Failed to find entry for wc24boottitle auto-update version info.\n");
			}
			else
			{
				retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)retval, 0x0);
				WC24_ReadEntry(myent.index, &myent);
				if(retval<0)printf("KD_Download for wc24boottitle auto-update version info entry failed: %d\n", retval);
				if(myent.error_code!=0 && myent.error_code!=WC24_EHTTP304)printf("WC24 error code: %d\n", myent.error_code);
				printf("cnt_nextdl: %x\n", (u32)myent.cnt_nextdl);
			}
		}

		if(entry_bitmask & BIT(2))
		{
			memset(url, 0, 256);
			snprintf(url, 255, "%swc24boottitle/bootmailupd%s", SRVR_BASEURL, url_id);
			retval = WC24_FindEntry((u32)curtitleid, url, &myent, 0);
			if(retval<0)
			{
				printf("Failed to find entry for wc24boottitle auto-update boot mail.\n");
			}
			else
			{
				retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)retval, 0x0);
				WC24_ReadEntry(myent.index, &myent);
				if(retval<0)printf("KD_Download for wc24boottitle auto-update boot mail entry failed: %d\n", retval);
				if(myent.error_code!=0 && myent.error_code!=WC24_EHTTP304)printf("WC24 error code: %d\n", myent.error_code);
				printf("cnt_nextdl: %x\n", (u32)myent.cnt_nextdl);
			}
		}

		if(entry_bitmask & BIT(3))
		{
			memset(url, 0, 256);
			snprintf(url, 255, "%swc24boottitle/bootmailbt%s", SRVR_BASEURL, url_id);
			retval = WC24_FindEntry((u32)curtitleid, url, &myent, 0);
			if(retval<0)
			{
				printf("Failed to find entry for wc24boottitle boot mail.\n");
			}
			else
			{
				retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)retval, 0x0);
				WC24_ReadEntry(myent.index, &myent);
				if(retval<0)printf("KD_Download for wc24boottitle boot mail entry failed: %d\n", retval);
				if(myent.error_code!=0 && myent.error_code!=WC24_EHTTP304)printf("WC24 error code: %d\n", myent.error_code);
				printf("cnt_nextdl: %x\n", (u32)myent.cnt_nextdl);
			}
		}

		if(entry_bitmask & BIT(4))
		{
			memset(url, 0, 256);
			snprintf(url, 255, "%swc24boottitle/changelogmail%s", SRVR_BASEURL, url_id);
			retval = WC24_FindEntry((u32)curtitleid, url, &myent, 0);
			if(retval<0)
			{
				printf("Failed to find entry for wc24boottitle changelog mail.\n");
			}
			else
			{
				retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)retval, 0x0);
				WC24_ReadEntry(myent.index, &myent);
				if(retval<0)printf("KD_Download for wc24boottitle changelog mail entry failed: %d\n", retval);
				if(myent.error_code!=0 && myent.error_code!=WC24_EHTTP304)printf("WC24 error code: %d\n", myent.error_code);
				printf("cnt_nextdl: %x\n", (u32)myent.cnt_nextdl);
			}
		}
	}

	printf("Processing content in wc24dl.vff...\n");
	WC24_MountWC24DlVFF();

	fdol = fopen("wc24dl.vff:/" VFFPATH "installer.dol", "r");
	if(fdol==NULL)
	{
		printf("wc24dl.vff:/" VFFPATH "installer.dol doesn't exist, no update is available.\n");
	}
	else
	{
		fver = fopen("wc24dl.vff:/" VFFPATH "verinfo", "r");
		if(fver==NULL)
		{
			printf("wc24dl.vff:/" VFFPATH "verinfo doesn't exist, no update is available.\n");
		}
		else
		{
			configbuf = (char*)malloc(0x200);
			updateinfobuf = (char*)malloc(0x200);
			memset(configbuf, 0, 0x200);
			memset(updateinfobuf, 0, 0x200);
			for(i=0; i<0x10; i++)
			{
				configlines[i] = &configbuf[i*0x20];
				updateinfolines[i] = &updateinfobuf[i*0x20];
			}
			fread(updateinfobuf, 1, 0x200, fver);
			fclose(fver);

			fconfig = fopen("wc24dl.vff:/" VFFPATH "config", "r+");
			if(fconfig==NULL)
			{
				printf("Config file doesn't exist, creating.\n");
				fconfig = fopen("wc24dl.vff:/" VFFPATH "config", "w+");
				strncpy(configlines[0], WC24BOOTTITLE_VERSION, 0x1f);
				snprintf(configlines[1], 0x1f, "Revision: %d", 0);//SVN beta auto-update isn't implemented yet.
				fwrite(configbuf, 1, 0x200, fconfig);
				fseek(fconfig, 0, SEEK_SET);
			}
			else
			{
				fread(configbuf, 1, 0x200, fconfig);
				fseek(fconfig, 0, SEEK_SET);

				if(strncmp(configlines[0], WC24BOOTTITLE_VERSION, 0x1f)<0)
				{
					printf("The stable version contained in the config is older than the version contained in the title dol, updating the config version...\n");
					strncpy(configlines[0], WC24BOOTTITLE_VERSION, 0x1f);
					fwrite(configbuf, 1, 0x200, fconfig);
					fseek(fconfig, 0, SEEK_SET);
				}
			}

			if(strncmp(configlines[0], updateinfolines[0], 0x1f)<0)
			{
				printf("The stable version contained in the config is older than the version contained in the stable wc24boottitle version info WC24 dl content, updating...\n");
				strncpy(configlines[0], updateinfolines[0], 0x1f);
				fwrite(configbuf, 1, 0x200, fconfig);
				fseek(fconfig, 0, SEEK_SET);

				stat("wc24dl.vff:/" VFFPATH "installer.dol", &dolstats);
				dol_size = dolstats.st_size;
				fread((void*)0x90100000, 1, dol_size, fdol);
				DCFlushRange((void*)0x90100000, dol_size);
				printf("Update size: %x\n", dol_size);

				free(updateinfobuf);
				free(configbuf);
				fclose(fconfig);
				fclose(fdol);
				fclose(fver);
				unlink("wc24dl.vff:/" VFFPATH "installer.dol");
				unlink("wc24dl.vff:/" VFFPATH "verinfo");
				VFF_Unmount("wc24dl.vff");

				argv = (char**)malloc(16);
				memset(argv, 0, 16);
				for(i=0; i<4; i++)
				{
					argv[i] = (char*)malloc(256);
					memset(argv[i], 0, 256);
				}
				strncpy(argv[0], "0001000857434254", 255);
				strncpy(argv[1], "wc24dl.vff:/" VFFPATH "installer.dol", 255);
				strncpy(argv[2], "1", 255);
				strncpy(argv[3], "0", 255);

				ProcessArgs(4, argv, 1);
			}
			else
			{
				printf("Deleting wc24dl.vff:/" VFFPATH "installer.dol and wc24dl.vff:/" VFFPATH "verinfo since no update is available.\n");
				unlink("wc24dl.vff:/" VFFPATH "installer.dol");
				unlink("wc24dl.vff:/" VFFPATH "verinfo");
			}

			free(updateinfobuf);
			free(configbuf);
			fclose(fconfig);
		}
	}

	if(fdol)fclose(fdol);
	if(fver)fclose(fver);
	VFF_Unmount("wc24dl.vff");

	return 0;
}
示例#4
0
//a function made by joostin that checks consoleID to see if its vwii or wii.
//personally i'd like to check it differently but i dont know how so ye, this'll work i guess
bool CheckvWii (void) {
    u32 deviceID = 0;
    ES_GetDeviceID(&deviceID);
    // If it is greater than or equal to 0x20000000 (536870912), then you are running on a Wii U
    return (deviceID >= 536870912);
}