diff --git a/src/xenia/kernel/xam/content_manager.cc b/src/xenia/kernel/xam/content_manager.cc index 930818eaa..523fc9f2c 100644 --- a/src/xenia/kernel/xam/content_manager.cc +++ b/src/xenia/kernel/xam/content_manager.cc @@ -129,6 +129,28 @@ std::vector ContentManager::ListContent(uint32_t device_id, content_data.content_type = content_type; content_data.display_name = file_info.name; content_data.file_name = xe::to_string(file_info.name); + + if (file_info.type != xe::filesystem::FileInfo::Type::kDirectory) { + // Not a directory so must be a package, verify size to make sure + if (file_info.total_size <= vfs::StfsHeader::kHeaderLength) { + continue; // Invalid package (maybe .headers file) + } + + auto map = MappedMemory::Open(file_info.path + file_info.name, + MappedMemory::Mode::kRead, 0, + vfs::StfsHeader::kHeaderLength); + if (map) { + vfs::StfsHeader header; + header.Read(map->data()); + + content_data.content_type = static_cast(header.content_type); + content_data.display_name = header.display_names; + // TODO: select localized display name + // some games may expect different ones depending on language setting. + map->Close(); + } + } + result.emplace_back(std::move(content_data)); } diff --git a/src/xenia/vfs/devices/stfs_container_device.h b/src/xenia/vfs/devices/stfs_container_device.h index 9819084f0..3a295ac85 100644 --- a/src/xenia/vfs/devices/stfs_container_device.h +++ b/src/xenia/vfs/devices/stfs_container_device.h @@ -117,6 +117,8 @@ struct SvodVolumeDescriptor { class StfsHeader { public: + static const uint32_t kHeaderLength = 0xA000; + bool Read(const uint8_t* p); uint8_t license_entries[0x100];