mirror of
https://github.com/martravi/wiiqt6.git
synced 2024-11-25 14:17:00 +01:00
* minor optimizations
git-svn-id: http://wiiqt.googlecode.com/svn/trunk@86 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
parent
c891dd5ff5
commit
1dab1d2a59
@ -2,14 +2,14 @@
|
||||
#include "tools.h"
|
||||
#include "tiktmd.h"
|
||||
|
||||
Blocks0to7::Blocks0to7( QList<QByteArray>blocks )
|
||||
Blocks0to7::Blocks0to7( const QList<QByteArray> &blocks )
|
||||
{
|
||||
_ok = false;
|
||||
if( !blocks.isEmpty() )
|
||||
SetBlocks( blocks );
|
||||
}
|
||||
|
||||
bool Blocks0to7::SetBlocks( QList<QByteArray>blocks )
|
||||
bool Blocks0to7::SetBlocks( const QList<QByteArray> &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<Boot2Info> Blocks0to7::Boot2Infos()
|
||||
const QList<Boot2Info> &Blocks0to7::Boot2Infos()
|
||||
{
|
||||
if( !boot2Infos.isEmpty() )
|
||||
{
|
||||
@ -66,13 +66,10 @@ QList<Boot2Info> 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<Boot2Info> 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;
|
||||
|
@ -61,31 +61,31 @@ struct Boot2Info //this little guy is just some container to hold the informa
|
||||
class Blocks0to7
|
||||
{
|
||||
public:
|
||||
Blocks0to7( QList<QByteArray>blocks = QList<QByteArray>() );
|
||||
bool SetBlocks( QList<QByteArray>blocks );
|
||||
Blocks0to7( const QList<QByteArray> &blocks = QList<QByteArray>() );
|
||||
bool SetBlocks( const QList<QByteArray> &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<Boot2Info> Boot2Infos();
|
||||
const QList<Boot2Info> &Boot2Infos();
|
||||
|
||||
private:
|
||||
bool _ok;
|
||||
//should hold the blocks, without ecc
|
||||
QList<QByteArray>blocks;
|
||||
|
||||
//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 );
|
||||
|
||||
};
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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 ................
|
||||
|
||||
*/
|
||||
|
@ -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() )
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user