* fix bug in nand.bin class: when creating a new nand.bin, initialize fst_pos in fst entries

* insert new entries in nand.bin at the start of the chain instead of at the end ( to closer mimic IOS FS behavior )
* oneswanzenegger: create /sys/cert.sys when creating a new nand.bin
This commit is contained in:
giantpune@gmail.com 2011-01-03 04:02:00 +00:00
parent fe3ec0de0a
commit 8e3d07daad
4 changed files with 288 additions and 260 deletions

View File

@ -90,6 +90,9 @@ bool NandBin::CreateNew( const QString &path, const QByteArray &keys, const QByt
fats.clear();
memset( &fsts, 0, sizeof( fst_t ) * 0x17ff );
for( quint16 i = 0; i < 0x17ff; i++ )
fsts[ i ].fst_pos = i;
//reserve blocks 0 - 7
for( quint16 i = 0; i < 0x40; i++ )
{
@ -1193,7 +1196,12 @@ quint16 NandBin::CreateEntry( const QString &path, quint32 uid, quint16 gid, qui
if( !ret )
return 0;
fsts[ entryNo ].sib = ret;
//method 1: this works, and the nand is bootable. but doesnt mimic the IOS FS driver. ( my entries appear in reversed order when walking the FS )
//fsts[ entryNo ].sib = ret;
//method 2: trying to mimic the IOS FS driver ( insert new entries at the start of the chain, instead of the end )
fsts[ ret ].sib = fsts[ parIdx ].sub;
fsts[ parIdx ].sub = ret;
}
QTreeWidgetItem *child = CreateItem( par, name, 0, ret, uid, gid, 0, fsts[ ret ].attr, 0 );
if( attr == NAND_FILE )

View File

@ -454,7 +454,7 @@ bool MainWindow::UpdateTree()
quint16 MainWindow::CreateIfNeeded( const QString &path, quint32 uid, quint16 gid, quint8 attr, quint8 user_perm, quint8 group_perm, quint8 other_perm )
{
// qDebug() << "MainWindow::CreateIfNeeded" << path;
// qDebug() << "MainWindow::CreateIfNeeded" << path;
QTreeWidgetItem *item = ItemFromPath( path );
if( !item )
{
@ -662,7 +662,7 @@ bool MainWindow::InstallNUSItem( NusJob job )
//nand.Delete( "/title/" + upper );
//UpdateTree();
return true;
error:
error:
ShowMessage( "<b>Error installing title " + title + " to nand</b>" );
return false;
}

View File

@ -110,7 +110,20 @@ void NewNandBin::on_buttonBox_accepted()
|| !nand.CreateEntry( "/tmp", 0, 0, NAND_DIR, NAND_RW, NAND_RW, NAND_RW )
|| !nand.WriteMetaData() )
{
qWarning() << "NewNandBin::on_buttonBox_accepted -> error creating the new nand";
qWarning() << "NewNandBin::on_buttonBox_accepted -> error creating directories in the new nand";
return;
}
//add cert.sys
quint16 handle = nand.CreateEntry( "/sys/cert.sys", 0, 0, NAND_FILE, NAND_RW, NAND_RW, NAND_READ );
if( !handle || !nand.SetData( "/sys/cert.sys", QByteArray( (const char*)&certs_dat, CERTS_DAT_SIZE ) ) )
{
qWarning() << "NewNandBin::on_buttonBox_accepted -> error creating cert in the new nand";
return;
}
//commit changes to metadata
if( !nand.WriteMetaData() )
{
qWarning() << "NewNandBin::on_buttonBox_accepted -> error writing metadata";
return;
}

View File

@ -1,4 +1,11 @@
this is a tool to list saves in an extracted nand dump
this is a tool to list/extract/delete saves to/from an extracted nand dump. saves are extracted, packed into a data.bin, zipped up with a txt file
that says a bit about the save, and then stored in a folder. you must designate a folder and provide the necessary keys before extracting saves
will work. i chose to go with data.bin as it is a way to store the entire save in 1 file and also allow the save to be installed using the
system menu. and i went with the zip format 1) to save space, and 2) to keep a save and the description all in 1 compact file.
saves are extracted to "<the folder you specify>/<TID upper>/<TID lower>/#.zip". the # is chosen by the lowest available number starting with 1.
there is no need for the saves to be in numerical order, if you have 10 zips for the same game and you decide to delete "3.zip", it will cause
no issues, and next time you extract a save for this game, it will use the filename "3.zip".
TODO:
add some sort of extract/delete/install functionality
installing saves back to sneek nand still isnt done