* oneswanzenegger: create factory test logs and dirs when creating a blank nand.bin

git-svn-id: http://wiiqt.googlecode.com/svn/trunk@43 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
giantpune@gmail.com 2011-01-03 05:09:49 +00:00
parent 1801f7f8cf
commit adebd42830
5 changed files with 42 additions and 2 deletions

View File

@ -3,6 +3,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Q_INIT_RESOURCE( rc );
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
w.show(); w.show();

View File

@ -7,6 +7,14 @@
#include "../WiiQt/tools.h" #include "../WiiQt/tools.h"
#include "../WiiQt/wad.h" #include "../WiiQt/wad.h"
//on 1 of my wiis, disc 123J owns the test directory & testlog. this wii came from the factory as 3.2u
//#define NAND_TEST_OWNER 0x100003132334aull
//on my later wiis, disc 121J owns the test directory & testlog. all came with 4.2u or later
#define NAND_TEST_OWNER 0x100003132314aull
//the group of the test dir/files seems to always be 4
#define NAND_TEST_GROUP 4
MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ), nus ( this ), nand ( this ) MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ), nus ( this ), nand ( this )
{ {
@ -243,7 +251,7 @@ void MainWindow::on_actionSetting_txt_triggered()
//nand-dump -> flush //nand-dump -> flush
void MainWindow::on_actionFlush_triggered() void MainWindow::on_actionFlush_triggered()
{ {
if( !nandInited ) if( nandInited )
FlushNand(); FlushNand();
} }
@ -298,6 +306,29 @@ void MainWindow::on_actionNew_nand_from_keys_triggered()
return; return;
InitNand( path ); InitNand( path );
ui->lineEdit_nandPath->setText( path ); ui->lineEdit_nandPath->setText( path );
//add some factory test logs and whatnot
quint32 _uid = uid.GetUid( NAND_TEST_OWNER, true );
if( !nand.CreateEntry( "/shared2/test", _uid, NAND_TEST_GROUP, NAND_DIR, NAND_RW, NAND_RW, NAND_RW )
|| !nand.CreateEntry( "/shared2/sys", _uid, NAND_TEST_GROUP, NAND_DIR, NAND_RW, NAND_RW, NAND_RW ) )
{
ShowMessage( "<b>Error creating folder for testlog<\b>" );
return;
}
quint16 handle = nand.CreateEntry( "/shared2/test/testlog.txt", _uid, NAND_TEST_GROUP, NAND_FILE, NAND_RW, NAND_RW, NAND_RW );
if( !handle )
{
ShowMessage( "<b>Error creating testlog<\b>" );
return;
}
QByteArray tLog = ReadFile( ":/testlog.txt" );
if( !nand.SetData( handle, tLog ) )
{
ShowMessage( "<b>Error writing to testlog.txt<\b>" );
return;
}
UpdateTree();
ShowMessage( "Created /shared2/test/testlog.txt" );
} }
void MainWindow::on_pushButton_initNand_clicked() void MainWindow::on_pushButton_initNand_clicked()
@ -307,7 +338,7 @@ void MainWindow::on_pushButton_initNand_clicked()
ShowMessage( "<b>Please enter a path for nand.bin<\b>" ); ShowMessage( "<b>Please enter a path for nand.bin<\b>" );
return; return;
} }
InitNand( ui->lineEdit_nandPath->text() ); InitNand( ui->lineEdit_nandPath->text() );
} }
bool MainWindow::InitNand( const QString &path ) bool MainWindow::InitNand( const QString &path )

View File

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

View File

@ -47,3 +47,6 @@ HEADERS += mainwindow.h \
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
../WiiQt/settingtxtdialog.ui \ ../WiiQt/settingtxtdialog.ui \
newnandbin.ui newnandbin.ui
RESOURCES += \
rc.qrc

Binary file not shown.