mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-26 22:30:21 +00:00
Begin implementing experimental mitm for bluetooth service
This commit is contained in:
parent
ef48b1e7dd
commit
859b13d3a7
7 changed files with 130 additions and 0 deletions
10
btdrv-mitm/source/btdrv_mitm_service.cpp
Normal file
10
btdrv-mitm/source/btdrv_mitm_service.cpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#include "btdrv_mitm_service.hpp"
|
||||||
|
#include "btdrv_shim.h"
|
||||||
|
|
||||||
|
namespace btdrv::mitm {
|
||||||
|
|
||||||
|
Result InitializeBluetooth(ams::os::SystemEvent *event) {
|
||||||
|
return btdrvInitializeBluetoothFwd(this->forward_service.get(), );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
btdrv-mitm/source/btdrv_mitm_service.hpp
Normal file
32
btdrv-mitm/source/btdrv_mitm_service.hpp
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#pragma once
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace btdrv::mitm {
|
||||||
|
|
||||||
|
class BtdrvMitmService : public sf::IMitmServiceObject {
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum class CommandId {
|
||||||
|
InitializeBluetooth = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
SF_MITM_SERVICE_OBJECT_CTOR(BtdrvMitmService) { /* ... */ }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Result InitializeBluetooth(ams::os::SystemEvent *event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||||
|
MAKE_SERVICE_COMMAND_META(InitializeBluetooth),
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
12
btdrv-mitm/source/btdrv_shim.c
Normal file
12
btdrv-mitm/source/btdrv_shim.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include "btdrv_shim.h"
|
||||||
|
#include <stratosphere/sf/sf_mitm_dispatch.h>
|
||||||
|
|
||||||
|
/* Command forwarders. */
|
||||||
|
Result btdrvInitializeBluetoothFwd(Service* s, Event *event) {
|
||||||
|
Handle handle = INVALID_HANDLE;
|
||||||
|
|
||||||
|
return serviceMitmDispatch(s, 1,
|
||||||
|
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
||||||
|
.out_handles = &handle,
|
||||||
|
);
|
||||||
|
}
|
13
btdrv-mitm/source/btdrv_shim.h
Normal file
13
btdrv-mitm/source/btdrv_shim.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Command forwarders. */
|
||||||
|
Result btdrvInitializeBluetoothFwd(Service* s, Event *event);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
22
btdrv-mitm/source/btdrvmitm_module.cpp
Normal file
22
btdrv-mitm/source/btdrvmitm_module.cpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include "btdrvmitm_module.hpp"
|
||||||
|
#include "btdrv_mitm_service.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace btdrv::mitm {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr sm::ServiceName MitmServiceName = sm::ServiceName::Encode("btdrv");
|
||||||
|
|
||||||
|
struct ServerOptions {
|
||||||
|
static constexpr size_t PointerBufferSize = 0x200;
|
||||||
|
static constexpr size_t MaxDomains = 0;
|
||||||
|
static constexpr size_t MaxDomainObjects = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr size_t MaxServers = 1;
|
||||||
|
sf::hipc::ServerManager<MaxServers, ServerOptions> g_server_manager;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
8
btdrv-mitm/source/btdrvmitm_module.hpp
Normal file
8
btdrv-mitm/source/btdrvmitm_module.hpp
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
|
||||||
|
namespace btdrv::mitm {
|
||||||
|
|
||||||
|
DEFINE_MITM_MODULE_CLASS(0x8000, AMS_GET_SYSTEM_THREAD_PRIORITY(btdrv, IpcServer));
|
||||||
|
|
||||||
|
}
|
33
btdrv-mitm/source/main.cpp
Normal file
33
btdrv-mitm/source/main.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
extern u32 __start__;
|
||||||
|
u32 __nx_applet_type = AppletType_None;
|
||||||
|
u32 __nx_fs_num_sessions = 1;
|
||||||
|
|
||||||
|
|
||||||
|
void __libnx_initheap(void) {
|
||||||
|
void* addr = nx_inner_heap;
|
||||||
|
size_t size = nx_inner_heap_size;
|
||||||
|
|
||||||
|
extern char* fake_heap_start;
|
||||||
|
extern char* fake_heap_end;
|
||||||
|
|
||||||
|
fake_heap_start = (char*)addr;
|
||||||
|
fake_heap_end = (char*)addr + size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __appInit(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void __appExit(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue