diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2009-10-11 16:06:02 +0000 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2009-10-11 16:06:02 +0000 |
| commit | 92b0d620b922d9edfa527665bf7fff242e61fd6f (patch) | |
| tree | 8d6f5d8c1aac567dd49df20442eb68f88a6ca471 /Source/Core/DiscIO | |
| parent | 56224bd9664140f276824bf32b9de81c4b8db74a (diff) | |
Allow dumping of dol files from gc discs
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4394 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/Src/FileSystemGCWii.cpp | 88 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/FileSystemGCWii.h | 3 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/Filesystem.h | 3 |
3 files changed, 48 insertions, 46 deletions
diff --git a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp index b054b6066f..4457a25d63 100644 --- a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp @@ -116,45 +116,42 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi return false; } -void CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const +bool CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const { - char exportName[512]; - - // Extract Apploader - // ------------------ - // 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); - - char* buffer = new char[AppSize]; - m_rVolume->Read(0x2440, AppSize, (u8*)buffer); - sprintf(exportName, "%s/apploader.ldr", _rExportFolder); - FILE* AppFile = fopen(exportName,"w"); - if (!AppFile) + u32 AppSize = Read32(0x2440 + 0x14) << m_OffsetShift;// apploader size + AppSize += Read32(0x2440 + 0x18) << m_OffsetShift; // + trailer size + AppSize += 0x20; // + header size + DEBUG_LOG(DISCIO,"AppSize -> %x", AppSize); + + u8* buffer = new u8[AppSize]; + if (m_rVolume->Read(0x2440, AppSize, buffer)) { - PanicAlert("Failed to create %s! canceling further extraction",exportName); - return; + char exportName[512]; + sprintf(exportName, "%s/apploader.img", _rExportFolder); + FILE* AppFile = fopen(exportName, "wb"); + if (AppFile) + { + fwrite(buffer, AppSize, 1, AppFile); + fclose(AppFile); + delete[] buffer; + return true; + } } - fwrite(buffer, 1, AppSize, AppFile); - fclose(AppFile); - //delete[] buffer; buffer = 0; - /* TODO : This part crashes with Wii games :/ - // Extract dol(bootfile) - // --------------------- + delete[] buffer; + return false; +} + +bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const +{ u32 DolOffset = Read32(0x420) << m_OffsetShift; - u32 DolSize = 0, offset = 0, size = 0, max = 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 :/) + u32 DolSize, offset = 0, size = 0; // Iterate through the 7 code segments for (u8 i = 0; i < 7; i++) { - m_rVolume->Read(DolOffset + 0x00 + i * 4, 4, (u8*)&offset); - m_rVolume->Read(DolOffset + 0x90 + i * 4, 4, (u8*)&size); + offset = Read32(DolOffset + 0x00 + i * 4); + size = Read32(DolOffset + 0x90 + i * 4); if (offset + size > DolSize) DolSize = offset + size; } @@ -162,26 +159,29 @@ void CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const // Iterate through the 11 data segments for (u8 i = 0; i < 11; i++) { - m_rVolume->Read(DolOffset + 0x1c + i * 4, 4, (u8*)&offset); - m_rVolume->Read(DolOffset + 0xac + i * 4, 4, (u8*)&size); + offset = Read32(DolOffset + 0x1c + i * 4); + size = Read32(DolOffset + 0xac + i * 4); if (offset + size > DolSize) DolSize = offset + size; } - // Add header to size - DolSize += 0x40; - buffer = new char[DolSize]; - m_rVolume->Read(DolOffset, DolSize, (u8*)&buffer); - sprintf(exportName, "%s/boot.dol", _rExportFolder); - FILE* DolFile = fopen(exportName, "w"); - if (!DolFile) + + u8* buffer = new u8[DolSize]; + if (m_rVolume->Read(DolOffset, DolSize, buffer)) { - PanicAlert("Failed to create %s! canceling further extraction",exportName); - return; + char exportName[512]; + sprintf(exportName, "%s/boot.dol", _rExportFolder); + FILE* DolFile = fopen(exportName, "wb"); + if (DolFile) + { + fwrite(buffer, DolSize, 1, DolFile); + fclose(DolFile); + delete[] buffer; + return true; + } } - fwrite(buffer, 1, DolSize, DolFile); - fclose(DolFile); + delete[] buffer; - */ + return false; } u32 CFileSystemGCWii::Read32(u64 _Offset) const diff --git a/Source/Core/DiscIO/Src/FileSystemGCWii.h b/Source/Core/DiscIO/Src/FileSystemGCWii.h index 6cdf632df8..3bfc40643d 100644 --- a/Source/Core/DiscIO/Src/FileSystemGCWii.h +++ b/Source/Core/DiscIO/Src/FileSystemGCWii.h @@ -36,7 +36,8 @@ public: virtual const char* GetFileName(u64 _Address) const; virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) 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: diff --git a/Source/Core/DiscIO/Src/Filesystem.h b/Source/Core/DiscIO/Src/Filesystem.h index 7eece8d26c..2fa44ecb81 100644 --- a/Source/Core/DiscIO/Src/Filesystem.h +++ b/Source/Core/DiscIO/Src/Filesystem.h @@ -54,7 +54,8 @@ public: virtual u64 GetFileSize(const char* _rFullPath) 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 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 IVolume *GetVolume() const { return m_rVolume; } |
