* nandBin - change the way gathering clusters for new data works. this seems to better emulate the way IOS does it

This commit is contained in:
giantpune@gmail.com 2011-01-16 14:40:14 +00:00
parent c81e7a9c17
commit 9360cd9721
4 changed files with 11 additions and 5 deletions

View File

@ -1539,8 +1539,10 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
quint16 cl = freeClusters.takeAt( idx ); //remove this number from the list
fts << cl; //add this one to the clusters that will be used to hold the data
quint16 block = cl / 8; //try to find other clusters in the same block
for( quint16 i = block * 8; i < ( ( block + 1 ) * 8 ) && fts.size() < clCnt; i++ )
quint16 block = cl / 8; //try to find other clusters in the same block
//for( quint16 i = block * 8; i < ( ( block + 1 ) * 8 ) && fts.size() < clCnt; i++ )
quint16 max = freeClusters.at( freeClusters.size() - 1 );
for( quint16 i = block * 8; i < max && fts.size() < clCnt; i++ )
{
if( cl == i ) //this one is already added to the list
continue;
@ -1568,6 +1570,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
}
}
qSort( fts.begin(), fts.end() );
//qDebug() << "about to writing shit" << clCnt << fts.size();
//qDebug() << "file will be on clusters\n" << hex << fts;
for( quint32 i = 0; i < clCnt; i++ )
@ -1674,6 +1677,7 @@ bool NandBin::WriteMetaData()
//qDebug() << "done adding shit" << hex << (quint32)b.pos();
b.close();
QByteArray hmR = spare.Get_hmac_meta( scl, nextSuperCluster );
qDebug() << "about to write the meta block" << hex << nextSuperCluster << nextClusterVersion << "to page" << (quint32)( nextSuperCluster * 8 );
for( quint8 i = 0; i < 0x10; i++ )
@ -1826,7 +1830,7 @@ bool NandBin::CheckHmacMeta( quint16 clNo )
}
sp1 = sp1.right( 0x40 ); //only keep the spare data and drop the data
sp2 = sp2.right( 0x40 );
sp2 = sp2.right( 0x40 );
//this part is kinda ugly, but this is how it is layed out by big N
//really it allows 1 copy of hmac to be bad, but im being strict about it

View File

@ -209,7 +209,7 @@ QByteArray NandSpare::Get_hmac_meta( const QByteArray cluster, quint16 super_blk
fs_hmac_set_key( hmacKey.data(), 0x14 );
QByteArray ret( 0x14, '\0' );
fs_hmac_meta( (const unsigned char *)cluster.data(), super_blk, (unsigned char *)ret.data() );
fs_hmac_meta( (const unsigned char *)cluster.data(), super_blk, (unsigned char *)ret.data() );
return ret;
}

View File

@ -378,7 +378,8 @@ bool CheckTitleIntegrity( quint64 tid )
if( verbose )
{
qDebug() << "\tversion:" << t.Version() << hex << t.Version();
qDebug() << "\taccess :" << hex << t.AccessFlags();
if( t.AccessFlags() )
qDebug() << "\taccess :" << hex << t.AccessFlags();
}
}
else

View File

@ -165,6 +165,7 @@ void NgDialog::on_pushButton_keys_clicked()
default:
break;
}
//WriteFile( QFileInfo( fn ).absoluteDir().absoluteFilePath( "keys.bin" ), ba );
if( ba.size() != 0x400 )
{