From 351b5d23f4b332a36e4b5c7668809deae4de4af1 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Thu, 15 Dec 2016 09:54:25 +0000 Subject: [PATCH] loader: Implement ReadProgramId --- src/core/loader/loader.h | 9 +++++++++ src/core/loader/ncch.cpp | 12 ++++++++++++ src/core/loader/ncch.h | 7 +++++++ 3 files changed, 28 insertions(+) diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 5e3d466385..a6c2a745f7 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -143,6 +143,15 @@ public: return ResultStatus::ErrorNotImplemented; } + /** + * Get the program id of the application + * @param out_program_id Reference to store program id into + * @return ResultStatus result of function + */ + virtual ResultStatus ReadProgramId(u64& out_program_id) { + return ResultStatus::ErrorNotImplemented; + } + /** * Get the RomFS of the application * Since the RomFS can be huge, we return a file reference instead of copying to a buffer diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index d4be61e0e4..6f21644286 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -344,6 +344,18 @@ ResultStatus AppLoader_NCCH::ReadLogo(std::vector& buffer) { return LoadSectionExeFS("logo", buffer); } +ResultStatus AppLoader_NCCH::ReadProgramId(u64& out_program_id) { + if (!file.IsOpen()) + return ResultStatus::Error; + + ResultStatus result = LoadExeFS(); + if (result != ResultStatus::Success) + return result; + + out_program_id = ncch_header.program_id; + return ResultStatus::Success; +} + ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr& romfs_file, u64& offset, u64& size) { if (!file.IsOpen()) diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index bcf3ae6e3d..6c93d46d8f 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -219,6 +219,13 @@ public: */ ResultStatus ReadLogo(std::vector& buffer) override; + /** + * Get the program id of the application + * @param out_program_id Reference to store program id into + * @return ResultStatus result of function + */ + ResultStatus ReadProgramId(u64& out_program_id) override; + /** * Get the RomFS of the application * @param romfs_file Reference to buffer to store data