Fix ListOpenContextStoredUsers stub

The problem is in StoreOpenContext wasn't storing any user, but ListOpenContextStoredUsers was writing default user (when it's not stored by StoreOpenContext)
This commit is contained in:
Dima 2022-12-06 19:52:09 +03:00 committed by Billy Laws
parent 3c5f8dd876
commit 3a94bcf692
4 changed files with 14 additions and 4 deletions

View File

@ -88,7 +88,7 @@ namespace skyline::service::account {
if (id == UserId{}) if (id == UserId{})
return result::NullArgument; return result::NullArgument;
manager.RegisterService(SRVREG(IManagerForApplication), session, response); manager.RegisterService(std::make_shared<IManagerForApplication>(state, manager, openedUsers), session, response);
return {}; return {};
} }
@ -116,7 +116,7 @@ namespace skyline::service::account {
Result IAccountServiceForApplication::ListOpenContextStoredUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { Result IAccountServiceForApplication::ListOpenContextStoredUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
try { try {
return WriteUserList(request.outputBuf.at(0), {constant::DefaultUserId}); return WriteUserList(request.outputBuf.at(0), openedUsers);
} catch (const std::out_of_range &) { } catch (const std::out_of_range &) {
return result::InvalidInputBuffer; return result::InvalidInputBuffer;
} }

View File

@ -32,6 +32,8 @@ namespace skyline {
*/ */
class IAccountServiceForApplication : public BaseService { class IAccountServiceForApplication : public BaseService {
private: private:
std::vector<account::UserId> openedUsers;
/** /**
* @brief Writes a vector of 128-bit user IDs to an output buffer * @brief Writes a vector of 128-bit user IDs to an output buffer
*/ */

View File

@ -5,7 +5,9 @@
#include "IAccountServiceForApplication.h" #include "IAccountServiceForApplication.h"
namespace skyline::service::account { namespace skyline::service::account {
IManagerForApplication::IManagerForApplication(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} IManagerForApplication::IManagerForApplication(const DeviceState &state, ServiceManager &manager, std::vector<UserId> &openedUsers) : BaseService(state, manager) {
this->openedUsers = std::make_shared<std::vector<UserId>>(openedUsers);
}
Result IManagerForApplication::CheckAvailability(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { Result IManagerForApplication::CheckAvailability(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
response.Push(false); response.Push(false);
@ -18,6 +20,8 @@ namespace skyline::service::account {
} }
Result IManagerForApplication::StoreOpenContext(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { Result IManagerForApplication::StoreOpenContext(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
openedUsers->clear();
openedUsers->push_back(constant::DefaultUserId);
return {}; return {};
} }
} }

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <services/serviceman.h> #include <services/serviceman.h>
#include "IAccountServiceForApplication.h"
namespace skyline::service::account { namespace skyline::service::account {
/** /**
@ -11,8 +12,11 @@ namespace skyline::service::account {
* @url https://switchbrew.org/wiki/Account_services#IManagerForApplication * @url https://switchbrew.org/wiki/Account_services#IManagerForApplication
*/ */
class IManagerForApplication : public BaseService { class IManagerForApplication : public BaseService {
private:
std::shared_ptr<std::vector<UserId>> openedUsers;
public: public:
IManagerForApplication(const DeviceState &state, ServiceManager &manager); IManagerForApplication(const DeviceState &state, ServiceManager &manager, std::vector<UserId> &openedUsers);
/** /**
* @brief This checks if the given user has access to online services * @brief This checks if the given user has access to online services