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;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <auto CommandId, auto CommandImpl, typename OverrideClassType, FirmwareVersion Low = FirmwareVersion_Min, FirmwareVersion High = FirmwareVersion_Max>
|
||||||
template <auto c, auto CommandImpl, FirmwareVersion l = FirmwareVersion_Min, FirmwareVersion h = FirmwareVersion_Max>
|
|
||||||
inline static constexpr ServiceCommandMeta MakeServiceCommandMeta() {
|
inline static constexpr ServiceCommandMeta MakeServiceCommandMeta() {
|
||||||
return {
|
return {
|
||||||
.fw_low = l,
|
.fw_low = Low,
|
||||||
.fw_high = h,
|
.fw_high = High,
|
||||||
.cmd_id = static_cast<u32>(c),
|
.cmd_id = static_cast<u32>(CommandId),
|
||||||
.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),
|
|
||||||
.handler = WrapIpcCommandImpl<CommandImpl, OverrideClassType>,
|
.handler = WrapIpcCommandImpl<CommandImpl, OverrideClassType>,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MAKE_SERVICE_COMMAND_META(class, name, ...) MakeServiceCommandMeta<CommandId::name, &class::name, class, ##__VA_ARGS__>()
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
@ -22,14 +22,6 @@
|
|||||||
#include "ipc_service_object.hpp"
|
#include "ipc_service_object.hpp"
|
||||||
#include "ipc_serialization.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
|
class ServiceSession : public IWaitable
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -268,6 +260,14 @@ class ServiceSession : public IWaitable
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
class IHipcControlService : public IServiceObject {
|
class IHipcControlService : public IServiceObject {
|
||||||
|
private:
|
||||||
|
enum class CommandId {
|
||||||
|
ConvertCurrentObjectToDomain = 0,
|
||||||
|
CopyFromCurrentDomain = 1,
|
||||||
|
CloneCurrentObject = 2,
|
||||||
|
QueryPointerBufferSize = 3,
|
||||||
|
CloneCurrentObjectEx = 4,
|
||||||
|
};
|
||||||
private:
|
private:
|
||||||
ServiceSession *session;
|
ServiceSession *session;
|
||||||
public:
|
public:
|
||||||
@ -334,11 +334,11 @@ class ServiceSession : public IWaitable
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||||
MakeServiceCommandMeta<HipcControlCommand_ConvertCurrentObjectToDomain, &ServiceSession::IHipcControlService::ConvertCurrentObjectToDomain>(),
|
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, ConvertCurrentObjectToDomain),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_CopyFromCurrentDomain, &ServiceSession::IHipcControlService::CopyFromCurrentDomain>(),
|
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, CopyFromCurrentDomain),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObject, &ServiceSession::IHipcControlService::CloneCurrentObject>(),
|
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, CloneCurrentObject),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_QueryPointerBufferSize, &ServiceSession::IHipcControlService::QueryPointerBufferSize>(),
|
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, QueryPointerBufferSize),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObjectEx, &ServiceSession::IHipcControlService::CloneCurrentObjectEx>(),
|
MAKE_SERVICE_COMMAND_META(ServiceSession::IHipcControlService, CloneCurrentObjectEx),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -18,11 +18,6 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
|
|
||||||
enum MitmQueryServiceCommand {
|
|
||||||
MQS_Cmd_ShouldMitm = 65000,
|
|
||||||
MQS_Cmd_AssociatePidTid = 65001
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace MitmQueryUtils {
|
namespace MitmQueryUtils {
|
||||||
Result GetAssociatedTidForPid(u64 pid, u64 *tid);
|
Result GetAssociatedTidForPid(u64 pid, u64 *tid);
|
||||||
|
|
||||||
@ -31,6 +26,11 @@ namespace MitmQueryUtils {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class MitmQueryService : public IServiceObject {
|
class MitmQueryService : public IServiceObject {
|
||||||
|
private:
|
||||||
|
enum class CommandId {
|
||||||
|
ShouldMitm = 65000,
|
||||||
|
AssociatePidToTid = 65001,
|
||||||
|
};
|
||||||
protected:
|
protected:
|
||||||
void ShouldMitm(Out<bool> should_mitm, u64 pid) {
|
void ShouldMitm(Out<bool> should_mitm, u64 pid) {
|
||||||
should_mitm.SetValue(false);
|
should_mitm.SetValue(false);
|
||||||
@ -44,7 +44,7 @@ class MitmQueryService : public IServiceObject {
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||||
MakeServiceCommandMeta<MQS_Cmd_ShouldMitm, &MitmQueryService<T>::ShouldMitm>(),
|
MAKE_SERVICE_COMMAND_META(MitmQueryService<T>, ShouldMitm),
|
||||||
MakeServiceCommandMeta<MQS_Cmd_AssociatePidTid, &MitmQueryService<T>::AssociatePidToTid>(),
|
MAKE_SERVICE_COMMAND_META(MitmQueryService<T>, AssociatePidToTid),
|
||||||
};
|
};
|
||||||
};
|
};
|
@ -220,6 +220,14 @@ class MitmSession final : public ServiceSession {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
class IMitmHipcControlService : public IServiceObject {
|
class IMitmHipcControlService : public IServiceObject {
|
||||||
|
private:
|
||||||
|
enum class CommandId {
|
||||||
|
ConvertCurrentObjectToDomain = 0,
|
||||||
|
CopyFromCurrentDomain = 1,
|
||||||
|
CloneCurrentObject = 2,
|
||||||
|
QueryPointerBufferSize = 3,
|
||||||
|
CloneCurrentObjectEx = 4,
|
||||||
|
};
|
||||||
private:
|
private:
|
||||||
MitmSession *session;
|
MitmSession *session;
|
||||||
public:
|
public:
|
||||||
@ -324,11 +332,11 @@ class MitmSession final : public ServiceSession {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||||
MakeServiceCommandMeta<HipcControlCommand_ConvertCurrentObjectToDomain, &MitmSession::IMitmHipcControlService::ConvertCurrentObjectToDomain>(),
|
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, ConvertCurrentObjectToDomain),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_CopyFromCurrentDomain, &MitmSession::IMitmHipcControlService::CopyFromCurrentDomain>(),
|
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, CopyFromCurrentDomain),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObject, &MitmSession::IMitmHipcControlService::CloneCurrentObject>(),
|
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, CloneCurrentObject),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_QueryPointerBufferSize, &MitmSession::IMitmHipcControlService::QueryPointerBufferSize>(),
|
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, QueryPointerBufferSize),
|
||||||
MakeServiceCommandMeta<HipcControlCommand_CloneCurrentObjectEx, &MitmSession::IMitmHipcControlService::CloneCurrentObjectEx>(),
|
MAKE_SERVICE_COMMAND_META(MitmSession::IMitmHipcControlService, CloneCurrentObjectEx),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user