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>
|
|
|
|
#include <stratosphere/iserviceobject.hpp>
|
|
|
|
|
|
|
|
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,
|
|
|
|
User_Cmd_AtmosphereAssociatePidTidForMitm = 65002
|
2018-04-22 04:17:57 +01:00
|
|
|
};
|
|
|
|
|
2018-06-12 23:00:09 +01:00
|
|
|
class UserService final : public IServiceObject {
|
2018-07-02 15:26:03 +01:00
|
|
|
u64 pid = U64_MAX;
|
|
|
|
bool has_initialized = false;
|
|
|
|
u64 deferred_service = 0;
|
2018-04-22 04:40:26 +01:00
|
|
|
|
2018-04-22 04:17:57 +01:00
|
|
|
public:
|
2018-06-03 06:46:27 +01:00
|
|
|
Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
|
|
|
|
Result handle_deferred() override;
|
2018-04-22 04:17:57 +01:00
|
|
|
|
2018-06-12 23:00:09 +01:00
|
|
|
UserService *clone() override {
|
|
|
|
auto new_srv = new UserService();
|
|
|
|
new_srv->pid = pid;
|
|
|
|
new_srv->has_initialized = has_initialized;
|
|
|
|
new_srv->deferred_service = deferred_service;
|
|
|
|
return new_srv;
|
|
|
|
}
|
|
|
|
|
2018-04-22 04:17:57 +01:00
|
|
|
private:
|
|
|
|
/* Actual commands. */
|
|
|
|
std::tuple<Result> initialize(PidDescriptor pid);
|
|
|
|
std::tuple<Result, MovedHandle> get_service(u64 service);
|
2018-04-22 10:02:08 +01:00
|
|
|
std::tuple<Result, MovedHandle> deferred_get_service(u64 service);
|
2018-04-22 04:17:57 +01:00
|
|
|
std::tuple<Result, MovedHandle> register_service(u64 service, u8 is_light, u32 max_sessions);
|
|
|
|
std::tuple<Result> unregister_service(u64 service);
|
2018-06-03 06:38:01 +01:00
|
|
|
|
|
|
|
/* Atmosphere commands. */
|
2018-06-15 00:50:01 +01:00
|
|
|
std::tuple<Result, MovedHandle, MovedHandle> install_mitm(u64 service);
|
2018-06-03 06:38:01 +01:00
|
|
|
std::tuple<Result> uninstall_mitm(u64 service);
|
2018-06-15 00:50:01 +01:00
|
|
|
std::tuple<Result> associate_pid_tid_for_mitm(u64 pid, u64 tid);
|
2018-06-03 06:46:27 +01:00
|
|
|
};
|