2019-12-09 12:57:37 +01:00
|
|
|
/*
|
2021-10-04 21:59:10 +02:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2019-12-09 12:57:37 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2021-01-17 16:55:32 +01:00
|
|
|
#include <stratosphere/sf/sf_common.hpp>
|
|
|
|
#include <stratosphere/sf/sf_out.hpp>
|
|
|
|
#include <stratosphere/sf/sf_shared_object.hpp>
|
2019-12-09 12:57:37 +01:00
|
|
|
|
|
|
|
namespace ams::sf {
|
|
|
|
|
2021-01-17 16:55:32 +01:00
|
|
|
class IServiceObject : public ISharedObject {
|
2019-12-09 12:57:37 +01:00
|
|
|
public:
|
|
|
|
virtual ~IServiceObject() { /* ... */ }
|
|
|
|
};
|
|
|
|
|
2020-07-08 02:07:23 +02:00
|
|
|
template<typename T>
|
|
|
|
concept IsServiceObject = std::derived_from<T, IServiceObject>;
|
|
|
|
|
2019-12-09 12:57:37 +01:00
|
|
|
class IMitmServiceObject : public IServiceObject {
|
2020-07-08 02:07:23 +02:00
|
|
|
public:
|
|
|
|
virtual ~IMitmServiceObject() { /* ... */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MitmServiceImplBase {
|
2019-12-09 12:57:37 +01:00
|
|
|
protected:
|
2021-10-10 09:14:06 +02:00
|
|
|
std::shared_ptr<::Service> m_forward_service;
|
|
|
|
sm::MitmProcessInfo m_client_info;
|
2019-12-09 12:57:37 +01:00
|
|
|
public:
|
2021-10-10 09:14:06 +02:00
|
|
|
MitmServiceImplBase(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : m_forward_service(std::move(s)), m_client_info(c) { /* ... */ }
|
2019-12-09 12:57:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
2020-07-08 02:07:23 +02:00
|
|
|
concept IsMitmServiceObject = IsServiceObject<T> && std::derived_from<T, IMitmServiceObject>;
|
2019-12-09 12:57:37 +01:00
|
|
|
|
2020-07-08 02:07:23 +02:00
|
|
|
template<typename T>
|
|
|
|
concept IsMitmServiceImpl = requires (std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) {
|
|
|
|
{ T(std::forward<std::shared_ptr<::Service>>(s), c) };
|
|
|
|
{ T::ShouldMitm(c) } -> std::same_as<bool>;
|
2019-12-09 12:57:37 +01:00
|
|
|
};
|
|
|
|
|
2020-10-31 11:22:01 +01:00
|
|
|
}
|