Преглед на файлове

loader: Implement ReadProgramId

MerryMage преди 9 години
родител
ревизия
351b5d23f4
променени са 3 файла, в които са добавени 28 реда и са изтрити 0 реда
  1. 9 0
      src/core/loader/loader.h
  2. 12 0
      src/core/loader/ncch.cpp
  3. 7 0
      src/core/loader/ncch.h

+ 9 - 0
src/core/loader/loader.h

@@ -143,6 +143,15 @@ public:
         return ResultStatus::ErrorNotImplemented;
         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
      * Get the RomFS of the application
      * Since the RomFS can be huge, we return a file reference instead of copying to a buffer
      * Since the RomFS can be huge, we return a file reference instead of copying to a buffer

+ 12 - 0
src/core/loader/ncch.cpp

@@ -344,6 +344,18 @@ ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) {
     return LoadSectionExeFS("logo", 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<FileUtil::IOFile>& romfs_file, u64& offset,
 ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
                                        u64& size) {
                                        u64& size) {
     if (!file.IsOpen())
     if (!file.IsOpen())

+ 7 - 0
src/core/loader/ncch.h

@@ -219,6 +219,13 @@ public:
      */
      */
     ResultStatus ReadLogo(std::vector<u8>& buffer) override;
     ResultStatus ReadLogo(std::vector<u8>& 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
      * Get the RomFS of the application
      * @param romfs_file Reference to buffer to store data
      * @param romfs_file Reference to buffer to store data