2018-10-30 05:18:04 +00:00
|
|
|
/*
|
2019-04-08 02:00:49 +00:00
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
2018-10-30 05:18:04 +00: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 <switch.h>
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
|
2019-01-21 07:13:16 +00:00
|
|
|
#include "setsys_shim.h"
|
|
|
|
|
2018-10-30 05:18:04 +00:00
|
|
|
enum SetSysCmd : u32 {
|
|
|
|
SetSysCmd_GetFirmwareVersion = 3,
|
|
|
|
SetSysCmd_GetFirmwareVersion2 = 4,
|
2019-01-21 07:13:16 +00:00
|
|
|
SetSysCmd_GetSettingsItemValueSize = 37,
|
|
|
|
SetSysCmd_GetSettingsItemValue = 38,
|
|
|
|
|
|
|
|
/* Commands for which set:sys *must* act as a passthrough. */
|
|
|
|
/* TODO: Solve the relevant IPC detection problem. */
|
|
|
|
SetSysCmd_GetEdid = 41,
|
2018-10-30 05:18:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SetSysMitmService : public IMitmServiceObject {
|
|
|
|
public:
|
2018-11-15 22:59:47 +00:00
|
|
|
SetSysMitmService(std::shared_ptr<Service> s, u64 pid) : IMitmServiceObject(s, pid) {
|
2018-10-30 05:18:04 +00:00
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ShouldMitm(u64 pid, u64 tid) {
|
2019-01-21 07:13:16 +00:00
|
|
|
/* Mitm everything. */
|
|
|
|
return true;
|
2018-10-30 05:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/* Overridden commands. */
|
|
|
|
Result GetFirmwareVersion(OutPointerWithServerSize<SetSysFirmwareVersion, 0x1> out);
|
|
|
|
Result GetFirmwareVersion2(OutPointerWithServerSize<SetSysFirmwareVersion, 0x1> out);
|
2019-01-21 07:13:16 +00:00
|
|
|
Result GetSettingsItemValueSize(Out<u64> out_size, InPointer<char> name, InPointer<char> key);
|
|
|
|
Result GetSettingsItemValue(Out<u64> out_size, OutBuffer<u8> out_value, InPointer<char> name, InPointer<char> key);
|
|
|
|
|
|
|
|
/* Forced passthrough commands. */
|
|
|
|
Result GetEdid(OutPointerWithServerSize<SetSysEdid, 0x1> out);
|
2018-10-30 05:18:04 +00:00
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
MakeServiceCommandMeta<SetSysCmd_GetFirmwareVersion, &SetSysMitmService::GetFirmwareVersion>(),
|
|
|
|
MakeServiceCommandMeta<SetSysCmd_GetFirmwareVersion2, &SetSysMitmService::GetFirmwareVersion2>(),
|
2019-01-21 07:13:16 +00:00
|
|
|
MakeServiceCommandMeta<SetSysCmd_GetSettingsItemValueSize, &SetSysMitmService::GetSettingsItemValueSize>(),
|
|
|
|
MakeServiceCommandMeta<SetSysCmd_GetSettingsItemValue, &SetSysMitmService::GetSettingsItemValue>(),
|
|
|
|
|
|
|
|
MakeServiceCommandMeta<SetSysCmd_GetEdid, &SetSysMitmService::GetEdid>(),
|
2018-10-30 05:18:04 +00:00
|
|
|
};
|
|
|
|
};
|