예제 #1
0
void InstallConfigData(){
	if(CheckInstallationData() == 0)
	{
		first_boot = false;
		return;
	}

	first_boot = true;
	trySetLangFromTheme();
	writeCfg();

	sprintf(str, "/rxTools/Theme/%u/cfg0TOP.bin", cfgs[CFG_THEME].val.i);
	DrawTopSplash(str, str, str);
	sprintf(str, "/rxTools/Theme/%u/cfg0.bin", cfgs[CFG_THEME].val.i);
	DrawBottomSplash(str);

	int res = InstallData("0");	//SD Card
	sprintf(str, "/rxTools/Theme/%u/cfg1%c.bin", cfgs[CFG_THEME].val.i, res == 0 ? 'O' : 'E');
	DrawBottomSplash(str);
	sprintf(str, "/rxTools/Theme/%u/TOP.bin", cfgs[CFG_THEME].val.i);
	sprintf(strl, "/rxTools/Theme/%u/TOPL.bin", cfgs[CFG_THEME].val.i);
	sprintf(strr, "/rxTools/Theme/%u/TOPR.bin", cfgs[CFG_THEME].val.i);
	DrawTopSplash(str, strl, strr);

	InputWait();
}
예제 #2
0
파일: cfw.c 프로젝트: nastys/rxTools
void rxModeSys(){
	sprintf(str, "/rxTools/Theme/%u/boot.bin", cfgs[CFG_THEME].val.i);
	DrawBottomSplash(str);
	rxMode(0);
	sprintf(str, "/rxTools/Theme/%u/bootE.bin", cfgs[CFG_THEME].val.i);
	DrawBottomSplash(str);
	WaitForButton(BUTTON_A);
}
예제 #3
0
// @breif  Main routine surely.
int main(void) {

	FSInit();
	CFW_getSystemVersion();
	if (cfw_bootGUI==true) //If gui autoboot is enabled or L is held, show the ui //L held not working
	{
		DrawClearScreenAll();
		//MENU
		while (true)
		{
			//DRAW GUI
			if (menu_idx == MENU_ITEMS - 1)
			{
				sprintf(str, "/3ds/PastaCFW/UI/%c/menu6.bin", cfw_theme);
				DrawBottomSplash(str);
				sprintf(str, "/3ds/PastaCFW/UI/%c/creditsTOP.bin", cfw_theme);
				DrawTopSplash(str);
				TOP_Current = 0;
			}
			else
			{
				sprintf(str, "/3ds/PastaCFW/UI/%c/menu0.bin", cfw_theme);
				str[23] = menu_idx + 48;
				DrawBottomSplash(str); //BOTTOM SCREEN
				if (TOP_Current == 0){
					sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme);
					DrawTopSplash(str); //TOP SCREEN
					TOP_Current = 1;
				}
			}
			//MENU CONTROLS
			u32 pad_state = HidWaitForInput();
			if ((pad_state & BUTTON_RIGHT || pad_state & BUTTON_DOWN) && menu_idx != MENU_ITEMS - 1) menu_idx++; //MOVE RIGHT/DOWN (It depends on the theme)
			else if ((pad_state & BUTTON_LEFT || pad_state & BUTTON_UP) && menu_idx != 0)menu_idx--; //MOVE LEFT/UP (It depends on the theme)
			else if (pad_state & BUTTON_A)//SELECT
			{
				if (menu_idx == 0){ CFW_Boot(); break; }//BOOT CFW
				else if (menu_idx == 1)break; //REBOOT
				else if (menu_idx == 2)CFW_NandDumper(); //NAND DUMPER
				else if (menu_idx == 4)CFW_ARM9Dumper(); //ARM9 RAM DUMPER
				else if (menu_idx == 5)CFW_Settings(); //SETTINGS
			}
			else if (pad_state & BUTTON_START && pad_state & BUTTON_SELECT) //POWER OFF
			{
				i2cWriteRegister(I2C_DEV_MCU, 0x20, (u8)(1 << 0)); //As seen on 3dbrew
				while (1);
			}
		}
	}
	else CFW_Boot(); //else directly boot the cfw
	if (firmlaunch == true && cfw_enablefirmlaunch) FirmLaunch();

	// return control to FIRM ARM9 code (performs firmlaunch)
	return 0;
}
예제 #4
0
파일: cfw.c 프로젝트: nastys/rxTools
void rxModeEmu(){
	if (!checkEmuNAND()) rxModeSys();
	else{
		sprintf(str, "/rxTools/Theme/%u/boot.bin", cfgs[CFG_THEME].val.i);
		DrawBottomSplash(str);
		rxMode(1);
		sprintf(str, "/rxTools/Theme/%u/bootE.bin", cfgs[CFG_THEME].val.i);
		DrawBottomSplash(str);
		WaitForButton(BUTTON_A);
	}
}
예제 #5
0
파일: firm.c 프로젝트: Syphurith/rxTools
void rxModeWithSplash(int emu)
{
	char s[32];

	sprintf(s, "/rxTools/Theme/%u/boot.bin", cfgs[CFG_THEME].val.i);
	DrawBottomSplash(s);
	rxMode(emu);
}
예제 #6
0
파일: main.c 프로젝트: ArnoJuan/rxTools
static void drawBottom()
{
	wchar_t str[_MAX_LFN];

	swprintf(str, _MAX_LFN, L"/rxTools/Theme/%u/BOT%u.bin",
		cfgs[CFG_THEME].val.i, cfgs[CFG_DEFAULT].val.i);
	DrawBottomSplash(str);
}
예제 #7
0
파일: firm.c 프로젝트: Taktloss/rxTools
void rxModeWithSplash(int emu)
{
	wchar_t s[_MAX_LFN];

	swprintf(s, _MAX_LFN, L"/rxTools/Theme/%u/boot.bin",
		cfgs[CFG_THEME].val.i);
	DrawBottomSplash(s);
	rxMode(emu);
}
예제 #8
0
void CFW_NandDumper(void){
	//Nand dumper
	unsigned char* buf = 0x21000000;
	unsigned int nsectors = 0x200;  //sectors in a row

	//Here we draw the gui
	TOP_Current = 0;
	sprintf(str, "/3ds/PastaCFW/UI/%c/nand0.bin", cfw_theme);
	DrawBottomSplash(str);
	u32 pad_state = HidWaitForInput();
	if (pad_state & BUTTON_A)
	{
		int PERCENTAGE = 0;
		int NAND_SIZE;
		if (cfw_FWValue == 'a' || cfw_FWValue == 'b') NAND_SIZE = NAND_SIZE_N3DS;
		else  NAND_SIZE = NAND_SIZE_O3DS;
		sprintf(str, "/3ds/PastaCFW/UI/%c/nand1.bin", cfw_theme);
		DrawBottomSplash(str);
		if (FSFileCreate("/NAND.bin", true))
		{
			for (int count = 0; count < NAND_SIZE / NAND_SECTOR_SIZE / nsectors; count++)
			{
				sdmmc_nand_readsectors(count*nsectors, nsectors, buf);

				FSFileWrite(buf, nsectors*NAND_SECTOR_SIZE, count*NAND_SECTOR_SIZE*nsectors);
				if ((count % (int)(NAND_SIZE / NAND_SECTOR_SIZE / nsectors / 100)) == 0 && count != 0)
				{		
					sprintf(str, "%d%%", PERCENTAGE);
					DrawString(SCREEN_AREA_BOT0, str, 150, 195, RGB(255, 255, 255), RGB(187, 223, 249));
					DrawString(SCREEN_AREA_BOT1, str, 150, 195, RGB(255, 255, 255), RGB(187, 223, 249));
					PERCENTAGE++;
				}
			}
			FSFileClose();
			sprintf(str, "/3ds/PastaCFW/UI/%c/nand2O.bin", cfw_theme);
			DrawBottomSplash(str);
		}
		else {
			sprintf(str, "/3ds/PastaCFW/UI/%c/nand2E.bin", cfw_theme);
			DrawBottomSplash(str);
		}
	}
	HidWaitForInput();
}
예제 #9
0
// @breif  Dump ARM9 Ram to file.
void CFW_ARM9Dumper(void) {
	TOP_Current = 0;
	sprintf(str, "/3ds/PastaCFW/UI/%c/arm90.bin", cfw_theme);
	DrawBottomSplash(str);
	u32 pad_state = HidWaitForInput();
	if (pad_state & BUTTON_A)
	{
		sprintf(str, "/3ds/PastaCFW/UI/%c/arm91.bin", cfw_theme);
		DrawBottomSplash(str);
		u32 bytesWritten = 0;
		u32 currentWritten = 0;
		u32 result = 0;
		u32 currentSize = 0;
		void *dumpAddr = (void*)0x08000000;
		u32 fullSize = 0x00100000;
		const u32 chunkSize = 0x10000;

		if (FSFileCreate("/3ds/PastaCFW/RAM.bin", true)) {
			while (currentWritten < fullSize) {
				currentSize = fullSize - currentWritten < chunkSize ? fullSize - currentWritten : chunkSize;
				bytesWritten = FSFileWrite((u8 *)dumpAddr + currentWritten, currentSize, currentWritten);
				if (bytesWritten != currentSize) break;
				currentWritten += bytesWritten;
				char str[100];
				sprintf(str, "%lu%%", (currentWritten * 100) / fullSize);
				DrawString(SCREEN_AREA_BOT0, str, 150, 195, RGB(255, 255, 255), RGB(187, 223, 249));
				DrawString(SCREEN_AREA_BOT1, str, 150, 195, RGB(255, 255, 255), RGB(187, 223, 249));
			}
			FSFileClose();
			result = (fullSize == currentWritten);
		}
		if(result == 1){
			sprintf(str, "/3ds/PastaCFW/UI/%c/arm92OK.bin", cfw_theme);
			DrawBottomSplash(str);
		}
		else{
			sprintf(str, "/3ds/PastaCFW/UI/%c/arm2E.bin", cfw_theme);
			DrawBottomSplash(str);
		}
		HidWaitForInput();
	}
}
예제 #10
0
void InstallConfigData(){
	if(CheckInstallationData() == 0) return;
	
	sprintf(str, "/rxTools/Theme/%c/cfg0TOP.bin", Theme);
	DrawTopSplash(str);
	sprintf(str, "/rxTools/Theme/%c/cfg0.bin", Theme);
	DrawBottomSplash(str);

	int res = InstallData("0");	//SD Card
	if (res == 0)
	{
		sprintf(str, "/rxTools/Theme/%c/cfg1O.bin", Theme);
		DrawBottomSplash(str);
	}
	else
	{
		sprintf(str, "/rxTools/Theme/%c/cfg1E.bin", Theme);
		DrawBottomSplash(str);
	}
	
	//print("\nPress A to exit\n"); 
	WaitForButton(BUTTON_A);
}
예제 #11
0
파일: firm.c 프로젝트: Syphurith/rxTools
int rxMode(int emu)
{
	if (!checkEmuNAND() && emu)
	{
		ConsoleInit();
		ConsoleSetTitle(L"EMUNAND NOT FOUND!");
		print(L"The emunand was not found on\n");
		print(L"your SDCard. \n");
		print(L"\n");
		print(L"Press A to boot SYSNAND\n");
		ConsoleShow();
		WaitForButton(BUTTON_A);
		emu = 0;
		char s[32];
		sprintf(s, "/rxTools/Theme/%u/boot.bin", cfgs[CFG_THEME].val.i);
		DrawBottomSplash(s);
	}

	static const char patchNandPrefix[] = ".patch.p9.nand";
	unsigned int cur, offset, shstrSize;
	char path[64], shstrtab[512], *sh_name;
	const char *platformDir;
	const wchar_t *msg;
	int r, sector;
	void *p;
	Elf32_Ehdr ehdr;
	Elf32_Shdr shdr;
	FIL fd, keyxFd;
	UINT br, fsz;

	setAgbBios();

	getFirmPath(path, getMpInfo() == MPINFO_KTR ?
		TID_KTR_NATIVE_FIRM : TID_CTR_NATIVE_FIRM);
    strcpy(path + strlen(path) - 4, "orig.bin");
	r = loadFirm(path, &fsz);
	if (r) {
		msg = L"Failed to load NATIVE_FIRM: %d\n"
			L"Reboot rxTools and try again.\n";
		goto fail;
	}

	r = getMpInfo();
	switch (r) {
		case MPINFO_KTR:
			platformDir = "ktr";
			break;

		case MPINFO_CTR:
			platformDir = "ctr";
			break;

		default:
			msg = L"Unknown Platform: %d";
			goto fail;
	}

	sprintf(path, SYS_PATH "/patches/%s/native_firm.elf", platformDir);
	r = f_open(&fd, path, FA_READ);
	if (r != FR_OK)
		goto patchFail;

	r = f_read(&fd, &ehdr, sizeof(ehdr), &br);
	if (r != FR_OK)
		goto patchFail;

	r = f_lseek(&fd, ehdr.e_shoff + ehdr.e_shstrndx * sizeof(Elf32_Shdr));
	if (r != FR_OK)
		goto patchFail;

	r = f_read(&fd, &shdr, sizeof(shdr), &br);
	if (r != FR_OK)
		goto patchFail;

	r = f_lseek(&fd, shdr.sh_offset);
	if (r != FR_OK)
		goto patchFail;

	r = f_read(&fd, shstrtab, shdr.sh_size > sizeof(shstrtab) ?
		sizeof(shstrtab) : shdr.sh_size, &shstrSize);
	if (r != FR_OK)
		goto patchFail;

	if (emu) {
		sector = checkEmuNAND();
		if (sector == 0) {
			msg = L"Failed to find EmuNAND.\n"
				L"Check your EmuNAND.\n";
			goto fail;
		}
	} else
		sector = 0;

	cur = ehdr.e_shoff;
	for (; ehdr.e_shnum; ehdr.e_shnum--, cur += sizeof(shdr)) {
		if (f_lseek(&fd, cur) != FR_OK)
			continue;

		if (f_read(&fd, &shdr, sizeof(shdr), &br) != FR_OK)
			continue;

		if (!(shdr.sh_flags & SHF_ALLOC) || shdr.sh_name >= shstrSize)
			continue;

		offset = locateSecInFirm(&shdr, (FirmHdr *)FIRM_ADDR);
		if (offset == 0)
			continue;

		p = (void *)(FIRM_ADDR + offset);
		sh_name = shstrtab + shdr.sh_name;

		if (!strcmp(sh_name, ".rodata.keyx")) {
			if (sysver >= 7)
				continue;

			if (f_open(&keyxFd, "slot0x25KeyX.bin", FA_READ) != FR_OK)
				continue;

			f_read(&keyxFd, p, shdr.sh_size, &br);
			f_close(&keyxFd);
		} else if (!strcmp(sh_name, ".rodata.nand.sector")) {
			if (sector)
				*(uint32_t *)p = (sector / 0x200) - 1;
		} else if (!strcmp(sh_name, ".rodata.label")) {
			*(uint32_t *)p = sector ? 'E-XR' : 'S-XR';
		} else if (shdr.sh_type == SHT_PROGBITS
			&& (sector || memcmp(sh_name, patchNandPrefix, sizeof(patchNandPrefix) - 1))
			&& (sysver < 7 || strcmp(sh_name, ".patch.p9.keyx")))
		{
			if (f_lseek(&fd, shdr.sh_offset) != FR_OK)
				continue;

			f_read(&fd, p, shdr.sh_size, &br);
		}
	}

	getFirmPath(path, getMpInfo() == MPINFO_KTR ?
		TID_KTR_NATIVE_FIRM : TID_CTR_NATIVE_FIRM);
	f_open(&fd, path, FA_WRITE | FA_CREATE_ALWAYS);
	f_write(&fd, (void *)FIRM_ADDR, fsz, &br);
	f_close(&fd);

	r = loadExecReboot(); // This won't return if it succeeds.
	msg = L"Failed to load reboot.bin: %d\n"
		L"Check your installation.\n";

fail:
	ConsoleInit();
	ConsoleSetTitle(L"rxMode");
	print(msg, r);
	print(L"\n");
	print(strings[STR_PRESS_BUTTON_ACTION],
		strings[STR_BUTTON_A], strings[STR_CONTINUE]);
	ConsoleShow();
	WaitForButton(BUTTON_A);

	return r;

patchFail:
	msg = L"Failed to load native_firm.elf: %d\n"
		L"Check your installation.\n";
	goto fail;
}
예제 #12
0
파일: firm.c 프로젝트: Taktloss/rxTools
int rxMode(int emu)
{
	wchar_t path[64];
	const char *shstrtab;
	const wchar_t *msg;
	uint8_t keyx[16];
	uint32_t tid;
	int r, sector;
	Elf32_Ehdr *ehdr;
	Elf32_Shdr *shdr, *btm;
	void *keyxArg;
	FIL fd;
	UINT br, fsz;

	if (emu) {
		sector = checkEmuNAND();
		if (sector == 0) {
			ConsoleInit();
			ConsoleSetTitle(L"EMUNAND NOT FOUND!");
			print(L"The emunand was not found on\n");
			print(L"your SDCard. \n");
			print(L"\n");
			print(L"Press A to boot SYSNAND\n");
			ConsoleShow();

			WaitForButton(BUTTON_A);

			swprintf(path, _MAX_LFN, L"/rxTools/Theme/%u/boot.bin",
				cfgs[CFG_THEME].val.i);
			DrawBottomSplash(path);
		}
	} else
		sector = 0;

	r = getMpInfo();
	switch (r) {
		case MPINFO_KTR:
			tid = TID_KTR_NATIVE_FIRM;
			break;

		case MPINFO_CTR:
			tid = TID_CTR_NATIVE_FIRM;
			break;

		default:
			msg = L"Unknown Platform: %d";
			goto fail;
	}

	setAgbBios();

	if (sysver < 7 && f_open(&fd, _T("slot0x25KeyX.bin"), FA_READ) == FR_OK) {
		f_read(&fd, keyx, sizeof(keyx), &br);
		f_close(&fd);
		keyxArg = keyx;
	} else
		keyxArg = NULL;

	getFirmPath(path, tid);
	r = loadFirm(path, &fsz);
	if (r) {
		msg = L"Failed to load NATIVE_FIRM: %d\n"
			L"Reboot rxTools and try again.\n";
		goto fail;
	}

	((FirmHdr *)FIRM_ADDR)->arm9Entry = 0x0801B01C;

	getFirmPatchPath(path, tid);
	r = f_open(&fd, path, FA_READ);
	if (r != FR_OK)
		goto patchFail;

	r = f_read(&fd, (void *)PATCH_ADDR, PATCH_SIZE, &br);
	if (r != FR_OK)
		goto patchFail;

	f_close(&fd);

	ehdr = (void *)PATCH_ADDR;
	shdr = (void *)(PATCH_ADDR + ehdr->e_shoff);
	shstrtab = (char *)PATCH_ADDR + shdr[ehdr->e_shstrndx].sh_offset;
	for (btm = shdr + ehdr->e_shnum; shdr != btm; shdr++) {
		if (!strcmp(shstrtab + shdr->sh_name, ".patch.p9.reboot.body")) {
			execReboot(sector, keyxArg, ehdr->e_entry, shdr);
			__builtin_unreachable();
		}
	}

	msg = L".patch.p9.reboot.body not found\n"
		L"Please check your installation.\n";
fail:
	ConsoleInit();
	ConsoleSetTitle(L"rxMode");
	print(msg, r);
	print(L"\n");
	print(strings[STR_PRESS_BUTTON_ACTION],
		strings[STR_BUTTON_A], strings[STR_CONTINUE]);
	ConsoleShow();
	WaitForButton(BUTTON_A);

	return r;

patchFail:
	msg = L"Failed to load the patch: %d\n"
		L"Check your installation.\n";
	goto fail;
}
예제 #13
0
파일: main.c 프로젝트: motezazer/rxTools
int Initialize()
{
	char str[100];
	char strl[100];
	char strr[100];
	char tmp[256];
	wchar_t wtmp[256];
	int r;

	preloadStringsA();

	DrawString(BOT_SCREEN, strings[STR_INITIALIZING], FONT_WIDTH, SCREEN_HEIGHT-FONT_HEIGHT, WHITE, BLACK);

	if(FSInit()){
		DrawString(BOT_SCREEN, strings[STR_LOADING], BOT_SCREEN_WIDTH/2, SCREEN_HEIGHT-FONT_HEIGHT, WHITE, BLACK);
	}else{
		DrawString(BOT_SCREEN, strings[STR_FAILED], BOT_SCREEN_WIDTH/2, SCREEN_HEIGHT-FONT_HEIGHT, RED, BLACK);
		return 1;
	}

	LoadFont();
	if (fontLoaded){
		swprintf(wtmp, sizeof(wtmp)/sizeof(wtmp[0]), strings[STR_ERROR_OPENING], fontpath);
		DrawString(BOT_SCREEN, wtmp, FONT_WIDTH, SCREEN_HEIGHT-FONT_HEIGHT*2, RED, BLACK);
	}else{
		preloadStringsU();
	}

	//Console Stuff
	ConsoleSetXY(15, 20);
	ConsoleSetWH(BOT_SCREEN_WIDTH-30, SCREEN_HEIGHT-80);
	ConsoleSetBorderColor(BLUE);
	ConsoleSetTextColor(RGB(0, 141, 197));
	ConsoleSetBackgroundColor(TRANSPARENT);
	ConsoleSetSpecialColor(BLUE);
	ConsoleSetSpacing(2);
	ConsoleSetBorderWidth(3);
	//Check that the data is installed
	f_mkdir("rxTools");
	f_mkdir("rxTools/nand");
	InstallConfigData();
	readCfg();

	if (fontLoaded)
		cfgs[CFG_LANG].val.s = cfgLang;
	r = loadStrings();
	if (r) {
		sprintf(tmp, "%s/%s", langPath, cfgs[CFG_LANG].val.s);
		swprintf(wtmp, sizeof(wtmp)/sizeof(wtmp[0]), strings[STR_ERROR_OPENING], tmp);
		DrawString(BOT_SCREEN, wtmp, FONT_WIDTH, SCREEN_HEIGHT-FONT_HEIGHT*3, RED, BLACK);
	}
	sprintf(str, "/rxTools/Theme/%u/TOP.bin", cfgs[CFG_THEME].val.i);
	sprintf(strl, "/rxTools/Theme/%u/TOPL.bin", cfgs[CFG_THEME].val.i);
	sprintf(strr, "/rxTools/Theme/%u/TOPR.bin", cfgs[CFG_THEME].val.i);
	if (cfgs[CFG_3D].val.i)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);

	if (!cfgs[CFG_GUI].val.i)
	{
		if(cfgs[CFG_SILENT].val.i)
		{
			sprintf(str, "/rxTools/Theme/%u/boot.bin", cfgs[CFG_THEME].val.i);
			DrawBottomSplash(str);

			for (int i = 0; i < 0x333333 * 2; i++){
				uint32_t pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
		else
		{
			ConsoleInit();
			ConsoleSetTitle(strings[STR_AUTOBOOT]);
			print(strings[STR_HOLD_BUTTON_ACTION], strings[STR_BUTTON_R], strings[STR_OPEN_MENU]);
			ConsoleShow();

			for (int i = 0; i < 0x333333 * 6; i++){
				uint32_t pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
		rxMode(1);
	}
rxTools_boot:
	sprintf(str, "/rxTools/Theme/%u/TOP.bin", cfgs[CFG_THEME].val.i);
	sprintf(strl, "/rxTools/Theme/%u/TOPL.bin", cfgs[CFG_THEME].val.i);
	sprintf(strr, "/rxTools/Theme/%u/TOPR.bin", cfgs[CFG_THEME].val.i);
	if (cfgs[CFG_3D].val.i)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);

	return 0;
}
예제 #14
0
void CFW_Settings(void)
{
	TOP_Current = 0;
	int settings_idx = 0;
	bool autobootgui = false;
	bool enable_firmlaunch = false;
	char settings[4];
	if (FSFileOpen("/3ds/PastaCFW/system.txt")){
		FSFileRead(settings, 4, 0);
		FSFileClose();
		if (settings[1] == '2')autobootgui = true;
		if (settings[2] == '1' || settings[2] == '3')enable_firmlaunch = true;
		cfw_theme = settings[3];
	}
	while (true)
	{
		//DRAW GUI
		sprintf(str, "/3ds/PastaCFW/UI/%c/options.bin", cfw_theme);
		DrawBottomSplash(str);
		TOP_Current = 0;
		drawInternalY = 0;
		DrawDebug(1, 1, "");
		DrawDebug(1, 1, "");
		DrawDebug(1, 1, "");
		DrawDebug(1, 1, "");
		int i;
		char* beg;
		for (i = 0; i < SETTINGS_ITEMS; i++)
		{
			if (i == settings_idx) beg = "->";
			else beg = "  ";

			       if (i == 0)DrawSettingsDebug(1, "%s Always boot the GUI         <%s>", beg, autobootgui ? "YES" : "NO ");
			  else if (i == 1)DrawSettingsDebug(1, "%s Enable FirmLaunch           <%s>", beg, enable_firmlaunch ? "YES" : "NO ");
			  else if (i == 2)DrawSettingsDebug(1, "%s Change theme                < %c >", beg, cfw_theme);
			  DrawDebug(1, 1, "");
		}

		//APP CONTROLS
		u32 pad_state = HidWaitForInput();
		if (pad_state & BUTTON_DOWN)
		{
			if (settings_idx != SETTINGS_ITEMS - 1) settings_idx++; //MOVE DOWN
			else settings_idx = 0; //MOVE DOWN While at bottom -> go to top
		}
		else if (pad_state & BUTTON_UP)
		{
			if (settings_idx != 0) settings_idx--; //MOVE UP
			else settings_idx = SETTINGS_ITEMS - 1; //MOVE UP While at top -> go to bottom
		}
		else if (pad_state & BUTTON_LEFT || pad_state & BUTTON_RIGHT)
		{
			if (settings_idx == 0) autobootgui = !autobootgui; //autobootgui settings
			else if (settings_idx == 1) enable_firmlaunch = !enable_firmlaunch; //enable firmlaunch
			else if (settings_idx == 2) //theme selection
			{
				if (pad_state & BUTTON_LEFT && cfw_theme != '0')
				{
					cfw_theme--;
					sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme); //DRAW TOP SCREEN TO SEE THE NEW THEME
					DrawTopSplash(str); //TOP SCREEN
				}
				else if (pad_state & BUTTON_RIGHT && cfw_theme != '9')
				{
					sprintf(str, "/3ds/PastaCFW/UI/%c/options.bin", cfw_theme + 1);
					if (FSFileOpen(str))
					{
						cfw_theme++;
						sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme);//DRAW TOP SCREEN TO SEE THE NEW THEME
						DrawTopSplash(str); 
					}
				}
			}
		}
		else if (pad_state & BUTTON_A)
		{
			//SAVE SETTINGS
			FSFileOpen("/3ds/PastaCFW/system.txt");
			char tobewritten[4];
			tobewritten[0] = cfw_FWValue;
			tobewritten[1] = autobootgui ? '2' : '1';
			tobewritten[2] = enable_firmlaunch ? '1' : '0';
			tobewritten[3] = cfw_theme;
			cfw_enablefirmlaunch = enable_firmlaunch;
			FSFileWrite(tobewritten, 4, 0);
			FSFileClose();
			break;
		}
		else if (pad_state & BUTTON_B) {
			cfw_theme = settings[3]; break;
		} //EXIT WITHOUT SAVING
	}
}
예제 #15
0
파일: main.c 프로젝트: Golui/rxTools
void Initialize(){
	char str[100];
	char strl[100];
	char strr[100];
	DrawString(BOT_SCREEN,  " INITIALIZE... ", 0, SCREEN_HEIGHT-FONT_SIZE, WHITE, BLACK);
	if(FSInit()){
		DrawString(BOT_SCREEN,  " LOADING...    ", 0, SCREEN_HEIGHT-FONT_SIZE, WHITE, BLACK);
	}else{
		DrawString(BOT_SCREEN,  " ERROR!        ", 0, SCREEN_HEIGHT-FONT_SIZE, RED, BLACK);
	}
	LoadPack();

	//Console Stuff
	ConsoleSetXY(15, 20);
	ConsoleSetWH(SCREEN_WIDTH-30, SCREEN_HEIGHT-80);
	ConsoleSetBorderColor(BLUE);
	ConsoleSetTextColor(RGB(0, 141, 197));
	ConsoleSetBackgroundColor(TRANSPARENT);
	ConsoleSetSpecialColor(BLUE);
	ConsoleSetSpacing(2);
	ConsoleSetBorderWidth(3);
	//Check that the data is installed
	f_mkdir("rxTools");
	f_mkdir("rxTools/nand");
	InstallConfigData();
	LoadSettings();

	sprintf(str, "/rxTools/Theme/%c/TOP.bin", Theme);
	sprintf(strl, "/rxTools/Theme/%c/TOPL.bin", Theme);
	sprintf(strr, "/rxTools/Theme/%c/TOPR.bin", Theme);
	if(theme_3d)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);

	if (!bootGUI)
	{
		if(silent_boot)
		{
			sprintf(str, "/rxTools/Theme/%c/boot.bin", Theme);
			DrawBottomSplash(str);

			for (int i = 0; i < 0x333333 * 2; i++){
				u32 pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
		else
		{
			ConsoleInit();
			ConsoleSetTitle(STR_AUTOBOOT[language]);
			print(STR_HOLD_R[language]);
			ConsoleShow();

			for (int i = 0; i < 0x333333 * 6; i++){
				u32 pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
				

		rxModeQuickBoot();
	}
rxTools_boot:

	sprintf(str, "/rxTools/Theme/%c/TOP.bin", Theme);
	sprintf(strl, "/rxTools/Theme/%c/TOPL.bin", Theme);
	sprintf(strr, "/rxTools/Theme/%c/TOPR.bin", Theme);
	if(theme_3d)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);
}
예제 #16
0
파일: firm.c 프로젝트: 173210/rxTools
int rxMode(int emu)
{
    const Elf32_Addr line = 32;
    wchar_t path[64];
    const char *shstrtab;
    const wchar_t *msg;
    uint8_t keyx[16];
    uint32_t tid;
    int r, sector;
    Elf32_Ehdr *ehdr;
    Elf32_Shdr *shdr, *btmShdr;
    Elf32_Addr cur, btm;
    void *keyxArg;
    FIL fd;
    UINT br, fsz;

    if (emu) {
        sector = checkEmuNAND();
        if (sector == 0) {
            ConsoleInit();
            ConsoleSetTitle(L"EMUNAND NOT FOUND!");
            print(L"The emunand was not found on\n");
            print(L"your SDCard. \n");
            print(L"\n");
            print(L"Press A to boot SYSNAND\n");
            ConsoleShow();

            WaitForButton(BUTTON_A);

            swprintf(path, _MAX_LFN, L"/rxTools/Theme/%u/boot.bin",
                     cfgs[CFG_THEME].val.i);
            DrawBottomSplash(path);
        }
    } else
        sector = 0;

    r = getMpInfo();
    switch (r) {
    case MPINFO_KTR:
        tid = TID_KTR_NATIVE_FIRM;
        break;

    case MPINFO_CTR:
        tid = TID_CTR_NATIVE_FIRM;
        break;

    default:
        msg = L"Unknown Platform: %d";
        goto fail;
    }

    setAgbBios();

    if (sysver < 7 && f_open(&fd, _T("slot0x25KeyX.bin"), FA_READ) == FR_OK) {
        f_read(&fd, keyx, sizeof(keyx), &br);
        f_close(&fd);
        keyxArg = keyx;
    } else
        keyxArg = NULL;

    getFirmPath(path, tid);
    r = loadFirm(path, &fsz);
    if (r) {
        msg = L"Failed to load NATIVE_FIRM: %d\n"
              L"Reboot rxTools and try again.\n";
        goto fail;
    }

    ((FirmHdr *)FIRM_ADDR)->arm9Entry = 0x0801B01C;

    getFirmPatchPath(path, tid);
    r = f_open(&fd, path, FA_READ);
    if (r != FR_OK)
        goto patchFail;

    r = f_read(&fd, (void *)PATCH_ADDR, PATCH_SIZE, &br);
    if (r != FR_OK)
        goto patchFail;

    f_close(&fd);

    ehdr = (void *)PATCH_ADDR;
    shdr = (void *)(PATCH_ADDR + ehdr->e_shoff);
    shstrtab = (char *)PATCH_ADDR + shdr[ehdr->e_shstrndx].sh_offset;
    for (btmShdr = shdr + ehdr->e_shnum; shdr != btmShdr; shdr++) {
        if (!strcmp(shstrtab + shdr->sh_name, ".patch.p9.reboot.body")) {
            memcpy((void *)ehdr->e_entry,
                   (void *)(PATCH_ADDR + shdr->sh_offset),
                   shdr->sh_size);

            // Drain write buffer
            __asm__ volatile ("mcr p15, 0, %0, c7, c10, 4" :: "r"(0));

            cur = ehdr->e_entry & ~(line - 1);
            btm = ehdr->e_entry + shdr->sh_size;
            while (cur < btm) {
                __asm__ volatile (
                    // Clean Dcache
                    "mcr p15, 0, %0, c7, c10, 1\n\t"

                    // Flush Icache
                    "mcr p15, 0, %0, c7, c5, 1"
                    :: "r"(cur));

                cur += line;
            }

            ((void (*)(uint32_t, void *, uintptr_t))ehdr->e_entry)(
                sector, keyxArg, 0x1FFFFFF8);

            __builtin_unreachable();
        }
    }