2018-09-07 16:00:13 +01:00
|
|
|
/*
|
2019-04-08 03:00:49 +01:00
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
2018-09-07 16:00:13 +01:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2019-05-28 05:52:28 +01:00
|
|
|
|
2018-05-05 01:25:26 +01:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2018-10-30 00:29:35 +00:00
|
|
|
#include <stratosphere.hpp>
|
2018-05-05 01:25:26 +01:00
|
|
|
|
|
|
|
#include "pm_registration.hpp"
|
|
|
|
|
2019-06-28 07:34:26 +01:00
|
|
|
/* Represents modern ShellService (5.0.0+) */
|
|
|
|
class ShellService : public IServiceObject {
|
2018-05-05 01:25:26 +01:00
|
|
|
private:
|
2019-06-28 07:34:26 +01:00
|
|
|
enum class CommandId {
|
|
|
|
LaunchProcess = 0,
|
|
|
|
TerminateProcessId = 1,
|
|
|
|
TerminateTitleId = 2,
|
|
|
|
GetProcessWaitEvent = 3,
|
|
|
|
GetProcessEventType = 4,
|
|
|
|
NotifyBootFinished = 5,
|
|
|
|
GetApplicationProcessId = 6,
|
|
|
|
BoostSystemMemoryResourceLimit = 7,
|
|
|
|
BoostSystemThreadsResourceLimit = 8,
|
|
|
|
GetBootFinishedEvent = 9,
|
|
|
|
};
|
|
|
|
protected:
|
2018-05-05 01:25:26 +01:00
|
|
|
/* Actual commands. */
|
2018-10-30 13:29:30 +00:00
|
|
|
Result LaunchProcess(Out<u64> pid, Registration::TidSid tid_sid, u32 launch_flags);
|
2018-10-30 00:29:35 +00:00
|
|
|
Result TerminateProcessId(u64 pid);
|
|
|
|
Result TerminateTitleId(u64 tid);
|
|
|
|
void GetProcessWaitEvent(Out<CopiedHandle> event);
|
|
|
|
void GetProcessEventType(Out<u64> type, Out<u64> pid);
|
|
|
|
Result FinalizeExitedProcess(u64 pid);
|
|
|
|
Result ClearProcessNotificationFlag(u64 pid);
|
|
|
|
void NotifyBootFinished();
|
|
|
|
Result GetApplicationProcessId(Out<u64> pid);
|
|
|
|
Result BoostSystemMemoryResourceLimit(u64 sysmem_size);
|
2019-01-31 11:32:47 +00:00
|
|
|
Result BoostSystemThreadsResourceLimit();
|
2019-05-28 05:52:28 +01:00
|
|
|
void GetBootFinishedEvent(Out<CopiedHandle> event);
|
2018-10-30 00:29:35 +00:00
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
/* 5.0.0-* */
|
2019-06-28 07:34:26 +01:00
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, LaunchProcess),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, TerminateProcessId),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, TerminateTitleId),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, GetProcessWaitEvent),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, GetProcessEventType),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, NotifyBootFinished),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, GetApplicationProcessId),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, BoostSystemMemoryResourceLimit),
|
2019-05-28 05:52:28 +01:00
|
|
|
|
2019-01-31 11:32:47 +00:00
|
|
|
/* 7.0.0-* */
|
2019-06-28 07:34:26 +01:00
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, BoostSystemThreadsResourceLimit, FirmwareVersion_700),
|
2019-05-28 05:52:28 +01:00
|
|
|
|
2019-04-18 08:18:53 +01:00
|
|
|
/* 8.0.0-* */
|
2019-06-28 07:34:26 +01:00
|
|
|
MAKE_SERVICE_COMMAND_META(ShellService, GetBootFinishedEvent, FirmwareVersion_800),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Represents deprecated ShellService (1.0.0-4.1.0). */
|
|
|
|
class ShellServiceDeprecated : public ShellService {
|
|
|
|
private:
|
|
|
|
enum class CommandId {
|
|
|
|
LaunchProcess = 0,
|
|
|
|
TerminateProcessId = 1,
|
|
|
|
TerminateTitleId = 2,
|
|
|
|
GetProcessWaitEvent = 3,
|
|
|
|
GetProcessEventType = 4,
|
|
|
|
FinalizeExitedProcess = 5,
|
|
|
|
ClearProcessNotificationFlag = 6,
|
|
|
|
NotifyBootFinished = 7,
|
|
|
|
GetApplicationProcessId = 8,
|
|
|
|
BoostSystemMemoryResourceLimit = 9,
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
/* 1.0.0- */
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, LaunchProcess),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, TerminateProcessId),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, TerminateTitleId),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetProcessWaitEvent),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetProcessEventType),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, FinalizeExitedProcess),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, ClearProcessNotificationFlag),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, NotifyBootFinished),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetApplicationProcessId),
|
|
|
|
|
|
|
|
/* 4.0.0- */
|
|
|
|
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, BoostSystemMemoryResourceLimit, FirmwareVersion_400),
|
2018-10-30 00:29:35 +00:00
|
|
|
};
|
2018-06-03 06:46:27 +01:00
|
|
|
};
|