summaryrefslogtreecommitdiff
path: root/src/core/hle/service/glue
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-06-25 22:25:10 -0400
committerGravatar Zach Hilman2019-06-25 22:25:10 -0400
commitd10fc2d7277cf075f875fe2831501cb79c50e21a (patch)
treea1ef0e65dfd79f8badde8dcd24014432428c51f8 /src/core/hle/service/glue
parentcore: Keep track of ARPManager and register current application on boot (diff)
downloadyuzu-d10fc2d7277cf075f875fe2831501cb79c50e21a.tar.gz
yuzu-d10fc2d7277cf075f875fe2831501cb79c50e21a.tar.xz
yuzu-d10fc2d7277cf075f875fe2831501cb79c50e21a.zip
glue: Correct missing bytes in ApplicationLaunchParameter
Diffstat (limited to 'src/core/hle/service/glue')
-rw-r--r--src/core/hle/service/glue/arp.cpp30
-rw-r--r--src/core/hle/service/glue/errors.h9
-rw-r--r--src/core/hle/service/glue/manager.cpp21
-rw-r--r--src/core/hle/service/glue/manager.h29
4 files changed, 61 insertions, 28 deletions
diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp
index 19c75ff2f..b591ce31b 100644
--- a/src/core/hle/service/glue/arp.cpp
+++ b/src/core/hle/service/glue/arp.cpp
@@ -58,7 +58,8 @@ void ARP_R::GetApplicationLaunchProperty(Kernel::HLERequestContext& ctx) {
58 if (!title_id.has_value()) { 58 if (!title_id.has_value()) {
59 LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!"); 59 LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!");
60 IPC::ResponseBuilder rb{ctx, 2}; 60 IPC::ResponseBuilder rb{ctx, 2};
61 rb.Push(ERR_NONEXISTENT); 61 rb.Push(ERR_NOT_REGISTERED);
62 return;
62 } 63 }
63 64
64 const auto res = manager.GetLaunchProperty(*title_id); 65 const auto res = manager.GetLaunchProperty(*title_id);
@@ -67,6 +68,7 @@ void ARP_R::GetApplicationLaunchProperty(Kernel::HLERequestContext& ctx) {
67 LOG_ERROR(Service_ARP, "Failed to get launch property!"); 68 LOG_ERROR(Service_ARP, "Failed to get launch property!");
68 IPC::ResponseBuilder rb{ctx, 2}; 69 IPC::ResponseBuilder rb{ctx, 2};
69 rb.Push(res.Code()); 70 rb.Push(res.Code());
71 return;
70 } 72 }
71 73
72 IPC::ResponseBuilder rb{ctx, 6}; 74 IPC::ResponseBuilder rb{ctx, 6};
@@ -86,6 +88,7 @@ void ARP_R::GetApplicationLaunchPropertyWithApplicationId(Kernel::HLERequestCont
86 LOG_ERROR(Service_ARP, "Failed to get launch property!"); 88 LOG_ERROR(Service_ARP, "Failed to get launch property!");
87 IPC::ResponseBuilder rb{ctx, 2}; 89 IPC::ResponseBuilder rb{ctx, 2};
88 rb.Push(res.Code()); 90 rb.Push(res.Code());
91 return;
89 } 92 }
90 93
91 IPC::ResponseBuilder rb{ctx, 6}; 94 IPC::ResponseBuilder rb{ctx, 6};
@@ -103,7 +106,8 @@ void ARP_R::GetApplicationControlProperty(Kernel::HLERequestContext& ctx) {
103 if (!title_id.has_value()) { 106 if (!title_id.has_value()) {
104 LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!"); 107 LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!");
105 IPC::ResponseBuilder rb{ctx, 2}; 108 IPC::ResponseBuilder rb{ctx, 2};
106 rb.Push(ERR_NONEXISTENT); 109 rb.Push(ERR_NOT_REGISTERED);
110 return;
107 } 111 }
108 112
109 const auto res = manager.GetControlProperty(*title_id); 113 const auto res = manager.GetControlProperty(*title_id);
@@ -112,6 +116,7 @@ void ARP_R::GetApplicationControlProperty(Kernel::HLERequestContext& ctx) {
112 LOG_ERROR(Service_ARP, "Failed to get control property!"); 116 LOG_ERROR(Service_ARP, "Failed to get control property!");
113 IPC::ResponseBuilder rb{ctx, 2}; 117 IPC::ResponseBuilder rb{ctx, 2};
114 rb.Push(res.Code()); 118 rb.Push(res.Code());
119 return;
115 } 120 }
116 121
117 ctx.WriteBuffer(*res); 122 ctx.WriteBuffer(*res);
@@ -132,6 +137,7 @@ void ARP_R::GetApplicationControlPropertyWithApplicationId(Kernel::HLERequestCon
132 LOG_ERROR(Service_ARP, "Failed to get control property!"); 137 LOG_ERROR(Service_ARP, "Failed to get control property!");
133 IPC::ResponseBuilder rb{ctx, 2}; 138 IPC::ResponseBuilder rb{ctx, 2};
134 rb.Push(res.Code()); 139 rb.Push(res.Code());
140 return;
135 } 141 }
136 142
137 ctx.WriteBuffer(*res); 143 ctx.WriteBuffer(*res);
@@ -168,14 +174,16 @@ private:
168 if (process_id == 0) { 174 if (process_id == 0) {
169 LOG_ERROR(Service_ARP, "Must have non-zero process ID!"); 175 LOG_ERROR(Service_ARP, "Must have non-zero process ID!");
170 IPC::ResponseBuilder rb{ctx, 2}; 176 IPC::ResponseBuilder rb{ctx, 2};
171 rb.Push(ERR_PROCESS_ID_ZERO); 177 rb.Push(ERR_INVALID_PROCESS_ID);
178 return;
172 } 179 }
173 180
174 if (issued) { 181 if (issued) {
175 LOG_ERROR(Service_ARP, 182 LOG_ERROR(Service_ARP,
176 "Attempted to issue registrar, but registrar is already issued!"); 183 "Attempted to issue registrar, but registrar is already issued!");
177 IPC::ResponseBuilder rb{ctx, 2}; 184 IPC::ResponseBuilder rb{ctx, 2};
178 rb.Push(ERR_ALREADY_ISSUED); 185 rb.Push(ERR_INVALID_ACCESS);
186 return;
179 } 187 }
180 188
181 issue_process_id(process_id, launch, std::move(control)); 189 issue_process_id(process_id, launch, std::move(control));
@@ -193,7 +201,8 @@ private:
193 Service_ARP, 201 Service_ARP,
194 "Attempted to set application launch property, but registrar is already issued!"); 202 "Attempted to set application launch property, but registrar is already issued!");
195 IPC::ResponseBuilder rb{ctx, 2}; 203 IPC::ResponseBuilder rb{ctx, 2};
196 rb.Push(ERR_ALREADY_ISSUED); 204 rb.Push(ERR_INVALID_ACCESS);
205 return;
197 } 206 }
198 207
199 IPC::RequestParser rp{ctx}; 208 IPC::RequestParser rp{ctx};
@@ -211,7 +220,8 @@ private:
211 Service_ARP, 220 Service_ARP,
212 "Attempted to set application control property, but registrar is already issued!"); 221 "Attempted to set application control property, but registrar is already issued!");
213 IPC::ResponseBuilder rb{ctx, 2}; 222 IPC::ResponseBuilder rb{ctx, 2};
214 rb.Push(ERR_ALREADY_ISSUED); 223 rb.Push(ERR_INVALID_ACCESS);
224 return;
215 } 225 }
216 226
217 control = ctx.ReadBuffer(); 227 control = ctx.ReadBuffer();
@@ -247,7 +257,7 @@ void ARP_W::AcquireRegistrar(Kernel::HLERequestContext& ctx) {
247 [this](u64 process_id, ApplicationLaunchProperty launch, std::vector<u8> control) { 257 [this](u64 process_id, ApplicationLaunchProperty launch, std::vector<u8> control) {
248 const auto res = GetTitleIDForProcessID(system, process_id); 258 const auto res = GetTitleIDForProcessID(system, process_id);
249 if (!res.has_value()) { 259 if (!res.has_value()) {
250 return ERR_NONEXISTENT; 260 return ERR_NOT_REGISTERED;
251 } 261 }
252 262
253 return manager.Register(*res, launch, std::move(control)); 263 return manager.Register(*res, launch, std::move(control));
@@ -267,7 +277,8 @@ void ARP_W::DeleteProperties(Kernel::HLERequestContext& ctx) {
267 if (process_id == 0) { 277 if (process_id == 0) {
268 LOG_ERROR(Service_ARP, "Must have non-zero process ID!"); 278 LOG_ERROR(Service_ARP, "Must have non-zero process ID!");
269 IPC::ResponseBuilder rb{ctx, 2}; 279 IPC::ResponseBuilder rb{ctx, 2};
270 rb.Push(ERR_PROCESS_ID_ZERO); 280 rb.Push(ERR_INVALID_PROCESS_ID);
281 return;
271 } 282 }
272 283
273 const auto title_id = GetTitleIDForProcessID(system, process_id); 284 const auto title_id = GetTitleIDForProcessID(system, process_id);
@@ -275,7 +286,8 @@ void ARP_W::DeleteProperties(Kernel::HLERequestContext& ctx) {
275 if (!title_id.has_value()) { 286 if (!title_id.has_value()) {
276 LOG_ERROR(Service_ARP, "No title ID for process ID!"); 287 LOG_ERROR(Service_ARP, "No title ID for process ID!");
277 IPC::ResponseBuilder rb{ctx, 2}; 288 IPC::ResponseBuilder rb{ctx, 2};
278 rb.Push(ERR_NONEXISTENT); 289 rb.Push(ERR_NOT_REGISTERED);
290 return;
279 } 291 }
280 292
281 IPC::ResponseBuilder rb{ctx, 2}; 293 IPC::ResponseBuilder rb{ctx, 2};
diff --git a/src/core/hle/service/glue/errors.h b/src/core/hle/service/glue/errors.h
index 594e20a01..c2874c585 100644
--- a/src/core/hle/service/glue/errors.h
+++ b/src/core/hle/service/glue/errors.h
@@ -8,10 +8,9 @@
8 8
9namespace Service::Glue { 9namespace Service::Glue {
10 10
11constexpr ResultCode ERR_OUTPUT_TOO_SMALL{0x3C9D}; 11constexpr ResultCode ERR_INVALID_RESOURCE{ErrorModule::ARP, 0x1E};
12constexpr ResultCode ERR_PROCESS_ID_ZERO{0x3E9D}; 12constexpr ResultCode ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 0x1F};
13constexpr ResultCode ERR_TITLE_ID_ZERO{0x3E9D}; 13constexpr ResultCode ERR_INVALID_ACCESS{ErrorModule::ARP, 0x2A};
14constexpr ResultCode ERR_ALREADY_ISSUED{0x549D}; 14constexpr ResultCode ERR_NOT_REGISTERED{ErrorModule::ARP, 0x66};
15constexpr ResultCode ERR_NONEXISTENT{0xCC9D};
16 15
17} // namespace Service::Glue 16} // namespace Service::Glue
diff --git a/src/core/hle/service/glue/manager.cpp b/src/core/hle/service/glue/manager.cpp
index 0d5bb4d50..6da52d2d6 100644
--- a/src/core/hle/service/glue/manager.cpp
+++ b/src/core/hle/service/glue/manager.cpp
@@ -7,18 +7,23 @@
7 7
8namespace Service::Glue { 8namespace Service::Glue {
9 9
10struct ARPManager::MapEntry {
11 ApplicationLaunchProperty launch;
12 std::vector<u8> control;
13};
14
10ARPManager::ARPManager() = default; 15ARPManager::ARPManager() = default;
11 16
12ARPManager::~ARPManager() = default; 17ARPManager::~ARPManager() = default;
13 18
14ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const { 19ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const {
15 if (title_id == 0) { 20 if (title_id == 0) {
16 return ERR_TITLE_ID_ZERO; 21 return ERR_INVALID_PROCESS_ID;
17 } 22 }
18 23
19 const auto iter = entries.find(title_id); 24 const auto iter = entries.find(title_id);
20 if (iter == entries.end()) { 25 if (iter == entries.end()) {
21 return ERR_NONEXISTENT; 26 return ERR_NOT_REGISTERED;
22 } 27 }
23 28
24 return MakeResult<ApplicationLaunchProperty>(iter->second.launch); 29 return MakeResult<ApplicationLaunchProperty>(iter->second.launch);
@@ -26,12 +31,12 @@ ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id)
26 31
27ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { 32ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
28 if (title_id == 0) { 33 if (title_id == 0) {
29 return ERR_TITLE_ID_ZERO; 34 return ERR_INVALID_PROCESS_ID;
30 } 35 }
31 36
32 const auto iter = entries.find(title_id); 37 const auto iter = entries.find(title_id);
33 if (iter == entries.end()) { 38 if (iter == entries.end()) {
34 return ERR_NONEXISTENT; 39 return ERR_NOT_REGISTERED;
35 } 40 }
36 41
37 return MakeResult<std::vector<u8>>(iter->second.control); 42 return MakeResult<std::vector<u8>>(iter->second.control);
@@ -40,12 +45,12 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
40ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, 45ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
41 std::vector<u8> control) { 46 std::vector<u8> control) {
42 if (title_id == 0) { 47 if (title_id == 0) {
43 return ERR_TITLE_ID_ZERO; 48 return ERR_INVALID_PROCESS_ID;
44 } 49 }
45 50
46 const auto iter = entries.find(title_id); 51 const auto iter = entries.find(title_id);
47 if (iter != entries.end()) { 52 if (iter != entries.end()) {
48 return ERR_ALREADY_ISSUED; 53 return ERR_INVALID_ACCESS;
49 } 54 }
50 55
51 entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)}); 56 entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)});
@@ -54,12 +59,12 @@ ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
54 59
55ResultCode ARPManager::Unregister(u64 title_id) { 60ResultCode ARPManager::Unregister(u64 title_id) {
56 if (title_id == 0) { 61 if (title_id == 0) {
57 return ERR_TITLE_ID_ZERO; 62 return ERR_INVALID_PROCESS_ID;
58 } 63 }
59 64
60 const auto iter = entries.find(title_id); 65 const auto iter = entries.find(title_id);
61 if (iter == entries.end()) { 66 if (iter == entries.end()) {
62 return ERR_NONEXISTENT; 67 return ERR_NOT_REGISTERED;
63 } 68 }
64 69
65 entries.erase(iter); 70 entries.erase(iter);
diff --git a/src/core/hle/service/glue/manager.h b/src/core/hle/service/glue/manager.h
index 561ebf4e0..a7f5ce3ee 100644
--- a/src/core/hle/service/glue/manager.h
+++ b/src/core/hle/service/glue/manager.h
@@ -4,6 +4,9 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <map>
8#include <vector>
9#include "common/common_types.h"
7#include "core/file_sys/control_metadata.h" 10#include "core/file_sys/control_metadata.h"
8#include "core/file_sys/romfs_factory.h" 11#include "core/file_sys/romfs_factory.h"
9#include "core/hle/result.h" 12#include "core/hle/result.h"
@@ -15,31 +18,45 @@ struct ApplicationLaunchProperty {
15 u32 version; 18 u32 version;
16 FileSys::StorageId base_game_storage_id; 19 FileSys::StorageId base_game_storage_id;
17 FileSys::StorageId update_storage_id; 20 FileSys::StorageId update_storage_id;
18 INSERT_PADDING_BYTES(0x2); 21 u8 program_index;
22 u8 reserved;
19}; 23};
20static_assert(sizeof(ApplicationLaunchProperty) == 0x10, 24static_assert(sizeof(ApplicationLaunchProperty) == 0x10,
21 "ApplicationLaunchProperty has incorrect size."); 25 "ApplicationLaunchProperty has incorrect size.");
22 26
27// A class to manage state related to the arp:w and arp:r services, specifically the registration
28// and unregistration of launch and control properties.
23class ARPManager { 29class ARPManager {
24public: 30public:
25 ARPManager(); 31 ARPManager();
26 ~ARPManager(); 32 ~ARPManager();
27 33
34 // Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was
35 // previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or
36 // ERR_INVALID_PROCESS_ID if the title ID is 0.
28 ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const; 37 ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const;
38
39 // Returns a vector of the raw bytes of NACP data (necessarily 0x4000 in size) corresponding to
40 // the provided title ID if it was previously registered, otherwise ERR_NOT_REGISTERED if it was
41 // never registered or ERR_INVALID_PROCESS_ID if the title ID is 0.
29 ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const; 42 ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const;
30 43
44 // Adds a new entry to the internal database with the provided parameters, returning
45 // ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
46 // step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
31 ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control); 47 ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
32 48
49 // Removes the registration for the provided title ID from the database, returning
50 // ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
51 // title ID is 0.
33 ResultCode Unregister(u64 title_id); 52 ResultCode Unregister(u64 title_id);
34 53
54 // Removes all entries from the database, always succeeds. Should only be used when resetting
55 // system state.
35 void ResetAll(); 56 void ResetAll();
36 57
37private: 58private:
38 struct MapEntry { 59 struct MapEntry;
39 ApplicationLaunchProperty launch;
40 std::vector<u8> control;
41 };
42
43 std::map<u64, MapEntry> entries; 60 std::map<u64, MapEntry> entries;
44}; 61};
45 62