Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 53 additions & 8 deletions rpcs3/Loader/ISO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,14 @@ u64 iso_file_encrypted::read_at(u64 offset, void* buffer, u64 size)
// ' ' ' '
// | first sec | inner sec(s) | last sec |

const u64 max_size = std::min(size, local_extent_remaining(offset));
u64 max_size = std::min(size, local_extent_remaining(offset));

if (max_size == 0)
{
return 0;
}

const u64 total_size = this->size();
const u64 archive_first_offset = file_offset(offset);
const u64 archive_last_offset = archive_first_offset + max_size - 1;
iso_sector first_sec, last_sec;
Expand Down Expand Up @@ -678,10 +679,19 @@ u64 iso_file_encrypted::read_at(u64 offset, void* buffer, u64 size)
{
if (total_read != first_sec.size_aligned)
{
iso_log.error("read_at: %s: Error reading from file (%llu/%llu)", m_meta.name, total_read, first_sec.size_aligned);
iso_log.error("read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu", m_meta.name,
offset, first_sec.address_aligned, first_sec.size_aligned, max_size, size, total_size, total_read);

return 0;
}

// If present, read the remaining chunk of data on next extent
if (size > max_size && (offset + max_size) < total_size)
{
iso_log.warning("read_at: %s: Extent limit reached reading from file (%llu/%llu)", m_meta.name, max_size, size);
max_size += read_at(offset + max_size, &reinterpret_cast<u8*>(buffer)[max_size], size - max_size);
}

return max_size;
}

Expand Down Expand Up @@ -739,12 +749,20 @@ u64 iso_file_encrypted::read_at(u64 offset, void* buffer, u64 size)

if (total_read != first_sec.size_aligned + last_sec.size_aligned + (sector_count - 2) * ISO_SECTOR_SIZE)
{
iso_log.error("read_at: %s: Error reading from file (%llu/%llu)", m_meta.name,
iso_log.error("read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu/%llu", m_meta.name,
offset, first_sec.address_aligned, last_sec.size_aligned, max_size, size, total_size,
total_read, ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2) * ISO_SECTOR_SIZE);

return 0;
}

// If present, read the remaining chunk of data on next extent
if (size > max_size && (offset + max_size) < total_size)
{
iso_log.warning("read_at: %s: Extent limit reached reading from file (%llu/%llu)", m_meta.name, max_size, size);
max_size += read_at(offset + max_size, &reinterpret_cast<u8*>(buffer)[max_size], size - max_size);
}

return max_size;
}

Expand Down Expand Up @@ -1250,13 +1268,14 @@ u64 iso_file::read(void* buffer, u64 size)

u64 iso_file::read_at(u64 offset, void* buffer, u64 size)
{
const u64 max_size = std::min(size, local_extent_remaining(offset));
u64 max_size = std::min(size, local_extent_remaining(offset));

if (max_size == 0)
{
return 0;
}

const u64 total_size = this->size();
const u64 archive_first_offset = file_offset(offset);

// If it's not a raw device
Expand All @@ -1266,10 +1285,19 @@ u64 iso_file::read_at(u64 offset, void* buffer, u64 size)

if (total_read != max_size)
{
iso_log.error("read_at: %s: Error reading from file (%llu/%llu)", m_meta.name, total_read, max_size);
iso_log.error("read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu (%llu), TR: %llu", m_meta.name,
offset, archive_first_offset, max_size, size, total_size, total_read);

return 0;
}

// If present, read the remaining chunk of data on next extent
if (size > max_size && (offset + max_size) < total_size)
{
iso_log.warning("read_at: %s: Extent limit reached reading from file (%llu/%llu)", m_meta.name, max_size, size);
max_size += read_at(offset + max_size, &reinterpret_cast<u8*>(buffer)[max_size], size - max_size);
}

return max_size;
}

Expand Down Expand Up @@ -1320,10 +1348,19 @@ u64 iso_file::read_at(u64 offset, void* buffer, u64 size)
{
if (total_read != ISO_SECTOR_SIZE)
{
iso_log.error("read_at: %s: Error reading from file (%llu/%llu)", m_meta.name, total_read, ISO_SECTOR_SIZE);
iso_log.error("read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu", m_meta.name,
offset, first_sec.lba_address, ISO_SECTOR_SIZE, max_size, size, total_size, total_read);

return 0;
}

// If present, read the remaining chunk of data on next extent
if (size > max_size && (offset + max_size) < total_size)
{
iso_log.warning("read_at: %s: Extent limit reached reading from file (%llu/%llu)", m_meta.name, max_size, size);
max_size += read_at(offset + max_size, &reinterpret_cast<u8*>(buffer)[max_size], size - max_size);
}

return max_size;
}

Expand Down Expand Up @@ -1357,12 +1394,20 @@ u64 iso_file::read_at(u64 offset, void* buffer, u64 size)

if (total_read != ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2) * ISO_SECTOR_SIZE)
{
iso_log.error("read_at: %s: Error reading from file (%llu/%llu)", m_meta.name,
total_read, ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2) * ISO_SECTOR_SIZE);
iso_log.error("read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu/%llu", m_meta.name,
offset, first_sec.lba_address, ISO_SECTOR_SIZE, max_size, size, total_size,
total_read, ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2) * ISO_SECTOR_SIZE);

return 0;
}

// If present, read the remaining chunk of data on next extent
if (size > max_size && (offset + max_size) < total_size)
{
iso_log.warning("read_at: %s: Extent limit reached reading from file (%llu/%llu)", m_meta.name, max_size, size);
max_size += read_at(offset + max_size, &reinterpret_cast<u8*>(buffer)[max_size], size - max_size);
}

return max_size;
}

Expand Down
Loading