Преглед изворни кода

loader: Add BKTR-specific error messages and codes

Zach Hilman пре 8 година
родитељ
комит
f5e03b9173
3 измењених фајлова са 28 додато и 7 уклоњено
  1. 4 0
      src/core/CMakeLists.txt
  2. 10 1
      src/core/loader/loader.cpp
  3. 14 6
      src/core/loader/loader.h

+ 4 - 0
src/core/CMakeLists.txt

@@ -35,8 +35,12 @@ add_library(core STATIC
     file_sys/mode.h
     file_sys/nca_metadata.cpp
     file_sys/nca_metadata.h
+    file_sys/nca_patch.cpp
+    file_sys/nca_patch.h
     file_sys/partition_filesystem.cpp
     file_sys/partition_filesystem.h
+    file_sys/patch_manager.cpp
+    file_sys/patch_manager.h
     file_sys/program_metadata.cpp
     file_sys/program_metadata.h
     file_sys/registered_cache.cpp

+ 10 - 1
src/core/loader/loader.cpp

@@ -93,7 +93,7 @@ std::string GetFileTypeString(FileType type) {
     return "unknown";
 }
 
-constexpr std::array<const char*, 50> RESULT_MESSAGES{
+constexpr std::array<const char*, 57> RESULT_MESSAGES{
     "The operation completed successfully.",
     "The loader requested to load is already loaded.",
     "The operation is not implemented.",
@@ -144,6 +144,15 @@ constexpr std::array<const char*, 50> RESULT_MESSAGES{
     "The SD Save Key Source could not be found.",
     "The SD NCA Key Source could not be found.",
     "The NSP file is missing a Program-type NCA."};
+    "The BKTR-type NCA has a bad BKTR header.",
+    "The BKTR Subsection entry is not located immediately after the Relocation entry.",
+    "The BKTR Subsection entry is not at the end of the media block.",
+    "The BKTR-type NCA has a bad Relocation block.",
+    "The BKTR-type NCA has a bad Subsection block.",
+    "The BKTR-type NCA has a bad Relocation bucket.",
+    "The BKTR-type NCA has a bad Subsection bucket.",
+    "The BKTR-type NCA is missing the base RomFS.",
+};
 
 std::ostream& operator<<(std::ostream& os, ResultStatus status) {
     os << RESULT_MESSAGES.at(static_cast<size_t>(status));

+ 14 - 6
src/core/loader/loader.h

@@ -107,6 +107,14 @@ enum class ResultStatus : u16 {
     ErrorMissingSDSaveKeySource,
     ErrorMissingSDNCAKeySource,
     ErrorNSPMissingProgramNCA,
+    ErrorBadBKTRHeader,
+    ErrorBKTRSubsectionNotAfterRelocation,
+    ErrorBKTRSubsectionNotAtEnd,
+    ErrorBadRelocationBlock,
+    ErrorBadSubsectionBlock,
+    ErrorBadRelocationBuckets,
+    ErrorBadSubsectionBuckets,
+    ErrorMissingBKTRBaseRomFS,
 };
 
 std::ostream& operator<<(std::ostream& os, ResultStatus status);
@@ -197,13 +205,13 @@ public:
     }
 
     /**
-     * Get the update RomFS of the application
-     * Since the RomFS can be huge, we return a file reference instead of copying to a buffer
-     * @param file The file containing the RomFS
-     * @return ResultStatus result of function
+     * Get whether or not updates can be applied to the RomFS.
+     * By default, this is true, however for formats where it cannot be guaranteed that the RomFS is
+     * the base game it should be set to false.
+     * @return bool whether or not updatable.
      */
-    virtual ResultStatus ReadUpdateRomFS(FileSys::VirtualFile& file) {
-        return ResultStatus::ErrorNotImplemented;
+    virtual bool IsRomFSUpdatable() {
+        return true;
     }
 
     /**