MissionControl/btdrv-mitm/source/btdrv_mitm_service.hpp

97 lines
3.9 KiB
C++
Raw Normal View History

#pragma once
#include <stratosphere.hpp>
2020-05-22 10:29:36 +00:00
#include "btdrv_mitm_logging.hpp"
2020-05-22 10:29:36 +00:00
namespace ams::mitm::btdrv {
class BtdrvMitmService : public sf::IMitmServiceObject {
private:
enum class CommandId {
InitializeBluetooth = 1,
FinalizeBluetooth = 4,
2020-06-09 19:58:32 +00:00
CancelBond = 12,
2020-06-09 19:58:32 +00:00
GetEventInfo = 15,
InitializeHid = 16,
WriteHidData = 19,
FinalizeHid = 26,
GetHidEventInfo = 27,
RegisterHidReportEventDeprecated = 36,
RegisterHidReportEvent = 37,
GetHidReportEventInfoDeprecated1 = 37,
GetHidReportEventInfoDeprecated2 = 38,
GetHidReportEventInfo = 38,
2020-05-22 10:29:36 +00:00
/* 5.0.0+ */
InitializeBle = 46,
FinalizeBle = 49,
/* Extensions */
RedirectSystemEvents = 65000,
};
public:
static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
return true;
}
public:
2020-05-22 10:29:36 +00:00
SF_MITM_SERVICE_OBJECT_CTOR(BtdrvMitmService) {
//BTDRV_LOG_FMT("\nbtdrv-mitm initialised");
2020-05-22 10:29:36 +00:00
}
protected:
2020-05-22 10:29:36 +00:00
Result InitializeBluetooth(sf::OutCopyHandle out_handle);
Result FinalizeBluetooth(void);
2020-06-09 19:58:32 +00:00
Result CancelBond(BluetoothAddress address);
2020-05-22 10:29:36 +00:00
Result GetEventInfo(sf::Out<u32> out_type, const sf::OutPointerBuffer &out_buffer);
Result InitializeHid(sf::OutCopyHandle out_handle, u16 version);
Result WriteHidData(BluetoothAddress address, const sf::InPointerBuffer &buffer);
Result FinalizeHid(void);
Result GetHidEventInfo(sf::Out<u32> out_type, const sf::OutPointerBuffer &out_buffer);
Result RegisterHidReportEventDeprecated(sf::OutCopyHandle out_handle);
2020-05-22 10:29:36 +00:00
Result RegisterHidReportEvent(sf::OutCopyHandle out_handle);
Result GetHidReportEventInfoDeprecated1(sf::Out<u32> out_type, const sf::OutPointerBuffer &out_buffer);
Result GetHidReportEventInfoDeprecated2(sf::Out<u32> out_type, const sf::OutPointerBuffer &out_buffer);
2020-05-22 10:29:36 +00:00
Result GetHidReportEventInfo(sf::OutCopyHandle out_handle);
Result InitializeBle(sf::OutCopyHandle out_handle);
Result FinalizeBle(void);
Result RedirectSystemEvents(bool redirect);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(InitializeBluetooth),
2020-05-22 10:29:36 +00:00
MAKE_SERVICE_COMMAND_META(FinalizeBluetooth),
2020-06-09 19:58:32 +00:00
MAKE_SERVICE_COMMAND_META(CancelBond),
2020-05-22 10:29:36 +00:00
MAKE_SERVICE_COMMAND_META(GetEventInfo),
MAKE_SERVICE_COMMAND_META(InitializeHid),
MAKE_SERVICE_COMMAND_META(WriteHidData),
MAKE_SERVICE_COMMAND_META(FinalizeHid),
MAKE_SERVICE_COMMAND_META(GetHidEventInfo),
MAKE_SERVICE_COMMAND_META(RegisterHidReportEventDeprecated, hos::Version_1_0_0, hos::Version_3_0_2),
MAKE_SERVICE_COMMAND_META(RegisterHidReportEvent, hos::Version_4_0_0),
MAKE_SERVICE_COMMAND_META(GetHidReportEventInfoDeprecated1, hos::Version_1_0_0, hos::Version_3_0_2),
MAKE_SERVICE_COMMAND_META(GetHidReportEventInfoDeprecated2, hos::Version_4_0_0, hos::Version_6_2_0),
MAKE_SERVICE_COMMAND_META(GetHidReportEventInfo, hos::Version_7_0_0),
2020-05-22 10:29:36 +00:00
MAKE_SERVICE_COMMAND_META(InitializeBle),
MAKE_SERVICE_COMMAND_META(FinalizeBle),
MAKE_SERVICE_COMMAND_META(RedirectSystemEvents),
};
};
}