diff options
author | David Marcec <dmarcecguzman@gmail.com> | 2019-06-27 08:44:42 +0200 |
---|---|---|
committer | David Marcec <dmarcecguzman@gmail.com> | 2019-06-27 08:44:42 +0200 |
commit | 0b03e8a98fc7685e5b44292327e1b31de27e9bcd (patch) | |
tree | b19bdd1fb7c812c17af02a4c0268ada73a22f263 /src/core/hle/service/acc/acc.cpp | |
parent | Merge pull request #2548 from DarkLordZach/applet-shopn (diff) | |
download | yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar.gz yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar.bz2 yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar.lz yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar.xz yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.tar.zst yuzu-0b03e8a98fc7685e5b44292327e1b31de27e9bcd.zip |
Diffstat (limited to 'src/core/hle/service/acc/acc.cpp')
-rw-r--r-- | src/core/hle/service/acc/acc.cpp | 80 |
1 files changed, 77 insertions, 3 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 @@ #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/service/acc/acc.h" #include "core/hle/service/acc/acc_aa.h" #include "core/hle/service/acc/acc_su.h" #include "core/hle/service/acc/acc_u0.h" #include "core/hle/service/acc/acc_u1.h" +#include "core/hle/service/acc/errors.h" #include "core/hle/service/acc/profile_manager.h" +#include "core/hle/service/glue/arp.h" +#include "core/hle/service/glue/manager.h" +#include "core/hle/service/sm/sm.h" #include "core/loader/loader.h" namespace Service::Account { @@ -217,10 +222,79 @@ void Module::Interface::IsUserRegistrationRequestPermitted(Kernel::HLERequestCon rb.Push(profile_manager->CanSystemRegisterUser()); } -void Module::Interface::InitializeApplicationInfoOld(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_ACC, "(STUBBED) called"); +void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + auto pid = rp.Pop<u64>(); + + LOG_DEBUG(Service_ACC, "called, process_id={}", pid); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(RESULT_SUCCESS); + rb.Push(InitializeApplicationInfoBase(pid)); +} + +void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + auto pid = rp.Pop<u64>(); + + LOG_WARNING(Service_ACC, "(Partial implementation) called, process_id={}", pid); + + const auto res = InitializeApplicationInfoBase(pid); + + // TODO(ogniK): We require checking if the user actually owns the title and what not. As of + // currently, we assume the user owns the title. + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(res); +} + +ResultCode Module::Interface::InitializeApplicationInfoBase(u64 process_id) { + if (application_info) { + return ERR_ACCOUNTINFO_ALREADY_INITIALIZED; + } + + Service::SM::ServiceManager& sm = system.ServiceManager(); + std::shared_ptr<Service::Glue::ARP_R> arp_r = sm.GetService<Service::Glue::ARP_R>("arp:r"); + if (arp_r == nullptr) { + LOG_ERROR(Service_ACC, "Failed to get arp:r service"); + application_info.application_type = ApplicationType::Unknown; + + return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION); + } + + const auto& list = system.Kernel().GetProcessList(); + const auto iter = std::find_if(list.begin(), list.end(), [&process_id](const auto& process) { + return process->GetProcessID() == process_id; + }); + + if (iter == list.end()) { + // Failed to find process ID + application_info.application_type = ApplicationType::Unknown; + + return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION); + } + + const auto launch_property = system.GetARPManager().GetLaunchProperty((*iter)->GetTitleID()); + + if (launch_property.Failed()) { + return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION); + } + + switch (launch_property->base_game_storage_id) { + case FileSys::StorageId::GameCard: + application_info.application_type = ApplicationType::GameCard; + break; + case FileSys::StorageId::Host: + case FileSys::StorageId::NandUser: + case FileSys::StorageId::SdCard: + application_info.application_type = ApplicationType::Digital; + break; + default: + return ResultCode(ERR_ACCOUNTINFO_BAD_APPLICATION); + } + + LOG_WARNING(Service_ACC, "ApplicationInfo init required"); + // TODO(ogniK): Actual initalization here + + return RESULT_SUCCESS; } void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) { |