diff --git a/.gitattributes b/.gitattributes index b90754f..a0d8dfc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -91,6 +91,7 @@ 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 saveToy/includes.h -text diff --git a/ohneschwanzenegger/mainwindow.cpp b/ohneschwanzenegger/mainwindow.cpp index 1178da0..0677763 100644 --- a/ohneschwanzenegger/mainwindow.cpp +++ b/ohneschwanzenegger/mainwindow.cpp @@ -57,6 +57,7 @@ MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::M LoadSettings(); ui->lineEdit_nandPath->setText( "./testNand.bin" ); + } MainWindow::~MainWindow() @@ -397,6 +398,7 @@ bool MainWindow::InitNand( const QString &path ) nandInited = false; sharedDirty = false; nandDirty = false; + ui->menuContent->setEnabled( false ); if( !nand.SetPath( path ) || !nand.InitNand() ) return false; @@ -441,6 +443,7 @@ bool MainWindow::InitNand( const QString &path ) //nand.Delete( "/title/00000001/00000002/content/title.tmd" ); nandInited = true; + ui->menuContent->setEnabled( true ); ShowMessage( "Set path to nand as " + path ); return true; } @@ -785,3 +788,102 @@ void MainWindow::TryToAddDefaultSettings() ShowMessage( "Wrote /shared2/sys/SYSCONF" ); } #endif + +//AFAIK, the stuff in the "/meta" folder is put there by the disc that installs the IOS & system menu at the factory. +//i have not been able to get the wii to create this data on its own using any officially release system menu or other program +void MainWindow::AddStuffToMetaFolder() +{ + if( !ItemFromPath( "/meta" ) ) + return; + + if( !CreateIfNeeded( "/meta/00000001", 0x1000, 1, NAND_DIR, NAND_RW, NAND_RW, NAND_RW ) ) + { + ShowMessage( "Cannot create folder for metacrap" ); + return; + } + bool written = false; + + //these are the bare minimum metadata files ive seen on a nand + //i have seen some where there are full banners for the 0x10002 titles, but this is not always the case + for( quint16 i = 0; i < 3; i++ ) + { + quint64 tid; + quint16 ver; + QString desc; + switch( i ) + { + case 0: + tid = 0x100000004ull; + ver = 3; + desc = "sd_os1_1.64"; + break; + case 1: + tid = 0x100000009ull; + ver = 1; + desc = "sd_os1_1.64"; + break; + case 2: + tid = 0x100000002ull; + ver = 0; + desc = "systemmenu.rvl.0.4"; + break; + } + QString tidStr = QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) ); + tidStr.insert( 8, "/" ); + QString path = "/meta/" + tidStr + "/title.met"; + if( ItemFromPath( path ) )//already have this metadata + continue; + + //create subfolder + path = "/meta/" + tidStr; + if( !CreateIfNeeded( path, 0x1000, 1, NAND_DIR, NAND_RW, NAND_RW, NAND_RW ) ) + { + ShowMessage( "Cannot create " + path + " for metacrap" ); + return; + } + path = "/meta/" + tidStr + "/title.met"; + + //generate metacrap + QByteArray stuff = GenMeta( desc, tid, ver ); + + quint16 handle = nand.CreateEntry( path, 0x1000, 1, NAND_FILE, NAND_RW, NAND_RW, NAND_RW ); + if( !handle || !nand.SetData( handle, stuff ) || !UpdateTree() ) + { + ShowMessage( "Error writing data for " + path + " " ); + return; + } + written = true; + } + if( !written ) + { + ShowMessage( "Nothing to write in \"/meta\"" ); + return; + } + if( !nand.WriteMetaData() ) + { + ShowMessage( "Error writing nand matedata for \"/meta\"" ); + return; + } + ShowMessage( "Wrote entries for \"/meta\"" ); +} + +QByteArray MainWindow::GenMeta( const QString &desc, quint64 tid, quint16 version ) +{ + QByteArray ret( 0x40, '\0' ); + QBuffer buf( &ret ); + buf.open( QIODevice::WriteOnly ); + buf.write( desc.toLatin1().data() ); + tid = qFromBigEndian( tid ); + buf.seek( 0x20 ); + buf.write( (const char*)&tid, 8 ); + version = qFromBigEndian( version ); + buf.write( (const char*)&version, 4 ); + buf.close(); + return ret; + +} + +void MainWindow::on_actionWrite_meta_entries_triggered() +{ + AddStuffToMetaFolder(); +} diff --git a/ohneschwanzenegger/mainwindow.h b/ohneschwanzenegger/mainwindow.h index 69dca1d..8d1a3c6 100644 --- a/ohneschwanzenegger/mainwindow.h +++ b/ohneschwanzenegger/mainwindow.h @@ -51,6 +51,8 @@ private: #if 0 void TryToAddDefaultSettings(); #endif + void AddStuffToMetaFolder(); + QByteArray GenMeta( const QString &desc, quint64 tid, quint16 version ); public slots: //slots for getting info from the NUS downloader @@ -60,7 +62,8 @@ public slots: void ReceiveTitleFromNus( NusJob job ); private slots: - void on_pushButton_CachePathBrowse_clicked(); + void on_actionWrite_meta_entries_triggered(); + void on_pushButton_CachePathBrowse_clicked(); void on_actionAbout_triggered(); void on_pushButton_initNand_clicked(); void on_actionNew_nand_from_keys_triggered(); diff --git a/ohneschwanzenegger/mainwindow.ui b/ohneschwanzenegger/mainwindow.ui index acdd896..ffe7479 100644 --- a/ohneschwanzenegger/mainwindow.ui +++ b/ohneschwanzenegger/mainwindow.ui @@ -179,8 +179,6 @@ Nand Dump - - @@ -190,7 +188,19 @@ + + + false + + + Content + + + + + + @@ -208,13 +218,16 @@ + + true + Flush - Import Wad + Import Wads... @@ -230,6 +243,11 @@ About + + + Write meta entries + + diff --git a/ohneschwanzenegger/readmii.txt b/ohneschwanzenegger/readmii.txt new file mode 100644 index 0000000..542882f --- /dev/null +++ b/ohneschwanzenegger/readmii.txt @@ -0,0 +1,56 @@ +*ohneschwanzenegger* + +This is a tool to build a nand.bin suitable for installing on a Nintendo Wii via bootmii. It cannot build one from scratch - you must provide some data from the Wii. It needs to have a copy of the first 8 blocks of nand, a list of bad blocks, and AES & hmac keys. All of this data can be gotten from a bootmii nand dump, even if that nand is bricked. + +Creating a "blank" nand: +Select File -> New Nand ( ctrl + N ) +select the destination for the new file in the "destination" field !make sure you have 528MiB of free space! +If you have an existing nand.bin from the Wii, you can select it by clicking the big "Existing Nand" button. This will fill in the rest of the necessary information. +If you dont have an existing dump to read from, you can enter the path of "keys.bin", the first 8 blocks of nand (including spare data), and the bad blocks using the rest of the dialog window. Bad blocks may be entered manually, or read from a plaintext file with 1 number on each line. +When you click the "Ok" button, the Gui will hang a bit as it writes the full 528MiB file to your PC. + + + +Opening an existing nand: +Enter a path of an existing nand.bin in the "nand.bin" field, or press the "search" button to browse for it on your PC. Once you have selected one, click "init nand" to tell the gui you are ready. IT IS NOT RECCOMMENDED TO USE THIS PROGRAM ON YOUR ONLY COPY OF A NAND. MAKE A COPY AND THAT. + + +Downloading titles and installing them: +Before you do anything, set a path for the NUS cache. This is where the program will cache downloaded files for later use. This should be a location that has decent reading & writing speeds (dont use an SD card). +The upper fields accept a TID and/or version to download and install a specific title. Leave the version field empty to get the latest version. +It also accepts a string such as "3.2u", 4.3e", or "3.5k". This will attempt to get all of the titles that were in the given update. I have used wiimpersonator logs when available, and game update partitions where the wiimpersonator logs were missing. There are some discrepancies as to which titles should be in a given update based on update partitions, but I believe I've gotten it pretty close. +Press the "get it" button. +When all teh titles are done downloading, it will ceck for a setting.txt. If there is a system menu, but no setting.txt, it will prompt to create one. + + +Installing wads: +After the gui knows which nand.bin you want to edit, you can go to File -> Import Wad, and select some wads to install. + + +creating & editing setting.txt +Select Content -> setting.txt. If there is already one, it will be read from the current nand. A dialog window will pop up and you can enter values such as region & serial number. +Clicking "Ok" will have the program try to write the setting.txt to the nand. + +Content -> Write meta entries +This will write the garbage in "/meta" in the nand FS. These serve no purpose other than to take up space. The wii appears to run perfectly fine without them. If I had to guess, I would say they are created during the initial installation of titles in the factory and simply never deleted. There are discrepencies as to which entries are in the /meta folder based on which wii you look at. This program will only write the bare minimum ones: the system menu, IOS4, and IOS9. However, I have seen entries for bc, mios, all the 10002 channels, and the stock hidden channels. + + +Error handling: +There is a log window in the gui. Any time there is an error, it should show up bold. Due to the huge size for a nand, and my lack of wanting to create one, there is no "undo". When a mistake/error/bug happens, there is no turning back. If you see an error dealing with writing to a file, it is recommended that you delete that file and start over. + +Do not install anything this program writes without first verifying its contents. + + + + +This tool is made possible by the open-source efforts from others - including, but not limited to: +bushing +segher +comex +marcan +trap15 +grey +parannoyed +everybody behind the Qt framework + +