diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-07-28 05:55:23 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-08-01 06:16:54 +0200 |
commit | df5b75694f5abde94ccf05fa6c7a557b1ba9079b (patch) | |
tree | 70f0cf96b1a9834360fb1c5d5547939693ecd577 /src/core/file_sys/card_image.h | |
parent | Merge pull request #871 from bunnei/audio-config (diff) | |
download | yuzu-df5b75694f5abde94ccf05fa6c7a557b1ba9079b.tar yuzu-df5b75694f5abde94ccf05fa6c7a557b1ba9079b.tar.gz yuzu-df5b75694f5abde94ccf05fa6c7a557b1ba9079b.tar.bz2 yuzu-df5b75694f5abde94ccf05fa6c7a557b1ba9079b.tar.lz yuzu-df5b75694f5abde94ccf05fa6c7a557b1ba9079b.tar.xz yuzu-df5b75694f5abde94ccf05fa6c7a557b1ba9079b.tar.zst yuzu-df5b75694f5abde94ccf05fa6c7a557b1ba9079b.zip |
Diffstat (limited to 'src/core/file_sys/card_image.h')
-rw-r--r-- | src/core/file_sys/card_image.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/core/file_sys/card_image.h b/src/core/file_sys/card_image.h new file mode 100644 index 000000000..b765c8bc1 --- /dev/null +++ b/src/core/file_sys/card_image.h @@ -0,0 +1,93 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <vector> +#include "common/swap.h" +#include "core/file_sys/content_archive.h" +#include "core/file_sys/vfs.h" + +namespace FileSys { + +enum class GamecardSize : u8 { + S_1GB = 0xFA, + S_2GB = 0xF8, + S_4GB = 0xF0, + S_8GB = 0xE0, + S_16GB = 0xE1, + S_32GB = 0xE2, +}; + +struct GamecardInfo { + std::array<u8, 0x70> data; +}; +static_assert(sizeof(GamecardInfo) == 0x70, "GamecardInfo has incorrect size."); + +struct GamecardHeader { + std::array<u8, 0x100> signature; + u32_le magic; + u32_le secure_area_start; + u32_le backup_area_start; + u8 kek_index; + GamecardSize size; + u8 header_version; + u8 flags; + u64_le package_id; + u64_le valid_data_end; + u128 info_iv; + u64_le hfs_offset; + u64_le hfs_size; + std::array<u8, 0x20> hfs_header_hash; + std::array<u8, 0x20> initial_data_hash; + u32_le secure_mode_flag; + u32_le title_key_flag; + u32_le key_flag; + u32_le normal_area_end; + GamecardInfo info; +}; +static_assert(sizeof(GamecardHeader) == 0x200, "GamecardHeader has incorrect size."); + +enum class XCIPartition : u8 { Update, Normal, Secure, Logo }; + +class XCI : public ReadOnlyVfsDirectory { +public: + explicit XCI(VirtualFile file); + + Loader::ResultStatus GetStatus() const; + + u8 GetFormatVersion() const; + + VirtualDir GetPartition(XCIPartition partition) const; + VirtualDir GetSecurePartition() const; + VirtualDir GetNormalPartition() const; + VirtualDir GetUpdatePartition() const; + VirtualDir GetLogoPartition() const; + + std::shared_ptr<NCA> GetNCAByType(NCAContentType type) const; + VirtualFile GetNCAFileByType(NCAContentType type) const; + + std::vector<std::shared_ptr<VfsFile>> GetFiles() const override; + + std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override; + + std::string GetName() const override; + + std::shared_ptr<VfsDirectory> GetParentDirectory() const override; + +protected: + bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override; + +private: + Loader::ResultStatus AddNCAFromPartition(XCIPartition part); + + VirtualFile file; + GamecardHeader header{}; + + Loader::ResultStatus status; + + std::vector<VirtualDir> partitions; + std::vector<std::shared_ptr<NCA>> ncas; +}; +} // namespace FileSys |