summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar David Marcec2019-06-27 16:44:42 +1000
committerGravatar David Marcec2019-06-27 16:44:42 +1000
commit0b03e8a98fc7685e5b44292327e1b31de27e9bcd (patch)
treeb19bdd1fb7c812c17af02a4c0268ada73a22f263 /src
parentMerge pull request #2548 from DarkLordZach/applet-shopn (diff)
downloadyuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar.gz
yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar.xz
yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.zip
Implemented InitializeApplicationInfo & InitializeApplicationInfoRestricted
InitializeApplicationInfoRestricted will need further implementation as it's checking for other user requirements about the game. As we're emulating, we're assuming the user owns the game so we skip these checks currently, implementation will need to be added further on
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/acc/acc.cpp80
-rw-r--r--src/core/hle/service/acc/acc.h24
-rw-r--r--src/core/hle/service/acc/acc_u0.cpp4
-rw-r--r--src/core/hle/service/acc/errors.h12
4 files changed, 114 insertions, 6 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 0cd8158df..6aabe7409 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -15,13 +15,18 @@
15#include "core/file_sys/control_metadata.h" 15#include "core/file_sys/control_metadata.h"
16#include "core/file_sys/patch_manager.h" 16#include "core/file_sys/patch_manager.h"
17#include "core/hle/ipc_helpers.h" 17#include "core/hle/ipc_helpers.h"
18#include "core/hle/kernel/kernel.h"
18#include "core/hle/kernel/process.h" 19#include "core/hle/kernel/process.h"
19#include "core/hle/service/acc/acc.h" 20#include "core/hle/service/acc/acc.h"
20#include "core/hle/service/acc/acc_aa.h" 21#include "core/hle/service/acc/acc_aa.h"
21#include "core/hle/service/acc/acc_su.h" 22#include "core/hle/service/acc/acc_su.h"
22#include "core/hle/service/acc/acc_u0.h" 23#include "core/hle/service/acc/acc_u0.h"
23#include "core/hle/service/acc/acc_u1.h" 24#include "core/hle/service/acc/acc_u1.h"
25#include "core/hle/service/acc/errors.h"
24#include "core/hle/service/acc/profile_manager.h" 26#include "core/hle/service/acc/profile_manager.h"
27#include "core/hle/service/glue/arp.h"
28#include "core/hle/service/glue/manager.h"
29#include "core/hle/service/sm/sm.h"
25#include "core/loader/loader.h" 30#include "core/loader/loader.h"
26 31
27namespace Service::Account { 32namespace Service::Account {
@@ -217,10 +222,79 @@ void Module::Interface::IsUserRegistrationRequestPermitted(Kernel::HLERequestCon
217 rb.Push(profile_manager->CanSystemRegisterUser()); 222 rb.Push(profile_manager->CanSystemRegisterUser());
218} 223}
219 224
220void Module::Interface::InitializeApplicationInfoOld(Kernel::HLERequestContext& ctx) { 225void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
221 LOG_WARNING(Service_ACC, "(STUBBED) called"); 226 IPC::RequestParser rp{ctx};
227 auto pid = rp.Pop<u64>();
228
229 LOG_DEBUG(Service_ACC, "called, process_id={}", pid);
222 IPC::ResponseBuilder rb{ctx, 2}; 230 IPC::ResponseBuilder rb{ctx, 2};
223 rb.Push(RESULT_SUCCESS); 231 rb.Push(InitializeApplicationInfoBase(pid));
232}
233
234void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx) {
235 IPC::RequestParser rp{ctx};
236 auto pid = rp.Pop<u64>();
237
238 LOG_WARNING(Service_ACC, "(Partial implementation) called, process_id={}", pid);
239
240 const auto res = InitializeApplicationInfoBase(pid);
241
242 // TODO(ogniK): We require checking if the user actually owns the title and what not. As of
243 // currently, we assume the user owns the title.
244
245 IPC::ResponseBuilder rb{ctx, 2};
246 rb.Push(res);
247}
248
249ResultCode Module::Interface::InitializeApplicationInfoBase(u64 process_id) {
250 if (application_info) {
251 return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;
252 }
253
254 Service::SM::ServiceManager& sm = system.ServiceManager();
255 std::shared_ptr<Service::Glue::ARP_R> arp_r = sm.GetService<Service::Glue::ARP_R>("arp:r");
256 if (arp_r == nullptr) {
257 LOG_ERROR(Service_ACC, "Failed to get arp:r service");
258 application_info.application_type = ApplicationType::Unknown;
259
260 return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION);
261 }
262
263 const auto& list = system.Kernel().GetProcessList();
264 const auto iter = std::find_if(list.begin(), list.end(), [&process_id](const auto& process) {
265 return process->GetProcessID() == process_id;
266 });
267
268 if (iter == list.end()) {
269 // Failed to find process ID
270 application_info.application_type = ApplicationType::Unknown;
271
272 return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION);
273 }
274
275 const auto launch_property = system.GetARPManager().GetLaunchProperty((*iter)->GetTitleID());
276
277 if (launch_property.Failed()) {
278 return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION);
279 }
280
281 switch (launch_property->base_game_storage_id) {
282 case FileSys::StorageId::GameCard:
283 application_info.application_type = ApplicationType::GameCard;
284 break;
285 case FileSys::StorageId::Host:
286 case FileSys::StorageId::NandUser:
287 case FileSys::StorageId::SdCard:
288 application_info.application_type = ApplicationType::Digital;
289 break;
290 default:
291 return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION);
292 }
293
294 LOG_WARNING(Service_ACC, "ApplicationInfo init required");
295 // TODO(ogniK): Actual initalization here
296
297 return RESULT_SUCCESS;
224} 298}
225 299
226void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) { 300void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h
index 350f123a0..f651773b7 100644
--- a/src/core/hle/service/acc/acc.h
+++ b/src/core/hle/service/acc/acc.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "core/hle/service/glue/manager.h"
7#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
8 9
9namespace Service::Account { 10namespace Service::Account {
@@ -25,12 +26,33 @@ public:
25 void ListOpenUsers(Kernel::HLERequestContext& ctx); 26 void ListOpenUsers(Kernel::HLERequestContext& ctx);
26 void GetLastOpenedUser(Kernel::HLERequestContext& ctx); 27 void GetLastOpenedUser(Kernel::HLERequestContext& ctx);
27 void GetProfile(Kernel::HLERequestContext& ctx); 28 void GetProfile(Kernel::HLERequestContext& ctx);
28 void InitializeApplicationInfoOld(Kernel::HLERequestContext& ctx); 29 void InitializeApplicationInfo(Kernel::HLERequestContext& ctx);
30 void InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx);
29 void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx); 31 void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx);
30 void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx); 32 void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx);
31 void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx); 33 void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx);
32 void IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx); 34 void IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx);
33 35
36 private:
37 ResultCode InitializeApplicationInfoBase(u64 process_id);
38
39 enum class ApplicationType : u32_le {
40 GameCard = 0,
41 Digital = 1,
42 Unknown = 3,
43 };
44
45 struct ApplicationInfo {
46 Service::Glue::ApplicationLaunchProperty launch_property;
47 ApplicationType application_type;
48
49 constexpr explicit operator bool() const {
50 return launch_property.title_id != 0x0;
51 }
52 };
53
54 ApplicationInfo application_info{};
55
34 protected: 56 protected:
35 std::shared_ptr<Module> module; 57 std::shared_ptr<Module> module;
36 std::shared_ptr<ProfileManager> profile_manager; 58 std::shared_ptr<ProfileManager> profile_manager;
diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp
index 2f239e8c0..0ac19f4ff 100644
--- a/src/core/hle/service/acc/acc_u0.cpp
+++ b/src/core/hle/service/acc/acc_u0.cpp
@@ -22,7 +22,7 @@ ACC_U0::ACC_U0(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p
22 {51, &ACC_U0::TrySelectUserWithoutInteraction, "TrySelectUserWithoutInteraction"}, 22 {51, &ACC_U0::TrySelectUserWithoutInteraction, "TrySelectUserWithoutInteraction"},
23 {60, nullptr, "ListOpenContextStoredUsers"}, 23 {60, nullptr, "ListOpenContextStoredUsers"},
24 {99, nullptr, "DebugActivateOpenContextRetention"}, 24 {99, nullptr, "DebugActivateOpenContextRetention"},
25 {100, &ACC_U0::InitializeApplicationInfoOld, "InitializeApplicationInfoOld"}, 25 {100, &ACC_U0::InitializeApplicationInfo, "InitializeApplicationInfo"},
26 {101, &ACC_U0::GetBaasAccountManagerForApplication, "GetBaasAccountManagerForApplication"}, 26 {101, &ACC_U0::GetBaasAccountManagerForApplication, "GetBaasAccountManagerForApplication"},
27 {102, nullptr, "AuthenticateApplicationAsync"}, 27 {102, nullptr, "AuthenticateApplicationAsync"},
28 {103, nullptr, "CheckNetworkServiceAvailabilityAsync"}, 28 {103, nullptr, "CheckNetworkServiceAvailabilityAsync"},
@@ -31,7 +31,7 @@ ACC_U0::ACC_U0(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p
31 {120, nullptr, "CreateGuestLoginRequest"}, 31 {120, nullptr, "CreateGuestLoginRequest"},
32 {130, nullptr, "LoadOpenContext"}, 32 {130, nullptr, "LoadOpenContext"},
33 {131, nullptr, "ListOpenContextStoredUsers"}, 33 {131, nullptr, "ListOpenContextStoredUsers"},
34 {140, nullptr, "InitializeApplicationInfo"}, 34 {140, &ACC_U0::InitializeApplicationInfoRestricted, "InitializeApplicationInfoRestricted"},
35 {141, nullptr, "ListQualifiedUsers"}, 35 {141, nullptr, "ListQualifiedUsers"},
36 {150, &ACC_U0::IsUserAccountSwitchLocked, "IsUserAccountSwitchLocked"}, 36 {150, &ACC_U0::IsUserAccountSwitchLocked, "IsUserAccountSwitchLocked"},
37 }; 37 };
diff --git a/src/core/hle/service/acc/errors.h b/src/core/hle/service/acc/errors.h
new file mode 100644
index 000000000..86876dfd6
--- /dev/null
+++ b/src/core/hle/service/acc/errors.h
@@ -0,0 +1,12 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/result.h"
8
9namespace Service::Account {
10constexpr ResultCode ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22};
11constexpr ResultCode ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41};
12} // namespace Service::Account