Esempio n. 1
0
void WaitForButton(u32 button){
	while (true) {
		TryScreenShot(); //Maybe someone wanna take screenshots while waiting
        u32 pad_state = InputWait();
        if (pad_state & button)
            return;
    }
}
Esempio n. 2
0
static void bgWork()
{
	TryScreenShot();

	// Check whether HOME or POWER button has been pressed
	if (*(volatile uint8_t *)0x10147021 == 13) {
		fadeOut();
		// Return to HOME menu
		i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
		while (1);
	}
}
Esempio n. 3
0
void NandDumper(){
	File myFile;
	int isEmuNand = SYS_NAND;
	if(checkEmuNAND() && (isEmuNand = NandSwitch()) == UNK_NAND) return;
	isEmuNand--;
	ConsoleInit();
	ConsoleSetTitle(L"%sNAND Dumper", isEmuNand ? "emu" : "sys");
	unsigned char* buf = (void*)0x21000000;
	unsigned int nsectors = 0x200;  //sectors in a row
	wchar_t ProgressBar[] = L"⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ ";
	unsigned int progress = 0;
/*      int BACKCOLOR = */ConsoleGetBackgroundColor(); //can be removed, left only to keep binaries the same
	if(FileOpen(&myFile, isEmuNand ? "rxTools/nand/EMUNAND.bin" : "rxTools/nand/NAND.bin", 1)){
		print(L"Dumping...\n\n");
		ConsoleShow();
		int x, y;
		ConsoleGetXY(&x, &y);
		y += FONT_HEIGHT * 6;
		x += FONT_HWIDTH * 2;
		DrawString(BOT_SCREEN, ProgressBar, x, y, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
		DrawString(BOT_SCREEN, L"Press Ⓑ anytime to abort", x, y + FONT_HEIGHT*2, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

		for(int count = 0; count < NAND_SIZE/NAND_SECTOR_SIZE/nsectors; count++){

			if(isEmuNand) sdmmc_sdcard_readsectors(count*nsectors, nsectors, buf);
			else sdmmc_nand_readsectors(count*nsectors, nsectors, buf);

			FileWrite(&myFile, buf, nsectors*NAND_SECTOR_SIZE, count*NAND_SECTOR_SIZE*nsectors);
			TryScreenShot();
			if((count % (int)(NAND_SIZE/NAND_SECTOR_SIZE/nsectors/16)) == 0 && count != 0){
				DrawString(BOT_SCREEN, PROGRESS_OK, x+(FONT_WIDTH*(progress++)), y, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
			}
			unsigned int pad = GetInput();
			if(pad & BUTTON_B) break;
		}
		if(isEmuNand){
			sdmmc_sdcard_readsectors(checkEmuNAND()/0x200, 1, buf);
			FileWrite(&myFile, buf, 0x200, 0);
		}
		FileClose(&myFile);
		print(L"\nFinished dumping!\n");
		ConsoleShow();
	}else{
		print(L"Failed to create the dump.\n");
		ConsoleShow();
	}
	print(L"\nPress Ⓐ to exit\n");
	ConsoleShow();
	WaitForButton(BUTTON_A);
}
Esempio n. 4
0
void NandMenu(){
	f_mkdir ("nand");
	MenuInit(&NandOptions);
	MenuShow();

    while (true) {
        u32 pad_state = InputWait();
		if(pad_state & BUTTON_DOWN) MenuNextSelection();
		if(pad_state & BUTTON_UP)   MenuPrevSelection();
		if(pad_state & BUTTON_A)    MenuSelect();
		if(pad_state & BUTTON_B) 	break;
		TryScreenShot();
		MenuShow();
    }
}
Esempio n. 5
0
void NandDumper(){
	File myFile;
	int isEmuNand = checkEmuNAND() ? NandSwitch() : 0;
	if(isEmuNand == -1) return;

	ConsoleInit();
	ConsoleAddText(isEmuNand ? "EmuNAND Dumper\n" : "NAND Dumper\n");
	unsigned char* buf = 0x21000000;
	unsigned int nsectors = 0x200;  //sectors in a row
	char ProgressBar[] = "[                            ]";
	unsigned int progress = 1;
	int BACKCOLOR = ConsoleGetBackgroundColor();
	if(FileOpen(&myFile, isEmuNand ? "/nand/EMUNAND.bin" : "/nand/NAND.bin", 1)){
		ConsoleAddText("Dumping...\n"); ConsoleShow();
		int x, y; ConsoleGetXY(&x, &y); y += CHAR_WIDTH * 6; x += CHAR_WIDTH*2;
		DrawString(TOP_SCREEN, ProgressBar, x, y, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
		DrawString(TOP_SCREEN, "Press B anytime to abort", x, y + CHAR_WIDTH*2, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

		for(int count = 0; count < NAND_SIZE/NAND_SECTOR_SIZE/nsectors; count++){

			if(isEmuNand) sdmmc_sdcard_readsectors(count*nsectors, nsectors, buf);
			else sdmmc_nand_readsectors(count*nsectors, nsectors, buf);

			FileWrite(&myFile, buf, nsectors*NAND_SECTOR_SIZE, count*NAND_SECTOR_SIZE*nsectors);
			TryScreenShot();
			if((count % (int)(NAND_SIZE/NAND_SECTOR_SIZE/nsectors/25)) == 0 && count != 0){
				DrawString(TOP_SCREEN, "-", x+(CHAR_WIDTH*(progress++)), y, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
			}
			unsigned int pad = GetInput();
			if(pad & BUTTON_B) break;
		}
		if(isEmuNand){
			sdmmc_sdcard_readsectors(checkEmuNAND()/0x200, 1, buf);
			FileWrite(&myFile, buf, 0x200, 0);
		}
		FileClose(&myFile);
		ConsoleAddText("\nFinished dumping!"); ConsoleShow();
	}else{
		ConsoleAddText("Failed to create the dump"); ConsoleShow();
	}
	ConsoleAddText("\nPress A to exit"); ConsoleShow();
	WaitForButton(BUTTON_A);
}
Esempio n. 6
0
int main(){
	if (Initialize())
		while (1);

	//7.X Keys stuff
	File KeyFile;
	const char *keyfile = "/slot0x25KeyX.bin";
	if(FileOpen(&KeyFile, keyfile, 0)){
		uint8_t keyX[16];
		FileRead(&KeyFile, keyX, 16, 0);
		FileClose(&KeyFile);
		setup_aeskeyX(0x25, keyX);
	}else{
		if (sysver < 7) {
			ConsoleInit();
			ConsoleSetTitle(strings[STR_WARNING]);
			print(strings[STR_ERROR_OPENING], keyfile);
			print(strings[STR_WARNING_KEYFILE]);
			print(strings[STR_PRESS_BUTTON_ACTION], strings[STR_BUTTON_A], strings[STR_CONTINUE]);
			ConsoleShow();
			WaitForButton(BUTTON_A);
		}
	}

	//That's the Main Menu initialization, easy and cool
	OpenAnimation();
	MenuInit(&MainMenu);
	MenuShow();
	while (true) {
		uint32_t pad_state = InputWait();
		if (pad_state & (BUTTON_DOWN | BUTTON_RIGHT | BUTTON_R1)) MenuNextSelection(); //I try to support every theme style
		if (pad_state & (BUTTON_UP   | BUTTON_LEFT  | BUTTON_L1)) MenuPrevSelection();
		if (pad_state & BUTTON_A)    	{ OpenAnimation(); MenuSelect(); }
		if (pad_state & BUTTON_SELECT)	{ fadeOut(); ShutDown(); }
		if (pad_state & BUTTON_START)	{ fadeOut(); returnHomeMenu(); }
		TryScreenShot();
		MenuShow();
	}

	FSDeInit();
	return 0;
}
Esempio n. 7
0
int main(){
	Initialize();
	DrawString(TOP_SCREEN, "SUPPORT THE ORIGINAL, NOT THE IMITATION!", 75, 240-10, GREY, BLACK);
	//7.X Keys stuff
	File KeyFile;
	if(FileOpen(&KeyFile, "/slot0x25KeyX.bin", 0)){
		u8 keyX[16];
		FileRead(&KeyFile, keyX, 16, 0);
		FileClose(&KeyFile);
		setup_aeskeyX(0x25, keyX);
		DrawString(TOP_SCREEN, " NewKeyX ", 0, 240-8, GREEN, BLACK);
	}else{
		if(GetSystemVersion() < 3){
			ConsoleInit();
			print("WARNING:\n\nCannot find slot0x25KeyX.bin.\nSome titles decryption will fail,\nand some some EmuNANDs will not boot.\n\nPress A to continue...\n");
			ConsoleShow();
			WaitForButton(BUTTON_A);
		}
		DrawString(TOP_SCREEN, " NewKeyX ", 0, 240-8, RED, BLACK);
	}
	DrawString(TOP_SCREEN, " EmuNAND ", 0, 240-16, checkEmuNAND() ? GREEN : RED, BLACK);

	//That's the Main Menu initialization, easy and cool
	MenuInit(&MainMenu);
	MenuShow();

    while (true) {
		DrawString(TOP_SCREEN,  "[SELECT] Reboot", 349-18*8, 181-24-8, RED, BLACK);
		DrawString(TOP_SCREEN,  "[START]  Shutdown", 349-18*8, 181-24, RED, BLACK);
        u32 pad_state = InputWait();
		if(pad_state & BUTTON_DOWN) 	MenuNextSelection();
		if(pad_state & BUTTON_UP)   	MenuPrevSelection();
		if(pad_state & BUTTON_A)    	MenuSelect();
		if(pad_state & BUTTON_SELECT)	returnHomeMenu();
		if(pad_state & BUTTON_START)	ShutDown();
		TryScreenShot();
		MenuShow();
    }

    FSDeInit();
    return 0;
}
Esempio n. 8
0
u32 DecryptPartition(PartitionInfo* info){
    size_t bytesWritten;
	if(info->keyY != NULL)
		setup_aeskey(info->keyslot, AES_BIG_INPUT|AES_NORMAL_INPUT, info->keyY);
    use_aeskey(info->keyslot);

    u8 ctr[16] __attribute__((aligned(32)));
    memcpy(ctr, info->ctr, 16);

    u32 size_bytes = info->size;
    for (u32 i = 0; i < size_bytes; i += BLOCK_SIZE) {
        u32 j;
        for (j = 0; (j < BLOCK_SIZE) && (i+j < size_bytes); j+= 16) {
            set_ctr(AES_BIG_INPUT|AES_NORMAL_INPUT, ctr);
            aes_decrypt((void*)info->buffer+j, (void*)info->buffer+j, ctr, 1, AES_CTR_MODE);
            add_ctr(ctr, 1);
			TryScreenShot(); //Putting it here allows us to take screenshots at any decryption point, since everyting loops in this
        }
    }
    return 0;
}
Esempio n. 9
0
File: main.c Progetto: Golui/rxTools
int main(){
	Initialize();
	//7.X Keys stuff
	File KeyFile;
	if(FileOpen(&KeyFile, "/slot0x25KeyX.bin", 0)){
		u8 keyX[16];
		FileRead(&KeyFile, keyX, 16, 0);
		FileClose(&KeyFile);
		setup_aeskeyX(0x25, keyX);
	}else{
		if(GetSystemVersion() < 3){
			ConsoleInit();
			ConsoleSetTitle("          WARNING");
			print("WARNING:\n\nCannot find slot0x25KeyX.bin. If\nyour firmware version is less than\n7.X, some titles decryption will\nfail, and some EmuNANDs will not\nboot.\n\nPress A to continue...\n");
			ConsoleShow();
			WaitForButton(BUTTON_A);
		}
	}

	//That's the Main Menu initialization, easy and cool
	MenuInit(&MainMenu);
	MenuShow();

	while (true) {
		u32 pad_state = InputWait();
		if (pad_state & (BUTTON_DOWN | BUTTON_RIGHT | BUTTON_R1)) MenuNextSelection(); //I try to support every theme style
		if (pad_state & (BUTTON_UP   | BUTTON_LEFT  | BUTTON_L1)) MenuPrevSelection();
		if(pad_state & BUTTON_A)    	MenuSelect();
		if(pad_state & BUTTON_SELECT)	ShutDown();
		if(pad_state & BUTTON_START)	returnHomeMenu();
		TryScreenShot();
		MenuShow();
	}

	FSDeInit();
	return 0;
}
Esempio n. 10
0
void restoreCoolFiles(){
    int nandtype = NandSwitch();
    if(nandtype == -1){
        return;
    }
    selectedFile = -1;
    MenuInit(&CoolFilesMenu);
    MenuShow();
    while (true) {
        u32 pad_state = InputWait();
		if(pad_state & BUTTON_DOWN) MenuNextSelection();
		if(pad_state & BUTTON_UP)   MenuPrevSelection();
		if(pad_state & BUTTON_A)    { MenuSelect(); break; }
		if(pad_state & BUTTON_B) 	break;
		TryScreenShot();
		MenuShow();
    }
    if(selectedFile == -1) return;
    ConsoleInit();
    ConsoleSetTitle("File Inject : %s", CoolFiles[selectedFile].name);
    char dest[256];
    sprintf(tmpstr, "rxTools/%s", CoolFiles[selectedFile].name);
    sprintf(dest, "%d:%s", nandtype + 1, CoolFiles[selectedFile].path);
    print("Injecting...\n"); ConsoleShow();
    int res = FileCopy(dest, tmpstr);
    char* showres;
    switch(res){
        case 1 : showres = "Success!"; break;
        case -1 : showres = "Cannot write to file!"; break;
        case -2 : showres = "Cannot read from file!"; break;
        default : showres = "Failure!"; break;
    }
    print(showres); print("\n");
    print("\nPress A to exit\n");
	ConsoleShow();
	WaitForButton(BUTTON_A);
}
Esempio n. 11
0
void dumpCoolFiles()
{
	int nandtype = NandSwitch();
	if (nandtype == UNK_NAND) return;

	selectedFile = -1;
	MenuInit(&CoolFilesMenu);
	MenuShow();

	while (true)
	{
		uint32_t pad_state = InputWait();
		if (pad_state & BUTTON_DOWN) MenuNextSelection();
		if (pad_state & BUTTON_UP) MenuPrevSelection();
		if (pad_state & BUTTON_A) { MenuSelect(); break; }
		if (pad_state & BUTTON_B) break;
		TryScreenShot();
		MenuShow();
	}

	if (selectedFile == -1) return;
	ConsoleInit();
	ConsoleSetTitle(strings[STR_DUMP], strings[STR_FILES]);

	char dest[256], tmpstr[sizeof(dest)];
	wchar_t wsrc[sizeof(tmpstr)];
	sprintf(dest, "rxTools/%s", CoolFiles[selectedFile].name);
	sprintf(tmpstr, "%d:%s/%s", nandtype, CoolFiles[selectedFile].path, CoolFiles[selectedFile].name);
	mbstowcs(wsrc, tmpstr, sizeof(tmpstr));
	print(strings[STR_DUMPING], wsrc, dest);
	ConsoleShow();

	unsigned int res = FSFileCopy(dest, tmpstr);
	if (res != 0 && (selectedFile == 1 || selectedFile == 2)){
		if (selectedFile == 1)
		{
			/* Fix for SecureInfo_B */
			sprintf(dest, "rxTools/%.11s%c", CoolFiles[selectedFile].name, 'B');
			sprintf(tmpstr, "%d:%s/%.11s%c", nandtype, CoolFiles[selectedFile].path, CoolFiles[selectedFile].name, 'B');
		}
		else if (selectedFile == 2)
		{
			/* Fix for LocalFriendCodeSeed_A */
			sprintf(dest, "rxTools/%.20s%c", CoolFiles[selectedFile].name, 'A');
			sprintf(tmpstr, "%d:%s/%.20s%c", nandtype, CoolFiles[selectedFile].path, CoolFiles[selectedFile].name, 'A');
		}
		mbstowcs(wsrc, tmpstr, sizeof(tmpstr));
		print(strings[STR_FAILED]);
		print(strings[STR_DUMPING], wsrc, dest);
		ConsoleShow();
		res = FSFileCopy(dest, tmpstr);
	}

	switch ((res >> 8) & 0xFF)
	{
		case 0:
			print(strings[STR_COMPLETED]);
			break;
		case 1:
			print(strings[STR_ERROR_OPENING], tmpstr);
			break;
		case 2:
			print(strings[STR_ERROR_CREATING], dest);
			break;
		case 3:
		case 4:
			print(strings[STR_ERROR_READING], tmpstr);
			break;
		case 5:
		case 6:
			print(strings[STR_ERROR_WRITING], dest);
			break;
		default:
			print(strings[STR_FAILED]);
			break;
	}

	print(strings[STR_PRESS_BUTTON_ACTION], strings[STR_BUTTON_A], strings[STR_CONTINUE]);
	ConsoleShow();
	WaitForButton(BUTTON_A);
}
Esempio n. 12
0
void NandDumper(){
	ConsoleSetTitle(strings[STR_DUMP], strings[STR_NAND]);
	File myFile;
	int isEmuNand = SYS_NAND;
	if(checkEmuNAND() && (isEmuNand = NandSwitch()) == UNK_NAND) return;
	isEmuNand--;
	ConsoleInit();
	ConsoleSetTitle(strings[STR_DUMP], strings[STR_NAND]);
	unsigned char* buf = (void*)0x21000000;
	unsigned int nsectors = 0x200;  //sectors in a row
	wchar_t tmpstr[STR_MAX_LEN];
	wchar_t ProgressBar[41] = {0,};
	for(int i=0; i<PROGRESS_WIDTH; i++)
		wcscat(ProgressBar, strings[STR_PROGRESS]);
	unsigned int progress = 0;
	wchar_t filename[_MAX_LFN];
	swprintf(filename, _MAX_LFN, L"rxTools/nand/%sNAND.bin",
		isEmuNand ? L"EMU" : L"");
	if(FileOpen(&myFile, filename, 1)){
		print(strings[STR_DUMPING], isEmuNand ? strings[STR_EMUNAND] : strings[STR_SYSNAND], filename);
		ConsoleShow();
		int x, y;
		ConsoleGetXY(&x, &y);
		y += FONT_HEIGHT * 6;
		x += FONT_HWIDTH * 2;

		DrawString(BOT_SCREEN, ProgressBar, x, y, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
		swprintf(tmpstr, STR_MAX_LEN, strings[STR_PRESS_BUTTON_ACTION], strings[STR_BUTTON_B], strings[STR_CANCEL]);
		DrawString(BOT_SCREEN, tmpstr, x, y + FONT_HEIGHT*2, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

		for(int count = 0; count < getNandSize()/NAND_SECTOR_SIZE/nsectors; count++){

			if(isEmuNand) sdmmc_sdcard_readsectors(count*nsectors, nsectors, buf);
			else sdmmc_nand_readsectors(count*nsectors, nsectors, buf);

			FileWrite(&myFile, buf, nsectors*NAND_SECTOR_SIZE, count*NAND_SECTOR_SIZE*nsectors);
			TryScreenShot();
			if((count % (int)(getNandSize()/NAND_SECTOR_SIZE/nsectors/PROGRESS_WIDTH)) == 0 && count != 0){
				DrawString(BOT_SCREEN, strings[STR_PROGRESS_OK], x+(FONT_WIDTH*(progress++)), y, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
			}
			unsigned int pad = GetInput();
			if (pad & BUTTON_B) {
				FileClose(&myFile);
				goto end;
			}
		}
		if(isEmuNand){
			sdmmc_sdcard_readsectors(checkEmuNAND()/0x200, 1, buf);
			FileWrite(&myFile, buf, 0x200, 0);
		}
		FileClose(&myFile);
		print(strings[STR_COMPLETED]);
		ConsoleShow();
	}else{
		print(strings[STR_FAILED]);
		ConsoleShow();
	}

end:
	print(strings[STR_PRESS_BUTTON_ACTION], strings[STR_BUTTON_A], strings[STR_CONTINUE]);
	ConsoleShow();
	WaitForButton(BUTTON_A);
}
Esempio n. 13
0
static void statusDrawFinish() {
	DisplayScreen(&bottomScreen);
	DisplayScreen(&top1Screen);
//	DisplayScreen(&top2Screen);
	TryScreenShot();
}