From 1b86844eb49b90b088e35d78a43cdb7f04e4f3d7 Mon Sep 17 00:00:00 2001 From: "giantpune@gmail.com" Date: Sun, 12 Dec 2010 11:48:51 +0000 Subject: [PATCH] changes to the nandExtractor... * add more info at the bottom of the block map including free space, key, and file details * make the blocks a bit smaller so the screen doesnt need to be quite as freakin huge * blockmap is hidable and resizable --- nandExtract/black.png | Bin 2913 -> 2883 bytes nandExtract/blue.png | Bin 2979 -> 2927 bytes nandExtract/green.png | Bin 2917 -> 2883 bytes nandExtract/grey.png | Bin 2926 -> 2882 bytes nandExtract/nandwindow.cpp | 153 +++++++++++++++++++++++++++--------- nandExtract/nandwindow.h | 21 +++-- nandExtract/nandwindow.ui | 155 ++++++++++++++++++++++--------------- nandExtract/pink.png | Bin 2939 -> 2897 bytes 8 files changed, 225 insertions(+), 104 deletions(-) diff --git a/nandExtract/black.png b/nandExtract/black.png index 060039de976dca86cffd8d198494e634970d94b6..512bae26ae03c6c6156c9a32808408059f8fdca4 100755 GIT binary patch delta 175 zcmaDTc34cYGr-TCmrII^fq{Y7)59eQNOOQN2NRI=&egoLQE@(3eV(U_V@Sm7U32liBL{Q4GJ0x0000DNk~Le0000A0000A2m$~A00K~0>aii83V)1A zL_t(|+Dwi?ZpBax0?BXAllxz-HVj?leW@dPWf*Zi&trS-o!Qynncdml-L><9wk=4d zm8$ooOZp^EQV4B<7W#J7+jf$~*bsVjRV&@QLvUi-4oMP9soHyHOC2Y9ML4G-r_cBaii83V+T? zL_t(|+62K_PQySD1kmcmm_!62F2WaQ=5m0@YI&xsn)mGU<16zNzQUrL;$FJVd7krk z%%6N(-Xl*D2S*4ZA6^R@-6idrdCGjtJUUV++A;z4pf-;~MjSGZnXhh(G|TfTX$fTP9U$$Qmx&U4k}e*iRa Vr^C$_Vw?Z~002ovPDHLkV1i9rcWwXx diff --git a/nandExtract/green.png b/nandExtract/green.png index e83e3b96e707d125316e02f6d32abd026103e655..62d6ffbe2a11b2a5f033c33cfb6af30821e0461d 100755 GIT binary patch delta 175 zcmaDVc34cYGr-TCmrII^fq{Y7)59eQNOOQN2NRI=&egoLQE@(3eV(U_V@Sm+o)62Z9q}*__m-M@No7w&VCNNyN+XW&tbf6e&vv&Lc+X#y?)oY5!OZ=P a471;we%utj;}Xyb44$rjE-dSu5}E)j=tV04 delta 209 zcmV;?051Q-7UdQpiBL{Q4GJ0x0000DNk~Le0000A0000A2m$~A00K~0>aii83V)DE zL_t(|+BD8fa>76mz|c3Q4TQkSb6Usc@ps%=1gf->HY$F?izjzF8Y>e+8iWT=Ufc;9 z6&$R>l^b7t6U9NMgSoisbm_u{;6V^{|718hY3$T=(7fd-Y%KI7QM5F(u%%6?1lZ~F zbDk=TFn-#Nj*~4_Mke8xmR9;t-X@uu7=wmRHv=i`y4w{WoOK{b1_Hl8_u7} aXGoN*;z>W-x(Db222WQ%mvzie2~7apEk@%2 delta 218 zcmV<0044vz7VZ`yiBL{Q4GJ0x0000DNk~Le0000A0000A2m$~A00K~0>aii83V)eN zL_t(|+ANMSjsrjt!ho6omwD{%09Pc98_SaU`Fv((q>^Zp*uJ}W@BQ7*%o$vPDlO=sE(%NzCd-wc500V}q U_P_FfSO5S307*qoM6N<$f^u46P5=M^ diff --git a/nandExtract/nandwindow.cpp b/nandExtract/nandwindow.cpp index 3c00a2a..4a5303a 100755 --- a/nandExtract/nandwindow.cpp +++ b/nandExtract/nandwindow.cpp @@ -1,39 +1,18 @@ #include "nandwindow.h" #include "ui_nandwindow.h" +#include "../WiiQt/tools.h" NandWindow::NandWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::NandWindow ), nThread( this ) { ui->setupUi( this ); - freeSpace = 0; //setup the block map - ui->graphicsView_blocks->setScene( &gv ); - ui->graphicsView_blocks->setAlignment( Qt::AlignRight ); - ui->graphicsView_blocks->setRenderHint( QPainter::Antialiasing ); - - QPixmap blue( ":/blue.png" ); - QPixmap green( ":/green.png" ); - QPixmap pink( ":/pink.png" ); - QPixmap grey( ":/grey.png" ); - - quint16 i = 0; - for( quint16 y = 0; y < 352; y += 11 ) - { - for( quint16 x = 0; x < 1408; x += 11 ) - { - pmi[ i ] = new QGraphicsPixmapItem( grey ); - pmi[ i ]->setPos( x, y ); - gv.addItem( pmi[ i ] );//items belong to this now. no need to delete them - - i++; - } - } + SetUpBlockMap(); //put the progressbar on the status bar ui->progressBar->setVisible( false ); ui->statusBar->addPermanentWidget( ui->progressBar, 0 ); - //ui->treeWidget->header()->resizeSection( 0, 300 );//name QFontMetrics fm( fontMetrics() ); ui->treeWidget->header()->resizeSection( 0, fm.width( QString( 22, 'W' ) ) );//name ui->treeWidget->header()->resizeSection( 1, fm.width( "WWWWW" ) );//entry # @@ -44,13 +23,11 @@ NandWindow::NandWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::N ui->treeWidget->header()->resizeSection( 6, fm.width( "WWWWW" ) );//mode ui->treeWidget->header()->resizeSection( 7, fm.width( "WWWWW" ) );//attr - - //connect( &nandBin, SIGNAL( SendError( QString ) ), this, SLOT( GetError( QString ) ) ); - //connect( &nandBin, SIGNAL( SendText( QString ) ), this, SLOT( GetStatusUpdate( QString ) ) ); connect( &nThread, SIGNAL( SendError( QString ) ), this, SLOT( GetError( QString ) ) ); connect( &nThread, SIGNAL( SendText( QString ) ), this, SLOT( GetStatusUpdate( QString ) ) ); connect( &nThread, SIGNAL( SendExtractDone() ), this, SLOT( ThreadIsDone() ) ); connect( &nThread, SIGNAL( SendProgress( int ) ), ui->progressBar, SLOT( setValue( int ) ) ); + } NandWindow::~NandWindow() @@ -58,6 +35,80 @@ NandWindow::~NandWindow() delete ui; } +void NandWindow::SetUpBlockMap() +{ + ui->graphicsView_blocks->setScene( &gv ); + + QPixmap grey( ":/grey.png" ); + + quint16 i = 0; + for( quint16 y = 0; y < 288; y += 9 ) //create all the blocks and make them grey + { + for( quint16 x = 0; x < 1152; x += 9 ) + { + pmi[ i ] = new QGraphicsPixmapItem( grey ); + pmi[ i ]->setPos( x, y ); + gv.addItem( pmi[ i ] );//items belong to this now. no need to delete them + + i++; + } + } + QFontMetrics fm( fontMetrics() ); + + quint16 y = 288; + quint16 x = 10; + quint16 x2 = 200; + quint8 spacing = 5; + + fileSize = new QGraphicsTextItem(); + fileSize->setPos( x, y ); + nandSize = new QGraphicsTextItem(); + nandSize->setPos( x + 400, y ); + + y += fm.height() + 2; + + QGraphicsTextItem *badText = new QGraphicsTextItem( tr( "Bad" ) ); + QGraphicsTextItem *freeText = new QGraphicsTextItem( tr( "Free" ) ); + QGraphicsTextItem *usedText = new QGraphicsTextItem( tr( "Used" ) ); + QGraphicsTextItem *used2Text = new QGraphicsTextItem( tr( "Selected file" ) ); + QGraphicsTextItem *resText = new QGraphicsTextItem( tr( "Reserved" ) ); + + QGraphicsPixmapItem *greySquare = new QGraphicsPixmapItem( grey ); + QGraphicsPixmapItem *blackSquare = new QGraphicsPixmapItem( QPixmap( ":/black.png" ) ); + QGraphicsPixmapItem *blueSquare = new QGraphicsPixmapItem( QPixmap( ":/blue.png" ) ); + QGraphicsPixmapItem *greenSquare = new QGraphicsPixmapItem( QPixmap( ":/green.png" ) ); + QGraphicsPixmapItem *pinkSquare = new QGraphicsPixmapItem( QPixmap( ":/pink.png" ) ); + + greySquare->setPos( x, y + fm.height() / 2 ); + freeText->setPos( greySquare->pos().x() + 8 + spacing, y ); + greenSquare->setPos( x2, y + fm.height() / 2 ); + usedText->setPos( greenSquare->pos().x() + 8 + spacing, y ); + y += fontMetrics().height() + 2; + + blackSquare->setPos( x, y + fm.height() / 2 ); + badText->setPos( blackSquare->pos().x() + 8 + spacing, y ); + pinkSquare->setPos( x2, y + fm.height() / 2 ); + used2Text->setPos( pinkSquare->pos().x() + 8 + spacing, y ); + y += fontMetrics().height() + 2; + + blueSquare->setPos( x, y + fm.height() / 2 ); + resText->setPos( blueSquare->pos().x() + 8 + spacing, y ); + + gv.addItem( fileSize ); + gv.addItem( nandSize ); + gv.addItem( badText ); + gv.addItem( freeText ); + gv.addItem( usedText ); + gv.addItem( used2Text ); + gv.addItem( resText ); + gv.addItem( greySquare ); + gv.addItem( blackSquare ); + gv.addItem( blueSquare ); + gv.addItem( greenSquare ); + gv.addItem( pinkSquare ); + +} + void NandWindow::ThreadIsDone() { qDebug() << "NandWindow::ThreadIsDone"; @@ -172,7 +223,7 @@ void NandWindow::on_actionOpen_Nand_triggered() void NandWindow::GetBlocksfromNand() { blocks.clear(); - freeSpace = 0; + quint32 freeSpace = 0; QList clusters = nThread.GetFats(); if( !clusters.size() == 0x8000 ) @@ -180,30 +231,33 @@ void NandWindow::GetBlocksfromNand() QMessageBox::warning( this, tr( "Error" ), tr( "Expected 0x8000 clusters from the nand, but got %1 instead!" ).arg( clusters.size(), 0, 16 ), QMessageBox::Ok ); return; } - //QString str; + for( quint16 i = 0; i < 0x8000; i += 8 )//first cluster of each block. { quint16 thisBlock = clusters.at( i ); - //str += QString( "%1 " ).arg( thisBlock, 4, 16 ); if( thisBlock == 0xFFFC || thisBlock == 0xFFFD ) { - //qDebug() << "adding" << hex << thisBlock; blocks << thisBlock; continue; } - bool used = 0; + bool used = false; for( quint16 j = i; j < i + 8; j++ )//each individual cluster { - thisBlock = clusters.at( i ); - if( thisBlock == 0xFFFE ) - freeSpace += 0x800; + if( clusters.at( j ) == 0xFFFE ) + freeSpace += 0x4000; else used = true; } blocks << ( used ? 1 : 0xfffe ); // just put 1 for used blocks } + quint32 used = 0x20000000 - freeSpace; + float per = (float)((float)used/(float)0x20000000) * 100.0f; + float usedMb = (float)((float)used/(float)0x100000); + + nandSize->setHtml( QString( "%1Mib ( %2 % ) used" ).arg( usedMb, 3, 'f', 2 ).arg( per, 3, 'f', 2 ) ); + } @@ -320,7 +374,34 @@ void NandWindow::on_treeWidget_currentItemChanged( QTreeWidgetItem* current, QTr return; } - QList blocks = ToBlocks( nThread.GetFatsForFile( entry ) ); - //qDebug() << "blocks for" << current->text( 0 ) << blocks; + QList clusters = nThread.GetFatsForFile( entry ); + QList blocks = ToBlocks( clusters ); + DrawBlockMap( blocks ); + float size = current->text( 2 ).toInt( &ok, 16 ); + if( !ok ) + { + qDebug() << "error converting" << current->text( 2 ) << "to int"; + return; + } + QString unit = "bytes"; + if( size > 1024 ) + { + unit = "KiB"; + size /= 1024.0f; + } + if( size > 1024 ) + { + unit = "MiB"; + size /= 1024.0f; + } + QString clusterStr = clusters.size() == 1 ? tr( "%1 cluster" ).arg( 1 ) : tr( "%1 clusters" ).arg( clusters.size() ); + QString blockStr = blocks.size() == 1 ? tr( "%1 block" ).arg( 1 ) : tr( "%1 blocks" ).arg( blocks.size() ); + QString sizeStr = QString( "( %1 %2 )" ).arg( size, 0, 'f', 2 ).arg( unit ); + + + fileSize->setHtml( QString( "%1 - %2 in %3 %4" ).arg( current->text( 0 ) ).arg( clusterStr ).arg( blockStr ).arg( sizeStr ) ); + //qDebug() << "blocks for" << current->text( 0 ) << blocks; + } + diff --git a/nandExtract/nandwindow.h b/nandExtract/nandwindow.h index 8df0f59..9261268 100755 --- a/nandExtract/nandwindow.h +++ b/nandExtract/nandwindow.h @@ -24,14 +24,21 @@ private: NandThread nThread; + void SetUpBlockMap(); + //changes the blocks in the blockmap with different colors void DrawBlockMap( QList newFile = QList() ); - QGraphicsScene gv;//scene to hold the blockmap images - QGraphicsPixmapItem *pmi[ 0x1000 ];//pointers to all the blocks in the display - //quint16 ClusterToBlock( quint16 cluster ); + QGraphicsScene gv; //scene to hold the blockmap images + QGraphicsPixmapItem *pmi[ 0x1000 ]; //pointers to all the blocks in the display - QList blocks; - quint32 freeSpace; + QGraphicsTextItem *nandSize; //pointers to the items to show info under the blockmap + QGraphicsTextItem *fileSize; + /*QGraphicsTextItem *badText; + QGraphicsTextItem *freeText; + QGraphicsTextItem *usedText; + QGraphicsTextItem *resText;*/ + + QList blocks; //hold a list of what the blocks in the nand are used for void GetBlocksfromNand(); QList ToBlocks( QList clusters ); @@ -48,6 +55,10 @@ private slots: void on_actionShow_Usage_triggered(); void on_actionOpen_Nand_triggered(); void on_treeWidget_customContextMenuRequested(QPoint pos); + //void ScaleBlockMap(); + +protected: + //void resizeEvent( QResizeEvent* event ); }; #endif // NANDWINDOW_H diff --git a/nandExtract/nandwindow.ui b/nandExtract/nandwindow.ui index a1d6b94..ae47522 100755 --- a/nandExtract/nandwindow.ui +++ b/nandExtract/nandwindow.ui @@ -6,85 +6,91 @@ 0 0 - 930 - 472 + 1180 + 654 NandWindow - + + + 0 + 2 - - 2 - - - - - Qt::CustomContextMenu + + + + Qt::Vertical - - - Name + + + Qt::CustomContextMenu - - - - Entry + + + Name + + + + + Entry + + + + + Size + + + + + uid + + + + + gid + + + + + x3 + + + + + Mode + + + + + Attr + + + + + + Qt::ScrollBarAlwaysOn - - - - Size + + false - - - - uid + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - gid + + QPainter::HighQualityAntialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing - - - - x3 + + QGraphicsView::CacheBackground - - - - Mode - - - - - Attr - - + - - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing - - - QGraphicsView::CacheBackground - - - - + @@ -104,7 +110,7 @@ 0 0 - 930 + 1180 27 @@ -141,6 +147,12 @@ + + true + + + true + Show Usage... @@ -151,5 +163,22 @@ - + + + actionShow_Usage + toggled(bool) + graphicsView_blocks + setVisible(bool) + + + -1 + -1 + + + 309 + 351 + + + + diff --git a/nandExtract/pink.png b/nandExtract/pink.png index 36afc61701f15260a450fcdcd9b8999a0cdde2e0..138a1166d2d399fa9586e7e0de6a98813787684e 100755 GIT binary patch delta 189 zcmV;u07C!!7SR?ViBL{Q4GJ0x0000DNk~Le00008000082m$~A084Et+_52_3V(b_ zL_t(|+9bh2k^(Ud1VO2-nBaH(|I8a;*JG)R1DW}HJ};?K1PAZ&yXVtgm-JYxBtVww zOTLv=nI%2eGB~=(rIfNDfZ-%mTz delta 231 zcmVaii83V)_a zL_t(|+9b%qVZ<;D13`eIuf6O4ncC3%vM&2tE_oqk#I*%ne@Cp&pE59xbmJIf^r h5jbIoCwVe|0{~upqrFJ1d}{yz002ovPDHLkV1neJU=jcT