btdrv.mitm: update for new sf semantics

This commit is contained in:
ndeadly 2021-02-03 23:21:59 +01:00
parent 5f1bd20f5c
commit 9ec22870ad
3 changed files with 97 additions and 79 deletions

View file

@ -24,15 +24,15 @@
namespace ams::mitm::btdrv {
Result BtdrvMitmService::InitializeBluetooth(sf::OutCopyHandle out_handle) {
if (!bluetooth::core::IsInitialized()) {
if (!ams::bluetooth::core::IsInitialized()) {
Handle handle = INVALID_HANDLE;
R_TRY(btdrvInitializeBluetoothFwd(this->forward_service.get(), &handle));
R_TRY(bluetooth::core::Initialize(handle));
R_TRY(bluetooth::hid::report::InitializeReportBuffer());
R_TRY(ams::bluetooth::core::Initialize(handle));
R_TRY(ams::bluetooth::hid::report::InitializeReportBuffer());
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::core::GetForwardEvent()));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::core::GetForwardEvent()));
} else {
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::core::GetUserForwardEvent()));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::core::GetUserForwardEvent()));
}
return ams::ResultSuccess();
@ -47,8 +47,8 @@ namespace ams::mitm::btdrv {
return ams::ResultSuccess();
}
Result BtdrvMitmService::GetEventInfo(sf::Out<bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(bluetooth::core::GetEventInfo(this->client_info.program_id,
Result BtdrvMitmService::GetEventInfo(sf::Out<ams::bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(ams::bluetooth::core::GetEventInfo(this->client_info.program_id,
out_type.GetPointer(),
static_cast<uint8_t *>(out_buffer.GetPointer()),
static_cast<size_t>(out_buffer.GetSize())
@ -58,22 +58,22 @@ namespace ams::mitm::btdrv {
}
Result BtdrvMitmService::InitializeHid(sf::OutCopyHandle out_handle, u16 version) {
if (!bluetooth::hid::IsInitialized()) {
if (!ams::bluetooth::hid::IsInitialized()) {
Handle handle = INVALID_HANDLE;
R_TRY(btdrvInitializeHidFwd(this->forward_service.get(), &handle, version));
R_TRY(bluetooth::hid::Initialize(handle));
R_TRY(ams::bluetooth::hid::Initialize(handle));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::hid::GetForwardEvent()));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::hid::GetForwardEvent()));
}
else {
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::hid::GetUserForwardEvent()));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::hid::GetUserForwardEvent()));
}
return ams::ResultSuccess();
}
Result BtdrvMitmService::WriteHidData(bluetooth::Address address, const sf::InPointerBuffer &buffer) {
auto report = reinterpret_cast<const bluetooth::HidReport *>(buffer.GetPointer());
Result BtdrvMitmService::WriteHidData(ams::bluetooth::Address address, const sf::InPointerBuffer &buffer) {
auto report = reinterpret_cast<const ams::bluetooth::HidReport *>(buffer.GetPointer());
if (this->client_info.program_id == ncm::SystemProgramId::Hid) {
auto device = controller::LocateHandler(&address);
@ -97,8 +97,8 @@ namespace ams::mitm::btdrv {
return ams::ResultSuccess();
}
Result BtdrvMitmService::GetHidEventInfo(sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(bluetooth::hid::GetEventInfo(this->client_info.program_id,
Result BtdrvMitmService::GetHidEventInfo(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(ams::bluetooth::hid::GetEventInfo(this->client_info.program_id,
out_type.GetPointer(),
static_cast<uint8_t *>(out_buffer.GetPointer()),
static_cast<size_t>(out_buffer.GetSize())
@ -114,22 +114,22 @@ namespace ams::mitm::btdrv {
/* 4.0.0+ */
Result BtdrvMitmService::RegisterHidReportEvent(sf::OutCopyHandle out_handle) {
if (!bluetooth::hid::report::IsInitialized()) {
if (!ams::bluetooth::hid::report::IsInitialized()) {
Handle handle = INVALID_HANDLE;
R_TRY(btdrvRegisterHidReportEventFwd(this->forward_service.get(), &handle));
R_TRY(bluetooth::hid::report::Initialize(handle, this->forward_service.get(), os::GetThreadId(os::GetCurrentThread())));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::hid::report::GetForwardEvent()));
R_TRY(ams::bluetooth::hid::report::Initialize(handle, this->forward_service.get(), os::GetThreadId(os::GetCurrentThread())));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::hid::report::GetForwardEvent()));
}
else {
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::hid::report::GetUserForwardEvent()));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::hid::report::GetUserForwardEvent()));
}
return ams::ResultSuccess();
}
/* 1.0.0 - 6.2.0 */
Result _GetHidReportEventInfoDeprecated(Service *srv, sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(bluetooth::hid::report::GetEventInfo(out_type.GetPointer(),
Result _GetHidReportEventInfoDeprecated(Service *srv, sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(ams::bluetooth::hid::report::GetEventInfo(out_type.GetPointer(),
static_cast<uint8_t *>(out_buffer.GetPointer()),
static_cast<size_t>(out_buffer.GetSize())
));
@ -138,12 +138,12 @@ namespace ams::mitm::btdrv {
}
/* 1.0.0 - 3.0.2 */
Result BtdrvMitmService::GetHidReportEventInfoDeprecated1(sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
Result BtdrvMitmService::GetHidReportEventInfoDeprecated1(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
return _GetHidReportEventInfoDeprecated(this->forward_service.get(), out_type, out_buffer);
}
/* 4.0.0 - 6.2.0 */
Result BtdrvMitmService::GetHidReportEventInfoDeprecated2(sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
Result BtdrvMitmService::GetHidReportEventInfoDeprecated2(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
return _GetHidReportEventInfoDeprecated(this->forward_service.get(), out_type, out_buffer);
}
@ -151,22 +151,22 @@ namespace ams::mitm::btdrv {
Result BtdrvMitmService::GetHidReportEventInfo(sf::OutCopyHandle out_handle) {
Handle handle = INVALID_HANDLE;
R_TRY(btdrvGetHidReportEventInfoFwd(this->forward_service.get(), &handle));
R_TRY(bluetooth::hid::report::MapRemoteSharedMemory(handle));
out_handle.SetValue(bluetooth::hid::report::GetFakeSharedMemory()->handle);
R_TRY(ams::bluetooth::hid::report::MapRemoteSharedMemory(handle));
out_handle.SetValue(ams::bluetooth::hid::report::GetFakeSharedMemory()->handle);
return ams::ResultSuccess();
}
Result BtdrvMitmService::InitializeBle(sf::OutCopyHandle out_handle) {
if (!bluetooth::ble::IsInitialized()) {
if (!ams::bluetooth::ble::IsInitialized()) {
Handle handle = INVALID_HANDLE;
R_TRY(btdrvInitializeBleFwd(this->forward_service.get(), &handle));
R_TRY(bluetooth::ble::Initialize(handle));
R_TRY(ams::bluetooth::ble::Initialize(handle));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::ble::GetForwardEvent()));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::ble::GetForwardEvent()));
}
else {
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::ble::GetUserForwardEvent()));
out_handle.SetValue(os::GetReadableHandleOfSystemEvent(ams::bluetooth::ble::GetUserForwardEvent()));
}
return ams::ResultSuccess();
@ -180,12 +180,12 @@ namespace ams::mitm::btdrv {
return ams::ResultSuccess();
}
Result BtdrvMitmService::GetBleManagedEventInfoDeprecated(sf::Out<bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
Result BtdrvMitmService::GetBleManagedEventInfoDeprecated(sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
return GetBleManagedEventInfo(out_type, out_buffer);
}
Result BtdrvMitmService::GetBleManagedEventInfo(sf::Out<bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(bluetooth::ble::GetEventInfo(this->client_info.program_id,
Result BtdrvMitmService::GetBleManagedEventInfo(sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer) {
R_TRY(ams::bluetooth::ble::GetEventInfo(this->client_info.program_id,
out_type.GetPointer(),
static_cast<uint8_t *>(out_buffer.GetPointer()),
static_cast<size_t>(out_buffer.GetSize())
@ -195,12 +195,12 @@ namespace ams::mitm::btdrv {
}
Result BtdrvMitmService::GetRealSharedMemory(sf::OutCopyHandle out_handle) {
out_handle.SetValue(bluetooth::hid::report::GetRealSharedMemory()->handle);
out_handle.SetValue(ams::bluetooth::hid::report::GetRealSharedMemory()->handle);
return ams::ResultSuccess();
}
Result BtdrvMitmService::GetFakeSharedMemory(sf::OutCopyHandle out_handle) {
out_handle.SetValue(bluetooth::hid::report::GetFakeSharedMemory()->handle);
out_handle.SetValue(ams::bluetooth::hid::report::GetFakeSharedMemory()->handle);
return ams::ResultSuccess();
}

View file

@ -17,39 +17,35 @@
#include <stratosphere.hpp>
#include "bluetooth/bluetooth_types.hpp"
#define AMS_BTDRV_MITM_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 1, Result, InitializeBluetooth, (sf::OutCopyHandle out_handle), (out_handle)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, FinalizeBluetooth, (void), ()) \
AMS_SF_METHOD_INFO(C, H, 15, Result, GetEventInfo, (sf::Out<ams::bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 16, Result, InitializeHid, (sf::OutCopyHandle out_handle, u16 version), (out_handle, version)) \
AMS_SF_METHOD_INFO(C, H, 19, Result, WriteHidData, (ams::bluetooth::Address address, const sf::InPointerBuffer &buffer), (address, buffer)) \
AMS_SF_METHOD_INFO(C, H, 26, Result, FinalizeHid, (void), ()) \
AMS_SF_METHOD_INFO(C, H, 27, Result, GetHidEventInfo, (sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 36, Result, RegisterHidReportEventDeprecated, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_1_0_0, hos::Version_3_0_2) \
AMS_SF_METHOD_INFO(C, H, 37, Result, RegisterHidReportEvent, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 37, Result, GetHidReportEventInfoDeprecated1, (sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_1_0_0, hos::Version_3_0_2) \
AMS_SF_METHOD_INFO(C, H, 38, Result, GetHidReportEventInfoDeprecated2, (sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_4_0_0, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 38, Result, GetHidReportEventInfo, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 46, Result, InitializeBle, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 49, Result, FinalizeBle, (void), (), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 78, Result, GetBleManagedEventInfoDeprecated, (sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_5_0_0, hos::Version_5_0_2) \
AMS_SF_METHOD_INFO(C, H, 79, Result, GetBleManagedEventInfo, (sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, GetRealSharedMemory, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, GetFakeSharedMemory, (sf::OutCopyHandle out_handle), (out_handle)) \
AMS_SF_METHOD_INFO(C, H, 65002, void, RedirectCoreEvents, (bool redirect), (redirect)) \
AMS_SF_METHOD_INFO(C, H, 65003, void, RedirectHidEvents, (bool redirect), (redirect)) \
AMS_SF_METHOD_INFO(C, H, 65004, void, RedirectHidReportEvents, (bool redirect), (redirect)) \
AMS_SF_METHOD_INFO(C, H, 65005, void, RedirectBleEvents, (bool redirect), (redirect)) \
AMS_SF_DEFINE_MITM_INTERFACE(ams::mitm::btdrv, IBtdrvMitmInterface, AMS_BTDRV_MITM_INTERFACE_INFO)
namespace ams::mitm::btdrv {
namespace {
#define AMS_BTDRV_MITM_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 1, Result, InitializeBluetooth, (sf::OutCopyHandle out_handle)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, FinalizeBluetooth, (void)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, GetEventInfo, (sf::Out<bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 16, Result, InitializeHid, (sf::OutCopyHandle out_handle, u16 version)) \
AMS_SF_METHOD_INFO(C, H, 19, Result, WriteHidData, (bluetooth::Address address, const sf::InPointerBuffer &buffer)) \
AMS_SF_METHOD_INFO(C, H, 26, Result, FinalizeHid, (void)) \
AMS_SF_METHOD_INFO(C, H, 27, Result, GetHidEventInfo, (sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 36, Result, RegisterHidReportEventDeprecated, (sf::OutCopyHandle out_handle), hos::Version_1_0_0, hos::Version_3_0_2) \
AMS_SF_METHOD_INFO(C, H, 37, Result, RegisterHidReportEvent, (sf::OutCopyHandle out_handle), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 37, Result, GetHidReportEventInfoDeprecated1, (sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), hos::Version_1_0_0, hos::Version_3_0_2) \
AMS_SF_METHOD_INFO(C, H, 38, Result, GetHidReportEventInfoDeprecated2, (sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), hos::Version_4_0_0, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 38, Result, GetHidReportEventInfo, (sf::OutCopyHandle out_handle), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 46, Result, InitializeBle, (sf::OutCopyHandle out_handle), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 49, Result, FinalizeBle, (void), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 78, Result, GetBleManagedEventInfoDeprecated, (sf::Out<bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer), hos::Version_5_0_0, hos::Version_5_0_2) \
AMS_SF_METHOD_INFO(C, H, 79, Result, GetBleManagedEventInfo, (sf::Out<bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer), hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, GetRealSharedMemory, (sf::OutCopyHandle out_handle), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, GetFakeSharedMemory, (sf::OutCopyHandle out_handle)) \
AMS_SF_METHOD_INFO(C, H, 65002, void, RedirectCoreEvents, (bool redirect)) \
AMS_SF_METHOD_INFO(C, H, 65003, void, RedirectHidEvents, (bool redirect)) \
AMS_SF_METHOD_INFO(C, H, 65004, void, RedirectHidReportEvents, (bool redirect)) \
AMS_SF_METHOD_INFO(C, H, 65005, void, RedirectBleEvents, (bool redirect)) \
AMS_SF_DEFINE_MITM_INTERFACE(IBtdrvMitmInterface, AMS_BTDRV_MITM_INTERFACE_INFO)
}
class BtdrvMitmService : public sf::MitmServiceImplBase {
class BtdrvMitmService : public sf::MitmServiceImplBase {
public:
using MitmServiceImplBase::MitmServiceImplBase;
@ -62,21 +58,21 @@ namespace ams::mitm::btdrv {
public:
Result InitializeBluetooth(sf::OutCopyHandle out_handle);
Result FinalizeBluetooth(void);
Result GetEventInfo(sf::Out<bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetEventInfo(sf::Out<ams::bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result InitializeHid(sf::OutCopyHandle out_handle, u16 version);
Result WriteHidData(bluetooth::Address address, const sf::InPointerBuffer &buffer);
Result WriteHidData(ams::bluetooth::Address address, const sf::InPointerBuffer &buffer);
Result FinalizeHid(void);
Result GetHidEventInfo(sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetHidEventInfo(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result RegisterHidReportEventDeprecated(sf::OutCopyHandle out_handle);
Result RegisterHidReportEvent(sf::OutCopyHandle out_handle);
Result GetHidReportEventInfoDeprecated1(sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetHidReportEventInfoDeprecated2(sf::Out<bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetHidReportEventInfoDeprecated1(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetHidReportEventInfoDeprecated2(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetHidReportEventInfo(sf::OutCopyHandle out_handle);
/* 5.0.0+ */
Result InitializeBle(sf::OutCopyHandle out_handle);
Result FinalizeBle(void);
Result GetBleManagedEventInfoDeprecated(sf::Out<bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetBleManagedEventInfo(sf::Out<bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetBleManagedEventInfoDeprecated(sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetBleManagedEventInfo(sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
/* Extensions */
Result GetRealSharedMemory(sf::OutCopyHandle out_handle);

View file

@ -18,13 +18,17 @@
#include "bluetooth/bluetooth_events.hpp"
#include "../bluetoothmitm_utils.hpp"
#include <stratosphere.hpp>
#include <memory>
namespace ams::mitm::btdrv {
namespace {
constexpr sm::ServiceName MitmServiceName = sm::ServiceName::Encode("btdrv");
enum PortIndex {
PortIndex_BtdrvMitm,
PortIndex_Count,
};
constexpr sm::ServiceName BtdrvMitmServiceName = sm::ServiceName::Encode("btdrv");
struct ServerOptions {
static constexpr size_t PointerBufferSize = 0x1000;
@ -32,19 +36,37 @@ namespace ams::mitm::btdrv {
static constexpr size_t MaxDomainObjects = 0;
};
constexpr size_t MaxServers = 1;
constexpr size_t MaxSessions = 6;
class ServerManager final : public sf::hipc::ServerManager<PortIndex_Count, ServerOptions, MaxSessions> {
private:
virtual Result OnNeedsToAccept(int port_index, Server *server) override;
};
ServerManager g_server_manager;
Result ServerManager::OnNeedsToAccept(int port_index, Server *server) {
/* Acknowledge the mitm session. */
std::shared_ptr<::Service> fsrv;
sm::MitmProcessInfo client_info;
server->AcknowledgeMitmSession(std::addressof(fsrv), std::addressof(client_info));
switch (port_index) {
case PortIndex_BtdrvMitm:
return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced<IBtdrvMitmInterface, BtdrvMitmService>(decltype(fsrv)(fsrv), client_info), fsrv);
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
os::ThreadType g_btdrv_mitm_thread;
alignas(os::ThreadStackAlignment) u8 g_btdrv_mitm_thread_stack[0x2000];
s32 g_btdrv_mitm_thread_priority = utils::ConvertToUserPriority(17);
void BtdrvMitmThreadFunction(void *arg) {
R_ABORT_UNLESS(bluetooth::events::Initialize());
R_ABORT_UNLESS(ams::bluetooth::events::Initialize());
auto server_manager = std::make_unique<sf::hipc::ServerManager<MaxServers, ServerOptions, MaxSessions>>();
R_ABORT_UNLESS((server_manager->RegisterMitmServer<ams::mitm::btdrv::IBtdrvMitmInterface, ams::mitm::btdrv::BtdrvMitmService>(MitmServiceName)));
server_manager->LoopProcess();
R_ABORT_UNLESS((g_server_manager.RegisterMitmServer<BtdrvMitmService>(PortIndex_BtdrvMitm, BtdrvMitmServiceName)));
g_server_manager.LoopProcess();
}
}