Esempio n. 1
0
 TEST(WadTest, loadEntries) {
     const Path wadPath = Disk::getCurrentWorkingDir() + Path("data/IO/Wad/cr8_czg.wad");
     Wad wad(wadPath);
     
     const WadEntryList& entries = wad.allEntries();
     ASSERT_EQ(21u, entries.size());
     ASSERT_EQ(String("cr8_czg_1"), entries[ 0].name());
     ASSERT_EQ(String("cr8_czg_2"), entries[ 1].name());
     ASSERT_EQ(String("cr8_czg_3"), entries[ 2].name());
     ASSERT_EQ(String("cr8_czg_4"), entries[ 3].name());
     ASSERT_EQ(String("cr8_czg_5"), entries[ 4].name());
     ASSERT_EQ(String("speedM_1"), entries[ 5].name());
     ASSERT_EQ(String("cap4can-o-jam"), entries[ 6].name());
     ASSERT_EQ(String("can-o-jam"), entries[ 7].name());
     ASSERT_EQ(String("eat_me"), entries[ 8].name());
     ASSERT_EQ(String("coffin1"), entries[ 9].name());
     ASSERT_EQ(String("coffin2"), entries[10].name());
     ASSERT_EQ(String("czg_fronthole"), entries[11].name());
     ASSERT_EQ(String("czg_backhole"), entries[12].name());
     ASSERT_EQ(String("u_get_this"), entries[13].name());
     ASSERT_EQ(String("for_sux-m-ass"), entries[14].name());
     ASSERT_EQ(String("dex_5"), entries[15].name());
     ASSERT_EQ(String("polished_turd"), entries[16].name());
     ASSERT_EQ(String("crackpipes"), entries[17].name());
     ASSERT_EQ(String("bongs2"), entries[18].name());
     ASSERT_EQ(String("blowjob_machine"), entries[19].name());
     ASSERT_EQ(String("lasthopeofhuman"), entries[20].name());
 }
Esempio n. 2
0
bool CNANDContentLoader::Initialize(const std::string& name)
{
	if (name.empty())
		return false;

	m_Path = name;

	WiiWAD wad(name);
	std::vector<u8> data_app;
	std::vector<u8> tmd;
	std::vector<u8> decrypted_title_key;

	if (wad.IsValid())
	{
		m_IsWAD = true;
		m_Ticket = wad.GetTicket();
		decrypted_title_key = GetKeyFromTicket(m_Ticket);
		tmd = wad.GetTMD();
		data_app = wad.GetDataApp();
	}
	else
	{
		std::string tmd_filename(m_Path);

		if (tmd_filename.back() == '/')
			tmd_filename += "title.tmd";
		else
			m_Path = tmd_filename.substr(0, tmd_filename.find("title.tmd"));

		File::IOFile tmd_file(tmd_filename, "rb");
		if (!tmd_file)
		{
			WARN_LOG(DISCIO, "CreateFromDirectory: error opening %s", tmd_filename.c_str());
			return false;
		}

		tmd.resize(static_cast<size_t>(File::GetSize(tmd_filename)));
		tmd_file.ReadBytes(tmd.data(), tmd.size());
	}

	std::copy(&tmd[0],     &tmd[TMD_HEADER_SIZE], m_TMDHeader);
	std::copy(&tmd[0x180], &tmd[0x180 + TMD_VIEW_SIZE], m_TMDView);

	m_TitleVersion = Common::swap16(&tmd[0x01DC]);
	m_NumEntries   = Common::swap16(&tmd[0x01DE]);
	m_BootIndex    = Common::swap16(&tmd[0x01E0]);
	m_TitleID      = Common::swap64(&tmd[0x018C]);
	m_IosVersion   = Common::swap16(&tmd[0x018A]);
	m_Country      = static_cast<u8>(m_TitleID & 0xFF);

	if (m_Country == 2) // SYSMENU
		m_Country = GetSysMenuRegion(m_TitleVersion);

	InitializeContentEntries(tmd, decrypted_title_key, data_app);
	return true;
}
Esempio n. 3
0
 TEST(WadTest, getMipSize) {
     const Path wadPath = Disk::getCurrentWorkingDir() + Path("data/IO/Wad/cr8_czg.wad");
     Wad wad(wadPath);
     
     const WadEntryList& entries = wad.allEntries();
     ASSERT_EQ(MipSize( 64,  64), wad.mipSize(entries[0]));
     ASSERT_EQ(MipSize( 64,  64), wad.mipSize(entries[1]));
     ASSERT_EQ(MipSize( 64, 128), wad.mipSize(entries[2]));
     ASSERT_EQ(MipSize( 64, 128), wad.mipSize(entries[3]));
     ASSERT_EQ(MipSize( 64, 128), wad.mipSize(entries[4]));
 }
Esempio n. 4
0
//nand-dump -> ImportWad
void MainWindow::on_actionImportWad_triggered()
{
    if( !nandInited && !InitNand( 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 fn = QFileDialog::getOpenFileName( this, tr("Wad files(*.wad)"), QCoreApplication::applicationDirPath(), tr("WadFiles (*.wad)") );
    QStringList fns = QFileDialog::getOpenFileNames( this, tr("Wad files(*.wad)"), QCoreApplication::applicationDirPath(), tr("WadFiles (*.wad)") );

    if( fns.isEmpty() )
        return;
    foreach( const QString &fn, fns )
    {
        QByteArray data = ReadFile( fn );
        if( data.isEmpty() )
            continue;

        Wad wad( data );
        if( !wad.IsOk() )
        {
            ShowMessage( tr( "Wad data not ok for \"%1\"" ).arg( fn ) );
            continue;
        }

        //work smart, not hard... just turn the wad into a NUSJob and reused the same code to install it
        NusJob job;
        job.tid = wad.Tid();
        job.data << wad.getTmd();
        job.data << wad.getTik();

        Tmd t( wad.getTmd() );
        job.version = t.Version();
        quint16 cnt  = t.Count();
        for( quint16 i = 0; i < cnt; i++ )
        {
            job.data << wad.Content( i );
        }

        job.decrypt = true;
        ShowMessage( tr( "Installing %1 to nand" ).arg( fn ) );
        InstallNUSItem( job );
    }
Esempio n. 5
0
        TextureCollection::TextureCollection(const String& name, const String& path) throw (IO::IOException) :
        m_name(name),
        m_path(path) {
            IO::Mip::List mips;
            try {
                IO::Wad wad(m_path);
                mips = wad.loadMips(0);
            } catch (IO::IOException& e) {
                while (!mips.empty()) delete mips.back(), mips.pop_back();
                throw e;
            }

            while (!mips.empty()) {
                IO::Mip* mip = mips.back();
                Texture* texture = new Texture(*this, mip->name(), mip->width(), mip->height());
                m_textures.push_back(texture);
                delete mip;
                mips.pop_back();
            }

            m_texturesByName = m_textures;
            m_texturesByUsage = m_textures;
            std::sort(m_texturesByName.begin(), m_texturesByName.end(), CompareTexturesByName());
        }