From 0581d8eb07b2625a70f6f68108858d7394e5a101 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 18 Jan 2014 22:49:26 -0800 Subject: [PATCH] Fixing STFS reading. --- src/xenia/kernel/fs/devices/stfs_container_file.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/xenia/kernel/fs/devices/stfs_container_file.cc b/src/xenia/kernel/fs/devices/stfs_container_file.cc index c7baa5ccb..80509b692 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_file.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_file.cc @@ -54,13 +54,17 @@ X_STATUS STFSContainerFile::ReadSync( stfs_entry->block_list.size(), (size_t)ceil((byte_offset + real_length) / 4096.0)); uint8_t* dest_ptr = (uint8_t*)buffer; + size_t remaining_length = real_length; for (size_t n = start_block; n < end_block; n++) { auto& record = stfs_entry->block_list[n]; size_t offset = record.offset; - size_t read_length = record.length; - xe_copy_memory(dest_ptr, buffer_length - (dest_ptr - (uint8_t*)buffer), - map_ptr + offset, read_length); + if (n == start_block) { + offset += byte_offset % 4096; + } + size_t read_length = MIN(remaining_length, record.length); + xe_copy_struct(dest_ptr, map_ptr + offset, read_length); dest_ptr += read_length; + remaining_length -= read_length; } *out_bytes_read = real_length; return X_STATUS_SUCCESS;