diff --git a/WiiQt/nandbin.cpp b/WiiQt/nandbin.cpp index 8cf4817..3a85f2d 100755 --- a/WiiQt/nandbin.cpp +++ b/WiiQt/nandbin.cpp @@ -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 diff --git a/WiiQt/nandspare.cpp b/WiiQt/nandspare.cpp index 52773d2..99e0e84 100644 --- a/WiiQt/nandspare.cpp +++ b/WiiQt/nandspare.cpp @@ -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; } diff --git a/nandBinCheck/main.cpp b/nandBinCheck/main.cpp index a49852f..af57444 100644 --- a/nandBinCheck/main.cpp +++ b/nandBinCheck/main.cpp @@ -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 diff --git a/saveToy/ngdialog.cpp b/saveToy/ngdialog.cpp index 1855f66..ec93c3a 100644 --- a/saveToy/ngdialog.cpp +++ b/saveToy/ngdialog.cpp @@ -165,6 +165,7 @@ void NgDialog::on_pushButton_keys_clicked() default: break; } + //WriteFile( QFileInfo( fn ).absoluteDir().absoluteFilePath( "keys.bin" ), ba ); if( ba.size() != 0x400 ) {