NUS NAND Builder and base ported to QT 6

This commit is contained in:
martravi 2024-07-19 16:36:53 +02:00
parent 4ad7db8134
commit 0da56e8f75
33 changed files with 324 additions and 1120 deletions

172
.gitattributes vendored Normal file
View File

@ -0,0 +1,172 @@
* text=auto !eol
WiiQt/aes.c -text
WiiQt/aes.h -text
WiiQt/ash.cpp -text
WiiQt/ash.h -text
WiiQt/blocks0to7.cpp -text
WiiQt/blocks0to7.h -text
WiiQt/bn.cpp -text
WiiQt/bn.h -text
WiiQt/ec.cpp -text
WiiQt/ec.h -text
WiiQt/includes.h -text
WiiQt/keysbin.cpp -text
WiiQt/keysbin.h -text
WiiQt/lz77.cpp -text
WiiQt/lz77.h -text
WiiQt/md5.cpp -text
WiiQt/md5.h -text
WiiQt/nandbin.cpp -text
WiiQt/nandbin.h -text
WiiQt/nanddump.cpp -text
WiiQt/nanddump.h -text
WiiQt/nandspare.cpp -text
WiiQt/nandspare.h -text
WiiQt/nusdownloader.cpp -text
WiiQt/nusdownloader.h -text
WiiQt/savebanner.cpp -text
WiiQt/savebanner.h -text
WiiQt/savedatabin.cpp -text
WiiQt/savedatabin.h -text
WiiQt/settingtxtdialog.cpp -text
WiiQt/settingtxtdialog.h -text
WiiQt/settingtxtdialog.ui -text
WiiQt/sha1.c -text
WiiQt/sha1.h -text
WiiQt/sharedcontentmap.cpp -text
WiiQt/sharedcontentmap.h -text
WiiQt/tiktmd.cpp -text
WiiQt/tiktmd.h -text
WiiQt/tools.cpp -text
WiiQt/tools.h -text
WiiQt/u8.cpp -text
WiiQt/u8.h -text
WiiQt/uidmap.cpp -text
WiiQt/uidmap.h -text
WiiQt/wad.cpp -text
WiiQt/wad.h -text
breft_editor/breft.cpp -text
breft_editor/breft.h -text
breft_editor/breft.pro -text
breft_editor/main.cpp -text
breft_editor/mainwindow.cpp -text
breft_editor/mainwindow.h -text
breft_editor/texture.cpp -text
breft_editor/texture.h -text
nandBinCheck/main.cpp -text
nandBinCheck/nandBinCheck.pro -text
nandBinCheck/readmii.txt -text
nandExtract/black.png -text
nandExtract/blue.png -text
nandExtract/boot2infodialog.cpp -text
nandExtract/boot2infodialog.h -text
nandExtract/boot2infodialog.ui -text
nandExtract/green.png -text
nandExtract/grey.png -text
nandExtract/icon.png -text
nandExtract/main.cpp -text
nandExtract/nandExtract.pro -text
nandExtract/nandthread.cpp -text
nandExtract/nandthread.h -text
nandExtract/nandwindow.cpp -text
nandExtract/nandwindow.h -text
nandExtract/nandwindow.ui -text
nandExtract/pink.png -text
nandExtract/rc.qrc -text
nandExtract/readmii.txt -text
nandDump/icon.png -text
nandDump/main.cpp -text
nandDump/mainwindow.cpp -text
nandDump/mainwindow.h -text
nandDump/mainwindow.ui -text
nandDump/nand.pro -text
nandDump/rc.qrc -text
nandDump/readmii.txt -text
ohneschwanzenegger/icon.png -text
ohneschwanzenegger/main.cpp -text
ohneschwanzenegger/mainwindow.cpp -text
ohneschwanzenegger/mainwindow.h -text
ohneschwanzenegger/mainwindow.ui -text
ohneschwanzenegger/newnandbin.cpp -text
ohneschwanzenegger/newnandbin.h -text
ohneschwanzenegger/newnandbin.ui -text
ohneschwanzenegger/rc.qrc -text
ohneschwanzenegger/readmii.txt -text
ohneschwanzenegger/refleurii.pro -text
ohneschwanzenegger/testlog.txt -text
punetwiin/main.cpp -text
punetwiin/punetween.pro -text
saveToy/includes.h -text
saveToy/main.cpp -text
saveToy/mainwindow.cpp -text
saveToy/mainwindow.h -text
saveToy/mainwindow.ui -text
saveToy/ngdialog.cpp -text
saveToy/ngdialog.h -text
saveToy/ngdialog.ui -text
saveToy/noBanner.png -text
saveToy/noIcon.png -text
saveToy/quazip/include/JlCompress.h -text
saveToy/quazip/include/crypt.h -text
saveToy/quazip/include/ioapi.h -text
saveToy/quazip/include/quaadler32.h -text
saveToy/quazip/include/quachecksum32.h -text
saveToy/quazip/include/quacrc32.h -text
saveToy/quazip/include/quazip.h -text
saveToy/quazip/include/quazipfile.h -text
saveToy/quazip/include/quazipfileinfo.h -text
saveToy/quazip/include/quazipnewinfo.h -text
saveToy/quazip/include/unzip.h -text
saveToy/quazip/include/zconf.h -text
saveToy/quazip/include/zip.h -text
saveToy/quazip/include/zlib.h -text
saveToy/quazip/lib/linux_x64/libquazip.a -text
saveToy/quazip/lib/linux_x86/libquazip.a -text
saveToy/quazip/lib/mac/libquazip.a -text
saveToy/quazip/lib/win32/libquazip.a -text
saveToy/rc.qrc -text
saveToy/readmii.txt -text
saveToy/saveToy.pro -text
saveToy/savelistitem.cpp -text
saveToy/savelistitem.h -text
saveToy/saveloadthread.cpp -text
saveToy/saveloadthread.h -text
saveToy/textdialog.cpp -text
saveToy/textdialog.h -text
saveToy/textdialog.ui -text
symbolizer/be.cpp -text
symbolizer/be.h -text
symbolizer/dol.cpp -text
symbolizer/dol.h -text
symbolizer/elfparser.cpp -text
symbolizer/elfparser.h -text
symbolizer/main.cpp -text
symbolizer/ppc_disasm.c -text
symbolizer/ppc_disasm.h -text
symbolizer/symbolizer.pro -text
thp_player/ffw.png -text
thp_player/gcvid.cpp -text
thp_player/gcvid.h -text
thp_player/jpeg62.dll -text
thp_player/libpng/include/jconfig.h -text
thp_player/libpng/include/jerror.h -text
thp_player/libpng/include/jmorecfg.h -text
thp_player/libpng/include/jpeglib.h -text
thp_player/libpng/lib/libjpeg.dll.a -text
thp_player/main.cpp -text
thp_player/next.png -text
thp_player/pause.png -text
thp_player/play.png -text
thp_player/prev.png -text
thp_player/rc.qrc -text
thp_player/repeat.png -text
thp_player/rev.png -text
thp_player/star.png -text
thp_player/stop.png -text
thp_player/thp_player.pro -text
thp_player/thpwindow.cpp -text
thp_player/thpwindow.h -text
thp_player/thpwindow.ui -text
thp_player/vol_high.png -text
thp_player/vol_low.png -text
thp_player/vol_med.png -text

54
.gitignore vendored Normal file
View File

@ -0,0 +1,54 @@
# build folders
*/build/
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCreator CMake
CMakeLists.txt.user*
# QtCreator 4.8< compilation database
compile_commands.json
# QtCreator local machine specific files for imported projects
*creator.user*

View File

@ -22,7 +22,7 @@ bool Blocks0to7::SetBlocks( const QList<QByteArray> &blocks )
{ {
if( blocks.at( i ).size() != 0x20000 ) if( blocks.at( i ).size() != 0x20000 )
{ {
qWarning() << "Blocks0to7::SetBlocks -> block" << i << "is" << hex << blocks.at( i ).size() << "bytes"; qWarning() << "Blocks0to7::SetBlocks -> block" << i << "is" << Qt::hex << blocks.at( i ).size() << "bytes";
return false; return false;
} }
} }

View File

@ -20,7 +20,6 @@
#include <QObject> #include <QObject>
#include <QProcess> #include <QProcess>
#include <QQueue> #include <QQueue>
#include <QRegExp>
#include <QSettings> #include <QSettings>
#include <QtDebug> #include <QtDebug>
#include <QTimer> #include <QTimer>

View File

