2019-06-29 11:20:36 +02:00
|
|
|
/*
|
2020-01-24 11:10:40 +01:00
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
2019-06-29 11:20:36 +02: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/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
|
2019-10-24 11:30:10 +02:00
|
|
|
namespace ams::pm::shell {
|
2019-06-29 11:20:36 +02:00
|
|
|
|
2019-10-15 07:49:06 +02:00
|
|
|
class ShellServiceBase : public sf::IServiceObject {
|
2019-06-29 11:20:36 +02:00
|
|
|
protected:
|
|
|
|
/* Actual command implementations. */
|
2019-10-28 05:43:01 +01:00
|
|
|
virtual Result LaunchProgram(sf::Out<os::ProcessId> out_process_id, const ncm::ProgramLocation &loc, u32 flags);
|
2019-10-15 07:49:06 +02:00
|
|
|
virtual Result TerminateProcess(os::ProcessId process_id);
|
2019-10-28 05:43:01 +01:00
|
|
|
virtual Result TerminateProgram(ncm::ProgramId program_id);
|
2019-10-15 07:49:06 +02:00
|
|
|
virtual void GetProcessEventHandle(sf::OutCopyHandle out);
|
|
|
|
virtual void GetProcessEventInfo(sf::Out<ProcessEventInfo> out);
|
|
|
|
virtual Result CleanupProcess(os::ProcessId process_id);
|
|
|
|
virtual Result ClearExceptionOccurred(os::ProcessId process_id);
|
2019-06-29 11:20:36 +02:00
|
|
|
virtual void NotifyBootFinished();
|
2019-10-15 07:49:06 +02:00
|
|
|
virtual Result GetApplicationProcessIdForShell(sf::Out<os::ProcessId> out);
|
2019-06-29 11:20:36 +02:00
|
|
|
virtual Result BoostSystemMemoryResourceLimit(u64 boost_size);
|
2019-07-03 06:27:53 +02:00
|
|
|
virtual Result BoostApplicationThreadResourceLimit();
|
2019-10-15 07:49:06 +02:00
|
|
|
virtual void GetBootFinishedEventHandle(sf::OutCopyHandle out);
|
2019-06-29 11:20:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This represents modern ShellService (5.0.0+). */
|
|
|
|
class ShellService final : public ShellServiceBase {
|
|
|
|
private:
|
|
|
|
enum class CommandId {
|
2019-10-28 05:43:01 +01:00
|
|
|
LaunchProgram = 0,
|
2019-07-03 06:27:53 +02:00
|
|
|
TerminateProcess = 1,
|
2019-10-28 05:43:01 +01:00
|
|
|
TerminateProgram = 2,
|
2019-07-03 06:27:53 +02:00
|
|
|
GetProcessEventHandle = 3,
|
|
|
|
GetProcessEventInfo = 4,
|
|
|
|
NotifyBootFinished = 5,
|
|
|
|
GetApplicationProcessIdForShell = 6,
|
|
|
|
BoostSystemMemoryResourceLimit = 7,
|
|
|
|
BoostApplicationThreadResourceLimit = 8,
|
|
|
|
GetBootFinishedEventHandle = 9,
|
2019-06-29 11:20:36 +02:00
|
|
|
};
|
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
/* 5.0.0-* */
|
2019-10-28 05:43:01 +01:00
|
|
|
MAKE_SERVICE_COMMAND_META(LaunchProgram),
|
2019-10-15 07:49:06 +02:00
|
|
|
MAKE_SERVICE_COMMAND_META(TerminateProcess),
|
2019-10-28 05:43:01 +01:00
|
|
|
MAKE_SERVICE_COMMAND_META(TerminateProgram),
|
2019-10-15 07:49:06 +02:00
|
|
|
MAKE_SERVICE_COMMAND_META(GetProcessEventHandle),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetProcessEventInfo),
|
|
|
|
MAKE_SERVICE_COMMAND_META(NotifyBootFinished),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetApplicationProcessIdForShell),
|
|
|
|
MAKE_SERVICE_COMMAND_META(BoostSystemMemoryResourceLimit),
|
2019-06-29 11:20:36 +02:00
|
|
|
|
|
|
|
/* 7.0.0-* */
|
2020-04-14 07:19:44 +02:00
|
|
|
MAKE_SERVICE_COMMAND_META(BoostApplicationThreadResourceLimit, hos::Version_7_0_0),
|
2019-06-29 11:20:36 +02:00
|
|
|
|
|
|
|
/* 8.0.0-* */
|
2020-04-14 07:19:44 +02:00
|
|
|
MAKE_SERVICE_COMMAND_META(GetBootFinishedEventHandle, hos::Version_8_0_0),
|
2019-06-29 11:20:36 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This represents deprecated ShellService (1.0.0-4.1.0). */
|
|
|
|
class ShellServiceDeprecated final : public ShellServiceBase {
|
|
|
|
private:
|
|
|
|
enum class CommandId {
|
2019-10-28 05:43:01 +01:00
|
|
|
LaunchProgram = 0,
|
2019-06-29 11:20:36 +02:00
|
|
|
TerminateProcess = 1,
|
2019-10-28 05:43:01 +01:00
|
|
|
TerminateProgram = 2,
|
2019-06-29 11:20:36 +02:00
|
|
|
GetProcessEventHandle = 3,
|
|
|
|
GetProcessEventInfo = 4,
|
|
|
|
CleanupProcess = 5,
|
|
|
|
ClearExceptionOccurred = 6,
|
|
|
|
NotifyBootFinished = 7,
|
|
|
|
GetApplicationProcessIdForShell = 8,
|
|
|
|
BoostSystemMemoryResourceLimit = 9,
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
/* 1.0.0-4.1.0 */
|
2019-10-28 05:43:01 +01:00
|
|
|
MAKE_SERVICE_COMMAND_META(LaunchProgram),
|
2019-10-15 07:49:06 +02:00
|
|
|
MAKE_SERVICE_COMMAND_META(TerminateProcess),
|
2019-10-28 05:43:01 +01:00
|
|
|
MAKE_SERVICE_COMMAND_META(TerminateProgram),
|
2019-10-15 07:49:06 +02:00
|
|
|
MAKE_SERVICE_COMMAND_META(GetProcessEventHandle),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetProcessEventInfo),
|
|
|
|
MAKE_SERVICE_COMMAND_META(CleanupProcess),
|
|
|
|
MAKE_SERVICE_COMMAND_META(ClearExceptionOccurred),
|
|
|
|
MAKE_SERVICE_COMMAND_META(NotifyBootFinished),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetApplicationProcessIdForShell),
|
2019-06-29 11:20:36 +02:00
|
|
|
|
|
|
|
/* 4.0.0-4.1.0 */
|
2020-04-14 07:19:44 +02:00
|
|
|
MAKE_SERVICE_COMMAND_META(BoostSystemMemoryResourceLimit, hos::Version_4_0_0),
|
2019-06-29 11:20:36 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|