diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/acc/acc.cpp | 117 |
1 files changed, 57 insertions, 60 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 1241fcdff..120282aa4 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; @@ -294,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{}; @@ -311,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)) { @@ -325,7 +320,7 @@ protected: } } - void LoadImage(Kernel::HLERequestContext& ctx) { + void LoadImage(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -352,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); @@ -369,7 +364,7 @@ protected: } } - void Store(Kernel::HLERequestContext& ctx) { + void Store(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto base = rp.PopRaw<ProfileBase>(); @@ -383,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; } @@ -393,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; } @@ -401,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>(); @@ -416,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; } @@ -431,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; } @@ -498,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}; @@ -541,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}; @@ -556,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}; @@ -564,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); @@ -586,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(); @@ -688,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()); @@ -705,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()); @@ -736,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 @@ -763,7 +758,7 @@ 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 @@ -774,7 +769,7 @@ Result Module::Interface::InitializeApplicationInfoBase() { 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) { @@ -790,7 +785,7 @@ 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"); @@ -799,14 +794,14 @@ Result Module::Interface::InitializeApplicationInfoBase() { 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); @@ -833,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>(); @@ -851,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 @@ -862,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()); @@ -870,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>(); @@ -883,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>(); @@ -892,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; } @@ -919,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 @@ -950,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 |