
Hi,
I have found following code for reading Wii iso file may be optimized, although the improvement is ignorable under modern OS (ex: Windows)
When emulator read data from Wii iso file via VolumeWiiCrypted.cpp CVolumeWiiCrypted::Read (), it always reads 32Kbyte data, even only 1 byte is requested. This is strange.
// read current block
if (!m_pReader->Read(m_VolumeOffset + m_dataOffset + Block * 0x8000, 0x8000, m_pBuffer))
{
return(false);
}
if (m_LastDecryptedBlockOffset != Block)
{
memcpy(IV, m_pBuffer + 0x3d0, 16);
aes_crypt_cbc(m_AES_ctx.get(), AES_DECRYPT, 0x7C00, IV, m_pBuffer + 0x400, m_LastDecryptedBlock);
m_LastDecryptedBlockOffset = Block;
}
I think it can be optimized by following code:
if (m_LastDecryptedBlockOffset != Block)
{
if (!m_pReader->Read(m_VolumeOffset + dataOffset + Block * 0x8000, 0x8000, m_pBuffer))
return(false);
memcpy(IV, m_pBuffer + 0x3d0, 16);
aes_crypt_cbc(m_AES_ctx, AES_DECRYPT, 0x7C00, IV, m_pBuffer + 0x400, m_LastDecryptedBlock);
m_LastDecryptedBlockOffset = Block;
}
I have found following code for reading Wii iso file may be optimized, although the improvement is ignorable under modern OS (ex: Windows)
When emulator read data from Wii iso file via VolumeWiiCrypted.cpp CVolumeWiiCrypted::Read (), it always reads 32Kbyte data, even only 1 byte is requested. This is strange.
// read current block
if (!m_pReader->Read(m_VolumeOffset + m_dataOffset + Block * 0x8000, 0x8000, m_pBuffer))
{
return(false);
}
if (m_LastDecryptedBlockOffset != Block)
{
memcpy(IV, m_pBuffer + 0x3d0, 16);
aes_crypt_cbc(m_AES_ctx.get(), AES_DECRYPT, 0x7C00, IV, m_pBuffer + 0x400, m_LastDecryptedBlock);
m_LastDecryptedBlockOffset = Block;
}
I think it can be optimized by following code:
if (m_LastDecryptedBlockOffset != Block)
{
if (!m_pReader->Read(m_VolumeOffset + dataOffset + Block * 0x8000, 0x8000, m_pBuffer))
return(false);
memcpy(IV, m_pBuffer + 0x3d0, 16);
aes_crypt_cbc(m_AES_ctx, AES_DECRYPT, 0x7C00, IV, m_pBuffer + 0x400, m_LastDecryptedBlock);
m_LastDecryptedBlockOffset = Block;
}