diff options
| -rw-r--r-- | src/core/file_sys/content_archive.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/content_archive.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/am/library_applet_creator.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/service/am/process.cpp | 23 | ||||
| -rw-r--r-- | src/core/hle/service/am/process.h | 2 |
5 files changed, 33 insertions, 7 deletions
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 285fe4db6..665252358 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp | |||
| @@ -172,6 +172,10 @@ u32 NCA::GetSDKVersion() const { | |||
| 172 | return reader->GetSdkAddonVersion(); | 172 | return reader->GetSdkAddonVersion(); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | u8 NCA::GetKeyGeneration() const { | ||
| 176 | return reader->GetKeyGeneration(); | ||
| 177 | } | ||
| 178 | |||
| 175 | bool NCA::IsUpdate() const { | 179 | bool NCA::IsUpdate() const { |
| 176 | return is_update; | 180 | return is_update; |
| 177 | } | 181 | } |
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index f68464eb0..8560617f5 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h | |||
| @@ -77,6 +77,7 @@ public: | |||
| 77 | u64 GetTitleId() const; | 77 | u64 GetTitleId() const; |
| 78 | RightsId GetRightsId() const; | 78 | RightsId GetRightsId() const; |
| 79 | u32 GetSDKVersion() const; | 79 | u32 GetSDKVersion() const; |
| 80 | u8 GetKeyGeneration() const; | ||
| 80 | bool IsUpdate() const; | 81 | bool IsUpdate() const; |
| 81 | 82 | ||
| 82 | VirtualFile GetRomFS() const; | 83 | VirtualFile GetRomFS() const; |
diff --git a/src/core/hle/service/am/library_applet_creator.cpp b/src/core/hle/service/am/library_applet_creator.cpp index c48ed29bc..00d5a0705 100644 --- a/src/core/hle/service/am/library_applet_creator.cpp +++ b/src/core/hle/service/am/library_applet_creator.cpp | |||
| @@ -102,8 +102,16 @@ std::shared_ptr<ILibraryAppletAccessor> CreateGuestApplet(Core::System& system, | |||
| 102 | return {}; | 102 | return {}; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | // TODO: enable other versions of applets | ||
| 106 | enum : u8 { | ||
| 107 | Firmware1400 = 14, | ||
| 108 | Firmware1500 = 15, | ||
| 109 | Firmware1600 = 16, | ||
| 110 | Firmware1700 = 17, | ||
| 111 | }; | ||
| 112 | |||
| 105 | auto process = std::make_unique<Process>(system); | 113 | auto process = std::make_unique<Process>(system); |
| 106 | if (!process->Initialize(program_id)) { | 114 | if (!process->Initialize(program_id, Firmware1400, Firmware1700)) { |
| 107 | // Couldn't initialize the guest process | 115 | // Couldn't initialize the guest process |
| 108 | return {}; | 116 | return {}; |
| 109 | } | 117 | } |
diff --git a/src/core/hle/service/am/process.cpp b/src/core/hle/service/am/process.cpp index 16b685f86..992c50713 100644 --- a/src/core/hle/service/am/process.cpp +++ b/src/core/hle/service/am/process.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include "common/scope_exit.h" | 4 | #include "common/scope_exit.h" |
| 5 | 5 | ||
| 6 | #include "core/file_sys/content_archive.h" | ||
| 6 | #include "core/file_sys/nca_metadata.h" | 7 | #include "core/file_sys/nca_metadata.h" |
| 7 | #include "core/file_sys/registered_cache.h" | 8 | #include "core/file_sys/registered_cache.h" |
| 8 | #include "core/hle/kernel/k_process.h" | 9 | #include "core/hle/kernel/k_process.h" |
| @@ -20,7 +21,7 @@ Process::~Process() { | |||
| 20 | this->Finalize(); | 21 | this->Finalize(); |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | bool Process::Initialize(u64 program_id) { | 24 | bool Process::Initialize(u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation) { |
| 24 | // First, ensure we are not holding another process. | 25 | // First, ensure we are not holding another process. |
| 25 | this->Finalize(); | 26 | this->Finalize(); |
| 26 | 27 | ||
| @@ -29,21 +30,33 @@ bool Process::Initialize(u64 program_id) { | |||
| 29 | 30 | ||
| 30 | // Attempt to load program NCA. | 31 | // Attempt to load program NCA. |
| 31 | const FileSys::RegisteredCache* bis_system{}; | 32 | const FileSys::RegisteredCache* bis_system{}; |
| 32 | FileSys::VirtualFile nca{}; | 33 | FileSys::VirtualFile nca_raw{}; |
| 33 | 34 | ||
| 34 | // Get the program NCA from built-in storage. | 35 | // Get the program NCA from built-in storage. |
| 35 | bis_system = fsc.GetSystemNANDContents(); | 36 | bis_system = fsc.GetSystemNANDContents(); |
| 36 | if (bis_system) { | 37 | if (bis_system) { |
| 37 | nca = bis_system->GetEntryRaw(program_id, FileSys::ContentRecordType::Program); | 38 | nca_raw = bis_system->GetEntryRaw(program_id, FileSys::ContentRecordType::Program); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | // Ensure we retrieved a program NCA. | 41 | // Ensure we retrieved a program NCA. |
| 41 | if (!nca) { | 42 | if (!nca_raw) { |
| 42 | return false; | 43 | return false; |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 46 | // Ensure we have a suitable version. | ||
| 47 | if (minimum_key_generation > 0) { | ||
| 48 | FileSys::NCA nca(nca_raw); | ||
| 49 | if (nca.GetStatus() == Loader::ResultStatus::Success && | ||
| 50 | (nca.GetKeyGeneration() < minimum_key_generation || | ||
| 51 | nca.GetKeyGeneration() > maximum_key_generation)) { | ||
| 52 | LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, | ||
| 53 | nca.GetKeyGeneration()); | ||
| 54 | return false; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 45 | // Get the appropriate loader to parse this NCA. | 58 | // Get the appropriate loader to parse this NCA. |
| 46 | auto app_loader = Loader::GetLoader(m_system, nca, program_id, 0); | 59 | auto app_loader = Loader::GetLoader(m_system, nca_raw, program_id, 0); |
| 47 | 60 | ||
| 48 | // Ensure we have a loader which can parse the NCA. | 61 | // Ensure we have a loader which can parse the NCA. |
| 49 | if (!app_loader) { | 62 | if (!app_loader) { |
diff --git a/src/core/hle/service/am/process.h b/src/core/hle/service/am/process.h index 4b908ade4..4b8102fb6 100644 --- a/src/core/hle/service/am/process.h +++ b/src/core/hle/service/am/process.h | |||
| @@ -21,7 +21,7 @@ public: | |||
| 21 | explicit Process(Core::System& system); | 21 | explicit Process(Core::System& system); |
| 22 | ~Process(); | 22 | ~Process(); |
| 23 | 23 | ||
| 24 | bool Initialize(u64 program_id); | 24 | bool Initialize(u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation); |
| 25 | void Finalize(); | 25 | void Finalize(); |
| 26 | 26 | ||
| 27 | bool Run(); | 27 | bool Run(); |