Example #1
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();
}
Example #2
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();
	}
}
INT	_reentrant AASetActivationRecords( INT iNumRecords, INT unused2, INT * pActivationBuf )
{
	int	fp;
	int	bytesToWrite;
    int iFileAttribute;

    iNumRecords = 8;

	// Do a little error checking
	if ( (iNumRecords != 8) && !pActivationBuf )
		return -1;

    //Change to activation folder directory.  It may already exist if 
    //user has previously activated the account.  
    if( Chdir((_packed char *)ActivationFolder) != FS_SUCCESS )
    {
        //If there was an error, the folder may not exist.  Try to create it.  If 
        //it fails, something is wrong so return an error.
        if (Mkdir ((_packed char *)ActivationFolder) != FS_SUCCESS)
            return -2; 
    } 
	// Activation records are always stored in file on internal Flash
	fp = FSFileCreate( (_packed BYTE *) ActivationFilename, 0 );
	if ( fp < 0 ) {
		return -2;
	}

	// Write all the activation records at once
	bytesToWrite = 560;
	if ( FSFileWrite( bytesToWrite, fp, MEM_SPACE_Y, -1, (WORD *) pActivationBuf ) != bytesToWrite ) {
		return -3;
	}
    //Set the hidden attribute so the activation data will not be added to the database.
    iFileAttribute = filegetattrib ((_packed BYTE *) ActivationFilename);
    filesetattrib (fp, iFileAttribute | ATTR_HIDDEN );

	// Close the file and make sure stuff is saved off to Flash
	FSFileClose( fp );
	FlushCache( );

	return 0;
}
Example #4
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
	}
}