cdvd: Fix and switch to writing v2 format blockdumps

Switch to using vector for the dump sector table, and also fix a bug
where memory was not allocated when writing to a v2 format block dump,
causing a null pointer dereference.

Also switch to using the v2 block dump format, which generally produces
smaller dump files (the dumps also seem smaller than the ones generated
by cdvdiso, which seems to repeat sectors).
This commit is contained in:
Jonathan Li 2018-01-23 19:05:51 +00:00
parent f7c0a910f8
commit 79d57e2949
3 changed files with 7 additions and 13 deletions

View File

@ -394,7 +394,7 @@ bool DoCDVDopen()
cdvdTD td;
CDVD->getTD(0, &td);
blockDumpFile.Create(temp, 3);
blockDumpFile.Create(temp, 2);
if( blockDumpFile.IsOpened() )
{

View File

@ -113,9 +113,8 @@ protected:
// total number of blocks in the ISO image (including all parts)
u32 m_blocks;
// dtable / dtablesize are used when reading blockdumps
std::unique_ptr<u32[]> m_dtable;
int m_dtablesize;
// dtable is used when reading blockdumps
std::vector<u32> m_dtable;
std::unique_ptr<wxFileOutputStream> m_outstream;

View File

@ -47,9 +47,6 @@ void OutputIsoFile::_init()
m_blockofs = 0;
m_blocksize = 0;
m_blocks = 0;
m_dtable = 0;
m_dtablesize = 0;
}
void OutputIsoFile::Create(const wxString& filename, int version)
@ -93,12 +90,10 @@ void OutputIsoFile::WriteSector(const u8* src, uint lsn)
if (m_version == 2)
{
// Find and ignore blocks that have already been dumped:
for (int i=0; i<m_dtablesize; ++i)
{
if (m_dtable[i] == lsn) return;
}
if (std::any_of(std::begin(m_dtable), std::end(m_dtable), [=](const u32 entry) {return entry == lsn;}))
return;
m_dtable[m_dtablesize++] = lsn;
m_dtable.push_back(lsn);
WriteValue<u32>( lsn );
}
@ -114,7 +109,7 @@ void OutputIsoFile::WriteSector(const u8* src, uint lsn)
void OutputIsoFile::Close()
{
m_dtable.reset(nullptr);
m_dtable.clear();
_init();
}