diff --git a/WiiQt/blocks0to7.cpp b/WiiQt/blocks0to7.cpp index bc649fd..a29f2e3 100644 --- a/WiiQt/blocks0to7.cpp +++ b/WiiQt/blocks0to7.cpp @@ -2,14 +2,14 @@ #include "tools.h" #include "tiktmd.h" -Blocks0to7::Blocks0to7( QListblocks ) +Blocks0to7::Blocks0to7( const QList &blocks ) { _ok = false; if( !blocks.isEmpty() ) SetBlocks( blocks ); } -bool Blocks0to7::SetBlocks( QListblocks ) +bool Blocks0to7::SetBlocks( const QList &blocks ) { //qDebug() << "Blocks0to7::SetBlocks" << blocks.size(); _ok = false; @@ -58,7 +58,7 @@ quint8 Blocks0to7::Boot1Version() //this doesnt take into account the possibility that boot2 is bigger and takes up more than 2 blocks //there are 0x40 blocks in the blockmap, but only 8 are used. maybe IOS has the authority to hijack the others if //it runs out of room here. if that ever happns, this code will become quite wrong -QList Blocks0to7::Boot2Infos() +const QList &Blocks0to7::Boot2Infos() { if( !boot2Infos.isEmpty() ) { @@ -66,13 +66,10 @@ QList Blocks0to7::Boot2Infos() return boot2Infos; } - QList< Boot2Info > ret; - if( blocks.size() != 8 ) - return ret; - + //QList< Boot2Info > ret; quint16 cnt = blocks.size(); if( cnt != 8 ) - return ret; + return boot2Infos; //get all the blockmaps quint16 newest = 0; @@ -138,44 +135,44 @@ QList Blocks0to7::Boot2Infos() lbm[ j ] = info.blockMap[ j ]; } - ret << info; + boot2Infos << info; } //qDebug() << "newest blockmap" << QByteArray( (const char*)&lbm, 8 ).toHex(); - cnt = ret.size(); + cnt = boot2Infos.size(); bool foundBoot = false; bool foundBackup = false; for( quint8 i = 0; i < cnt; i++ ) { - ret[ i ] = CheckHashes( ret[ i ] );//check all the hashes and stuff - if( !foundBoot && !lbm[ ret.at( i ).firstBlock ] && !lbm[ ret.at( i ).secondBlock ] ) + boot2Infos[ i ] = CheckHashes( boot2Infos[ i ] );//check all the hashes and stuff + if( !foundBoot && !lbm[ boot2Infos.at( i ).firstBlock ] && !lbm[ boot2Infos.at( i ).secondBlock ] ) { //qDebug() << "copy" << i << "is used when booting"; - ret[ i ].state |= BOOT_2_USED_TO_BOOT; - //ret[ i ].usedToBoot = true; + boot2Infos[ i ].state |= BOOT_2_USED_TO_BOOT; foundBoot = true; } - else if( lbm[ ret.at( i ).firstBlock ] || lbm[ ret.at( i ).secondBlock ] ) + else if( lbm[ boot2Infos.at( i ).firstBlock ] || lbm[ boot2Infos.at( i ).secondBlock ] ) { - ret[ i ].state |= BOOT_2_MARKED_BAD; + boot2Infos[ i ].state |= BOOT_2_MARKED_BAD; } } - for( quint8 i = ret.size(); !foundBackup && i > 0; i-- ) + for( quint8 i = boot2Infos.size(); !foundBackup && i > 0; i-- ) { - if( !lbm[ ret.at( i - 1 ).firstBlock ] && !lbm[ ret.at( i - 1 ).secondBlock ] && ret.at( i - 1 ).firstBlock > ret.at( i - 1 ).secondBlock ) + if( !lbm[ boot2Infos.at( i - 1 ).firstBlock ] + && !lbm[ boot2Infos.at( i - 1 ).secondBlock ] + && boot2Infos.at( i - 1 ).firstBlock > boot2Infos.at( i - 1 ).secondBlock ) { //qDebug() << "copy" << i << "is used when booting from backup"; - ret[ i - 1 ].state |= BOOT_2_BACKUP_COPY; + boot2Infos[ i - 1 ].state |= BOOT_2_BACKUP_COPY; foundBackup = true; if( !foundBoot ) - ret[ i - 1 ].state |= BOOT_2_USED_TO_BOOT; + boot2Infos[ i - 1 ].state |= BOOT_2_USED_TO_BOOT; } } - boot2Infos = ret; - return ret; + return boot2Infos; } -Boot2Info Blocks0to7::GetBlockMap( QByteArray block ) +Boot2Info Blocks0to7::GetBlockMap( const QByteArray &block ) { Boot2Info ret; ret.state = BOOT_2_ERROR; @@ -201,7 +198,7 @@ Boot2Info Blocks0to7::GetBlockMap( QByteArray block ) return ret; } -Boot2Info Blocks0to7::CheckHashes( Boot2Info info ) +Boot2Info Blocks0to7::CheckHashes( const Boot2Info &info ) { Boot2Info ret = info; ret.state = BOOT_2_ERROR_PARSING; @@ -307,7 +304,7 @@ Boot2Info Blocks0to7::CheckHashes( Boot2Info info ) stuff += blocks.at( ret.secondBlock ); AesSetKey( ticket.DecryptedKey() ); - QByteArray decD = AesDecrypt( 0, stuff.mid( dataOff, RU( t.Size( 0 ), 0x40 ) ) ); + QByteArray decD = AesDecrypt( 0, stuff.mid( dataOff, RU( t.Size( 0 ), 0x40 ) ) ); decD.resize( t.Size( 0 ) ); QByteArray realHash = GetSha1( decD ); if( realHash != t.Hash( 0 ) ) diff --git a/WiiQt/blocks0to7.h b/WiiQt/blocks0to7.h index 13fcb93..dc8b75d 100644 --- a/WiiQt/blocks0to7.h +++ b/WiiQt/blocks0to7.h @@ -47,7 +47,7 @@ enum struct Boot2Info //this little guy is just some container to hold the information about the state of boot2 in these blocks { //the above values are used for the "state". it will either be < 0 or it will be any of the other values |'d together - //if the state is above 0, version will either be the version from the TMD or one of the BOOTMII_... values + //if the state is above 0, version will either be the version from the TMD or one of the BOOTMII_... values quint8 firstBlock; //block that contains the header quint8 secondBlock; //block that contains the blockmap @@ -61,31 +61,31 @@ struct Boot2Info //this little guy is just some container to hold the informa class Blocks0to7 { public: - Blocks0to7( QListblocks = QList() ); - bool SetBlocks( QListblocks ); + Blocks0to7( const QList &blocks = QList() ); + bool SetBlocks( const QList &blocks ); bool IsOk(){ return _ok; } //check which version of boot1 we have quint8 Boot1Version(); //get a list containing info for each copy of boot2 on the given blocks - QList Boot2Infos(); + const QList &Boot2Infos(); private: bool _ok; //should hold the blocks, without ecc QListblocks; - //after teh first time Boot2Infos() is called, store the result here so any subsequent calls can just return this for speed + //after the first time Boot2Infos() is called, store the result here so any subsequent calls can just return this for speed QList< Boot2Info > boot2Infos; //this one doesnt really return a complete info, it only gets the block map from a block //and returns it in an incomplete Boot2Info - Boot2Info GetBlockMap( QByteArray block ); + Boot2Info GetBlockMap( const QByteArray &block ); //checks the hashes and whatnot in a copy of boot2 //returns an incomplete Boot2Info - Boot2Info CheckHashes( Boot2Info info ); + Boot2Info CheckHashes( const Boot2Info &info ); }; diff --git a/WiiQt/nandbin.h b/WiiQt/nandbin.h index 915f2d6..af76e43 100755 --- a/WiiQt/nandbin.h +++ b/WiiQt/nandbin.h @@ -21,7 +21,6 @@ struct fst_t // class to deal with an encrypted wii nand dump // basic usage... create an object, set a path, call InitNand. then you can get the detailed list of entries with GetTree() // extract files with GetFile() -//! so far, all functions for writing to the nand are highly untested. it is not recommended to try to use this code productively!! //! you should verify anything written with this code before attempting to install it on you wii //once InitNand() is called, you can get the contents of the nand in a nice QTreeWidgetItem* with GetTree() @@ -134,16 +133,16 @@ public: //expects 0x7f00 - 0x7ff0 bool CheckHmacMeta( quint16 clNo ); - //wipe out all data within the nand FS, leaving only the root entry - //preserve all bad/reserved clusters - //if secure is true, overwrite old file data with 0xff - bool Format( bool secure = true ); + //wipe out all data within the nand FS, leaving only the root entry + //preserve all bad/reserved clusters + //if secure is true, overwrite old file data with 0xff + bool Format( bool secure = true ); - //get the path of this nand - const QString FilePath(); + //get the path of this nand + const QString FilePath(); - //get the keys.bin for this object - const QByteArray Keys(); + //get the keys.bin for this object + const QByteArray Keys(); private: diff --git a/WiiQt/nandspare.h b/WiiQt/nandspare.h index d2913a0..0196f5c 100644 --- a/WiiQt/nandspare.h +++ b/WiiQt/nandspare.h @@ -82,125 +82,3 @@ block fff cluster 7 page: 6 ( 3fffe ) block fff cluster 7 page: 7 ( 3ffff ) */ -/* -block ff1 cluster 7 page: 6 ( 3fc7e ) -NandBin::GetPage( 3fc7e , true ) - -00000000 ff1646bd cef67127 e662a4dc 5154ec52 ..F...q'.b..QT.R -00000010 c844ebb9 fb1646bd cef67127 e662a4dc .D....F...q'.b.. -00000020 51000000 00000000 00000000 00000000 Q............... -00000030 00000000 00000000 00000000 00000000 ................ -block ff1 cluster 7 page: 7 ( 3fc7f ) -NandBin::GetPage( 3fc7f , true ) - -00000000 ff54ec52 c844ebb9 fb000000 0020049e .T.R.D....... .. -00000010 00000000 40000000 002004f1 a8000000 ....@.... ...... -00000020 00000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ - -block ff3 cluster 7 page: 6 ( 3fcfe ) -NandBin::GetPage( 3fcfe , true ) - -00000000 ff199405 907b607c 4cd691d2 825f2de9 .....{`|L...._-. -00000010 18185217 38199405 907b607c 4cd691d2 ..R.8....{`|L... -00000020 82000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -block ff3 cluster 7 page: 7 ( 3fcff ) -NandBin::GetPage( 3fcff , true ) - -00000000 ff5f2de9 18185217 38600000 000043dd ._-...R.8`....C. -00000010 05cf0bd7 38c882b2 24b67f57 6087c41f ....8...$..W`... -00000020 4d000000 00000000 00000000 00000000 M............... -00000030 00000000 00000000 00000000 00000000 ................ - -block ff5 cluster 7 page: 6 ( 3fd7e ) -NandBin::GetPage( 3fd7e , true ) - -00000000 ff1c1964 3e97b995 b864f566 b9fa025d ...d>....d.f...] -00000010 4f708e95 cc1c1964 3e97b995 b864f566 Op.....d>....d.f -00000020 b9000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -block ff5 cluster 7 page: 7 ( 3fd7f ) -NandBin::GetPage( 3fd7f , true ) - -00000000 fffa025d 4f708e95 cc2004f8 80b8f3d4 ...]Op... ...... -00000010 b94820bc f631c4c2 40c8e1da 12a29ba9 .H ..1..@....... -00000020 df000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -*//* -block ff7 cluster 7 page: 6 ( 3fdfe ) -NandBin::GetPage( 3fdfe , true ) - -00000000 ffff8ca6 8f936ad2 d4fb8424 16cd48ef ......j....$..H. -00000010 1ee1003f edff8ca6 8f936ad2 d4fb8424 ...?......j....$ -00000020 16000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -block ff7 cluster 7 page: 7 ( 3fdff ) -NandBin::GetPage( 3fdff , true ) - -00000000 ffcd48ef 1ee1003f ed000000 1020000d ..H....?..... .. -00000010 eb000000 01000000 03000000 022004f7 ............. .. -00000020 f4000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ - -block ff9 cluster 7 page: 6 ( 3fe7e ) -NandBin::GetPage( 3fe7e , true ) - -00000000 ffada309 ba23b5e5 fa37a52d 10d13f10 .....#...7.-..?. -00000010 72265162 43ada309 ba23b5e5 fa37a52d r&QbC....#...7.- -00000020 10000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -block ff9 cluster 7 page: 7 ( 3fe7f ) -NandBin::GetPage( 3fe7f , true ) - -00000000 ffd13f10 72265162 432000ae 00000000 ..?.r&QbC ...... -00000010 002004ae 00000000 102004f1 e02000ad . ....... ... .. -00000020 c4000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ - -block ffb cluster 7 page: 6 ( 3fefe ) -NandBin::GetPage( 3fefe , true ) - -00000000 ff40a82f f3e32161 5f9e91e7 841daf5e .@./..!a_......^ -00000010 c74678b2 b540a82f f3e32161 5f9e91e7 .Fx..@./..!a_... -00000020 84000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -block ffb cluster 7 page: 7 ( 3feff ) -NandBin::GetPage( 3feff , true ) - -00000000 ff1daf5e c74678b2 b52000ae 0000ed15 ...^.Fx.. ...... -00000010 e892928e 766d0000 00000000 00022001 ....vm........ . -00000020 da000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ - -block ffd cluster 7 page: 6 ( 3ff7e ) -NandBin::GetPage( 3ff7e , true ) - -00000000 ff80ded9 67d7c195 ffd65a8b 907ea776 ....g.....Z..~.v -00000010 8c56dc33 8280ded9 67d7c195 ffd65a8b .V.3....g.....Z. -00000020 90000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -block ffd cluster 7 page: 7 ( 3ff7f ) -NandBin::GetPage( 3ff7f , true ) - -00000000 ff7ea776 8c56dc33 82000000 00200091 .~.v.V.3..... .. -00000010 c0000000 40000000 002004f1 80000000 ....@.... ...... -00000020 00000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ - -block fff cluster 7 page: 6 ( 3fffe ) -NandBin::GetPage( 3fffe , true ) - -00000000 ff9570f7 915460fe 3f32d363 9a1ebfa9 ..p..T`.?2.c.... -00000010 74d3e0a4 969570f7 915460fe 3f32d363 t.....p..T`.?2.c -00000020 9a000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ -block fff cluster 7 page: 7 ( 3ffff ) -NandBin::GetPage( 3ffff , true ) - -00000000 ff1ebfa9 74d3e0a4 962004f8 80b8f3d4 ....t.... ...... -00000010 b94820bc f631c4c2 40c8e1da 12a29ba9 .H ..1..@....... -00000020 df000000 00000000 00000000 00000000 ................ -00000030 00000000 00000000 00000000 00000000 ................ - - */ diff --git a/WiiQt/nusdownloader.cpp b/WiiQt/nusdownloader.cpp index 30390d8..d7aec87 100644 --- a/WiiQt/nusdownloader.cpp +++ b/WiiQt/nusdownloader.cpp @@ -113,7 +113,7 @@ void NusDownloader::StartNextJob() } //tries to read data for the job from the PC -QByteArray NusDownloader::GetDataFromCache( downloadJob job ) +QByteArray NusDownloader::GetDataFromCache( const downloadJob &job ) { //qDebug() << "NusDownloader::GetDataFromCache"; if( cachePath.isEmpty() || currentJob.version == TITLE_LATEST_VERSION ) @@ -330,7 +330,7 @@ QString NusDownloader::GetCachePath( quint32 idx ) } //print info about a job -void NusDownloader::DbgJoB( NusJob job ) +void NusDownloader::DbgJoB( const NusJob &job ) { QString dataStuff = QString( "%1 items:" ).arg( job.data.size() ); for( int i = 0; i < job.data.size(); i++ ) @@ -372,7 +372,7 @@ bool NusDownloader::DecryptCheckHashAndAppendData( const QByteArray &encData, qu } //something is done downloading -void NusDownloader::FileIsFinishedDownloading( downloadJob job ) +void NusDownloader::FileIsFinishedDownloading( const downloadJob &job ) { //qDebug() << "NusDownloader::FileIsFinishedDownloading" << job.index; if( job.data.isEmpty() ) diff --git a/WiiQt/nusdownloader.h b/WiiQt/nusdownloader.h index 8b5c605..74e2942 100644 --- a/WiiQt/nusdownloader.h +++ b/WiiQt/nusdownloader.h @@ -55,11 +55,11 @@ public: //get a list of titles for a given update //if a title is not available on NUS, a substitute is given instead ( a later version of the same title ) //to keep people from bulk DLing and installing and messing something up, any boot2 update will NOT be included - //in the list, ask for it specifically. + //in the list, ask for it specifically. //lists are created from wiimpersonator logs when available. otherwise they come from examining game update partitions - static QMap< quint64, quint16 > List20u();//* there are no games ive seen that contain this update. this is just a guess - static QMap< quint64, quint16 > List22u(); + static QMap< quint64, quint16 > List20u();//* there are no games ive seen that contain this update. this is just a guess + static QMap< quint64, quint16 > List22u(); static QMap< quint64, quint16 > List30u(); static QMap< quint64, quint16 > List31u(); static QMap< quint64, quint16 > List32u(); @@ -70,12 +70,12 @@ public: static QMap< quint64, quint16 > List42u(); static QMap< quint64, quint16 > List43u(); - static QMap< quint64, quint16 > List20e();//* there are no games ive seen that contain this update. this is just a guess - static QMap< quint64, quint16 > List21e(); - static QMap< quint64, quint16 > List22e(); //* there are no games ive seen that contain this update. this is just a guess + static QMap< quint64, quint16 > List20e();//* there are no games ive seen that contain this update. this is just a guess + static QMap< quint64, quint16 > List21e(); + static QMap< quint64, quint16 > List22e(); //* there are no games ive seen that contain this update. this is just a guess static QMap< quint64, quint16 > List30e(); static QMap< quint64, quint16 > List31e(); - static QMap< quint64, quint16 > List32e(); //* there are no games ive seen that contain this update, i have only copied 3.1e and changed the system menu + static QMap< quint64, quint16 > List32e(); //* there are no games ive seen that contain this update, i have only copied 3.1e and changed the system menu static QMap< quint64, quint16 > List33e(); static QMap< quint64, quint16 > List34e(); static QMap< quint64, quint16 > List40e(); @@ -88,11 +88,11 @@ public: static QMap< quint64, quint16 > List42k(); static QMap< quint64, quint16 > List43k(); - static QMap< quint64, quint16 > List20j(); - static QMap< quint64, quint16 > List22j();//* there are no games ive seen that contain this update, i have only copied 2.1e and changed the system menu - static QMap< quint64, quint16 > List30j(); + static QMap< quint64, quint16 > List20j(); + static QMap< quint64, quint16 > List22j();//* there are no games ive seen that contain this update, i have only copied 2.1e and changed the system menu + static QMap< quint64, quint16 > List30j(); static QMap< quint64, quint16 > List31j(); - static QMap< quint64, quint16 > List32j();//* there are no games ive seen that contain this update, i have only copied 3.1j and changed the system menu + static QMap< quint64, quint16 > List32j();//* there are no games ive seen that contain this update, i have only copied 3.1j and changed the system menu static QMap< quint64, quint16 > List33j(); static QMap< quint64, quint16 > List34j(); static QMap< quint64, quint16 > List40j(); @@ -110,7 +110,7 @@ private: //get data from the cache and put it in the job's data //uses the version from currentJob - QByteArray GetDataFromCache( downloadJob job ); + QByteArray GetDataFromCache( const downloadJob &job ); //saves downloaded data to the HDD for later use bool SaveDataToCache( const QString &path, const QByteArray &stuff ); @@ -121,13 +121,13 @@ private: bool DecryptCheckHashAndAppendData( const QByteArray &encData, quint16 idx ); //triggered when a file is done downloading - void FileIsFinishedDownloading( downloadJob job ); + void FileIsFinishedDownloading( const downloadJob &job ); //send a fail message about the current job and skip to the next void CurrentJobErrored( const QString &str ); //print info about a job to qDebug() - void DbgJoB( NusJob job ); + void DbgJoB( const NusJob &job ); //get the path for a file in the local cache QString GetCachePath( quint32 idx ); diff --git a/WiiQt/sharedcontentmap.h b/WiiQt/sharedcontentmap.h index 6a82466..d5764b0 100644 --- a/WiiQt/sharedcontentmap.h +++ b/WiiQt/sharedcontentmap.h @@ -26,7 +26,7 @@ public: void AddEntry( const QString &app, const QByteArray &hash ); //get the entire data ready for writing to a wii nand - const QByteArray Data(){ return data; } + const QByteArray &Data(){ return data; } const QByteArray Hash( quint16 i ); const QString Cid( quint16 i ); diff --git a/WiiQt/uidmap.h b/WiiQt/uidmap.h index d153b7c..590409d 100644 --- a/WiiQt/uidmap.h +++ b/WiiQt/uidmap.h @@ -20,13 +20,13 @@ public: quint32 GetUid( quint64 tid, bool autoCreate = true ); //creates a new uid.sys with the system menu entry. - //if addFactorySetupDiscs is anything other than 0, it will add some entries for the setup discs used in the wii factory - // addFactorySetupDiscs should be the region code: 0x45=E, 0x50=P... + //if addFactorySetupDiscs is anything other than 0, it will add some entries for the setup discs used in the wii factory + // addFactorySetupDiscs should be the region code: 0x45=E, 0x50=P... // ( serve no purpose other than to just exist ) - void CreateNew( quint8 addFactorySetupDiscs = 0 ); + void CreateNew( quint8 addFactorySetupDiscs = 0 ); //get th entire uid.sys data back in a state ready for writing to a nand - const QByteArray Data(){ return data; } + const QByteArray &Data(){ return data; } private: QByteArray data; diff --git a/punetwiin/main.cpp b/punetwiin/main.cpp index f331806..f8f5c35 100644 --- a/punetwiin/main.cpp +++ b/punetwiin/main.cpp @@ -7,10 +7,8 @@ QStringList args; NandBin nandS;//source NandBin nandD;//dest QTreeWidgetItem *root = NULL; -quint32 verbose = 0; bool color = true; bool testMode = true; -bool CheckTitleIntegrity( quint64 tid ); quint32 fileCnt = 0; quint32 dirCnt = 0;