sm: refactor to use R_TRY

This commit is contained in:
Michael Scire 2019-06-17 09:17:53 -07:00
parent a0cf3bbed8
commit dfcba5e6d4
10 changed files with 157 additions and 181 deletions

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <switch.h>
#include <stratosphere.hpp>
#include "sm_dmnt_service.hpp"

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <cstdint>
#include <cstring>
@ -35,7 +35,7 @@ extern "C" {
#define INNER_HEAP_SIZE 0x20000
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
char nx_inner_heap[INNER_HEAP_SIZE];
void __libnx_initheap(void);
void __appInit(void);
void __appExit(void);
@ -67,7 +67,7 @@ void __libnx_initheap(void) {
void __appInit(void) {
SetFirmwareVersionForLibnx();
/* We must do no service setup here, because we are sm. */
}
@ -81,34 +81,34 @@ void __appExit(void) {
int main(int argc, char **argv)
{
consoleDebugInit(debugDevice_SVC);
/* TODO: What's a good timeout value to use here? */
auto server_manager = new WaitableManager(1);
/* Create sm:, (and thus allow things to register to it). */
server_manager->AddWaitable(new ManagedPortServer<UserService>("sm:", 0x40));
/* Create sm:m manually. */
Handle smm_h;
if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h))) {
std::abort();
}
server_manager->AddWaitable(new ExistingPortServer<ManagerService>(smm_h, 1));
/*===== ATMOSPHERE EXTENSION =====*/
/* Create sm:dmnt manually. */
Handle smdmnt_h;
if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("sm:dmnt"), 1, false, &smdmnt_h))) {
std::abort();
}
server_manager->AddWaitable(new ExistingPortServer<DmntService>(smm_h, 1));;
/*================================*/
/* Loop forever, servicing our services. */
server_manager->Process();
/* Cleanup. */
delete server_manager;
return 0;

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <switch.h>
#include <stratosphere.hpp>
#include "sm_manager_service.hpp"

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
@ -22,7 +22,7 @@
enum ManagerServiceCmd {
Manager_Cmd_RegisterProcess = 0,
Manager_Cmd_UnregisterProcess = 1,
Manager_Cmd_AtmosphereEndInitDefers = 65000,
Manager_Cmd_AtmosphereHasMitm = 65001,
};
@ -38,7 +38,7 @@ class ManagerService final : public IServiceObject {
DEFINE_SERVICE_DISPATCH_TABLE {
MakeServiceCommandMeta<Manager_Cmd_RegisterProcess, &ManagerService::RegisterProcess>(),
MakeServiceCommandMeta<Manager_Cmd_UnregisterProcess, &ManagerService::UnregisterProcess>(),
MakeServiceCommandMeta<Manager_Cmd_AtmosphereEndInitDefers, &ManagerService::AtmosphereEndInitDefers>(),
MakeServiceCommandMeta<Manager_Cmd_AtmosphereHasMitm, &ManagerService::AtmosphereHasMitm>(),
};

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <switch.h>
#include <algorithm>
#include <stratosphere.hpp>
@ -62,7 +62,7 @@ bool Registration::ShouldInitDefer(u64 service) {
if (g_end_init_defers) {
return false;
}
/* This is a mechanism by which certain services will always be deferred until sm:m receives a special command. */
/* This can be extended with more services as needed at a later date. */
constexpr u64 FSP_SRV = EncodeNameConstant("fsp-srv");
@ -196,11 +196,11 @@ Result Registration::RegisterProcess(u64 pid, u8 *acid_sac, size_t acid_sac_size
if (proc == NULL) {
return ResultSmInsufficientProcesses;
}
if (aci0_sac_size && !ValidateSacAgainstRestriction(acid_sac, acid_sac_size, aci0_sac, aci0_sac_size)) {
return ResultSmNotAllowed;
}
proc->pid = pid;
proc->sac_size = aci0_sac_size;
std::copy(aci0_sac, aci0_sac + aci0_sac_size, proc->sac);
@ -212,7 +212,7 @@ Result Registration::UnregisterProcess(u64 pid) {
if (proc == NULL) {
return ResultSmInvalidClient;
}
proc->pid = 0;
return ResultSuccess;
}
@ -233,7 +233,7 @@ Result Registration::GetServiceHandle(u64 pid, u64 service, Handle *out) {
/* Note: This defers the result until later. */
return ResultServiceFrameworkRequestDeferredByUser;
}
*out = 0;
Result rc;
if (target_service->mitm_pid == 0 || target_service->mitm_pid == pid) {
@ -262,7 +262,7 @@ Result Registration::GetServiceHandle(u64 pid, u64 service, Handle *out) {
if (R_SUCCEEDED(rc)) {
if (resp->should_mitm) {
rc = svcConnectToPort(&target_service->mitm_fwd_sess_h, target_service->port_h);
if (R_SUCCEEDED(rc)) {
if (R_SUCCEEDED(rc)) {
rc = svcConnectToPort(out, target_service->mitm_port_h);
if (R_SUCCEEDED(rc)) {
target_service->mitm_waiting_ack_pid = pid;
@ -281,22 +281,23 @@ Result Registration::GetServiceHandle(u64 pid, u64 service, Handle *out) {
rc = svcConnectToPort(out, target_service->port_h);
}
}
if (R_FAILED(rc)) {
if ((rc & 0x3FFFFF) == ResultKernelOutOfSessions) {
/* Convert Kernel result to SM result. */
R_TRY_CATCH(rc) {
R_CATCH(ResultKernelOutOfSessions) {
return ResultSmInsufficientSessions;
}
}
} R_END_TRY_CATCH;
return rc;
return ResultSuccess;
}
Result Registration::GetServiceForPid(u64 pid, u64 service, Handle *out) {
if (!service) {
return ResultSmInvalidServiceName;
}
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
@ -310,18 +311,18 @@ Result Registration::GetServiceForPid(u64 pid, u64 service, Handle *out) {
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_800 && service == EncodeNameConstant("apm:p")) {
return ResultSmNotAllowed;
}
if (!IsInitialProcess(pid)) {
Registration::Process *proc = GetProcessForPid(pid);
if (proc == NULL) {
return ResultSmInvalidClient;
}
if (!IsValidForSac(proc->sac, proc->sac_size, service, false)) {
return ResultSmNotAllowed;
}
}
return GetServiceHandle(pid, service, out);
}
@ -329,29 +330,29 @@ Result Registration::RegisterServiceForPid(u64 pid, u64 service, u64 max_session
if (!service) {
return ResultSmInvalidServiceName;
}
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
}
if (!IsInitialProcess(pid)) {
Registration::Process *proc = GetProcessForPid(pid);
if (proc == NULL) {
return ResultSmInvalidClient;
}
if (!IsValidForSac(proc->sac, proc->sac_size, service, true)) {
return ResultSmNotAllowed;
}
}
if (HasService(service)) {
return ResultSmAlreadyRegistered;
}
#ifdef SM_MINIMUM_SESSION_LIMIT
if (max_sessions < SM_MINIMUM_SESSION_LIMIT) {
max_sessions = SM_MINIMUM_SESSION_LIMIT;
@ -362,35 +363,30 @@ Result Registration::RegisterServiceForPid(u64 pid, u64 service, u64 max_session
if (free_service == NULL) {
return ResultSmInsufficientServices;
}
*out = 0;
*free_service = (const Registration::Service){0};
Result rc = svcCreatePort(out, &free_service->port_h, max_sessions, is_light, (char *)&free_service->service_name);
if (R_SUCCEEDED(rc)) {
free_service->service_name = service;
free_service->owner_pid = pid;
free_service->max_sessions = max_sessions;
free_service->is_light = is_light;
}
return rc;
R_TRY(svcCreatePort(out, &free_service->port_h, max_sessions, is_light, (char *)&free_service->service_name));
free_service->service_name = service;
free_service->owner_pid = pid;
free_service->max_sessions = max_sessions;
free_service->is_light = is_light;
return ResultSuccess;
}
Result Registration::RegisterServiceForSelf(u64 service, u64 max_sessions, bool is_light, Handle *out) {
u64 pid;
Result rc = svcGetProcessId(&pid, CUR_PROCESS_HANDLE);
if (R_FAILED(rc)) {
return rc;
}
R_TRY(svcGetProcessId(&pid, CUR_PROCESS_HANDLE));
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
}
if (HasService(service)) {
return ResultSmAlreadyRegistered;
}
@ -400,38 +396,36 @@ Result Registration::RegisterServiceForSelf(u64 service, u64 max_sessions, bool
max_sessions = SM_MINIMUM_SESSION_LIMIT;
}
#endif
Registration::Service *free_service = GetFreeService();
if (free_service == NULL) {
return ResultSmInsufficientServices;
}
*out = 0;
*free_service = (const Registration::Service){0};
rc = svcCreatePort(out, &free_service->port_h, max_sessions, is_light, (char *)&free_service->service_name);
if (R_SUCCEEDED(rc)) {
free_service->service_name = service;
free_service->owner_pid = pid;
free_service->max_sessions = max_sessions;
free_service->is_light = is_light;
}
return rc;
R_TRY(svcCreatePort(out, &free_service->port_h, max_sessions, is_light, (char *)&free_service->service_name));
free_service->service_name = service;
free_service->owner_pid = pid;
free_service->max_sessions = max_sessions;
free_service->is_light = is_light;
return ResultSuccess;
}
Result Registration::UnregisterServiceForPid(u64 pid, u64 service) {
if (!service) {
return ResultSmInvalidServiceName;
}
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
}
Registration::Service *target_service = GetService(service);
if (target_service == NULL) {
return ResultSmNotRegistered;
@ -440,7 +434,7 @@ Result Registration::UnregisterServiceForPid(u64 pid, u64 service) {
if (!IsInitialProcess(pid) && target_service->owner_pid != pid) {
return ResultSmNotAllowed;
}
svcCloseHandle(target_service->port_h);
svcCloseHandle(target_service->mitm_port_h);
svcCloseHandle(target_service->mitm_query_h);
@ -453,60 +447,59 @@ Result Registration::InstallMitmForPid(u64 pid, u64 service, Handle *out, Handle
if (!service) {
return ResultSmInvalidServiceName;
}
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
}
/* Verify we're allowed to mitm the service. */
if (!IsInitialProcess(pid)) {
Registration::Process *proc = GetProcessForPid(pid);
if (proc == NULL) {
return ResultSmInvalidClient;
}
if (!IsValidForSac(proc->sac, proc->sac_size, service, true)) {
return ResultSmNotAllowed;
}
}
/* Verify the service exists. */
Registration::Service *target_service = GetService(service);
if (target_service == NULL) {
return ResultServiceFrameworkRequestDeferredByUser;
}
/* Verify the service isn't already being mitm'd. */
if (target_service->mitm_pid != 0) {
return ResultSmAlreadyRegistered;
}
*out = 0;
u64 x = 0;
Result rc = svcCreatePort(out, &target_service->mitm_port_h, target_service->max_sessions, target_service->is_light, (char *)&x);
if (R_SUCCEEDED(rc) && R_SUCCEEDED((rc = svcCreateSession(query_out, &target_service->mitm_query_h, 0, 0)))) {
target_service->mitm_pid = pid;
}
return rc;
R_TRY(svcCreatePort(out, &target_service->mitm_port_h, target_service->max_sessions, target_service->is_light, (char *)&x));
R_TRY(svcCreateSession(query_out, &target_service->mitm_query_h, 0, 0));
target_service->mitm_pid = pid;
return ResultSuccess;
}
Result Registration::UninstallMitmForPid(u64 pid, u64 service) {
if (!service) {
return ResultSmInvalidServiceName;
}
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
}
Registration::Service *target_service = GetService(service);
if (target_service == NULL) {
return ResultSmNotRegistered;
@ -515,7 +508,7 @@ Result Registration::UninstallMitmForPid(u64 pid, u64 service) {
if (!IsInitialProcess(pid) && target_service->mitm_pid != pid) {
return ResultSmNotAllowed;
}
svcCloseHandle(target_service->mitm_port_h);
svcCloseHandle(target_service->mitm_query_h);
target_service->mitm_pid = 0;
@ -526,14 +519,14 @@ Result Registration::AcknowledgeMitmSessionForPid(u64 pid, u64 service, Handle *
if (!service) {
return ResultSmInvalidServiceName;
}
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
}
Registration::Service *target_service = GetService(service);
if (target_service == NULL) {
return ResultSmNotRegistered;
@ -542,7 +535,7 @@ Result Registration::AcknowledgeMitmSessionForPid(u64 pid, u64 service, Handle *
if ((!IsInitialProcess(pid) && target_service->mitm_pid != pid) || !target_service->mitm_waiting_ack) {
return ResultSmNotAllowed;
}
*out = target_service->mitm_fwd_sess_h;
*out_pid = target_service->mitm_waiting_ack_pid;
target_service->mitm_fwd_sess_h = 0;
@ -586,26 +579,26 @@ Result Registration::GetServiceRecord(u64 service, SmServiceRecord *out) {
if (!service) {
return ResultSmInvalidServiceName;
}
u64 service_name_len = GetServiceNameLength(service);
/* If the service has bytes after a null terminator, that's no good. */
if (service_name_len != 8 && (service >> (8 * service_name_len))) {
return ResultSmInvalidServiceName;
}
Registration::Service *target_service = GetService(service);
if (target_service == NULL) {
return ResultSmNotRegistered;
}
ConvertServiceToRecord(target_service, out);
return ResultSuccess;
}
void Registration::ListServiceRecords(u64 offset, u64 max_out, SmServiceRecord *out, u64 *out_count) {
u64 count = 0;
for (auto it = g_service_list.begin(); it != g_service_list.end() && count < max_out; it++) {
if (it->service_name != 0) {
if (offset > 0) {
@ -616,6 +609,6 @@ void Registration::ListServiceRecords(u64 offset, u64 max_out, SmServiceRecord *
}
}
}
*out_count = count;
}

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
@ -31,30 +31,30 @@ class Registration {
u64 sac_size;
u8 sac[REGISTRATION_MAX_SAC_SIZE];
};
struct Service {
u64 service_name;
u64 owner_pid;
Handle port_h;
/* Debug. */
u64 max_sessions;
bool is_light;
/* Extension. */
u64 mitm_pid;
Handle mitm_port_h;
Handle mitm_query_h;
bool mitm_waiting_ack;
u64 mitm_waiting_ack_pid;
Handle mitm_fwd_sess_h;
};
/* Utilities. */
static void EndInitDefers();
static bool ShouldInitDefer(u64 service);
static Registration::Process *GetProcessForPid(u64 pid);
static Registration::Process *GetFreeProcess();
static Registration::Service *GetService(u64 service);
@ -64,11 +64,11 @@ class Registration {
static void CacheInitialProcessIdLimits();
static bool IsInitialProcess(u64 pid);
static u64 GetInitialProcessId();
/* Process management. */
static Result RegisterProcess(u64 pid, u8 *acid_sac, size_t acid_sac_size, u8 *aci0_sac, size_t aci0_sac_size);
static Result UnregisterProcess(u64 pid);
/* Service management. */
static bool HasService(u64 service);
static bool HasMitm(u64 service);
@ -77,13 +77,13 @@ class Registration {
static Result RegisterServiceForPid(u64 pid, u64 service, u64 max_sessions, bool is_light, Handle *out);
static Result RegisterServiceForSelf(u64 service, u64 max_sessions, bool is_light, Handle *out);
static Result UnregisterServiceForPid(u64 pid, u64 service);
/* Extension. */
static Result InstallMitmForPid(u64 pid, u64 service, Handle *out, Handle *query_out);
static Result UninstallMitmForPid(u64 pid, u64 service);
static Result AcknowledgeMitmSessionForPid(u64 pid, u64 service, Handle *out, u64 *out_pid);
static Result AssociatePidTidForMitm(u64 pid, u64 tid);
static void ConvertServiceToRecord(Registration::Service *service, SmServiceRecord *record);
static Result GetServiceRecord(u64 service, SmServiceRecord *out);
static void ListServiceRecords(u64 offset, u64 max_out, SmServiceRecord *out, u64 *out_count);

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
struct SmServiceName {
char name[sizeof(u64)];

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <switch.h>
#include <stratosphere.hpp>
#include "sm_user_service.hpp"
@ -27,99 +27,82 @@ Result UserService::Initialize(PidDescriptor pid) {
Result UserService::GetService(Out<MovedHandle> out_h, SmServiceName service) {
Handle session_h = 0;
Result rc = ResultSmInvalidClient;
#ifdef SM_ENABLE_SMHAX
if (!this->has_initialized) {
rc = Registration::GetServiceForPid(Registration::GetInitialProcessId(), smEncodeName(service.name), &session_h);
return ResultSmInvalidClient;
}
#endif
if (this->has_initialized) {
rc = Registration::GetServiceForPid(this->pid, smEncodeName(service.name), &session_h);
}
if (R_SUCCEEDED(rc)) {
out_h.SetValue(session_h);
}
return rc;
R_TRY(Registration::GetServiceForPid(this->pid, smEncodeName(service.name), &session_h));
out_h.SetValue(session_h);
return ResultSuccess;
}
Result UserService::RegisterService(Out<MovedHandle> out_h, SmServiceName service, u32 max_sessions, bool is_light) {
Handle service_h = 0;
Result rc = ResultSmInvalidClient;
#ifdef SM_ENABLE_SMHAX
if (!this->has_initialized) {
rc = Registration::RegisterServiceForPid(Registration::GetInitialProcessId(), smEncodeName(service.name), max_sessions, (is_light & 1) != 0, &service_h);
return ResultSmInvalidClient;
}
#endif
if (this->has_initialized) {
rc = Registration::RegisterServiceForPid(this->pid, smEncodeName(service.name), max_sessions, (is_light & 1) != 0, &service_h);
}
if (R_SUCCEEDED(rc)) {
out_h.SetValue(service_h);
}
return rc;
R_TRY(Registration::RegisterServiceForPid(this->pid, smEncodeName(service.name), max_sessions, (is_light & 1) != 0, &service_h));
out_h.SetValue(service_h);
return ResultSuccess;
}
Result UserService::UnregisterService(SmServiceName service) {
Result rc = ResultSmInvalidClient;
#ifdef SM_ENABLE_SMHAX
if (!this->has_initialized) {
rc = Registration::UnregisterServiceForPid(Registration::GetInitialProcessId(), smEncodeName(service.name));
return ResultSmInvalidClient;
}
#endif
if (this->has_initialized) {
rc = Registration::UnregisterServiceForPid(this->pid, smEncodeName(service.name));
}
return rc;
return Registration::UnregisterServiceForPid(this->pid, smEncodeName(service.name));
}
Result UserService::AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandle> qry_h, SmServiceName service) {
Handle service_h = 0;
Handle query_h = 0;
Result rc = ResultSmInvalidClient;
if (this->has_initialized) {
rc = Registration::InstallMitmForPid(this->pid, smEncodeName(service.name), &service_h, &query_h);
if (!this->has_initialized) {
return ResultSmInvalidClient;
}
if (R_SUCCEEDED(rc)) {
srv_h.SetValue(service_h);
qry_h.SetValue(query_h);
}
return rc;
R_TRY(Registration::InstallMitmForPid(this->pid, smEncodeName(service.name), &service_h, &query_h));
srv_h.SetValue(service_h);
qry_h.SetValue(query_h);
return ResultSuccess;
}
Result UserService::AtmosphereUninstallMitm(SmServiceName service) {
Result rc = ResultSmInvalidClient;
if (this->has_initialized) {
rc = Registration::UninstallMitmForPid(this->pid, smEncodeName(service.name));
if (!this->has_initialized) {
return ResultSmInvalidClient;
}
return rc;
return Registration::UninstallMitmForPid(this->pid, smEncodeName(service.name));
}
Result UserService::AtmosphereAcknowledgeMitmSession(Out<u64> client_pid, Out<MovedHandle> fwd_h, SmServiceName service) {
Result rc = ResultSmInvalidClient;
Handle out_fwd_h = 0;
if (this->has_initialized) {
rc = Registration::AcknowledgeMitmSessionForPid(this->pid, smEncodeName(service.name), &out_fwd_h, client_pid.GetPointer());
if (!this->has_initialized) {
return ResultSmInvalidClient;
}
if (R_SUCCEEDED(rc)) {
fwd_h.SetValue(out_fwd_h);
}
return rc;
R_TRY(Registration::AcknowledgeMitmSessionForPid(this->pid, smEncodeName(service.name), &out_fwd_h, client_pid.GetPointer()));
fwd_h.SetValue(out_fwd_h);
return ResultSuccess;
}
Result UserService::AtmosphereAssociatePidTidForMitm(u64 pid, u64 tid) {
Result rc = ResultSmInvalidClient;
if (this->has_initialized) {
if (Registration::IsInitialProcess(pid)) {
rc = ResultSmNotAllowed;
} else {
rc = Registration::AssociatePidTidForMitm(pid, tid);
}
if (!this->has_initialized) {
return ResultSmInvalidClient;
}
return rc;
if (Registration::IsInitialProcess(pid)) {
return ResultSmNotAllowed;
}
return Registration::AssociatePidTidForMitm(pid, tid);
}

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
@ -24,7 +24,7 @@ enum UserServiceCmd {
User_Cmd_GetService = 1,
User_Cmd_RegisterService = 2,
User_Cmd_UnregisterService = 3,
User_Cmd_AtmosphereInstallMitm = 65000,
User_Cmd_AtmosphereUninstallMitm = 65001,
User_Cmd_AtmosphereAssociatePidTidForMitm = 65002,
@ -35,13 +35,13 @@ class UserService final : public IServiceObject {
private:
u64 pid = U64_MAX;
bool has_initialized = false;
/* Actual commands. */
virtual Result Initialize(PidDescriptor pid);
virtual Result GetService(Out<MovedHandle> out_h, SmServiceName service);
virtual Result RegisterService(Out<MovedHandle> out_h, SmServiceName service, u32 max_sessions, bool is_light);
virtual Result UnregisterService(SmServiceName service);
/* Atmosphere commands. */
virtual Result AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandle> qry_h, SmServiceName service);
virtual Result AtmosphereUninstallMitm(SmServiceName service);
@ -53,7 +53,7 @@ class UserService final : public IServiceObject {
MakeServiceCommandMeta<User_Cmd_GetService, &UserService::GetService>(),
MakeServiceCommandMeta<User_Cmd_RegisterService, &UserService::RegisterService>(),
MakeServiceCommandMeta<User_Cmd_UnregisterService, &UserService::UnregisterService>(),
#ifdef SM_ENABLE_MITM
MakeServiceCommandMeta<User_Cmd_AtmosphereInstallMitm, &UserService::AtmosphereInstallMitm>(),
MakeServiceCommandMeta<User_Cmd_AtmosphereUninstallMitm, &UserService::AtmosphereUninstallMitm>(),