mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-19 01:15:08 -04:00
tipc: fix deserialization of buffers
This commit is contained in:
parent
20a7fa1588
commit
e3a65b1405
2 changed files with 38 additions and 39 deletions
|
@ -16,14 +16,20 @@
|
|||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp>
|
||||
|
||||
#define AMS_TEST_I_USER_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 0, Result, RegisterClient, (const tipc::ClientProcessId &client_process_id), (client_process_id)) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 1, Result, GetServiceHandle, (tipc::OutMoveHandle out_h, sm::ServiceName service), (out_h, service)) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 2, Result, RegisterService, (tipc::OutMoveHandle out_h, sm::ServiceName service, u32 max_sessions, bool is_light), (out_h, service, max_sessions, is_light)) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 3, Result, UnregisterService, (sm::ServiceName service), (service))
|
||||
#define AMS_TEST_I_USER_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 0, Result, RegisterClient, (const tipc::ClientProcessId &client_process_id), (client_process_id)) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 1, Result, GetServiceHandle, (tipc::OutMoveHandle out_h, sm::ServiceName service), (out_h, service)) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 2, Result, RegisterService, (tipc::OutMoveHandle out_h, sm::ServiceName service, u32 max_sessions, bool is_light), (out_h, service, max_sessions, is_light)) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 3, Result, UnregisterService, (sm::ServiceName service), (service))
|
||||
|
||||
AMS_TIPC_DEFINE_INTERFACE(ams::_test::impl, IUserInterface, AMS_TEST_I_USER_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
#define AMS_TEST_I_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 0, Result, RegisterProcess, (os::ProcessId process_id, const tipc::InBuffer acid_sac, const tipc::InBuffer aci_sac), (process_id, acid_sac, aci_sac)) \
|
||||
AMS_TIPC_METHOD_INFO(C, H, 1, Result, UnregisterProcess, (os::ProcessId process_id), (process_id))
|
||||
|
||||
AMS_TIPC_DEFINE_INTERFACE(ams::_test::impl, IManagerInterface, AMS_TEST_I_MANAGER_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
|
||||
namespace ams::_test {
|
||||
|
||||
|
@ -33,26 +39,17 @@ namespace ams::_test {
|
|||
Result GetServiceHandle(tipc::OutMoveHandle out_h, sm::ServiceName service);
|
||||
Result RegisterService(tipc::OutMoveHandle out_h, sm::ServiceName service, u32 max_sessions, bool is_light);
|
||||
Result UnregisterService(sm::ServiceName service);
|
||||
|
||||
Result ProcessDefaultServiceCommand(const svc::ipc::MessageBuffer &message_buffer);
|
||||
};
|
||||
static_assert(impl::IsIUserInterface<UserInterfaceFacade>);
|
||||
|
||||
|
||||
Result TestManualDispatch(UserInterfaceFacade *facade) {
|
||||
svc::ipc::MessageBuffer message_buffer(svc::ipc::GetMessageBuffer());
|
||||
|
||||
switch (svc::ipc::MessageBuffer::MessageHeader(message_buffer).GetTag()) {
|
||||
case 16:
|
||||
return tipc::impl::InvokeServiceCommandImpl<16, &UserInterfaceFacade::RegisterClient, UserInterfaceFacade>(facade, message_buffer);
|
||||
case 17:
|
||||
return tipc::impl::InvokeServiceCommandImpl<17, &UserInterfaceFacade::GetServiceHandle, UserInterfaceFacade>(facade, message_buffer);
|
||||
case 18:
|
||||
return tipc::impl::InvokeServiceCommandImpl<18, &UserInterfaceFacade::RegisterService, UserInterfaceFacade>(facade, message_buffer);
|
||||
case 19:
|
||||
return tipc::impl::InvokeServiceCommandImpl<19, &UserInterfaceFacade::UnregisterService, UserInterfaceFacade>(facade, message_buffer);
|
||||
default:
|
||||
return tipc::ResultInvalidMethod();
|
||||
}
|
||||
}
|
||||
class ManagerInterfaceFacade {
|
||||
public:
|
||||
Result RegisterProcess(os::ProcessId process_id, const tipc::InBuffer acid_sac, const tipc::InBuffer aci_sac);
|
||||
Result UnregisterProcess(os::ProcessId process_id);
|
||||
};
|
||||
static_assert(impl::IsIManagerInterface<ManagerInterfaceFacade>);
|
||||
|
||||
using UserInterfaceObject = ::ams::tipc::ServiceObject<impl::IUserInterface, UserInterfaceFacade>;
|
||||
|
||||
|
@ -60,5 +57,11 @@ namespace ams::_test {
|
|||
return object->ProcessRequest();
|
||||
}
|
||||
|
||||
using ManagerInterfaceObject = ::ams::tipc::ServiceObject<impl::IManagerInterface, ManagerInterfaceFacade>;
|
||||
|
||||
Result TestManagerDispatch(ManagerInterfaceObject *object) {
|
||||
return object->ProcessRequest();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue