Begin implementing experimental mitm for bluetooth service

This commit is contained in:
ndeadly 2020-05-11 22:30:08 +02:00
parent ef48b1e7dd
commit 859b13d3a7
7 changed files with 130 additions and 0 deletions

View 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(), );
}
}

View 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),
};
};
}

View 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,
);
}

View 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

View 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;
}
}

View 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));
}

View 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;
}