@ -68,7 +68,7 @@ bool NandBin::CreateNew( const QString &path, const QByteArray &keys, const QByt
#else #else
if( keys.size() != 0x400 || first8.size() != 0x108000 ) if( keys.size() != 0x400 || first8.size() != 0x108000 )
{ {
qWarning() << "NandBin::CreateNew -> bad sizes" << hex << keys.size() << first8.size(); qWarning() << "NandBin::CreateNew -> bad sizes" << Qt::hex << keys.size() << first8.size();
return false; return false;
} }
@ -168,7 +168,7 @@ bool NandBin::Format( bool secure )
#else #else
if( !f.isOpen() || fats.size() != 0x8000 ) if( !f.isOpen() || fats.size() != 0x8000 )
{ {
qWarning() << "NandBin::Format -> error" << hex << fats.size() << f.isOpen(); qWarning() << "NandBin::Format -> error" << Qt::hex << fats.size() << f.isOpen();
return false; return false;
} }
@ -282,7 +282,7 @@ QTreeWidgetItem *NandBin::CreateItem( QTreeWidgetItem *parent, const QString &na
bool NandBin::AddChildren( QTreeWidgetItem *parent, quint16 entry ) bool NandBin::AddChildren( QTreeWidgetItem *parent, quint16 entry )
{ {
//qDebug() << "NandBin::AddChildren" << parent->text( 0 ) << hex << entry; //qDebug() << "NandBin::AddChildren" << parent->text( 0 ) << Qt::hex << entry;
if( entry >= 0x17ff ) if( entry >= 0x17ff )
{ {
qDebug() << "NandBin::AddChildren: entry >= 0x17ff"; qDebug() << "NandBin::AddChildren: entry >= 0x17ff";
@ -346,7 +346,7 @@ const QString NandBin::FstName( fst_t fst )
bool NandBin::ExtractFST( quint16 entry, const QString &path, bool singleFile ) bool NandBin::ExtractFST( quint16 entry, const QString &path, bool singleFile )
{ {
//qDebug() << "NandBin::ExtractFST(" << hex << entry << "," << path << ")"; //qDebug() << "NandBin::ExtractFST(" << Qt::hex << entry << "," << path << ")";
fst_t fst = GetFST( entry ); fst_t fst = GetFST( entry );
if( !fst.filename[ 0 ] )//something is amiss, better quit now if( !fst.filename[ 0 ] )//something is amiss, better quit now
@ -506,11 +506,11 @@ void NandBin::ShowLostClusters()
break; break;
default: default:
lost++; lost++;
qDebug() << hex << i << fats.at( i ); qDebug() << Qt::hex << i << fats.at( i );
break; break;
} }
} }
qDebug() << "found" << lost << "lost clusters\nUNK ( 0xffff )" << hex << ffs.size() << ffs << qDebug() << "found" << lost << "lost clusters\nUNK ( 0xffff )" << Qt::hex << ffs.size() << ffs <<
"\nfree " << frs.size(); "\nfree " << frs.size();
} }
@ -692,7 +692,7 @@ qint32 NandBin::FindSuperblock()
f.read( (char*)&magic, 4 );//no need to switch endian here f.read( (char*)&magic, 4 );//no need to switch endian here
if( magic != 0x53464653 ) if( magic != 0x53464653 )
{ {
qWarning() << "oops, this isnt a supercluster" << hex << loc << magic << currentSuperCluster; qWarning() << "oops, this isnt a supercluster" << Qt::hex << loc << magic << currentSuperCluster;
rewind++; rewind++;
//hexdump( sss ); //hexdump( sss );
continue; continue;
@ -701,13 +701,13 @@ qint32 NandBin::FindSuperblock()
f.read( (char*)&current, 4 ); f.read( (char*)&current, 4 );
current = qFromBigEndian( current ); current = qFromBigEndian( current );
//qDebug() << "superblock" << hex << current << currentSuperCluster << loc; //qDebug() << "superblock" << Qt::hex << current << currentSuperCluster << loc;
if( current > superClusterVersion ) if( current > superClusterVersion )
superClusterVersion = current; superClusterVersion = current;
else else
{ {
//qDebug() << "using superblock" << hex << superClusterVersion << currentSuperCluster - 0x10 << f.pos() - n_len[ type ]; //qDebug() << "using superblock" << Qt::hex << superClusterVersion << currentSuperCluster - 0x10 << f.pos() - n_len[ type ];
//currentSuperCluster -= ( 0x10 * rewind ); //currentSuperCluster -= ( 0x10 * rewind );
//loc -= ( n_len[ type ] * rewind ); //loc -= ( n_len[ type ] * rewind );
rewind = 1; rewind = 1;
@ -724,13 +724,13 @@ qint32 NandBin::FindSuperblock()
currentSuperCluster -= ( 0x10 * rewind ); currentSuperCluster -= ( 0x10 * rewind );
loc -= ( n_len[ type ] * rewind ); loc -= ( n_len[ type ] * rewind );
//qDebug() << "using superblock" << hex << superClusterVersion << currentSuperCluster << "page:" << ( loc / 0x840 ); //qDebug() << "using superblock" << Qt::hex << superClusterVersion << currentSuperCluster << "page:" << ( loc / 0x840 );
return loc; return loc;
} }
fst_t NandBin::GetFST( quint16 entry ) fst_t NandBin::GetFST( quint16 entry )
{ {
//qDebug() << "NandBin::GetFST(" << hex << entry << ")"; //qDebug() << "NandBin::GetFST(" << Qt::hex << entry << ")";
fst_t fst; fst_t fst;
if( entry >= 0x17FF ) if( entry >= 0x17FF )
{ {
@ -740,7 +740,7 @@ fst_t NandBin::GetFST( quint16 entry )
} }
if( fstInited )//we've already read this once, just give back the one we already know if( fstInited )//we've already read this once, just give back the one we already know
{ {
//qDebug() << "reading from cache" << hex << entry; //qDebug() << "reading from cache" << Qt::hex << entry;
return fsts[ entry ]; return fsts[ entry ];
} }
// compensate for 64 bytes of ecc data every 64 fst entries // compensate for 64 bytes of ecc data every 64 fst entries
@ -748,7 +748,7 @@ fst_t NandBin::GetFST( quint16 entry )
int loc_entry = ( ( ( entry / 0x40 ) * n_fst[ type ] ) + entry ) * 0x20; int loc_entry = ( ( ( entry / 0x40 ) * n_fst[ type ] ) + entry ) * 0x20;
if( (quint32)f.size() < loc_fst + loc_entry + sizeof( fst_t ) ) if( (quint32)f.size() < loc_fst + loc_entry + sizeof( fst_t ) )
{ {
qDebug() << hex << (quint32)f.size() << loc_fst << loc_entry << type << n_fst[ type ]; qDebug() << Qt::hex << (quint32)f.size() << loc_fst << loc_entry << type << n_fst[ type ];
emit SendError( tr( "Tried to read fst_t beyond size of nand.bin" ) ); emit SendError( tr( "Tried to read fst_t beyond size of nand.bin" ) );
fst.filename[ 0 ] = '\0'; fst.filename[ 0 ] = '\0';
return fst; return fst;
@ -810,7 +810,7 @@ quint16 NandBin::GetFAT( quint16 fat_entry )
const QByteArray NandBin::GetPage( quint32 pageNo, bool withEcc ) const QByteArray NandBin::GetPage( quint32 pageNo, bool withEcc )
{ {
//qDebug() << "NandBin::GetPage( " << hex << pageNo << ", " << withEcc << " )"; //qDebug() << "NandBin::GetPage( " << Qt::hex << pageNo << ", " << withEcc << " )";
quint32 n_pagelen[] = { 0x800, 0x840, 0x840 }; quint32 n_pagelen[] = { 0x800, 0x840, 0x840 };
if( f.size() < ( pageNo + 1 ) * n_pagelen[ type ] ) if( f.size() < ( pageNo + 1 ) * n_pagelen[ type ] )
@ -819,14 +819,14 @@ const QByteArray NandBin::GetPage( quint32 pageNo, bool withEcc )
return QByteArray(); return QByteArray();
} }
f.seek( pageNo * n_pagelen[ type ] ); //seek to the beginning of the page to read f.seek( pageNo * n_pagelen[ type ] ); //seek to the beginning of the page to read
//qDebug() << "reading page from" << hex << (quint32)f.pos(); //qDebug() << "reading page from" << Qt::hex << (quint32)f.pos();
QByteArray page = f.read( ( type && withEcc ) ? n_pagelen[ type ] : 0x800 ); QByteArray page = f.read( ( type && withEcc ) ? n_pagelen[ type ] : 0x800 );
return page; return page;
} }
const QByteArray NandBin::GetCluster( quint16 cluster_entry, bool decrypt ) const QByteArray NandBin::GetCluster( quint16 cluster_entry, bool decrypt )
{ {
//qDebug() << "NandBin::GetCluster" << hex << cluster_entry; //qDebug() << "NandBin::GetCluster" << Qt::hex << cluster_entry;
quint32 n_clusterlen[] = { 0x4000, 0x4200, 0x4200 }; quint32 n_clusterlen[] = { 0x4000, 0x4200, 0x4200 };
quint32 n_pagelen[] = { 0x800, 0x840, 0x840 }; quint32 n_pagelen[] = { 0x800, 0x840, 0x840 };
@ -841,7 +841,7 @@ const QByteArray NandBin::GetCluster( quint16 cluster_entry, bool decrypt )
for( int i = 0; i < 8; i++ ) for( int i = 0; i < 8; i++ )
{ {
f.seek( ( cluster_entry * n_clusterlen[ type ] ) + ( i * n_pagelen[ type ] ) ); //seek to the beginning of the page to read f.seek( ( cluster_entry * n_clusterlen[ type ] ) + ( i * n_pagelen[ type ] ) ); //seek to the beginning of the page to read
//qDebug() << "reading page from" << hex << (quint32)f.pos(); //qDebug() << "reading page from" << Qt::hex << (quint32)f.pos();
//QByteArray page = f.read( n_pagelen[ type ] ); //read the page, with ecc //QByteArray page = f.read( n_pagelen[ type ] ); //read the page, with ecc
QByteArray page = f.read( 0x800 ); //read the page, skip the ecc QByteArray page = f.read( 0x800 ); //read the page, skip the ecc
//hexdump( page.mid( 0x800, 0x40 ) );//just here for debugging purposes //hexdump( page.mid( 0x800, 0x40 ) );//just here for debugging purposes
@ -851,7 +851,7 @@ const QByteArray NandBin::GetCluster( quint16 cluster_entry, bool decrypt )
} }
if( cluster.size() != 0x4000 ) if( cluster.size() != 0x4000 )
{ {
qDebug() << "actual cluster size" << hex << cluster.size(); qDebug() << "actual cluster size" << Qt::hex << cluster.size();
emit SendError( tr( "Error reading cluster" ) ); emit SendError( tr( "Error reading cluster" ) );
return QByteArray(); return QByteArray();
} }
@ -900,26 +900,26 @@ const QByteArray NandBin::GetFile( fst_t fst_ )
//readFats << fat; //readFats << fat;
fat = GetFAT( fat ); fat = GetFAT( fat );
} }
//qDebug() << "actually read data from fats\n" << hex << readFats; //qDebug() << "actually read data from fats\n" << Qt::hex << readFats;
//qDebug() << "stopped reading because of" << hex << fat; //qDebug() << "stopped reading because of" << Qt::hex << fat;
//this check doesnt really seem to matter, it always appears to be 1 extra cluster added to the end //this check doesnt really seem to matter, it always appears to be 1 extra cluster added to the end
//of the file and that extra bit is dropped in this function before the data is returned. //of the file and that extra bit is dropped in this function before the data is returned.
/*if( data.size() != cluster_span * 0x4000 ) /*if( data.size() != cluster_span * 0x4000 )
{ {
qDebug() << "data.size() != cluster_span * 0x4000 :: " qDebug() << "data.size() != cluster_span * 0x4000 :: "
<< hex << data.size() << Qt::hex << data.size()
<< cluster_span << cluster_span
<< ( cluster_span * 0x4000 ) << ( cluster_span * 0x4000 )
<< "expected size:" << hex << fst.size; << "expected size:" << Qt::hex << fst.size;
emit SendError( tr( "Error reading file [ block size is not a as expected ] %1" ).arg( FstName( fst ) ) ); emit SendError( tr( "Error reading file [ block size is not a as expected ] %1" ).arg( FstName( fst ) ) );
}*/ }*/
if( (quint32)data.size() < fst_.size ) if( (quint32)data.size() < fst_.size )
{ {
qWarning() << "NandBin::GetFile() -> (quint32)data.size() < fst.size : " qWarning() << "NandBin::GetFile() -> (quint32)data.size() < fst.size : "
<< hex << data.size() << Qt::hex << data.size()
<< "expected size:" << hex << fst_.size; << "expected size:" << Qt::hex << fst_.size;
emit SendError( tr( "Error reading file [ returned data size is less that the size in the fst ]" ) ); emit SendError( tr( "Error reading file [ returned data size is less that the size in the fst ]" ) );
return QByteArray(); return QByteArray();
@ -941,16 +941,16 @@ const QList<quint16> NandBin::GetFatsForFile( quint16 i )
return ret; return ret;
quint16 fat = fst.sub; quint16 fat = fst.sub;
//qDebug() << hex << fat; //qDebug() << Qt::hex << fat;
quint16 j = 0;//just to make sure a broken nand doesnt lead to an endless loop quint16 j = 0;//just to make sure a broken nand doesnt lead to an endless loop
while ( fat < 0x8000 && fat > 0 && ++j ) while ( fat < 0x8000 && fat > 0 && ++j )
{ {
ret << fat; ret << fat;
fat = GetFAT( fat ); fat = GetFAT( fat );
//qDebug() << hex << fat; //qDebug() << Qt::hex << fat;
} }
//qDebug() << hex << ret; //qDebug() << Qt::hex << ret;
return ret; return ret;
} }
@ -1138,7 +1138,7 @@ bool NandBin::WriteCluster( quint32 pageNo, const QByteArray &data, const QByteA
{ {
if( data.size() != 0x4000 ) if( data.size() != 0x4000 )
{ {
qWarning() << "NandBin::WriteCluster -> size:" << hex << data.size(); qWarning() << "NandBin::WriteCluster -> size:" << Qt::hex << data.size();
return false; return false;
} }
@ -1188,11 +1188,11 @@ bool NandBin::WritePage( quint32 pageNo, const QByteArray &data )
qWarning() << __FILE__ << "was built without write support"; qWarning() << __FILE__ << "was built without write support";
return false; return false;
#else #else
//qDebug() << "NandBin::WritePage(" << hex << pageNo << ")"; //qDebug() << "NandBin::WritePage(" << Qt::hex << pageNo << ")";
quint32 n_pagelen[] = { 0x800, 0x840, 0x840 }; quint32 n_pagelen[] = { 0x800, 0x840, 0x840 };
if( (quint32)data.size() != n_pagelen[ type ] ) if( (quint32)data.size() != n_pagelen[ type ] )
{ {
qWarning() << "data is wrong size" << hex << data.size(); qWarning() << "data is wrong size" << Qt::hex << data.size();
return false; return false;
} }
@ -1202,7 +1202,7 @@ bool NandBin::WritePage( quint32 pageNo, const QByteArray &data )
return false; return false;
} }
f.seek( (quint64)pageNo * (quint64)n_pagelen[ type ] ); //seek to the beginning of the page to write f.seek( (quint64)pageNo * (quint64)n_pagelen[ type ] ); //seek to the beginning of the page to write
//qDebug() << "writing page at:" << f.pos() << hex << (quint32)f.pos(); //qDebug() << "writing page at:" << f.pos() << Qt::hex << (quint32)f.pos();
//hexdump( data, 0, 0x20 ); //hexdump( data, 0, 0x20 );
return ( f.write( data ) == data.size() ); return ( f.write( data ) == data.size() );
#endif #endif
@ -1216,7 +1216,7 @@ quint16 NandBin::CreateNode( const QString &name, quint32 uid, quint16 gid, quin
//qDebug() << "looking for first empty node"; //qDebug() << "looking for first empty node";
for( i = 1; i < 0x17ff; i++ )//cant be entry 0 because that is the root for( i = 1; i < 0x17ff; i++ )//cant be entry 0 because that is the root
{ {
//qDebug() << hex << i << FstName( fsts[ i ] ); //qDebug() << Qt::hex << i << FstName( fsts[ i ] );
if( !fsts[ i ].filename[ 0 ] )//this one doesnt have a filename, it cant be used already if( !fsts[ i ].filename[ 0 ] )//this one doesnt have a filename, it cant be used already
break; break;
} }
@ -1226,8 +1226,8 @@ quint16 NandBin::CreateNode( const QString &name, quint32 uid, quint16 gid, quin
} }
QByteArray n = name.toLatin1(); QByteArray n = name.toLatin1();
n.resize( 12 ); n.resize( 12, 0x00 );
//qDebug() << "will add entry for" << n << "at" << hex << i; //qDebug() << "will add entry for" << n << "at" << Qt::hex << i;
memcpy( &fsts[ i ].filename, n.data(), 12 ); memcpy( &fsts[ i ].filename, n.data(), 12 );
fsts[ i ].attr = attr; fsts[ i ].attr = attr;
fsts[ i ].wtf = 0; fsts[ i ].wtf = 0;
@ -1514,7 +1514,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
//setup random number stuff to emulate wear leveling //setup random number stuff to emulate wear leveling
QTime midnight( 0, 0, 0 ); QTime midnight( 0, 0, 0 );
qsrand( midnight.secsTo( QTime::currentTime() ) ); QRandomGenerator rng(midnight.secsTo( QTime::currentTime() ));
//now grab the clusters that will be used from the list //now grab the clusters that will be used from the list
//qDebug() << "trying to find" << ( clCnt - fts.size() ) << "free clusters"; //qDebug() << "trying to find" << ( clCnt - fts.size() ) << "free clusters";
@ -1524,7 +1524,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
return false; return false;
//grab a random cluster from the list //grab a random cluster from the list
quint16 idx = qrand() % freeClusters.size(); quint16 idx = rng.generate() % freeClusters.size();
quint16 cl = freeClusters.takeAt( idx ); //remove this number from the list 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 fts << cl; //add this one to the clusters that will be used to hold the data
@ -1552,7 +1552,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
QByteArray spr = page.right( 0x40 ); QByteArray spr = page.right( 0x40 );
if( !spr.startsWith( 0xff ) ) if( !spr.startsWith( 0xff ) )
{ {
qWarning() << "page" << hex << ( cl * 8 ) << "is bad??"; qWarning() << "page" << Qt::hex << ( cl * 8 ) << "is bad??";
continue; continue;
} }
}*/ }*/
@ -1560,9 +1560,9 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
} }
} }
//sort clusters so file is written in order ( not like it matters on flash memory, though ) //sort clusters so file is written in order ( not like it matters on flash memory, though )
qSort( fts.begin(), fts.end() ); std::sort( fts.begin(), fts.end() );
//qDebug() << "about to writing shit" << clCnt << fts.size(); //qDebug() << "about to writing shit" << clCnt << fts.size();
//qDebug() << "file will be on clusters\n" << hex << fts; //qDebug() << "file will be on clusters\n" << Qt::hex << fts;
for( quint32 i = 0; i < clCnt; i++ ) for( quint32 i = 0; i < clCnt; i++ )
{ {
QByteArray cluster = pData.mid( i * 0x4000, 0x4000 ); QByteArray cluster = pData.mid( i * 0x4000, 0x4000 );
@ -1582,7 +1582,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
//qDebug() << "1 followed the chain to" << num << "items. expected" << clCnt; //qDebug() << "1 followed the chain to" << num << "items. expected" << clCnt;
fats.replace( fts.at( 0 ), 0xfffb );//last cluster in chain fats.replace( fts.at( 0 ), 0xfffb );//last cluster in chain
fts.takeFirst(); fts.takeFirst();
//qDebug() << "fixed the last one" << hex << fts; //qDebug() << "fixed the last one" << Qt::hex << fts;
// if the new data uses less clusters than the previous data, mark the extra ones as free // if the new data uses less clusters than the previous data, mark the extra ones as free
while( !fts.isEmpty() ) while( !fts.isEmpty() )
{ {
@ -1614,7 +1614,7 @@ bool NandBin::WriteMetaData()
quint32 nextClusterVersion = superClusterVersion + 1; quint32 nextClusterVersion = superClusterVersion + 1;
QByteArray scl( 0x4000 * 16, '\0' ); //this will hold all the data QByteArray scl( 0x4000 * 16, '\0' ); //this will hold all the data
//qDebug() << "created the meta block buffer" << hex << scl.size(); //qDebug() << "created the meta block buffer" << Qt::hex << scl.size();
QBuffer b( &scl ); QBuffer b( &scl );
b.open( QIODevice::WriteOnly ); b.open( QIODevice::WriteOnly );
quint32 tmp; quint32 tmp;
@ -1626,7 +1626,7 @@ bool NandBin::WriteMetaData()
tmp = qFromBigEndian( (quint32)0 ); tmp = qFromBigEndian( (quint32)0 );
//tmp = qFromBigEndian( (quint32)0x10 ); //wiibrew says its always 0x10. but mine is 0 //tmp = qFromBigEndian( (quint32)0x10 ); //wiibrew says its always 0x10. but mine is 0
b.write( (const char*)&tmp, 4 ); b.write( (const char*)&tmp, 4 );
//qDebug() << "writing the fats at" << hex << (quint32)b.pos(); //qDebug() << "writing the fats at" << Qt::hex << (quint32)b.pos();
//write all the fats //write all the fats
for( quint16 i = 0; i < 0x8000; i++ ) for( quint16 i = 0; i < 0x8000; i++ )
@ -1635,7 +1635,7 @@ bool NandBin::WriteMetaData()
b.write( (const char*)&t, 2 ); b.write( (const char*)&t, 2 );
} }
//qDebug() << "writing the fsts at" << hex << (quint32)b.pos(); //qDebug() << "writing the fsts at" << Qt::hex << (quint32)b.pos();
//write all the fst entries //write all the fst entries
for( quint16 i = 0; i < 0x17ff; i++ ) for( quint16 i = 0; i < 0x17ff; i++ )
{ {
@ -1665,11 +1665,11 @@ bool NandBin::WriteMetaData()
} }
//qDebug() << "done adding shit" << hex << (quint32)b.pos(); //qDebug() << "done adding shit" << Qt::hex << (quint32)b.pos();
b.close(); b.close();
QByteArray hmR = spare.Get_hmac_meta( scl, nextSuperCluster ); QByteArray hmR = spare.Get_hmac_meta( scl, nextSuperCluster );
//qDebug() << "about to write the meta block" << hex << nextSuperCluster << nextClusterVersion << "to page" << (quint32)( nextSuperCluster * 8 ); //qDebug() << "about to write the meta block" << Qt::hex << nextSuperCluster << nextClusterVersion << "to page" << (quint32)( nextSuperCluster * 8 );
for( quint8 i = 0; i < 0x10; i++ ) for( quint8 i = 0; i < 0x10; i++ )
{ {
@ -1731,7 +1731,7 @@ bool NandBin::CheckHmacData( quint16 entry )
{ {
if( entry > 0x17fe ) if( entry > 0x17fe )
{ {
qDebug() << "bad entry #" << hex << entry; qDebug() << "bad entry #" << Qt::hex << entry;
return false; return false;
} }
@ -1746,18 +1746,18 @@ bool NandBin::CheckHmacData( quint16 entry )
return true; return true;
quint16 clCnt = ( RU( fst.size, 0x4000 ) / 0x4000 ); quint16 clCnt = ( RU( fst.size, 0x4000 ) / 0x4000 );
//qDebug() << FstName( fst ) << "is" << hex << fst.size << "bytes (" << clCnt << ") clusters"; //qDebug() << FstName( fst ) << "is" << Qt::hex << fst.size << "bytes (" << clCnt << ") clusters";
quint16 fat = fst.sub; quint16 fat = fst.sub;
QByteArray sp1; QByteArray sp1;
QByteArray sp2; QByteArray sp2;
QByteArray hmac; QByteArray hmac;
//qDebug() << "fat" << hex << fat; //qDebug() << "fat" << Qt::hex << fat;
for( quint32 i = 0; i < clCnt; i++ ) for( quint32 i = 0; i < clCnt; i++ )
{ {
if( fat > 0x7fff ) if( fat > 0x7fff )
{ {
qDebug() << "fat is out of range" << hex << fat; qDebug() << "fat is out of range" << Qt::hex << fat;
return false; return false;
} }
QByteArray cluster = GetCluster( fat ); //hmac is calculated with the decrypted cluster data QByteArray cluster = GetCluster( fat ); //hmac is calculated with the decrypted cluster data
@ -1803,7 +1803,7 @@ bool NandBin::CheckHmacData( quint16 entry )
return true; return true;
error: error:
qWarning() << FstName( fst ) << "is" << hex << fst.size << "bytes (" << clCnt << ") clusters"; qWarning() << FstName( fst ) << "is" << Qt::hex << fst.size << "bytes (" << clCnt << ") clusters";
hexdump( sp1 ); hexdump( sp1 );
hexdump( sp2 ); hexdump( sp2 );
hexdump( hmac ); hexdump( hmac );
@ -1823,7 +1823,7 @@ bool NandBin::CheckHmacMeta( quint16 clNo )
} }
QByteArray hmac = spare.Get_hmac_meta( data, clNo ); QByteArray hmac = spare.Get_hmac_meta( data, clNo );
quint32 baseP = ( clNo + 15 ) * 8; quint32 baseP = ( clNo + 15 ) * 8;
//qDebug() << "baseP" << hex << baseP << ( baseP + 6 ) << ( baseP + 7 ); //qDebug() << "baseP" << Qt::hex << baseP << ( baseP + 6 ) << ( baseP + 7 );
QByteArray sp1 = GetPage( baseP + 6, true ); //the spare data of these 2 pages hold the hmac data for the supercluster QByteArray sp1 = GetPage( baseP + 6, true ); //the spare data of these 2 pages hold the hmac data for the supercluster
QByteArray sp2 = GetPage( baseP + 7, true ); QByteArray sp2 = GetPage( baseP + 7, true );
if( sp1.isEmpty() || sp2.isEmpty() ) if( sp1.isEmpty() || sp2.isEmpty() )
@ -1855,7 +1855,7 @@ bool NandBin::CheckHmacMeta( quint16 clNo )
return true; return true;
error: error:
qWarning() << "supercluster" << hex << clNo; qWarning() << "supercluster" << Qt::hex << clNo;
hexdump( sp1 ); hexdump( sp1 );
hexdump( sp2 ); hexdump( sp2 );
hexdump( hmac ); hexdump( hmac );

View File

@ -185,7 +185,7 @@ void fs_hmac_data( const unsigned char *data, quint32 uid, const unsigned char *
QByteArray NandSpare::Get_hmac_data( const QByteArray &cluster, quint32 uid, const unsigned char *name, quint32 entry_n, quint32 x3, quint16 blk ) QByteArray NandSpare::Get_hmac_data( const QByteArray &cluster, quint32 uid, const unsigned char *name, quint32 entry_n, quint32 x3, quint16 blk )
{ {
//qDebug() << "NandSpare::Get_hmac_data" << hex << cluster.size() << uid << QString( QByteArray( (const char*)name, 12 ) ) << entry_n << x3 << blk; //qDebug() << "NandSpare::Get_hmac_data" << Qt::hex << cluster.size() << uid << QString( QByteArray( (const char*)name, 12 ) ) << entry_n << x3 << blk;
if( hmacKey.size() != 0x14 || cluster.size() != 0x4000 ) if( hmacKey.size() != 0x14 || cluster.size() != 0x4000 )
return QByteArray(); return QByteArray();
@ -199,10 +199,10 @@ QByteArray NandSpare::Get_hmac_data( const QByteArray &cluster, quint32 uid, con
QByteArray NandSpare::Get_hmac_meta( const QByteArray &cluster, quint16 super_blk ) QByteArray NandSpare::Get_hmac_meta( const QByteArray &cluster, quint16 super_blk )
{ {
//qDebug() << "NandSpare::Get_hmac_meta" << hex << super_blk; //qDebug() << "NandSpare::Get_hmac_meta" << Qt::hex << super_blk;
if( hmacKey.size() != 0x14 || cluster.size() != 0x40000 ) if( hmacKey.size() != 0x14 || cluster.size() != 0x40000 )
{ {
//qDebug() << "NandSpare::Get_hmac_meta" << hex << hmacKey.size() << cluster.size(); //qDebug() << "NandSpare::Get_hmac_meta" << Qt::hex << hmacKey.size() << cluster.size();
return QByteArray(); return QByteArray();
} }

View File

@ -93,7 +93,7 @@ void NusDownloader::StartNextJob()
//DbgJoB( currentJob ); //DbgJoB( currentJob );
if( !stuff.isEmpty() ) if( !stuff.isEmpty() )
{ {
//qDebug() << "tmdJob.data size:" << hex << stuff.size(); //qDebug() << "tmdJob.data size:" << Qt::hex << stuff.size();
//DbgJoB( currentJob ); //DbgJoB( currentJob );
ReadTmdAndGetTicket( stuff ); ReadTmdAndGetTicket( stuff );
} }
@ -147,14 +147,14 @@ QByteArray NusDownloader::GetDataFromCache( const downloadJob &job )
//qDebug() << "reading data from PC"; //qDebug() << "reading data from PC";
QByteArray ret = f.readAll(); QByteArray ret = f.readAll();
f.close(); f.close();
//qDebug() << "read" << hex << ret.size() << "bytes of data from" << QFileInfo( f ).absoluteFilePath(); //qDebug() << "read" << Qt::hex << ret.size() << "bytes of data from" << QFileInfo( f ).absoluteFilePath();
return ret; return ret;
} }
//load the tmd and try to get the ticket //load the tmd and try to get the ticket
void NusDownloader::ReadTmdAndGetTicket( const QByteArray &ba ) void NusDownloader::ReadTmdAndGetTicket( const QByteArray &ba )
{ {
//qDebug() << "NusDownloader::ReadTmdAndGetTicket" << hex << ba.size(); //qDebug() << "NusDownloader::ReadTmdAndGetTicket" << Qt::hex << ba.size();
curTmd = Tmd( ba ); curTmd = Tmd( ba );
if( curTmd.Tid() != currentJob.tid ) if( curTmd.Tid() != currentJob.tid )
{ {
@ -247,7 +247,7 @@ bool NusDownloader::SaveDataToCache( const QString &path, const QByteArray &stuf
} }
f.flush(); f.flush();
f.close(); f.close();
//qDebug() << "saved" << hex << stuff.size() << "bytes to" << path; //qDebug() << "saved" << Qt::hex << stuff.size() << "bytes to" << path;
return true; return true;
} }
@ -291,7 +291,7 @@ void NusDownloader::GetNextItemForCurrentTitle()
} }
//send progress about how much of this title we already have //send progress about how much of this title we already have
int prog = (int)( (float)( (float)TitleSizeDownloaded() / (float)totalTitleSize ) * 100.0f ); int prog = (int)( (float)( (float)TitleSizeDownloaded() / (float)totalTitleSize ) * 100.0f );
//qDebug() << "titleProg:" << hex << TitleSizeDownloaded() << totalTitleSize << prog; //qDebug() << "titleProg:" << Qt::hex << TitleSizeDownloaded() << totalTitleSize << prog;
emit SendTitleProgress( prog ); emit SendTitleProgress( prog );
downloadJob appJob = CreateJob( curTmd.Cid( alreadyHave ), alreadyHave ); downloadJob appJob = CreateJob( curTmd.Cid( alreadyHave ), alreadyHave );
@ -379,14 +379,14 @@ bool NusDownloader::DecryptCheckHashAndAppendData( const QByteArray &encData, qu
//so multiple objects can be decrypting titles at the same time by different objects //so multiple objects can be decrypting titles at the same time by different objects
AesSetKey( decKey ); AesSetKey( decKey );
//qDebug() << "NusDownloader::DecryptCheckHashAndAppendData" << hex << encData.size() << idx; //qDebug() << "NusDownloader::DecryptCheckHashAndAppendData" << Qt::hex << encData.size() << idx;
QByteArray paddedEncrypted = PaddedByteArray( encData, 0x40 ); QByteArray paddedEncrypted = PaddedByteArray( encData, 0x40 );
QByteArray decData = AesDecrypt( idx, paddedEncrypted ); QByteArray decData = AesDecrypt( idx, paddedEncrypted );
decData.resize( curTmd.Size( idx ) ); decData.resize( curTmd.Size( idx ) );
QByteArray realHash = GetSha1( decData ); QByteArray realHash = GetSha1( decData );
if( realHash != curTmd.Hash( idx ) ) if( realHash != curTmd.Hash( idx ) )
{ {
qWarning() << "NusDownloader::DecryptCheckHashAndAppendData -> hash doesnt match for content" << hex << idx; qWarning() << "NusDownloader::DecryptCheckHashAndAppendData -> hash doesnt match for content" << Qt::hex << idx;
//CurrentJobErrored( tr( "Downloaded data has a different hash than expected." ) ); //CurrentJobErrored( tr( "Downloaded data has a different hash than expected." ) );
hexdump( realHash ); hexdump( realHash );
hexdump( curTmd.Hash( idx ) ); hexdump( curTmd.Hash( idx ) );

View File

@ -146,7 +146,7 @@ private:
QNetworkAccessManager manager; QNetworkAccessManager manager;
QQueue< downloadJob > downloadQueue; QQueue< downloadJob > downloadQueue;
QNetworkReply *currentDownload; QNetworkReply *currentDownload;
QTime downloadTime; QElapsedTimer downloadTime;
QString currentJobText; QString currentJobText;
downloadJob dlJob; downloadJob dlJob;

View File

@ -12,7 +12,7 @@ SettingTxtDialog::SettingTxtDialog( QWidget *parent, const QByteArray &old, qint
QString str( copy ); QString str( copy );
str.replace( "\r\n", "\n" );//maybe not needed to do this in 2 steps, but there may be some reason the file only uses "\n", so do it this way to be safe str.replace( "\r\n", "\n" );//maybe not needed to do this in 2 steps, but there may be some reason the file only uses "\n", so do it this way to be safe
QStringList parts = str.split( "\n", QString::SkipEmptyParts ); QStringList parts = str.split( "\n", Qt::SkipEmptyParts );
foreach( const QString &part, parts ) foreach( const QString &part, parts )
{ {
QString p = part; QString p = part;

View File

@ -12,7 +12,7 @@ bool SharedContentMap::Check( const QString &path )
{ {
if( !data.size() || data.size() % 28 ) if( !data.size() || data.size() % 28 )
{ {
qWarning() << "SharedContentMap::Check -> bad size" << hex << data.size(); qWarning() << "SharedContentMap::Check -> bad size" << Qt::hex << data.size();
return false; return false;
} }
@ -51,7 +51,7 @@ bool SharedContentMap::Check( const QString &path )
{ {
cid = data.mid( ( i * 28 ), 8 ); cid = data.mid( ( i * 28 ), 8 );
QString appName( cid ); QString appName( cid );
QFileInfo fi = dir.absoluteFilePath( appName + ".app" ); QFileInfo fi = QFileInfo(dir.absoluteFilePath( appName + ".app" ));
if( !fi.exists() ) if( !fi.exists() )
{ {
qWarning() << "SharedContentMap::Check -> content in the map isnt found in" << path; qWarning() << "SharedContentMap::Check -> content in the map isnt found in" << path;
@ -110,7 +110,7 @@ QString SharedContentMap::GetNextEmptyCid()
//find the lowest number cid that isnt used //find the lowest number cid that isnt used
while( cids.contains( ret ) ) while( cids.contains( ret ) )
ret++; ret++;
//qDebug() << hex << ret; //qDebug() << Qt::hex << ret;
return QString( "%1" ).arg( ret, 8, 16, QChar( '0' ) ); return QString( "%1" ).arg( ret, 8, 16, QChar( '0' ) );
} }
@ -118,7 +118,7 @@ void SharedContentMap::AddEntry( const QString &app, const QByteArray &hash )
{ {
if( app.size() != 8 || hash.size() != 20 ) if( app.size() != 8 || hash.size() != 20 )
{ {
qWarning() << "SharedContentMap::AddEntry -> bas size" << hex << app.size() << hash.size(); qWarning() << "SharedContentMap::AddEntry -> bas size" << Qt::hex << app.size() << hash.size();
return; return;
} }
data += app.toLatin1() + hash; data += app.toLatin1() + hash;

View File

@ -54,8 +54,7 @@ bool Tmd::SetIOS( quint64 ios )
bool Tmd::SetAhb( bool remove ) bool Tmd::SetAhb( bool remove )
{ {
if( !p_tmd ) if( !p_tmd ) return false;
return false;
quint32 access = qFromBigEndian( p_tmd->access_rights ); quint32 access = qFromBigEndian( p_tmd->access_rights );
if( remove ) if( remove )
@ -68,8 +67,7 @@ bool Tmd::SetAhb( bool remove )
bool Tmd::SetDiskAccess( bool allow ) bool Tmd::SetDiskAccess( bool allow )
{ {
if( !p_tmd ) if( !p_tmd ) return false;
return false;
quint32 access = qFromBigEndian( p_tmd->access_rights ); quint32 access = qFromBigEndian( p_tmd->access_rights );
if( allow ) if( allow )
@ -299,7 +297,7 @@ Ticket::Ticket( const QByteArray &stuff, bool fixKeyIndex )
qWarning() << "Ticket::Ticket -> ticket uses the korean key. Only titles encrypted with the common key are supported"; qWarning() << "Ticket::Ticket -> ticket uses the korean key. Only titles encrypted with the common key are supported";
return; return;
} }
qWarning() << "Ticket::Ticket -> key index is" << hex << *keyindex << ". Setting it to 0 and fakesigning"; qWarning() << "Ticket::Ticket -> key index is" << Qt::hex << *keyindex << ". Setting it to 0 and fakesigning";
*keyindex = 0;//anything other than 0 or 1 is probably an error. fix it *keyindex = 0;//anything other than 0 or 1 is probably an error. fix it
FakeSign(); FakeSign();
@ -316,8 +314,7 @@ quint64 Ticket::Tid()
bool Ticket::SetTid( quint64 tid ) bool Ticket::SetTid( quint64 tid )
{ {
if( !p_tik ) if( !p_tik ) return false;
return false;
p_tik->titleid = qFromBigEndian( tid ); p_tik->titleid = qFromBigEndian( tid );

View File

@ -83,14 +83,14 @@ void hexdump12( const QByteArray &d, int from, int len )
QByteArray PaddedByteArray( const QByteArray &orig, quint32 padTo ) QByteArray PaddedByteArray( const QByteArray &orig, quint32 padTo )
{ {
//qDebug() << "need to pad from" << hex << orig.size() << "to nearest" << padTo; //qDebug() << "need to pad from" << Qt::hex << orig.size() << "to nearest" << padTo;
QByteArray padding( RU( orig.size(), padTo ) - orig.size(), '\0' ); QByteArray padding( RU( orig.size(), padTo ) - orig.size(), '\0' );
return orig + padding; return orig + padding;
} }
QByteArray AesDecrypt( quint16 index, const QByteArray &source ) QByteArray AesDecrypt( quint16 index, const QByteArray &source )
{ {
//qDebug() << "AesDecrypt" << hex << index << source.size(); //qDebug() << "AesDecrypt" << Qt::hex << index << source.size();
quint8 iv[ 16 ]; quint8 iv[ 16 ];
quint16 beidx = qFromBigEndian( index ); quint16 beidx = qFromBigEndian( index );
@ -192,7 +192,7 @@ bool IsValidSave( const SaveGame &save )
} }
else //unknown attribute else //unknown attribute
{ {
qWarning() << "IsValidSave :unknown attribute" << i << hex << attr << NAND_ATTR_TYPE( attr ); qWarning() << "IsValidSave :unknown attribute" << i << Qt::hex << attr << NAND_ATTR_TYPE( attr );
return false; return false;
} }
@ -249,21 +249,6 @@ quint8 AttrFromSave( const SaveGame &save, const QString &name )
return 0; return 0;
} }
QString CleanSvnStr( const QString &orig )
{
QString ret = orig;
if( ret.isEmpty() )
return ret;
QRegExp notNum( "[^0-9]" );
QStringList parts = ret.split( notNum, QString::SkipEmptyParts );
if( parts.size() )
return parts.at( parts.size() - 1 );
return ret;
}
#define CERTS_DAT_SIZE 2560 #define CERTS_DAT_SIZE 2560
const quint8 certs_dat[ CERTS_DAT_SIZE ] = { const quint8 certs_dat[ CERTS_DAT_SIZE ] = {
0x00, 0x01, 0x00, 0x01, 0x7D, 0x9D, 0x5E, 0xBA, 0x52, 0x81, 0xDC, 0xA7, 0x06, 0x5D, 0x2F, 0x08, 0x00, 0x01, 0x00, 0x01, 0x7D, 0x9D, 0x5E, 0xBA, 0x52, 0x81, 0xDC, 0xA7, 0x06, 0x5D, 0x2F, 0x08,

View File

@ -82,9 +82,6 @@ QByteArray ReadFile( const QString &path );
//save a file to disc //save a file to disc
bool WriteFile( const QString &path, const QByteArray &ba ); bool WriteFile( const QString &path, const QByteArray &ba );
//cleanup an svn revision string
QString CleanSvnStr( const QString &orig );
#define CERTS_DAT_SIZE 2560 #define CERTS_DAT_SIZE 2560
extern const quint8 certs_dat[ CERTS_DAT_SIZE ]; extern const quint8 certs_dat[ CERTS_DAT_SIZE ];
extern const quint8 root_dat[]; extern const quint8 root_dat[];

View File

@ -16,7 +16,7 @@ bool UIDmap::Check()
{ {
if( !data.size() || data.size() % 12 ) if( !data.size() || data.size() % 12 )
{ {
qWarning() << "UIDmap::Check() bad size:" << hex << data.size(); qWarning() << "UIDmap::Check() bad size:" << Qt::hex << data.size();
return false; return false;
} }
@ -32,7 +32,7 @@ bool UIDmap::Check()
uid = qFromBigEndian( uid ); uid = qFromBigEndian( uid );
if( tid != 0x100000002ull || uid != 0x1000 )//system menu should be the first entry if( tid != 0x100000002ull || uid != 0x1000 )//system menu should be the first entry
{ {
qWarning() << "UIDmap::Check() system menu entry is messed up:" << hex << tid << uid; qWarning() << "UIDmap::Check() system menu entry is messed up:" << Qt::hex << tid << uid;
buf.close(); buf.close();
return false; return false;
} }
@ -55,7 +55,7 @@ bool UIDmap::Check()
} }
if( ( uid != 0x1000 + i ) || uids.contains( uid ) ) if( ( uid != 0x1000 + i ) || uids.contains( uid ) )
{ {
qWarning() << "UIDmap::Check() uid error:" << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) ) << hex << uid; qWarning() << "UIDmap::Check() uid error:" << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) ) << Qt::hex << uid;
buf.close(); buf.close();
return false; return false;
} }
@ -70,7 +70,7 @@ bool UIDmap::Check()
quint32 UIDmap::GetUid( quint64 id, bool autoCreate ) quint32 UIDmap::GetUid( quint64 id, bool autoCreate )
{ {
//qDebug() << "UIDmap::GetUid" << hex << id; //qDebug() << "UIDmap::GetUid" << Qt::hex << id;
quint64 tid; quint64 tid;
quint32 uid; quint32 uid;
QBuffer buf( &data ); QBuffer buf( &data );
@ -152,7 +152,7 @@ void UIDmap::CreateNew( quint8 addFactorySetupDiscs )
case 0x12:tid = qFromBigEndian( (quint64)( 0x0001000848414b00ull | reg ) ); break; case 0x12:tid = qFromBigEndian( (quint64)( 0x0001000848414b00ull | reg ) ); break;
case 0x13:tid = qFromBigEndian( 0x0001000031323200ull ); break; case 0x13:tid = qFromBigEndian( 0x0001000031323200ull ); break;
default: default:
qWarning() << "oops" << hex << i; qWarning() << "oops" << Qt::hex << i;
return; return;
break; break;
} }

View File

@ -95,7 +95,7 @@ Wad::Wad( const QByteArray &stuff )
qWarning() << "wad contains 2 different TIDs"; qWarning() << "wad contains 2 different TIDs";
quint32 cnt = t.Count(); quint32 cnt = t.Count();
//qDebug() << "Wad contains" << hex << cnt << "contents"; //qDebug() << "Wad contains" << Qt::hex << cnt << "contents";
//another quick sanity check //another quick sanity check
quint32 totalSize = 0; quint32 totalSize = 0;
@ -112,7 +112,7 @@ Wad::Wad( const QByteArray &stuff )
{ {
quint32 s = RU( t.Size( i ), 0x40 ); quint32 s = RU( t.Size( i ), 0x40 );
//qDebug() << "content" << i << "is at" << hex << pos //qDebug() << "content" << i << "is at" << Qt::hex << pos
// << "with size" << s; // << "with size" << s;
QByteArray encData = stuff.mid( pos, s ); QByteArray encData = stuff.mid( pos, s );
pos += s; pos += s;
@ -338,7 +338,7 @@ void Wad::Err( const QString &str )
const QByteArray Wad::Data( quint32 magicWord, const QByteArray &footer ) const QByteArray Wad::Data( quint32 magicWord, const QByteArray &footer )
{ {
//qDebug() << "Wad::Data" << hex << magicWord << footer.size(); //qDebug() << "Wad::Data" << Qt::hex << magicWord << footer.size();
if( !partsEnc.size() || tmdData.isEmpty() || tikData.isEmpty() || ( certData.isEmpty() && globalCert.isEmpty() ) ) if( !partsEnc.size() || tmdData.isEmpty() || tikData.isEmpty() || ( certData.isEmpty() && globalCert.isEmpty() ) )
{ {
Err( "Dont have all the parts to make a wad" ); Err( "Dont have all the parts to make a wad" );

View File

@ -1,6 +1,4 @@
#include "svnrev.h"
#include "../WiiQt/includes.h" #include "../WiiQt/includes.h"
#include "../WiiQt/nandbin.h" #include "../WiiQt/nandbin.h"
#include "../WiiQt/sharedcontentmap.h" #include "../WiiQt/sharedcontentmap.h"
@ -1323,7 +1321,6 @@ int main( int argc, char *argv[] )
qCritical() << "** nandBinCheck : Wii nand info tool **"; qCritical() << "** nandBinCheck : Wii nand info tool **";
qCritical() << " from giantpune"; qCritical() << " from giantpune";
qCritical() << " svn r:" << qPrintable( CleanSvnStr( SVN_REV_STR ) );
qCritical() << " built:" << __DATE__ << __TIME__; qCritical() << " built:" << __DATE__ << __TIME__;
if( args.contains( "-about", Qt::CaseInsensitive ) ) if( args.contains( "-about", Qt::CaseInsensitive ) )

View File

@ -45,13 +45,3 @@ HEADERS += ../WiiQt/tiktmd.h \
FORMS += \ FORMS += \
../WiiQt/settingtxtdialog.ui ../WiiQt/settingtxtdialog.ui
# create new svnrev.h
unix {
system( chmod 755 ../tools/makesvnrev.sh )
system( ../tools/makesvnrev.sh )
}
win32 {
system( "..\\tools\\SubWCRev.exe" "." "..\\tools\\svnrev_template.h" ".\\svnrev.h" )
}

View File

@ -30,13 +30,3 @@ FORMS += nandwindow.ui \
RESOURCES += \ RESOURCES += \
rc.qrc rc.qrc
# create new svnrev.h
unix {
system( chmod 755 ../tools/makesvnrev.sh )
system( ../tools/makesvnrev.sh )
}
win32 {
system( "..\\tools\\SubWCRev.exe" "." "..\\tools\\svnrev_template.h" ".\\svnrev.h" )
}

View File

@ -1,5 +1,4 @@
#include "nandwindow.h" #include "nandwindow.h"
#include "svnrev.h"
#include "ui_nandwindow.h" #include "ui_nandwindow.h"
#include "boot2infodialog.h" #include "boot2infodialog.h"
#include "../WiiQt/tools.h" #include "../WiiQt/tools.h"
@ -8,7 +7,7 @@ NandWindow::NandWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::N
{ {
ui->setupUi( this ); ui->setupUi( this );
ui->mainToolBar->setVisible( false ); ui->mainToolBar->setVisible( false );
this->setWindowTitle( "NAND Extract r" + CleanSvnStr( SVN_REV_STR ) ); this->setWindowTitle( "NAND Extract r" );
//setup the block map //setup the block map
SetUpBlockMap(); SetUpBlockMap();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -1,13 +0,0 @@
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE( rc );
QApplication a(argc, argv);
QApplication::setWindowIcon( QIcon( ":/icon.png" ) );
MainWindow w;
w.show();
return a.exec();
}

View File

@ -1,571 +0,0 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "../WiiQt/settingtxtdialog.h"
#include "../WiiQt/tiktmd.h"
#include "../WiiQt/tools.h"
#include "../WiiQt/wad.h"
MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ), nus ( this )
{
ui->setupUi(this);
ui->mainToolBar->setVisible( false );//hide toolbar for now
//resize buttons to be same size
QFontMetrics fm( fontMetrics() );
int max = fm.width( ui->pushButton_CachePathBrowse->text() );
max = MAX( max, fm.width( ui->pushButton_decFolder->text() ) );
max = MAX( max, fm.width( ui->pushButton_GetTitle->text() ) );
max = MAX( max, fm.width( ui->pushButton_nandPath->text() ) );
max = MAX( max, fm.width( ui->pushButton_wad->text() ) );
max += 15;
ui->pushButton_CachePathBrowse->setMinimumWidth( max );
ui->pushButton_decFolder->setMinimumWidth( max );
ui->pushButton_GetTitle->setMinimumWidth( max );
ui->pushButton_nandPath->setMinimumWidth( max );
ui->pushButton_wad->setMinimumWidth( max );
Wad::SetGlobalCert( QByteArray( (const char*)&certs_dat, CERTS_DAT_SIZE ) );
//connect to the nus object so we can respond to what it is saying with pretty stuff in the gui
connect( &nus, SIGNAL( SendDownloadProgress( int ) ), ui->progressBar_dl, SLOT( setValue( int ) ) );
connect( &nus, SIGNAL( SendTitleProgress( int ) ), ui->progressBar_title, SLOT( setValue( int ) ) );
connect( &nus, SIGNAL( SendTotalProgress( int ) ), ui->progressBar_whole, SLOT( setValue( int ) ) );
connect( &nus, SIGNAL( SendText( QString ) ), ui->statusBar, SLOT( showMessage( QString ) ) );
connect( &nus, SIGNAL( SendError( const QString &, const NusJob & ) ), this, SLOT( GetError( const QString &, const NusJob & ) ) );
connect( &nus, SIGNAL( SendDone() ), this, SLOT( NusIsDone() ) );
connect( &nus, SIGNAL( SendData( const NusJob & ) ), this, SLOT( ReceiveTitleFromNus( const NusJob & ) ) );
LoadSettings();
}
MainWindow::~MainWindow()
{
SaveSettings();
delete ui;
}
void MainWindow::SaveSettings()
{
QSettings s( QSettings::IniFormat, QSettings::UserScope, "WiiQt", "examples", this );
//settings specific to this program
s.beginGroup( "nusDownloader" );
//window geometry
s.setValue( "size", size() );
s.setValue( "pos", pos() );
//which radio button is selected
quint8 val = 0;
if( ui->radioButton_folder->isChecked() )
val = 1;
else if( ui->radioButton_wad->isChecked() )
val = 2;
s.setValue( "radio", val );
s.setValue( "folder", ui->lineEdit_extractPath->text() );
s.setValue( "nuswads", ui->lineEdit_wad->text() );
s.endGroup();
//settings shared in multiple programs
//paths
s.beginGroup( "paths" );
s.setValue( "nusCache", ui->lineEdit_cachePath->text() );
s.setValue( "sneek", ui->lineEdit_nandPath->text() );
s.endGroup();
}
#ifdef Q_WS_WIN
#define PATH_PREFIX QString("../..")
#else
#define PATH_PREFIX QString("..")
#endif
void MainWindow::LoadSettings()
{
QSettings s( QSettings::IniFormat, QSettings::UserScope, "WiiQt", "examples", this );
//settings specific to this program
s.beginGroup( "nusDownloader" );
resize( s.value("size", QSize( 585, 457 ) ).toSize() );
move( s.value("pos", QPoint( 2, 72 ) ).toPoint() );
quint8 radio = s.value( "radio", 0 ).toInt();
if( radio == 1 )
ui->radioButton_folder->setChecked( true );
else if( radio == 2 )
ui->radioButton_wad->setChecked( true );
ui->lineEdit_extractPath->setText( s.value( "folder", PATH_PREFIX + "/downloaded" ).toString() );
ui->lineEdit_wad->setText( s.value( "nuswads", PATH_PREFIX + "/wads" ).toString() );
s.endGroup();
//settings shared in multiple programs
s.beginGroup( "paths" );
QString cachePath = s.value( "nusCache", PATH_PREFIX + "/NUS_cache" ).toString();
QString nandPath = s.value( "sneek" ).toString();
ui->lineEdit_cachePath->setText( cachePath );
ui->lineEdit_nandPath->setText( nandPath );
if( !nandPath.isEmpty() )
nand.SetPath( QFileInfo( nandPath ).absoluteFilePath() );
if( !cachePath.isEmpty() )
nus.SetCachePath( QFileInfo( cachePath ).absoluteFilePath() );
s.endGroup();
}
//some slots to respond to the NUS downloader
void MainWindow::GetError( const QString &message, const NusJob &job )
{
QString dataStuff = QString( "%1 items:" ).arg( job.data.size() );
for( int i = 0; i < job.data.size(); i++ )
dataStuff += QString( " %1" ).arg( job.data.at( i ).size(), 0, 16, QChar( ' ' ) );
QString str = tr( "<b>Error getting title from NUS: %1</b>" ).arg( message );
QString j = QString( "NusJob( %1, %2, %3, %4 )<br>" )
.arg( job.tid, 16, 16, QChar( '0' ) )
.arg( job.version ).arg( job.decrypt ? "decrypted" : "encrypted" )
.arg( dataStuff );
ui->plainTextEdit_log->appendHtml( str );
ui->plainTextEdit_log->appendHtml( j );
}
void MainWindow::ShowMessage( const QString& mes )
{
QString str = mes + "<br>";
ui->plainTextEdit_log->appendHtml( str );
}
void MainWindow::NusIsDone()
{
QString str = tr( "NUS object is done working<br>" );
ui->plainTextEdit_log->appendHtml( str );
ui->statusBar->showMessage( tr( "Done" ), 5000 );
if( ui->radioButton_folder->isChecked() )
{
ui->lineEdit_extractPath->setEnabled( true );
ui->pushButton_decFolder->setEnabled( true );
}
else if( ui->radioButton_nand->isChecked() )
{
//check if IOS35 is present in nand dump - needed for sneek
QByteArray tmdBA = nand.GetFile( "/title/00000001/00000023/content/title.tmd" );
if( tmdBA.isEmpty() )
{
ui->plainTextEdit_log->appendHtml( tr( "IOS35 not found on nand. Getting it now...") );
nus.Get( 0x100000023ull, true );
return;
}
ui->lineEdit_nandPath->setEnabled( true );
ui->pushButton_nandPath->setEnabled( true );
//write the uid.sys and content.map to disc
ShowMessage( tr( "Flushing nand..." ) );
nand.Flush();
//make sure there is a setting.txt
QByteArray set = nand.GetSettingTxt();
if( set.isEmpty() )
{
quint8 reg = SETTING_TXT_UNK;
if( ui->lineEdit_tid->text().endsWith( "e", Qt::CaseInsensitive ) && ui->lineEdit_tid->text().size() == 4 )
reg = SETTING_TXT_PAL;
if( ui->lineEdit_tid->text().endsWith( "j", Qt::CaseInsensitive ) && ui->lineEdit_tid->text().size() == 4 )
reg = SETTING_TXT_JAP;
if( ui->lineEdit_tid->text().endsWith( "k", Qt::CaseInsensitive ) && ui->lineEdit_tid->text().size() == 4 )
reg = SETTING_TXT_KOR;
set = SettingTxtDialog::Edit( this, QByteArray(), reg );
if( !set.isEmpty() )
nand.SetSettingTxt( set );
}
/*QMap< quint64, quint16 > t = nand.GetInstalledTitles();
QMap< quint64, quint16 >::iterator i = t.begin();
while( i != t.end() )
{
QString title = QString( "%1v%2" ).arg( i.key(), 16, 16, QChar( '0' ) ).arg( i.value() );
qDebug() << "title:" << title;
i++;
}*/
}
else if( ui->radioButton_wad->isChecked() )
{
ui->lineEdit_wad->setEnabled( true );
ui->pushButton_wad->setEnabled( true );
}
ui->radioButton_folder->setEnabled( true );
ui->radioButton_nand->setEnabled( true );
ui->radioButton_wad->setEnabled( true );
}
void MainWindow::ReceiveTitleFromNus( const NusJob &job )
{
QString str = tr( "Received a completed download from NUS" );
QString title = QString( "%1v%2" ).arg( job.tid, 16, 16, QChar( '0' ) ).arg( job.version );
ui->plainTextEdit_log->appendHtml( str );
//do something with the data we got
if( ui->radioButton_folder->isChecked() )//copy its decrypted contents to a folder
{
SaveJobToFolder( job );
}
else if( ui->radioButton_nand->isChecked() )//install this title to a decrypted nand dump for sneek/dolphin
{
bool ok = nand.InstallNusItem( job );
if( ok )
ShowMessage( tr( "Installed %1 title to nand" ).arg( title ) );
else
ShowMessage( tr( "<b>Error installing %1 title to nand</b>" ).arg( title ) );
}
else if( ui->radioButton_wad->isChecked() )
{
SaveJobToWad( job );
}
}
//clicked the button to get a title
void MainWindow::on_pushButton_GetTitle_clicked()
{
bool ok = false;
bool wholeUpdate = false;
quint64 tid = 0;
quint32 ver = 0;
if( ui->lineEdit_tid->text().size() == 4 )
{
wholeUpdate = true;
}
else
{
tid = ui->lineEdit_tid->text().toLongLong( &ok, 16 );
if( !ok )
{
ShowMessage( "<b>Error converting \"" + ui->lineEdit_tid->text() + "\" to a hex number.</b>" );
return;
}
ver = TITLE_LATEST_VERSION;
if( !ui->lineEdit_version->text().isEmpty() )
{
ver = ui->lineEdit_version->text().toInt( &ok, 10 );
if( !ok )
{
ShowMessage( "<b>Error converting \"" + ui->lineEdit_version->text() + "\" to a decimal number.</b>" );
return;
}
if( ver > 0xffff )
{
ShowMessage( tr( "<b>Version %1 is too high. Max is 65535</b>" ).arg( ver ) );
return;
}
}
}
//decide how we want nus to give us the title
bool decrypt = true;
if( ui->radioButton_folder->isChecked() )
{
if( ui->lineEdit_extractPath->text().isEmpty() )
{
ShowMessage( tr( "<b>No path given to save downloads in.</b>" ) );
return;
}
ui->lineEdit_extractPath->setEnabled( false );
ui->pushButton_decFolder->setEnabled( false );
}
else if( ui->radioButton_nand->isChecked() )
{
if( nand.GetPath() != ui->lineEdit_nandPath->text() && !nand.SetPath( ui->lineEdit_nandPath->text() ) )
{
ShowMessage( tr( "<b>Error setting the basepath of the nand to %1</b>" )
.arg( QFileInfo( ui->lineEdit_nandPath->text() ).absoluteFilePath() ) );
return;
}
if( ui->lineEdit_nandPath->text().isEmpty() )
{
ShowMessage( tr( "<b>No path given for nand dump base.</b>" ) );
return;
}
ui->lineEdit_nandPath->setEnabled( false );
ui->pushButton_nandPath->setEnabled( false );
}
else if( ui->radioButton_wad->isChecked() )
{
if( ui->lineEdit_wad->text().isEmpty() )
{
ShowMessage( tr( "<b>No path given to save wads in.</b>" ) );
return;
}
decrypt = false;
ui->lineEdit_wad->setEnabled( false );
ui->pushButton_wad->setEnabled( false );
}
ui->radioButton_folder->setEnabled( false );
ui->radioButton_nand->setEnabled( false );
ui->radioButton_wad->setEnabled( false );
//dont set these to 0 in case the button is pressed while something else is already being downloaded
//ui->progressBar_dl->setValue( 0 );
//ui->progressBar_title->setValue( 0 );
//ui->progressBar_whole->setValue( 0 );
nus.SetCachePath( QFileInfo( ui->lineEdit_cachePath->text() ).absoluteFilePath() );
if( wholeUpdate )
{
if( !nus.GetUpdate( ui->lineEdit_tid->text(), decrypt ) )
{
ShowMessage( tr( "<b>I dont know the titles that were in the %1 update</b>" ).arg( ui->lineEdit_tid->text() ) );
return;
}
}
else
{
nus.Get( tid, decrypt, ver );
}
}
//ratio buttons toggled
void MainWindow::on_radioButton_nand_toggled( bool checked )
{
ui->lineEdit_nandPath->setEnabled( checked );
ui->pushButton_nandPath->setEnabled( checked );
}
void MainWindow::on_radioButton_folder_toggled( bool checked )
{
ui->lineEdit_extractPath->setEnabled( checked );
ui->pushButton_decFolder->setEnabled( checked );
}
void MainWindow::on_radioButton_wad_toggled( bool checked )
{
ui->lineEdit_wad->setEnabled( checked );
ui->pushButton_wad->setEnabled( checked );
}
//search for a path to use as the nand basepath
void MainWindow::on_pushButton_nandPath_clicked()
{
QString path = ui->lineEdit_nandPath->text().isEmpty() ? "/media" : ui->lineEdit_nandPath->text();
QString f = QFileDialog::getExistingDirectory( this, tr( "Select Nand Base Folder" ), path );
if( f.isEmpty() )
return;
ui->lineEdit_nandPath->setText( f );
nus.SetCachePath( ui->lineEdit_cachePath->text() );
}
void MainWindow::on_pushButton_decFolder_clicked()
{
QString path = ui->lineEdit_extractPath->text().isEmpty() ? QDir::currentPath() : ui->lineEdit_extractPath->text();
QString f = QFileDialog::getExistingDirectory( this, tr( "Select folder to save decrypted titles" ), path );
if( f.isEmpty() )
return;
ui->lineEdit_extractPath->setText( f );
}
void MainWindow::on_pushButton_wad_clicked()
{
QString path = ui->lineEdit_wad->text().isEmpty() ? QDir::currentPath() : ui->lineEdit_wad->text();
QString f = QFileDialog::getExistingDirectory( this, tr( "Select folder to save wads to" ), path );
if( f.isEmpty() )
return;
ui->lineEdit_wad->setText( f );
}
//nand-dump -> setting.txt
void MainWindow::on_actionSetting_txt_triggered()
{
if( nand.GetPath() != ui->lineEdit_nandPath->text() && !nand.SetPath( ui->lineEdit_nandPath->text() ) )
{
ShowMessage( tr( "<b>Error setting the basepath of the nand to %1</b>" )
.arg( QFileInfo( ui->lineEdit_nandPath->text() ).absoluteFilePath() ) );
return;
}
QByteArray ba = nand.GetSettingTxt(); //read the current setting.txt
ba = SettingTxtDialog::Edit( this, ba ); //call a dialog to edit that existing file and store the result in the same bytearray
if( !ba.isEmpty() ) //if the dialog returned anything ( cancel wasnt pressed ) write that new setting.txt to the nand dump
nand.SetSettingTxt( ba );
}
//nand-dump -> flush
void MainWindow::on_actionFlush_triggered()
{
if( !nand.GetPath().isEmpty() )
nand.Flush();
}
//nand-dump -> ImportWad
void MainWindow::on_actionImportWad_triggered()
{
if( nand.GetPath() != ui->lineEdit_nandPath->text() &&
!nand.SetPath( ui->lineEdit_nandPath->text() ) )
{
ShowMessage( tr( "<b>Error setting the basepath of the nand to %1</b>" ).arg( QFileInfo( ui->lineEdit_nandPath->text() ).absoluteFilePath() ) );
return;
}
QString path = ui->lineEdit_wad->text().isEmpty() ?
QCoreApplication::applicationDirPath() : ui->lineEdit_wad->text();
QString fn = QFileDialog::getOpenFileName( this,
tr("Wad files(*.wad)"),
path,
tr("WadFiles (*.wad)"));
if(fn == "") return;
QByteArray data = ReadFile( fn );
if( data.isEmpty() )
return;
Wad wad(data);
if( !wad.IsOk() ) {
ShowMessage( tr( "Wad data not ok" ) );;
return;
}
bool ok = nand.InstallWad( wad );
if( ok )
ShowMessage( tr( "Installed %1 title to nand" ).arg( wad.WadName() ) );
else
ShowMessage( tr( "<b>Error %1 title to nand</b>" ).arg( wad.WadName() ) );
}
//save a NUS job to a folder
void MainWindow::SaveJobToFolder( NusJob job )
{
QString title = QString( "%1v%2" ).arg( job.tid, 16, 16, QChar( '0' ) ).arg( job.version );
QFileInfo fi( ui->lineEdit_extractPath->text() );
if( fi.isFile() )
{
ShowMessage( "<b>" + ui->lineEdit_extractPath->text() + " is a file. I need a folder<\b>" );
return;
}
if( !fi.exists() )
{
ShowMessage( "<b>" + fi.absoluteFilePath() + " is not a folder!\nTrying to create it...<\b>" );
if( !QDir().mkpath( fi.absoluteFilePath() ) )
{
ShowMessage( "<b>Failed to make the directory!<\b>" );
return;
}
}
QString newFName = title;
int i = 1;
while( QFileInfo( fi.absoluteFilePath() + "/" + newFName ).exists() )//find a folder that doesnt exist and try to create it
{
newFName = QString( "%1 (copy%2)" ).arg( title ).arg( i++ );
}
if( !QDir().mkpath( fi.absoluteFilePath() + "/" + newFName ) )
{
ShowMessage( "<b>Can't create" + fi.absoluteFilePath() + "/" + newFName + " to save this title into!<\b>" );
return;
}
//start writing all this stuff to the HDD
QDir d( fi.absoluteFilePath() + "/" + newFName );
QByteArray tmdDat = job.data.takeFirst(); //remember the tmd and use it for getting the names of the .app files
if( !WriteFile( d.absoluteFilePath( "title.tmd" ), tmdDat ) )
{
ShowMessage( "<b>Error writing " + d.absoluteFilePath( "title.tmd" ) + "!<\b>" );
return;
}
if( !WriteFile( d.absoluteFilePath( "cetk" ), job.data.takeFirst() ) )
{
ShowMessage( "<b>Error writing " + d.absoluteFilePath( "cetk" ) + "!<\b>" );
return;
}
Tmd t( tmdDat );
quint16 cnt = t.Count();
if( job.data.size() != cnt )
{
ShowMessage( "<b>Error! Number of contents in the TMD dont match the number received from NUS!<\b>" );
return;
}
for( quint16 i = 0; i < cnt; i++ )//write all the contents in the new folder. if the job is decrypted, append ".app" to the end of their names
{
QString appName = t.Cid( i );
QByteArray stuff = job.data.takeFirst();
if( job.decrypt )
{
appName += ".app";
//qDebug() << "resizing from" << hex << stuff.size() << "to" << (quint32)t.Size( i );
//stuff.resize( t.Size( i ) );
}
if( !WriteFile( d.absoluteFilePath( appName ), stuff ) )
{
ShowMessage( "<b>Error writing " + d.absoluteFilePath( appName ) + "!<\b>" );
return;
}
}
ShowMessage( tr( "Wrote title to %1" ).arg( fi.absoluteFilePath() + "/" + newFName ) );
}
//save a completed job to wad
void MainWindow::SaveJobToWad( NusJob job )
{
QString title = QString( "%1v%2" ).arg( job.tid, 16, 16, QChar( '0' ) ).arg( job.version );
Wad wad( job.data );
if( !wad.IsOk() )
{
ShowMessage( "<b>Error making a wad from " + title + "<\b>" );
return;
}
QFileInfo fi( ui->lineEdit_wad->text() );
if( fi.isFile() )
{
ShowMessage( "<b>" + ui->lineEdit_wad->text() + " is a file. I need a folder<\b>" );
return;
}
if( !fi.exists() )
{
ShowMessage( "<b>" + fi.absoluteFilePath() + " is not a folder!\nTrying to create it...<\b>" );
if( !QDir().mkpath( ui->lineEdit_wad->text() ) )
{
ShowMessage( "<b>Failed to make the directory!<\b>" );
return;
}
}
QByteArray w = wad.Data();
if( w.isEmpty() )
{
ShowMessage( "<b>Error creating wad<br>" + wad.LastError() + "<\b>" );
return;
}
QString name = wad.WadName( fi.absoluteFilePath() );
if( name.isEmpty() )
{
name = QFileDialog::getSaveFileName( this, tr( "Filename for %1" ).arg( title ), fi.absoluteFilePath() );
if( name.isEmpty() )
{
ShowMessage( "<b>No save name given, aborting<\b>" );
return;
}
}
QFile file( fi.absoluteFilePath() + "/" + name );
if( !file.open( QIODevice::WriteOnly ) )
{
ShowMessage( "<b>Cant open " + fi.absoluteFilePath() + "/" + name + " for writing<\b>" );
return;
}
file.write( w );
file.close();
ShowMessage( "Saved " + title + " to " + fi.absoluteFilePath() + "/" + name );
}
void MainWindow::on_pushButton_CachePathBrowse_clicked()
{
QString f = QFileDialog::getExistingDirectory( this, tr( "Select NUS Cache base folder" ) );
if( f.isEmpty() )
return;
ui->lineEdit_cachePath->setText( f );
nus.SetCachePath( ui->lineEdit_cachePath->text() );
}

View File

@ -1,59 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "../WiiQt/includes.h"
#include "../WiiQt/nusdownloader.h"
#include "../WiiQt/nanddump.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow( QWidget *parent = 0 );
~MainWindow();
private:
Ui::MainWindow *ui;
NusDownloader nus;
NandDump nand;
void ShowMessage( const QString& mes );
//do something with a completed download
void SaveJobToFolder( NusJob job );
void SaveJobToWad( NusJob job );
//settings
void SaveSettings();
void LoadSettings();
public slots:
//slots for getting info from the NUS downloader
void GetError( const QString &message, const NusJob &job );
void NusIsDone();
void ReceiveTitleFromNus( const NusJob &job );
private slots:
void on_pushButton_CachePathBrowse_clicked();
void on_actionFlush_triggered();
void on_actionSetting_txt_triggered();
void on_actionImportWad_triggered();
void on_pushButton_wad_clicked();
void on_pushButton_decFolder_clicked();
void on_pushButton_nandPath_clicked();
void on_radioButton_wad_toggled(bool checked);
void on_radioButton_folder_toggled(bool checked);
void on_radioButton_nand_toggled(bool checked);
void on_pushButton_GetTitle_clicked();
};
#endif // MAINWINDOW_H

View File

@ -1,262 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>585</width>
<height>457</height>
</rect>
</property>
<property name="windowTitle">
<string>QtShitGetter</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_tid">
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>16</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4_version">
<property name="text">
<string>v</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_version">
<property name="maximumSize">
<size>
<width>107</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_GetTitle">
<property name="text">
<string>Get It!</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEdit_cachePath"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_CachePathBrowse">
<property name="text">
<string>Local Cache</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_progDl">
<property name="text">
<string>Download</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QProgressBar" name="progressBar_dl">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_progTitle">
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QProgressBar" name="progressBar_title">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_progTotal">
<property name="text">
<string>Total</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QProgressBar" name="progressBar_whole">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_nand">
<property name="text">
<string>Nand</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_nandPath"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_nandPath">
<property name="text">
<string>Search...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_folder">
<property name="text">
<string>Folder</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_extractPath">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_decFolder">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Search...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radioButton_wad">
<property name="text">
<string>Wad</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_wad">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_wad">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Search...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit_log"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>585</width>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="menuNand_Dump">
<property name="title">
<string>Nand Dump</string>
</property>
<addaction name="actionSetting_txt"/>
<addaction name="actionFlush"/>
<addaction name="actionImportWad"/>
<addaction name="actionImportFolder"/>
</widget>
<addaction name="menuNand_Dump"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionSetting_txt">
<property name="text">
<string>Setting.txt...</string>
</property>
</action>
<action name="actionFlush">
<property name="text">
<string>Flush</string>
</property>
</action>
<action name="actionImportWad">
<property name="text">
<string>Import Wad</string>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
</property>
</action>
<action name="actionImportFolder">
<property name="text">
<string>Import Folder</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -1,41 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2010-12-02T23:30:12
#
#-------------------------------------------------
QT += core gui network widgets
TARGET = nand
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
../WiiQt/tools.cpp \
../WiiQt/sharedcontentmap.cpp \
../WiiQt/tiktmd.cpp \
../WiiQt/nusdownloader.cpp \
../WiiQt/uidmap.cpp \
../WiiQt/nanddump.cpp \
../WiiQt/settingtxtdialog.cpp \
../WiiQt/wad.cpp \
../WiiQt/aes.c \
../WiiQt/sha1.c
HEADERS += mainwindow.h \
../WiiQt/tools.h \
../WiiQt/uidmap.h \
../WiiQt/sharedcontentmap.h \
../WiiQt/tiktmd.h \
../WiiQt/nusdownloader.h \
../WiiQt/uidmap.h \
../WiiQt/nanddump.h \
../WiiQt/settingtxtdialog.h \
../WiiQt/wad.h
FORMS += mainwindow.ui \
../WiiQt/settingtxtdialog.ui
RESOURCES += \
rc.qrc

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>icon.png</file>
</qresource>
</RCC>

View File

@ -1,5 +0,0 @@
this program downloads files from NUS. currently it supports installing them to an extracted nand dump for use in sneek/dolphin.
downloaded files can be cached to a local file so next time you try to download that title, you wont need to get it from NUS.
TODO...
saving content to a seperate folder and packing wads is only partially done

View File

@ -1,6 +1,5 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "newnandbin.h" #include "newnandbin.h"
#include "svnrev.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "../WiiQt/settingtxtdialog.h" #include "../WiiQt/settingtxtdialog.h"
@ -30,10 +29,10 @@ MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::M
//resize buttons to be same size //resize buttons to be same size
QFontMetrics fm( fontMetrics() ); QFontMetrics fm( fontMetrics() );
int max = fm.width( ui->pushButton_CachePathBrowse->text() ); int max = fm.horizontalAdvance( ui->pushButton_CachePathBrowse->text() );
max = MAX( max, fm.width( ui->pushButton_GetTitle->text() ) ); max = MAX( max, fm.horizontalAdvance( ui->pushButton_GetTitle->text() ) );
max = MAX( max, fm.width( ui->pushButton_initNand->text() ) ); max = MAX( max, fm.horizontalAdvance( ui->pushButton_initNand->text() ) );
max = MAX( max, fm.width( ui->pushButton_nandPath->text() ) ); max = MAX( max, fm.horizontalAdvance( ui->pushButton_nandPath->text() ) );
max += 20; max += 20;
ui->pushButton_CachePathBrowse->setFixedWidth( max ); ui->pushButton_CachePathBrowse->setFixedWidth( max );
@ -628,7 +627,7 @@ bool MainWindow::InstallNUSItem( NusJob job )
quint16 cnt; quint16 cnt;
bool deleted = false; bool deleted = false;
QTreeWidgetItem *content; QTreeWidgetItem *content;
if( !job.tid || !job.data.size() > 2 ) if( !job.tid || !(job.data.size() > 2) )
{ {
qWarning() << "bad sizes"; qWarning() << "bad sizes";
ShowMessage( "<b>Error installing title " + title + " to nand</b>" ); ShowMessage( "<b>Error installing title " + title + " to nand</b>" );
@ -773,7 +772,7 @@ bool MainWindow::InstallNUSItem( NusJob job )
} }
else else
{ {
qWarning() << "type" << hex << t.Type( i ); qWarning() << "type" << Qt::hex << t.Type( i );
goto error; goto error;
} }
} }
@ -795,7 +794,7 @@ void MainWindow::on_actionAbout_triggered()
"<br><br>IT SHOULD ONLY BE USED BY PEOPLE THAT KNOW HOW TO VERIFY THE FILES IT PRODUCES. AND HAVE A WAY TO FIX A BRICKED WII SHOULD THIS PROGRAM HAVE BUGS" "<br><br>IT SHOULD ONLY BE USED BY PEOPLE THAT KNOW HOW TO VERIFY THE FILES IT PRODUCES. AND HAVE A WAY TO FIX A BRICKED WII SHOULD THIS PROGRAM HAVE BUGS"
"<br><br>YOU HAVE BEEN WARNED" "<br><br>YOU HAVE BEEN WARNED"
"<br>giantpune" ); "<br>giantpune" );
QMessageBox::critical( this, tr( "svn r%1" ).arg( CleanSvnStr( SVN_REV_STR ) ), txt ); QMessageBox::critical( this, tr( "NUS NAND Builder" ), txt );
} }
#if 0 #if 0
@ -1008,7 +1007,7 @@ void MainWindow::on_actionFormat_triggered()
tid = qFromBigEndian( tid ); tid = qFromBigEndian( tid );
quint32 upper = ( ( tid >> 32 ) & 0xffffffff ); quint32 upper = ( ( tid >> 32 ) & 0xffffffff );
quint32 lower = ( tid & 0xffffffff ); quint32 lower = ( tid & 0xffffffff );
//qDebug() << hex << i << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) ) << upper << lower << QChar( ( lower >> 24 ) & 0xff ) << ( lower & 0xffffff00 ); //qDebug() << Qt::hex << i << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) ) << upper << lower << QChar( ( lower >> 24 ) & 0xff ) << ( lower & 0xffffff00 );
if( ( upper == 0x10001 && ( ( lower >> 24 ) & 0xff ) != 0x48 ) || //a channel, not starting with 'H' if( ( upper == 0x10001 && ( ( lower >> 24 ) & 0xff ) != 0x48 ) || //a channel, not starting with 'H'
lower == 0x48415858 || //original HBC lower == 0x48415858 || //original HBC
tid == 0x100000000ull || //bannerbomb -> ATD ( or any other program that uses the SU tid ) tid == 0x100000000ull || //bannerbomb -> ATD ( or any other program that uses the SU tid )

View File

@ -232,7 +232,7 @@ void NewNandBin::on_pushButton_badBlockFile_clicked()
ui->listWidget_badBlocks->clear(); ui->listWidget_badBlocks->clear();
str.replace( "\r\n", "\n" ); str.replace( "\r\n", "\n" );
QStringList lines = str.split( "\n", QString::SkipEmptyParts ); QStringList lines = str.split( "\n", Qt::SkipEmptyParts );
foreach( const QString &line, lines ) foreach( const QString &line, lines )
{ {
if( line.size() > 5 ) if( line.size() > 5 )
@ -307,7 +307,7 @@ void NewNandBin::on_pushButton_oldNand_clicked()
} }
QList<quint16> clusters = old.GetFats(); QList<quint16> clusters = old.GetFats();
QList<quint16> badBlacks; QList<quint16> badBlacks;
if( !clusters.size() == 0x8000 ) if( !(clusters.size() == 0x8000) )
{ {
QMessageBox::warning( this, tr( "Error" ), \ QMessageBox::warning( this, tr( "Error" ), \
tr( "Expected 0x8000 clusters from the nand, but got %1 instead!" ).arg( clusters.size(), 0, 16 ), QMessageBox::Ok ); tr( "Expected 0x8000 clusters from the nand, but got %1 instead!" ).arg( clusters.size(), 0, 16 ), QMessageBox::Ok );
@ -317,13 +317,13 @@ void NewNandBin::on_pushButton_oldNand_clicked()
} }
for( quint16 i = 0; i < 0x8000; i += 8 )//first cluster of each block. for( quint16 i = 0; i < 0x8000; i += 8 )//first cluster of each block.
{ {
//qDebug() << hex << i << clusters.at( i ); //qDebug() << Qt::hex << i << clusters.at( i );
if( clusters.at( i ) == 0xFFFD ) if( clusters.at( i ) == 0xFFFD )
{ {
quint16 block = ( i / 8 ); quint16 block = ( i / 8 );
badBlacks << block; badBlacks << block;
QString txt = QString( "%1" ).arg( block ); QString txt = QString( "%1" ).arg( block );
//qDebug() << "bad cluster" << hex << i << block << txt; //qDebug() << "bad cluster" << Qt::hex << i << block << txt;
//if( ui->listWidget_badBlocks->findItems( txt, Qt::MatchExactly ).isEmpty() )//just in case, but this should always be true //if( ui->listWidget_badBlocks->findItems( txt, Qt::MatchExactly ).isEmpty() )//just in case, but this should always be true
ui->listWidget_badBlocks->addItem( txt ); ui->listWidget_badBlocks->addItem( txt );
} }
@ -355,7 +355,7 @@ QByteArray NewNandBin::GetCleanUid( QByteArray old )
tid = qFromBigEndian( tid ); tid = qFromBigEndian( tid );
quint32 upper = ( ( tid >> 32 ) & 0xffffffff ); quint32 upper = ( ( tid >> 32 ) & 0xffffffff );
quint32 lower = ( tid & 0xffffffff ); quint32 lower = ( tid & 0xffffffff );
//qDebug() << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) ) << hex << upper << lower << ( ( lower >> 24 ) & 0xff ) << ( lower & 0xffff00 ); //qDebug() << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) ) << Qt::hex << upper << lower << ( ( lower >> 24 ) & 0xff ) << ( lower & 0xffff00 );
if( ( upper == 0x10001 && ( ( lower >> 24 ) & 0xff ) != 0x48 ) || //a channel, not starting with 'H' if( ( upper == 0x10001 && ( ( lower >> 24 ) & 0xff ) != 0x48 ) || //a channel, not starting with 'H'
lower == 0x48415858 || //original HBC lower == 0x48415858 || //original HBC
tid == 0x100000000ull || //bannerbomb -> ATD ( or any other program that uses the SU tid ) tid == 0x100000000ull || //bannerbomb -> ATD ( or any other program that uses the SU tid )

View File

@ -41,14 +41,3 @@ FORMS += mainwindow.ui \
../WiiQt/settingtxtdialog.ui \ ../WiiQt/settingtxtdialog.ui \
newnandbin.ui newnandbin.ui
RESOURCES += rc.qrc RESOURCES += rc.qrc
# create new svnrev.h
unix {
system( chmod 755 ../tools/makesvnrev.sh )
system( ../tools/makesvnrev.sh )
}
win32 {
system( "..\\tools\\SubWCRev.exe" "." "..\\tools\\svnrev_template.h" ".\\svnrev.h" )
}

Binary file not shown.

View File

@ -1,6 +0,0 @@
REV=`svnversion -n .`
echo $REV
cat > ./svnrev.h <<EOF
#define SVN_REV $REV
#define SVN_REV_STR "$REV"
EOF

View File

@ -1,2 +0,0 @@
#define SVN_REV $WCREV$
#define SVN_REV_STR "$WCMODS?$WCREV$M:$WCREV$$"