mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-29 15:45:29 +03:00
Add support for listing users in account services
This commit is contained in:
parent
cae270a174
commit
dc6da8303e
@ -1,6 +1,8 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
|
#include <span>
|
||||||
|
#include <kernel/types/KProcess.h>
|
||||||
#include "IManagerForApplication.h"
|
#include "IManagerForApplication.h"
|
||||||
#include "IProfile.h"
|
#include "IProfile.h"
|
||||||
#include "IAccountServiceForApplication.h"
|
#include "IAccountServiceForApplication.h"
|
||||||
@ -8,6 +10,8 @@
|
|||||||
namespace skyline::service::account {
|
namespace skyline::service::account {
|
||||||
IAccountServiceForApplication::IAccountServiceForApplication(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::account_IAccountServiceForApplication, "account:IAccountServiceForApplication", {
|
IAccountServiceForApplication::IAccountServiceForApplication(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::account_IAccountServiceForApplication, "account:IAccountServiceForApplication", {
|
||||||
{0x1, SFUNC(IAccountServiceForApplication::GetUserExistence)},
|
{0x1, SFUNC(IAccountServiceForApplication::GetUserExistence)},
|
||||||
|
{0x2, SFUNC(IAccountServiceForApplication::ListAllUsers)},
|
||||||
|
{0x3, SFUNC(IAccountServiceForApplication::ListOpenUsers)},
|
||||||
{0x4, SFUNC(IAccountServiceForApplication::GetLastOpenedUser)},
|
{0x4, SFUNC(IAccountServiceForApplication::GetLastOpenedUser)},
|
||||||
{0x5, SFUNC(IAccountServiceForApplication::GetProfile)},
|
{0x5, SFUNC(IAccountServiceForApplication::GetProfile)},
|
||||||
{0x64, SFUNC(IAccountServiceForApplication::InitializeApplicationInfoV0)},
|
{0x64, SFUNC(IAccountServiceForApplication::InitializeApplicationInfoV0)},
|
||||||
@ -20,6 +24,28 @@ namespace skyline::service::account {
|
|||||||
response.Push<u32>(id == constant::DefaultUserId);
|
response.Push<u32>(id == constant::DefaultUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IAccountServiceForApplication::ListAllUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
// We only support one active user currently so hardcode this and ListOpenUsers
|
||||||
|
WriteUserList(request.outputBuf.at(0), {constant::DefaultUserId});
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAccountServiceForApplication::ListOpenUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
WriteUserList(request.outputBuf.at(0), {constant::DefaultUserId});
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAccountServiceForApplication::WriteUserList(ipc::OutputBuffer buffer, std::vector<UserId> userIds) {
|
||||||
|
std::span outputUserIds(state.process->GetPointer<UserId>(buffer.address), buffer.size / sizeof(UserId));
|
||||||
|
|
||||||
|
for (auto &userId : outputUserIds) {
|
||||||
|
if (userIds.empty()) {
|
||||||
|
userId = UserId{};
|
||||||
|
} else {
|
||||||
|
userId = userIds.back();
|
||||||
|
userIds.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IAccountServiceForApplication::GetLastOpenedUser(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void IAccountServiceForApplication::GetLastOpenedUser(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
response.Push(constant::DefaultUserId);
|
response.Push(constant::DefaultUserId);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,12 @@ namespace skyline {
|
|||||||
* @brief IAccountServiceForApplication or acc:u0 provides functions for reading user information (https://switchbrew.org/wiki/Account_services#acc:u0)
|
* @brief IAccountServiceForApplication or acc:u0 provides functions for reading user information (https://switchbrew.org/wiki/Account_services#acc:u0)
|
||||||
*/
|
*/
|
||||||
class IAccountServiceForApplication : public BaseService {
|
class IAccountServiceForApplication : public BaseService {
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Writes a vector of 128-bit user IDs to an output buffer
|
||||||
|
*/
|
||||||
|
void WriteUserList(ipc::OutputBuffer buffer, std::vector<UserId> userIds);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IAccountServiceForApplication(const DeviceState &state, ServiceManager &manager);
|
IAccountServiceForApplication(const DeviceState &state, ServiceManager &manager);
|
||||||
|
|
||||||
@ -35,6 +41,16 @@ namespace skyline {
|
|||||||
*/
|
*/
|
||||||
void GetUserExistence(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
void GetUserExistence(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This returns a list of all user accounts on the console
|
||||||
|
*/
|
||||||
|
void ListAllUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This returns a list of all open user accounts on the console
|
||||||
|
*/
|
||||||
|
void ListOpenUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This returns the user ID of the last active user on the console
|
* @brief This returns the user ID of the last active user on the console
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user