summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-07-03 20:23:56 -0400
committerGravatar GitHub2019-07-03 20:23:56 -0400
commitbeb3d77a79e248212c4645f1e42cac7f46538bda (patch)
tree302787c69650a3d9536519c90fb607bead238497
parentMerge pull request #2608 from ogniK5377/Time_GetSharedMemoryNativeHandle (diff)
parentAdded errors.h to cmakelist (diff)
downloadyuzu-beb3d77a79e248212c4645f1e42cac7f46538bda.tar.gz
yuzu-beb3d77a79e248212c4645f1e42cac7f46538bda.tar.xz
yuzu-beb3d77a79e248212c4645f1e42cac7f46538bda.zip
Merge pull request #2613 from ogniK5377/InitalizeApplicationInfo
Implemented InitializeApplicationInfo & InitializeApplicationInfoRestricted
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/hle/service/acc/acc.cpp73
-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.h14
5 files changed, 110 insertions, 6 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 686262702..30eb9d82e 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -175,6 +175,7 @@ add_library(core STATIC
175 hle/service/acc/acc_u0.h 175 hle/service/acc/acc_u0.h
176 hle/service/acc/acc_u1.cpp 176 hle/service/acc/acc_u1.cpp
177 hle/service/acc/acc_u1.h 177 hle/service/acc/acc_u1.h
178 hle/service/acc/errors.h
178 hle/service/acc/profile_manager.cpp 179 hle/service/acc/profile_manager.cpp
179 hle/service/acc/profile_manager.h 180 hle/service/acc/profile_manager.h
180 hle/service/am/am.cpp 181 hle/service/am/am.cpp
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 0cd8158df..c01ee3eda 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,72 @@ 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 // TODO(ogniK): We require checking if the user actually owns the title and what not. As of
241 // currently, we assume the user owns the title. InitializeApplicationInfoBase SHOULD be called
242 // first then we do extra checks if the game is a digital copy.
243
244 IPC::ResponseBuilder rb{ctx, 2};
245 rb.Push(InitializeApplicationInfoBase(pid));
246}
247
248ResultCode Module::Interface::InitializeApplicationInfoBase(u64 process_id) {
249 if (application_info) {
250 LOG_ERROR(Service_ACC, "Application already initialized");
251 return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;
252 }
253
254 const auto& list = system.Kernel().GetProcessList();
255 const auto iter = std::find_if(list.begin(), list.end(), [&process_id](const auto& process) {
256 return process->GetProcessID() == process_id;
257 });
258
259 if (iter == list.end()) {
260 LOG_ERROR(Service_ACC, "Failed to find process ID");
261 application_info.application_type = ApplicationType::Unknown;
262
263 return ERR_ACCOUNTINFO_BAD_APPLICATION;
264 }
265
266 const auto launch_property = system.GetARPManager().GetLaunchProperty((*iter)->GetTitleID());
267
268 if (launch_property.Failed()) {
269 LOG_ERROR(Service_ACC, "Failed to get launch property");
270 return ERR_ACCOUNTINFO_BAD_APPLICATION;
271 }
272
273 switch (launch_property->base_game_storage_id) {
274 case FileSys::StorageId::GameCard:
275 application_info.application_type = ApplicationType::GameCard;
276 break;
277 case FileSys::StorageId::Host:
278 case FileSys::StorageId::NandUser:
279 case FileSys::StorageId::SdCard:
280 application_info.application_type = ApplicationType::Digital;
281 break;
282 default:
283 LOG_ERROR(Service_ACC, "Invalid game storage ID");
284 return ERR_ACCOUNTINFO_BAD_APPLICATION;
285 }
286
287 LOG_WARNING(Service_ACC, "ApplicationInfo init required");
288 // TODO(ogniK): Actual initalization here
289
290 return RESULT_SUCCESS;
224} 291}
225 292
226void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) { 293void 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..1f0577239
--- /dev/null
+++ b/src/core/hle/service/acc/errors.h
@@ -0,0 +1,14 @@
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 {
10
11constexpr ResultCode ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22};
12constexpr ResultCode ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41};
13
14} // namespace Service::Account