Exemple #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();
}
Exemple #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;
}