2018-09-07 16:00:13 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Atmosphère-NX
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-04-22 04:17:57 +01:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2018-10-30 00:28:37 +00:00
|
|
|
#include <stratosphere.hpp>
|
2018-10-30 13:29:30 +00:00
|
|
|
#include "sm_types.hpp"
|
2018-04-22 04:17:57 +01:00
|
|
|
|
|
|
|
enum UserServiceCmd {
|
|
|
|
User_Cmd_Initialize = 0,
|
|
|
|
User_Cmd_GetService = 1,
|
|
|
|
User_Cmd_RegisterService = 2,
|
2018-06-03 06:38:01 +01:00
|
|
|
User_Cmd_UnregisterService = 3,
|
|
|
|
|
|
|
|
User_Cmd_AtmosphereInstallMitm = 65000,
|
2018-06-15 00:50:01 +01:00
|
|
|
User_Cmd_AtmosphereUninstallMitm = 65001,
|
2018-11-15 22:19:34 +00:00
|
|
|
User_Cmd_AtmosphereAssociatePidTidForMitm = 65002,
|
|
|
|
User_Cmd_AtmosphereAcknowledgeMitmSession = 65003,
|
2018-04-22 04:17:57 +01:00
|
|
|
};
|
|
|
|
|
2018-06-12 23:00:09 +01:00
|
|
|
class UserService final : public IServiceObject {
|
2018-04-22 04:17:57 +01:00
|
|
|
private:
|
2018-10-30 00:28:37 +00:00
|
|
|
u64 pid = U64_MAX;
|
|
|
|
bool has_initialized = false;
|
|
|
|
|
2018-04-22 04:17:57 +01:00
|
|
|
/* Actual commands. */
|
2018-10-30 00:28:37 +00:00
|
|
|
virtual Result Initialize(PidDescriptor pid);
|
2018-10-30 13:29:30 +00:00
|
|
|
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);
|
2018-06-03 06:38:01 +01:00
|
|
|
|
|
|
|
/* Atmosphere commands. */
|
2018-10-30 13:29:30 +00:00
|
|
|
virtual Result AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandle> qry_h, SmServiceName service);
|
|
|
|
virtual Result AtmosphereUninstallMitm(SmServiceName service);
|
2018-10-30 00:28:37 +00:00
|
|
|
virtual Result AtmosphereAssociatePidTidForMitm(u64 pid, u64 tid);
|
2018-11-15 22:19:34 +00:00
|
|
|
virtual Result AtmosphereAcknowledgeMitmSession(Out<u64> client_pid, Out<MovedHandle> fwd_h, SmServiceName service);
|
2018-10-30 00:28:37 +00:00
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
MakeServiceCommandMeta<User_Cmd_Initialize, &UserService::Initialize>(),
|
|
|
|
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>(),
|
|
|
|
MakeServiceCommandMeta<User_Cmd_AtmosphereAssociatePidTidForMitm, &UserService::AtmosphereAssociatePidTidForMitm>(),
|
2018-11-15 22:19:34 +00:00
|
|
|
MakeServiceCommandMeta<User_Cmd_AtmosphereAcknowledgeMitmSession, &UserService::AtmosphereAcknowledgeMitmSession>(),
|
2018-10-30 00:28:37 +00:00
|
|
|
#endif
|
|
|
|
};
|
2018-06-03 06:46:27 +01:00
|
|
|
};
|