diff --git a/include/stratosphere/ipc/ipc_serialization.hpp b/include/stratosphere/ipc/ipc_serialization.hpp index abd698b3..07a5ee7a 100644 --- a/include/stratosphere/ipc/ipc_serialization.hpp +++ b/include/stratosphere/ipc/ipc_serialization.hpp @@ -649,25 +649,16 @@ constexpr Result WrapIpcCommandImpl(IpcResponseContext *ctx) { return ResultSuccess; } - -template +template inline static constexpr ServiceCommandMeta MakeServiceCommandMeta() { return { - .fw_low = l, - .fw_high = h, - .cmd_id = static_cast(c), - .handler = WrapIpcCommandImpl, - }; -}; - -template -inline static constexpr ServiceCommandMeta MakeServiceCommandMetaEx() { - return { - .fw_low = l, - .fw_high = h, - .cmd_id = static_cast(c), + .fw_low = Low, + .fw_high = High, + .cmd_id = static_cast(CommandId), .handler = WrapIpcCommandImpl, }; }; +#define MAKE_SERVICE_COMMAND_META(class, name, ...) MakeServiceCommandMeta() + #pragma GCC diagnostic pop diff --git a/include/stratosphere/ipc/ipc_service_session.hpp b/include/stratosphere/ipc/ipc_service_session.hpp index 758c4745..e6efc3a1 100644 --- a/include/stratosphere/ipc/ipc_service_session.hpp +++ b/include/stratosphere/ipc/ipc_service_session.hpp @@ -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(), - MakeServiceCommandMeta(), - MakeServiceCommandMeta(), - MakeServiceCommandMeta(), - MakeServiceCommandMeta(), + 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), }; }; }; diff --git a/include/stratosphere/mitm/mitm_query_service.hpp b/include/stratosphere/mitm/mitm_query_service.hpp index c0afab85..b60f67b1 100644 --- a/include/stratosphere/mitm/mitm_query_service.hpp +++ b/include/stratosphere/mitm/mitm_query_service.hpp @@ -18,11 +18,6 @@ #include #include -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 class MitmQueryService : public IServiceObject { + private: + enum class CommandId { + ShouldMitm = 65000, + AssociatePidToTid = 65001, + }; protected: void ShouldMitm(Out should_mitm, u64 pid) { should_mitm.SetValue(false); @@ -44,7 +44,7 @@ class MitmQueryService : public IServiceObject { } public: DEFINE_SERVICE_DISPATCH_TABLE { - MakeServiceCommandMeta::ShouldMitm>(), - MakeServiceCommandMeta::AssociatePidToTid>(), + MAKE_SERVICE_COMMAND_META(MitmQueryService, ShouldMitm), + MAKE_SERVICE_COMMAND_META(MitmQueryService, AssociatePidToTid), }; }; \ No newline at end of file diff --git a/include/stratosphere/mitm/mitm_session.hpp b/include/stratosphere/mitm/mitm_session.hpp index 69689c48..71c45cbb 100644 --- a/include/stratosphere/mitm/mitm_session.hpp +++ b/include/stratosphere/mitm/mitm_session.hpp @@ -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(), - MakeServiceCommandMeta(), - MakeServiceCommandMeta(), - MakeServiceCommandMeta(), - MakeServiceCommandMeta(), + 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), }; }; };