mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-30 15:02:42 +02:00
ipc: MAKE_SERVICE_COMMAND_META macro
This commit is contained in:
parent
403f1c7a01
commit
3f6df380c8
@ -649,25 +649,16 @@ constexpr Result WrapIpcCommandImpl(IpcResponseContext *ctx) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
|
||||
template <auto c, auto CommandImpl, FirmwareVersion l = FirmwareVersion_Min, FirmwareVersion h = FirmwareVersion_Max>
|
||||
template <auto CommandId, auto CommandImpl, typename OverrideClassType, FirmwareVersion Low = FirmwareVersion_Min, FirmwareVersion High = FirmwareVersion_Max>
|
||||
inline static constexpr ServiceCommandMeta MakeServiceCommandMeta() {
|
||||
return {
|
||||
.fw_low = l,
|
||||
.fw_high = h,
|
||||
.cmd_id = static_cast<u32>(c),
|
||||
.handler = WrapIpcCommandImpl<CommandImpl>,
|
||||
};
|
||||
};
|
||||
|
||||
template <auto c, auto CommandImpl, typename OverrideClassType, FirmwareVersion l = FirmwareVersion_Min, FirmwareVersion h = FirmwareVersion_Max>
|
||||
inline static constexpr ServiceCommandMeta MakeServiceCommandMetaEx() {
|
||||
return {
|
||||
.fw_low = l,
|
||||
.fw_high = h,
|
||||
.cmd_id = static_cast<u32>(c),
|
||||
.fw_low = Low,
|
||||
.fw_high = High,
|
||||
.cmd_id = static_cast<u32>(CommandId),
|
||||
.handler = WrapIpcCommandImpl<CommandImpl, OverrideClassType>,
|
||||
};
|
||||
};
|
||||
|
||||
#define MAKE_SERVICE_COMMAND_META(class, name, ...) MakeServiceCommandMeta<CommandId::name, &class::name, class, ##__VA_ARGS__>()
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -22,14 +22,6 @@
|
||||
#include "ipc_service_object.hpp"
|
||||
#include "ipc_serialization.hpp"
|
||||
|
||||
enum HipcControlCommand : u32 {
|
||||
HipcControlCommand_ConvertCurrentObjectToDomain = 0,
|
||||
HipcControlCommand_CopyFromCurrentDomain = 1,
|
||||
HipcControlCommand_CloneCurrentObject = 2,
|
||||
HipcControlCommand_QueryPointerBufferSize = 3,
|
||||
HipcControlCommand_CloneCurrentObjectEx = 4
|
||||
};
|
||||
|
||||
class ServiceSession : public IWaitable
|
||||
{
|
||||
protected:
|
||||
@ -268,6 +260,14 @@ class ServiceSession : public IWaitable
|
||||
|
||||
public:
|
||||
class IHipcControlService : public IServiceObject {
|
||||
private:
|
||||
enum class CommandId {
|
||||
ConvertCurrentObjectToDomain = 0,
|
||||
CopyFromCurrentDomain = 1,
|
||||
CloneCurrentObject = 2,
|
||||
QueryPointerBufferSize = 3,
|
||||
CloneCurrentObjectEx = 4,
|
||||
};
|
||||
private:
|
||||
ServiceSession *session;
|
||||
public:
|
||||
@ -334,11 +334,11 @@ class ServiceSession : public IWaitable
|
||||
|
||||
public:
|
||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||
MakeServiceCommandMeta<HipcControlCommand_ConvertCurrentObjectToDomain, &ServiceSession::IHipcControlService::ConvertCurrentObjectToDomain>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_CopyFromCurrentDomain, &ServiceSession::IHipcControlService::CopyFromCurrentDomain>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObject, &ServiceSession::IHipcControlService::CloneCurrentObject>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_QueryPointerBufferSize, &ServiceSession::IHipcControlService::QueryPointerBufferSize>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObjectEx, &ServiceSession::IHipcControlService::CloneCurrentObjectEx>(),
|
||||
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, ConvertCurrentObjectToDomain),
|
||||
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, CopyFromCurrentDomain),
|
||||
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, CloneCurrentObject),
|
||||
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, QueryPointerBufferSize),
|
||||
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, CloneCurrentObjectEx),
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -18,11 +18,6 @@
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
enum MitmQueryServiceCommand {
|
||||
MQS_Cmd_ShouldMitm = 65000,
|
||||
MQS_Cmd_AssociatePidTid = 65001
|
||||
};
|
||||
|
||||
namespace MitmQueryUtils {
|
||||
Result GetAssociatedTidForPid(u64 pid, u64 *tid);
|
||||
|
||||
@ -31,6 +26,11 @@ namespace MitmQueryUtils {
|
||||
|
||||
template <typename T>
|
||||
class MitmQueryService : public IServiceObject {
|
||||
private:
|
||||
enum class CommandId {
|
||||
ShouldMitm = 65000,
|
||||
AssociatePidToTid = 65001,
|
||||
};
|
||||
protected:
|
||||
void ShouldMitm(Out<bool> should_mitm, u64 pid) {
|
||||
should_mitm.SetValue(false);
|
||||
@ -44,7 +44,7 @@ class MitmQueryService : public IServiceObject {
|
||||
}
|
||||
public:
|
||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||
MakeServiceCommandMeta<MQS_Cmd_ShouldMitm, &MitmQueryService<T>::ShouldMitm>(),
|
||||
MakeServiceCommandMeta<MQS_Cmd_AssociatePidTid, &MitmQueryService<T>::AssociatePidToTid>(),
|
||||
MAKE_SERVICE_COMMAND_META(MitmQueryService<T>, ShouldMitm),
|
||||
MAKE_SERVICE_COMMAND_META(MitmQueryService<T>, AssociatePidToTid),
|
||||
};
|
||||
};
|
@ -220,6 +220,14 @@ class MitmSession final : public ServiceSession {
|
||||
|
||||
public:
|
||||
class IMitmHipcControlService : public IServiceObject {
|
||||
private:
|
||||
enum class CommandId {
|
||||
ConvertCurrentObjectToDomain = 0,
|
||||
CopyFromCurrentDomain = 1,
|
||||
CloneCurrentObject = 2,
|
||||
QueryPointerBufferSize = 3,
|
||||
CloneCurrentObjectEx = 4,
|
||||
};
|
||||
private:
|
||||
MitmSession *session;
|
||||
public:
|
||||
@ -324,11 +332,11 @@ class MitmSession final : public ServiceSession {
|
||||
|
||||
public:
|
||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||
MakeServiceCommandMeta<HipcControlCommand_ConvertCurrentObjectToDomain, &MitmSession::IMitmHipcControlService::ConvertCurrentObjectToDomain>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_CopyFromCurrentDomain, &MitmSession::IMitmHipcControlService::CopyFromCurrentDomain>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObject, &MitmSession::IMitmHipcControlService::CloneCurrentObject>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_QueryPointerBufferSize, &MitmSession::IMitmHipcControlService::QueryPointerBufferSize>(),
|
||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObjectEx, &MitmSession::IMitmHipcControlService::CloneCurrentObjectEx>(),
|
||||
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, ConvertCurrentObjectToDomain),
|
||||
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, CopyFromCurrentDomain),
|
||||
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, CloneCurrentObject),
|
||||
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, QueryPointerBufferSize),
|
||||
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, CloneCurrentObjectEx),
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user