Allow dumping of dol files from gc discs

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4394 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-10-11 16:06:02 +00:00
parent 56224bd966
commit 92b0d620b9
4 changed files with 50 additions and 45 deletions

View File

@ -116,45 +116,42 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi
return false; return false;
} }
void CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const bool CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const
{ {
char exportName[512]; u32 AppSize = Read32(0x2440 + 0x14) << m_OffsetShift;// apploader size
AppSize += Read32(0x2440 + 0x18) << m_OffsetShift; // + trailer size
// Extract Apploader AppSize += 0x20; // + header size
// ------------------
// Apploader code size
u32 AppSize = Read32(0x2440 + 0x14) << m_OffsetShift;
AppSize += Read32(0x2440 + 0x18) << m_OffsetShift; // + apptrailer size
AppSize += 0x20; // + the header = Apploader size! :')
DEBUG_LOG(DISCIO,"AppSize -> %x", AppSize); DEBUG_LOG(DISCIO,"AppSize -> %x", AppSize);
char* buffer = new char[AppSize]; u8* buffer = new u8[AppSize];
m_rVolume->Read(0x2440, AppSize, (u8*)buffer); if (m_rVolume->Read(0x2440, AppSize, buffer))
sprintf(exportName, "%s/apploader.ldr", _rExportFolder);
FILE* AppFile = fopen(exportName,"w");
if (!AppFile)
{ {
PanicAlert("Failed to create %s! canceling further extraction",exportName); char exportName[512];
return; sprintf(exportName, "%s/apploader.img", _rExportFolder);
} FILE* AppFile = fopen(exportName, "wb");
fwrite(buffer, 1, AppSize, AppFile); if (AppFile)
{
fwrite(buffer, AppSize, 1, AppFile);
fclose(AppFile); fclose(AppFile);
//delete[] buffer; buffer = 0; delete[] buffer;
return true;
}
}
/* TODO : This part crashes with Wii games :/ delete[] buffer;
// Extract dol(bootfile) return false;
// --------------------- }
bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const
{
u32 DolOffset = Read32(0x420) << m_OffsetShift; u32 DolOffset = Read32(0x420) << m_OffsetShift;
u32 DolSize = 0, offset = 0, size = 0, max = 0; u32 DolSize, offset = 0, size = 0;
// note DacoTaco : thank you shuffle and discscrubber :P . find it kinda of pointless to include
// the discscrubber just for the GetDolSize function so its copy pasta time ...
// TODO: fix boot.dol size. or gc-tool is again silly with size or we are wrong (more likely :/)
// Iterate through the 7 code segments // Iterate through the 7 code segments
for (u8 i = 0; i < 7; i++) for (u8 i = 0; i < 7; i++)
{ {
m_rVolume->Read(DolOffset + 0x00 + i * 4, 4, (u8*)&offset); offset = Read32(DolOffset + 0x00 + i * 4);
m_rVolume->Read(DolOffset + 0x90 + i * 4, 4, (u8*)&size); size = Read32(DolOffset + 0x90 + i * 4);
if (offset + size > DolSize) if (offset + size > DolSize)
DolSize = offset + size; DolSize = offset + size;
} }
@ -162,26 +159,29 @@ void CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const
// Iterate through the 11 data segments // Iterate through the 11 data segments
for (u8 i = 0; i < 11; i++) for (u8 i = 0; i < 11; i++)
{ {
m_rVolume->Read(DolOffset + 0x1c + i * 4, 4, (u8*)&offset); offset = Read32(DolOffset + 0x1c + i * 4);
m_rVolume->Read(DolOffset + 0xac + i * 4, 4, (u8*)&size); size = Read32(DolOffset + 0xac + i * 4);
if (offset + size > DolSize) if (offset + size > DolSize)
DolSize = offset + size; DolSize = offset + size;
} }
// Add header to size
DolSize += 0x40; u8* buffer = new u8[DolSize];
buffer = new char[DolSize]; if (m_rVolume->Read(DolOffset, DolSize, buffer))
m_rVolume->Read(DolOffset, DolSize, (u8*)&buffer);
sprintf(exportName, "%s/boot.dol", _rExportFolder);
FILE* DolFile = fopen(exportName, "w");
if (!DolFile)
{ {
PanicAlert("Failed to create %s! canceling further extraction",exportName); char exportName[512];
return; sprintf(exportName, "%s/boot.dol", _rExportFolder);
} FILE* DolFile = fopen(exportName, "wb");
fwrite(buffer, 1, DolSize, DolFile); if (DolFile)
{
fwrite(buffer, DolSize, 1, DolFile);
fclose(DolFile); fclose(DolFile);
delete[] buffer; delete[] buffer;
*/ return true;
}
}
delete[] buffer;
return false;
} }
u32 CFileSystemGCWii::Read32(u64 _Offset) const u32 CFileSystemGCWii::Read32(u64 _Offset) const

View File

@ -36,7 +36,8 @@ public:
virtual const char* GetFileName(u64 _Address) const; virtual const char* GetFileName(u64 _Address) const;
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const; virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const;
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const; virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const;
virtual void ExportApploader(const char* _rExportFolder) const; virtual bool ExportApploader(const char* _rExportFolder) const;
virtual bool ExportDOL(const char* _rExportFolder) const;
private: private:

View File

@ -54,7 +54,8 @@ public:
virtual u64 GetFileSize(const char* _rFullPath) const = 0; virtual u64 GetFileSize(const char* _rFullPath) const = 0;
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const = 0; virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const = 0;
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const = 0; virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const = 0;
virtual void ExportApploader(const char* _rExportFolder) const = 0; virtual bool ExportApploader(const char* _rExportFolder) const = 0;
virtual bool ExportDOL(const char* _rExportFolder) const = 0;
virtual const char* GetFileName(u64 _Address) const = 0; virtual const char* GetFileName(u64 _Address) const = 0;
virtual const IVolume *GetVolume() const { return m_rVolume; } virtual const IVolume *GetVolume() const { return m_rVolume; }

View File

@ -640,7 +640,10 @@ void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolde
index[0] = 0; index[0] = 0;
index[1] = (u32)fst.size(); index[1] = (u32)fst.size();
// Add buttons to do this without dumping whole disc, sometime
FS->ExportApploader(_rExportFolder); FS->ExportApploader(_rExportFolder);
if (!DiscIO::IsVolumeWiiDisc(OpenISO))
FS->ExportDOL(_rExportFolder);
} }
else // Look for the dir we are going to extract else // Look for the dir we are going to extract
{ {