* oneswanzenegger: add crap in /meta

git-svn-id: http://wiiqt.googlecode.com/svn/trunk@58 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
giantpune@gmail.com 2011-01-16 19:47:33 +00:00
parent 8a95fbcfa0
commit 07e2241cb6
4 changed files with 183 additions and 4 deletions

View File

@ -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( "<b>Cannot create folder for metacrap</b>" );
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( "<b>Cannot create " + path + " for metacrap</b>" );
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( "<b>Error writing data for " + path + " </b>" );
return;
}
written = true;
}
if( !written )
{
ShowMessage( "Nothing to write in \"/meta\"" );
return;
}
if( !nand.WriteMetaData() )
{
ShowMessage( "<b>Error writing nand matedata for \"/meta\"</b>" );
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();
}

View File

@ -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,6 +62,7 @@ public slots:
void ReceiveTitleFromNus( NusJob job );
private slots:
void on_actionWrite_meta_entries_triggered();
void on_pushButton_CachePathBrowse_clicked();
void on_actionAbout_triggered();
void on_pushButton_initNand_clicked();

View File

@ -179,8 +179,6 @@
<property name="title">
<string>Nand Dump</string>
</property>
<addaction name="actionSetting_txt"/>
<addaction name="actionFlush"/>
<addaction name="actionImportWad"/>
<addaction name="actionNew_nand_from_keys"/>
</widget>
@ -190,7 +188,19 @@
</property>
<addaction name="actionAbout"/>
</widget>
<widget class="QMenu" name="menuContent">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Content</string>
</property>
<addaction name="actionFlush"/>
<addaction name="actionSetting_txt"/>
<addaction name="actionWrite_meta_entries"/>
</widget>
<addaction name="menuNand_Dump"/>
<addaction name="menuContent"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
@ -208,13 +218,16 @@
</property>
</action>
<action name="actionFlush">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Flush</string>
</property>
</action>
<action name="actionImportWad">
<property name="text">
<string>Import Wad</string>
<string>Import Wads...</string>
</property>
</action>
<action name="actionNew_nand_from_keys">
@ -230,6 +243,11 @@
<string>About</string>
</property>
</action>
<action name="actionWrite_meta_entries">
<property name="text">
<string>Write meta entries</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>

View File

@ -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