summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/acc/acc.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/acc/acc.cpp131
1 files changed, 68 insertions, 63 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 6d1084fd1..6c29cb613 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -15,7 +15,6 @@
#include "core/core_timing.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
-#include "core/hle/ipc_helpers.h"
#include "core/hle/service/acc/acc.h"
#include "core/hle/service/acc/acc_aa.h"
#include "core/hle/service/acc/acc_su.h"
@@ -25,16 +24,12 @@
#include "core/hle/service/acc/errors.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/glue/glue_manager.h"
+#include "core/hle/service/ipc_helpers.h"
+#include "core/hle/service/server_manager.h"
#include "core/loader/loader.h"
namespace Service::Account {
-constexpr Result ERR_INVALID_USER_ID{ErrorModule::Account, 20};
-constexpr Result ERR_INVALID_APPLICATION_ID{ErrorModule::Account, 22};
-constexpr Result ERR_INVALID_BUFFER{ErrorModule::Account, 30};
-constexpr Result ERR_INVALID_BUFFER_SIZE{ErrorModule::Account, 31};
-constexpr Result ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100};
-
// Thumbnails are hard coded to be at least this size
constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
@@ -76,6 +71,8 @@ public:
{141, nullptr, "RefreshNetworkServiceLicenseCacheAsync"}, // 5.0.0+
{142, nullptr, "RefreshNetworkServiceLicenseCacheAsyncIfSecondsElapsed"}, // 5.0.0+
{150, nullptr, "CreateAuthorizationRequest"},
+ {160, nullptr, "RequiresUpdateNetworkServiceAccountIdTokenCache"},
+ {161, nullptr, "RequireReauthenticationOfNetworkServiceAccount"},
};
// clang-format on
@@ -136,7 +133,10 @@ public:
{140, nullptr, "GetNetworkServiceLicenseCache"}, // 5.0.0+
{141, nullptr, "RefreshNetworkServiceLicenseCacheAsync"}, // 5.0.0+
{142, nullptr, "RefreshNetworkServiceLicenseCacheAsyncIfSecondsElapsed"}, // 5.0.0+
+ {143, nullptr, "GetNetworkServiceLicenseCacheEx"},
{150, nullptr, "CreateAuthorizationRequest"},
+ {160, nullptr, "RequiresUpdateNetworkServiceAccountIdTokenCache"},
+ {161, nullptr, "RequireReauthenticationOfNetworkServiceAccount"},
{200, nullptr, "IsRegistered"},
{201, nullptr, "RegisterAsync"},
{202, nullptr, "UnregisterAsync"},
@@ -242,6 +242,7 @@ public:
{100, nullptr, "GetRequestWithTheme"},
{101, nullptr, "IsNetworkServiceAccountReplaced"},
{199, nullptr, "GetUrlForIntroductionOfExtraMembership"}, // 2.0.0 - 5.1.0
+ {200, nullptr, "ApplyAsyncWithAuthorizedToken"},
};
// clang-format on
@@ -288,7 +289,7 @@ public:
}
protected:
- void Get(Kernel::HLERequestContext& ctx) {
+ void Get(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
ProfileBase profile_base{};
UserData data{};
@@ -305,7 +306,7 @@ protected:
}
}
- void GetBase(Kernel::HLERequestContext& ctx) {
+ void GetBase(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
ProfileBase profile_base{};
if (profile_manager.GetProfileBase(user_id, profile_base)) {
@@ -319,7 +320,7 @@ protected:
}
}
- void LoadImage(Kernel::HLERequestContext& ctx) {
+ void LoadImage(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 3};
@@ -346,7 +347,7 @@ protected:
rb.Push<u32>(size);
}
- void GetImageSize(Kernel::HLERequestContext& ctx) {
+ void GetImageSize(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
@@ -363,7 +364,7 @@ protected:
}
}
- void Store(Kernel::HLERequestContext& ctx) {
+ void Store(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto base = rp.PopRaw<ProfileBase>();
@@ -377,7 +378,7 @@ protected:
if (user_data.size() < sizeof(UserData)) {
LOG_ERROR(Service_ACC, "UserData buffer too small!");
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ERR_INVALID_BUFFER);
+ rb.Push(Account::ResultInvalidArrayLength);
return;
}
@@ -387,7 +388,7 @@ protected:
if (!profile_manager.SetProfileBaseAndData(user_id, base, data)) {
LOG_ERROR(Service_ACC, "Failed to update user data and base!");
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ERR_FAILED_SAVE_DATA);
+ rb.Push(Account::ResultAccountUpdateFailed);
return;
}
@@ -395,7 +396,7 @@ protected:
rb.Push(ResultSuccess);
}
- void StoreWithImage(Kernel::HLERequestContext& ctx) {
+ void StoreWithImage(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto base = rp.PopRaw<ProfileBase>();
@@ -410,7 +411,7 @@ protected:
if (user_data.size() < sizeof(UserData)) {
LOG_ERROR(Service_ACC, "UserData buffer too small!");
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ERR_INVALID_BUFFER);
+ rb.Push(Account::ResultInvalidArrayLength);
return;
}
@@ -425,7 +426,7 @@ protected:
!profile_manager.SetProfileBaseAndData(user_id, base, data)) {
LOG_ERROR(Service_ACC, "Failed to update profile data, base, and image!");
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ERR_FAILED_SAVE_DATA);
+ rb.Push(Account::ResultAccountUpdateFailed);
return;
}
@@ -492,7 +493,7 @@ public:
}
~EnsureTokenIdCacheAsyncInterface() = default;
- void LoadIdTokenCache(Kernel::HLERequestContext& ctx) {
+ void LoadIdTokenCache(HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
@@ -535,14 +536,14 @@ public:
}
private:
- void CheckAvailability(Kernel::HLERequestContext& ctx) {
+ void CheckAvailability(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(false); // TODO: Check when this is supposed to return true and when not
}
- void GetAccountId(Kernel::HLERequestContext& ctx) {
+ void GetAccountId(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 4};
@@ -550,7 +551,7 @@ private:
rb.PushRaw<u64>(profile_manager->GetLastOpenedUser().Hash());
}
- void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) {
+ void EnsureIdTokenCacheAsync(HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -558,13 +559,13 @@ private:
rb.PushIpcInterface(ensure_token_id);
}
- void LoadIdTokenCache(Kernel::HLERequestContext& ctx) {
+ void LoadIdTokenCache(HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
ensure_token_id->LoadIdTokenCache(ctx);
}
- void GetNintendoAccountUserResourceCacheForApplication(Kernel::HLERequestContext& ctx) {
+ void GetNintendoAccountUserResourceCacheForApplication(HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
std::vector<u8> nas_user_base_for_application(0x68);
@@ -580,7 +581,7 @@ private:
rb.PushRaw<u64>(profile_manager->GetLastOpenedUser().Hash());
}
- void StoreOpenContext(Kernel::HLERequestContext& ctx) {
+ void StoreOpenContext(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
profile_manager->StoreOpenedUsers();
@@ -647,9 +648,11 @@ public:
{0, nullptr, "EnsureAuthenticationTokenCacheAsync"},
{1, nullptr, "LoadAuthenticationTokenCache"},
{2, nullptr, "InvalidateAuthenticationTokenCache"},
+ {3, nullptr, "IsDeviceAuthenticationTokenCacheAvailable"},
{10, nullptr, "EnsureEdgeTokenCacheAsync"},
{11, nullptr, "LoadEdgeTokenCache"},
{12, nullptr, "InvalidateEdgeTokenCache"},
+ {13, nullptr, "IsEdgeTokenCacheAvailable"},
{20, nullptr, "EnsureApplicationAuthenticationCacheAsync"},
{21, nullptr, "LoadApplicationAuthenticationTokenCache"},
{22, nullptr, "LoadApplicationNetworkServiceClientConfigCache"},
@@ -680,14 +683,14 @@ public:
}
};
-void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) {
+void Module::Interface::GetUserCount(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(profile_manager->GetUserCount()));
}
-void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
+void Module::Interface::GetUserExistence(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
Common::UUID user_id = rp.PopRaw<Common::UUID>();
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
@@ -697,28 +700,28 @@ void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
rb.Push(profile_manager->UserExists(user_id));
}
-void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) {
+void Module::Interface::ListAllUsers(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
ctx.WriteBuffer(profile_manager->GetAllUsers());
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
-void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) {
+void Module::Interface::ListOpenUsers(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
ctx.WriteBuffer(profile_manager->GetOpenUsers());
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
-void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
+void Module::Interface::GetLastOpenedUser(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 6};
rb.Push(ResultSuccess);
rb.PushRaw<Common::UUID>(profile_manager->GetLastOpenedUser());
}
-void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
+void Module::Interface::GetProfile(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
Common::UUID user_id = rp.PopRaw<Common::UUID>();
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
@@ -728,20 +731,20 @@ void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
rb.PushIpcInterface<IProfile>(system, user_id, *profile_manager);
}
-void Module::Interface::IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx) {
+void Module::Interface::IsUserRegistrationRequestPermitted(HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(profile_manager->CanSystemRegisterUser());
}
-void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
+void Module::Interface::InitializeApplicationInfo(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(InitializeApplicationInfoBase());
}
-void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx) {
+void Module::Interface::InitializeApplicationInfoRestricted(HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(Partial implementation) called");
// TODO(ogniK): We require checking if the user actually owns the title and what not. As of
@@ -755,18 +758,18 @@ void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestCo
Result Module::Interface::InitializeApplicationInfoBase() {
if (application_info) {
LOG_ERROR(Service_ACC, "Application already initialized");
- return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;
+ return Account::ResultApplicationInfoAlreadyInitialized;
}
// TODO(ogniK): This should be changed to reflect the target process for when we have multiple
// processes emulated. As we don't actually have pid support we should assume we're just using
// our own process
const auto launch_property =
- system.GetARPManager().GetLaunchProperty(system.GetCurrentProcessProgramID());
+ system.GetARPManager().GetLaunchProperty(system.GetApplicationProcessProgramID());
if (launch_property.Failed()) {
LOG_ERROR(Service_ACC, "Failed to get launch property");
- return ERR_ACCOUNTINFO_BAD_APPLICATION;
+ return Account::ResultInvalidApplication;
}
switch (launch_property->base_game_storage_id) {
@@ -782,23 +785,23 @@ Result Module::Interface::InitializeApplicationInfoBase() {
default:
LOG_ERROR(Service_ACC, "Invalid game storage ID! storage_id={}",
launch_property->base_game_storage_id);
- return ERR_ACCOUNTINFO_BAD_APPLICATION;
+ return Account::ResultInvalidApplication;
}
LOG_WARNING(Service_ACC, "ApplicationInfo init required");
- // TODO(ogniK): Actual initalization here
+ // TODO(ogniK): Actual initialization here
return ResultSuccess;
}
-void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) {
+void Module::Interface::GetBaasAccountManagerForApplication(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<IManagerForApplication>(system, profile_manager);
}
-void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) {
+void Module::Interface::IsUserAccountSwitchLocked(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
FileSys::NACP nacp;
const auto res = system.GetAppLoader().ReadControlData(nacp);
@@ -806,7 +809,7 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx
bool is_locked = false;
if (res != Loader::ResultStatus::Success) {
- const FileSys::PatchManager pm{system.GetCurrentProcessProgramID(),
+ const FileSys::PatchManager pm{system.GetApplicationProcessProgramID(),
system.GetFileSystemController(),
system.GetContentProvider()};
const auto nacp_unique = pm.GetControlMetadata().first;
@@ -825,14 +828,14 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx
rb.Push(is_locked);
}
-void Module::Interface::InitializeApplicationInfoV2(Kernel::HLERequestContext& ctx) {
+void Module::Interface::InitializeApplicationInfoV2(HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
-void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
+void Module::Interface::GetProfileEditor(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
Common::UUID user_id = rp.PopRaw<Common::UUID>();
@@ -843,7 +846,7 @@ void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
rb.PushIpcInterface<IProfileEditor>(system, user_id, *profile_manager);
}
-void Module::Interface::ListQualifiedUsers(Kernel::HLERequestContext& ctx) {
+void Module::Interface::ListQualifiedUsers(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
// All users should be qualified. We don't actually have parental control or anything to do with
@@ -854,7 +857,7 @@ void Module::Interface::ListQualifiedUsers(Kernel::HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
-void Module::Interface::ListOpenContextStoredUsers(Kernel::HLERequestContext& ctx) {
+void Module::Interface::ListOpenContextStoredUsers(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
ctx.WriteBuffer(profile_manager->GetStoredOpenedUsers());
@@ -862,7 +865,7 @@ void Module::Interface::ListOpenContextStoredUsers(Kernel::HLERequestContext& ct
rb.Push(ResultSuccess);
}
-void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestContext& ctx) {
+void Module::Interface::StoreSaveDataThumbnailApplication(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto uuid = rp.PopRaw<Common::UUID>();
@@ -875,7 +878,7 @@ void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestCont
StoreSaveDataThumbnail(ctx, uuid, tid);
}
-void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx) {
+void Module::Interface::StoreSaveDataThumbnailSystem(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto uuid = rp.PopRaw<Common::UUID>();
const auto tid = rp.Pop<u64_le>();
@@ -884,26 +887,26 @@ void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext&
StoreSaveDataThumbnail(ctx, uuid, tid);
}
-void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx,
- const Common::UUID& uuid, const u64 tid) {
+void Module::Interface::StoreSaveDataThumbnail(HLERequestContext& ctx, const Common::UUID& uuid,
+ const u64 tid) {
IPC::ResponseBuilder rb{ctx, 2};
if (tid == 0) {
LOG_ERROR(Service_ACC, "TitleID is not valid!");
- rb.Push(ERR_INVALID_APPLICATION_ID);
+ rb.Push(Account::ResultInvalidApplication);
return;
}
if (uuid.IsInvalid()) {
LOG_ERROR(Service_ACC, "User ID is not valid!");
- rb.Push(ERR_INVALID_USER_ID);
+ rb.Push(Account::ResultInvalidUserId);
return;
}
const auto thumbnail_size = ctx.GetReadBufferSize();
if (thumbnail_size != THUMBNAIL_SIZE) {
LOG_ERROR(Service_ACC, "Buffer size is empty! size={:X} expecting {:X}", thumbnail_size,
THUMBNAIL_SIZE);
- rb.Push(ERR_INVALID_BUFFER_SIZE);
+ rb.Push(Account::ResultInvalidArrayLength);
return;
}
@@ -911,7 +914,7 @@ void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx,
rb.Push(ResultSuccess);
}
-void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx) {
+void Module::Interface::TrySelectUserWithoutInteraction(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
// A u8 is passed into this function which we can safely ignore. It's to determine if we have
// access to use the network or not by the looks of it
@@ -942,18 +945,20 @@ Module::Interface::Interface(std::shared_ptr<Module> module_,
Module::Interface::~Interface() = default;
-void InstallInterfaces(Core::System& system) {
+void LoopProcess(Core::System& system) {
auto module = std::make_shared<Module>();
auto profile_manager = std::make_shared<ProfileManager>();
-
- std::make_shared<ACC_AA>(module, profile_manager, system)
- ->InstallAsService(system.ServiceManager());
- std::make_shared<ACC_SU>(module, profile_manager, system)
- ->InstallAsService(system.ServiceManager());
- std::make_shared<ACC_U0>(module, profile_manager, system)
- ->InstallAsService(system.ServiceManager());
- std::make_shared<ACC_U1>(module, profile_manager, system)
- ->InstallAsService(system.ServiceManager());
+ auto server_manager = std::make_unique<ServerManager>(system);
+
+ server_manager->RegisterNamedService("acc:aa",
+ std::make_shared<ACC_AA>(module, profile_manager, system));
+ server_manager->RegisterNamedService("acc:su",
+ std::make_shared<ACC_SU>(module, profile_manager, system));
+ server_manager->RegisterNamedService("acc:u0",
+ std::make_shared<ACC_U0>(module, profile_manager, system));
+ server_manager->RegisterNamedService("acc:u1",
+ std::make_shared<ACC_U1>(module, profile_manager, system));
+ ServerManager::RunServer(std::move(server_manager));
}
} // namespace Service::Account