summaryrefslogtreecommitdiffstats
path: root/src/core/loader/ncch.h
diff options
context:
space:
mode:
authorMax Thomas <mtinc2@gmail.com>2017-09-25 08:17:38 +0200
committerB3n30 <bene_thomas@web.de>2017-09-25 08:17:38 +0200
commitc91ccbd0ba4118554d7377bbc3bd4c64f9bccf84 (patch)
treed56b08a52a11f229e9ce30aeda2b22bfccd48034 /src/core/loader/ncch.h
parentServices/UDS: Added a function to send EAPoL-Start packets (#2920) (diff)
downloadyuzu-c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84.tar
yuzu-c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84.tar.gz
yuzu-c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84.tar.bz2
yuzu-c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84.tar.lz
yuzu-c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84.tar.xz
yuzu-c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84.tar.zst
yuzu-c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84.zip
Diffstat (limited to 'src/core/loader/ncch.h')
-rw-r--r--src/core/loader/ncch.h184
1 files changed, 9 insertions, 175 deletions
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index e40cef764..9b56465cb 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -5,155 +5,12 @@
#pragma once
#include <memory>
-#include "common/bit_field.h"
#include "common/common_types.h"
#include "common/swap.h"
+#include "core/file_sys/ncch_container.h"
#include "core/loader/loader.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
-/// NCCH header (Note: "NCCH" appears to be a publicly unknown acronym)
-
-struct NCCH_Header {
- u8 signature[0x100];
- u32_le magic;
- u32_le content_size;
- u8 partition_id[8];
- u16_le maker_code;
- u16_le version;
- u8 reserved_0[4];
- u64_le program_id;
- u8 reserved_1[0x10];
- u8 logo_region_hash[0x20];
- u8 product_code[0x10];
- u8 extended_header_hash[0x20];
- u32_le extended_header_size;
- u8 reserved_2[4];
- u8 flags[8];
- u32_le plain_region_offset;
- u32_le plain_region_size;
- u32_le logo_region_offset;
- u32_le logo_region_size;
- u32_le exefs_offset;
- u32_le exefs_size;
- u32_le exefs_hash_region_size;
- u8 reserved_3[4];
- u32_le romfs_offset;
- u32_le romfs_size;
- u32_le romfs_hash_region_size;
- u8 reserved_4[4];
- u8 exefs_super_block_hash[0x20];
- u8 romfs_super_block_hash[0x20];
-};
-
-static_assert(sizeof(NCCH_Header) == 0x200, "NCCH header structure size is wrong");
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// ExeFS (executable file system) headers
-
-struct ExeFs_SectionHeader {
- char name[8];
- u32 offset;
- u32 size;
-};
-
-struct ExeFs_Header {
- ExeFs_SectionHeader section[8];
- u8 reserved[0x80];
- u8 hashes[8][0x20];
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// ExHeader (executable file system header) headers
-
-struct ExHeader_SystemInfoFlags {
- u8 reserved[5];
- u8 flag;
- u8 remaster_version[2];
-};
-
-struct ExHeader_CodeSegmentInfo {
- u32 address;
- u32 num_max_pages;
- u32 code_size;
-};
-
-struct ExHeader_CodeSetInfo {
- u8 name[8];
- ExHeader_SystemInfoFlags flags;
- ExHeader_CodeSegmentInfo text;
- u32 stack_size;
- ExHeader_CodeSegmentInfo ro;
- u8 reserved[4];
- ExHeader_CodeSegmentInfo data;
- u32 bss_size;
-};
-
-struct ExHeader_DependencyList {
- u8 program_id[0x30][8];
-};
-
-struct ExHeader_SystemInfo {
- u64 save_data_size;
- u8 jump_id[8];
- u8 reserved_2[0x30];
-};
-
-struct ExHeader_StorageInfo {
- u8 ext_save_data_id[8];
- u8 system_save_data_id[8];
- u8 reserved[8];
- u8 access_info[7];
- u8 other_attributes;
-};
-
-struct ExHeader_ARM11_SystemLocalCaps {
- u64_le program_id;
- u32_le core_version;
- u8 reserved_flags[2];
- union {
- u8 flags0;
- BitField<0, 2, u8> ideal_processor;
- BitField<2, 2, u8> affinity_mask;
- BitField<4, 4, u8> system_mode;
- };
- u8 priority;
- u8 resource_limit_descriptor[0x10][2];
- ExHeader_StorageInfo storage_info;
- u8 service_access_control[0x20][8];
- u8 ex_service_access_control[0x2][8];
- u8 reserved[0xf];
- u8 resource_limit_category;
-};
-
-struct ExHeader_ARM11_KernelCaps {
- u32_le descriptors[28];
- u8 reserved[0x10];
-};
-
-struct ExHeader_ARM9_AccessControl {
- u8 descriptors[15];
- u8 descversion;
-};
-
-struct ExHeader_Header {
- ExHeader_CodeSetInfo codeset_info;
- ExHeader_DependencyList dependency_list;
- ExHeader_SystemInfo system_info;
- ExHeader_ARM11_SystemLocalCaps arm11_system_local_caps;
- ExHeader_ARM11_KernelCaps arm11_kernel_caps;
- ExHeader_ARM9_AccessControl arm9_access_control;
- struct {
- u8 signature[0x100];
- u8 ncch_public_key_modulus[0x100];
- ExHeader_ARM11_SystemLocalCaps arm11_system_local_caps;
- ExHeader_ARM11_KernelCaps arm11_kernel_caps;
- ExHeader_ARM9_AccessControl arm9_access_control;
- } access_desc;
-};
-
-static_assert(sizeof(ExHeader_Header) == 0x800, "ExHeader structure size is wrong");
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
// Loader namespace
namespace Loader {
@@ -162,7 +19,8 @@ namespace Loader {
class AppLoader_NCCH final : public AppLoader {
public:
AppLoader_NCCH(FileUtil::IOFile&& file, const std::string& filepath)
- : AppLoader(std::move(file)), filepath(filepath) {}
+ : AppLoader(std::move(file)), filepath(filepath), base_ncch(filepath),
+ overlay_ncch(&base_ncch) {}
/**
* Returns the type of the file
@@ -196,48 +54,24 @@ public:
ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
u64& size) override;
+ ResultStatus ReadUpdateRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
+ u64& size) override;
+
ResultStatus ReadTitle(std::string& title) override;
private:
/**
- * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
- * @param name Name of section to read out of NCCH file
- * @param buffer Vector to read data into
- * @return ResultStatus result of function
- */
- ResultStatus LoadSectionExeFS(const char* name, std::vector<u8>& buffer);
-
- /**
* Loads .code section into memory for booting
* @return ResultStatus result of function
*/
ResultStatus LoadExec();
- /**
- * Ensure ExeFS is loaded and ready for reading sections
- * @return ResultStatus result of function
- */
- ResultStatus LoadExeFS();
-
/// Reads the region lockout info in the SMDH and send it to CFG service
void ParseRegionLockoutInfo();
- bool is_exefs_loaded = false;
- bool is_compressed = false;
-
- u32 entry_point = 0;
- u32 code_size = 0;
- u32 stack_size = 0;
- u32 bss_size = 0;
- u32 core_version = 0;
- u8 priority = 0;
- u8 resource_limit_category = 0;
- u32 ncch_offset = 0; // Offset to NCCH header, can be 0 or after NCSD header
- u32 exefs_offset = 0;
-
- NCCH_Header ncch_header;
- ExeFs_Header exefs_header;
- ExHeader_Header exheader_header;
+ FileSys::NCCHContainer base_ncch;
+ FileSys::NCCHContainer update_ncch;
+ FileSys::NCCHContainer* overlay_ncch;
std::string filepath;
};