2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-08-25 15:45:26 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
2018-09-05 16:06:47 +00:00
|
|
|
#include <memory>
|
2021-07-20 05:10:05 +00:00
|
|
|
#include <set>
|
2018-08-25 15:45:26 +00:00
|
|
|
#include <vector>
|
|
|
|
#include "common/common_types.h"
|
2023-06-08 23:26:24 +00:00
|
|
|
#include "core/file_sys/nca_metadata.h"
|
2018-08-25 15:45:26 +00:00
|
|
|
#include "core/file_sys/vfs.h"
|
2018-09-05 16:06:47 +00:00
|
|
|
|
2020-08-23 18:20:37 +00:00
|
|
|
namespace Core::Crypto {
|
|
|
|
class KeyManager;
|
|
|
|
}
|
|
|
|
|
2018-09-05 16:06:47 +00:00
|
|
|
namespace Loader {
|
|
|
|
enum class ResultStatus : u16;
|
|
|
|
}
|
2018-08-25 15:45:26 +00:00
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2018-09-05 16:06:47 +00:00
|
|
|
class NCA;
|
2018-09-04 18:44:40 +00:00
|
|
|
class PartitionFilesystem;
|
|
|
|
|
2018-09-05 16:06:47 +00:00
|
|
|
enum class ContentRecordType : u8;
|
|
|
|
|
2018-08-25 15:45:26 +00:00
|
|
|
class NSP : public ReadOnlyVfsDirectory {
|
|
|
|
public:
|
2021-07-20 05:10:05 +00:00
|
|
|
explicit NSP(VirtualFile file_, u64 title_id = 0, std::size_t program_index_ = 0);
|
2018-09-19 23:19:05 +00:00
|
|
|
~NSP() override;
|
2018-08-25 15:45:26 +00:00
|
|
|
|
|
|
|
Loader::ResultStatus GetStatus() const;
|
2021-07-20 05:10:05 +00:00
|
|
|
Loader::ResultStatus GetProgramStatus() const;
|
2018-08-25 15:45:26 +00:00
|
|
|
// Should only be used when one title id can be assured.
|
|
|
|
u64 GetProgramTitleID() const;
|
2021-07-20 05:10:05 +00:00
|
|
|
u64 GetExtractedTitleID() const;
|
|
|
|
std::vector<u64> GetProgramTitleIDs() const;
|
2018-08-25 15:45:26 +00:00
|
|
|
|
|
|
|
bool IsExtractedType() const;
|
|
|
|
|
|
|
|
// Common (Can be safely called on both types)
|
|
|
|
VirtualFile GetRomFS() const;
|
|
|
|
VirtualDir GetExeFS() const;
|
|
|
|
|
|
|
|
// Type 0 Only (Collection of NCAs + Certificate + Ticket + Meta XML)
|
|
|
|
std::vector<std::shared_ptr<NCA>> GetNCAsCollapsed() const;
|
|
|
|
std::multimap<u64, std::shared_ptr<NCA>> GetNCAsByTitleID() const;
|
2018-12-28 05:03:38 +00:00
|
|
|
std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>> GetNCAs()
|
|
|
|
const;
|
|
|
|
std::shared_ptr<NCA> GetNCA(u64 title_id, ContentRecordType type,
|
|
|
|
TitleType title_type = TitleType::Application) const;
|
|
|
|
VirtualFile GetNCAFile(u64 title_id, ContentRecordType type,
|
|
|
|
TitleType title_type = TitleType::Application) const;
|
2018-08-25 15:45:26 +00:00
|
|
|
std::vector<Core::Crypto::Key128> GetTitlekey() const;
|
|
|
|
|
|
|
|
std::vector<VirtualFile> GetFiles() const override;
|
|
|
|
|
|
|
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
|
|
|
|
|
|
|
std::string GetName() const override;
|
|
|
|
|
|
|
|
VirtualDir GetParentDirectory() const override;
|
|
|
|
|
|
|
|
private:
|
2020-05-12 18:46:14 +00:00
|
|
|
void SetTicketKeys(const std::vector<VirtualFile>& files);
|
2018-10-03 05:43:34 +00:00
|
|
|
void InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files);
|
2018-10-03 05:35:38 +00:00
|
|
|
void ReadNCAs(const std::vector<VirtualFile>& files);
|
|
|
|
|
2018-08-25 15:45:26 +00:00
|
|
|
VirtualFile file;
|
|
|
|
|
2021-07-20 05:10:05 +00:00
|
|
|
const u64 expected_program_id;
|
2020-11-24 23:16:24 +00:00
|
|
|
const std::size_t program_index;
|
|
|
|
|
2018-10-03 05:47:32 +00:00
|
|
|
bool extracted = false;
|
2018-08-25 15:45:26 +00:00
|
|
|
Loader::ResultStatus status;
|
|
|
|
std::map<u64, Loader::ResultStatus> program_status;
|
|
|
|
|
|
|
|
std::shared_ptr<PartitionFilesystem> pfs;
|
|
|
|
// Map title id -> {map type -> NCA}
|
2018-12-28 05:03:38 +00:00
|
|
|
std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>> ncas;
|
2021-07-20 05:10:05 +00:00
|
|
|
std::set<u64> program_ids;
|
2018-08-25 15:45:26 +00:00
|
|
|
std::vector<VirtualFile> ticket_files;
|
|
|
|
|
2020-08-23 18:20:37 +00:00
|
|
|
Core::Crypto::KeyManager& keys;
|
2018-11-02 00:23:38 +00:00
|
|
|
|
2018-08-25 15:45:26 +00:00
|
|
|
VirtualFile romfs;
|
|
|
|
VirtualDir exefs;
|
|
|
|
};
|
|
|
|
} // namespace FileSys
|