feat: allow MAC spoofing in Bluetooth stack, show paired devices in Bluetooth app

This commit is contained in:
2026-06-16 08:49:06 +02:00
parent 4dc310e616
commit b091af7653
13 changed files with 700 additions and 44 deletions
+34
View File
@@ -56,6 +56,40 @@ namespace Montauk {
return (int64_t)Drivers::USB::Bluetooth::Disconnect(bdAddr);
}
static int64_t Sys_BtSetAddr(const uint8_t* bdAddr) {
if (!bdAddr) return -1;
if (!Drivers::USB::Bluetooth::IsInitialized()) return -1;
// bdAddr is a 6-byte buffer, addr[0] = least-significant octet.
return Drivers::USB::Bluetooth::SetAddress(bdAddr) ? 0 : -1;
}
static int64_t Sys_BtBonds(BtBondInfo* buf, int maxCount) {
if (!buf || maxCount <= 0) return 0;
if (!Drivers::USB::Bluetooth::IsInitialized()) return 0;
Drivers::USB::Bluetooth::Hci::BondInfo tmpBuf[8];
int kMax = maxCount;
if (kMax > 8) kMax = 8;
int count = Drivers::USB::Bluetooth::ListBonded(tmpBuf, kMax);
for (int i = 0; i < count; i++) {
memcpy(buf[i].bdAddr, tmpBuf[i].Addr, 6);
buf[i]._pad[0] = 0;
buf[i]._pad[1] = 0;
}
return (int64_t)count;
}
static int64_t Sys_BtForget(const uint8_t* bdAddr) {
if (!bdAddr) return -1;
if (!Drivers::USB::Bluetooth::IsInitialized()) return -1;
return (int64_t)Drivers::USB::Bluetooth::ForgetDevice(bdAddr);
}
static int64_t Sys_BtList(BtDevInfo* buf, int maxCount) {
if (!buf || maxCount <= 0) return 0;
if (!Drivers::USB::Bluetooth::IsInitialized()) return 0;
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 22
#define MONTAUK_BUILD_NUMBER 24
+10
View File
@@ -377,6 +377,16 @@ namespace Montauk {
case SYS_BTDISCONNECT:
if (!UserMemory::Range(frame->arg1, 6, false)) return -1;
return Sys_BtDisconnect((const uint8_t*)frame->arg1);
case SYS_BTSETADDR:
if (!UserMemory::Range(frame->arg1, 6, false)) return -1;
return Sys_BtSetAddr((const uint8_t*)frame->arg1);
case SYS_BTBONDS:
if ((int64_t)frame->arg2 < 0) return -1;
if (!UserMemory::Range(frame->arg1, (uint64_t)frame->arg2 * sizeof(BtBondInfo), true)) return -1;
return Sys_BtBonds((BtBondInfo*)frame->arg1, (int)frame->arg2);
case SYS_BTFORGET:
if (!UserMemory::Range(frame->arg1, 6, false)) return -1;
return Sys_BtForget((const uint8_t*)frame->arg1);
case SYS_BTLIST:
if ((int64_t)frame->arg2 < 0) return -1;
if (!UserMemory::Range(frame->arg1, (uint64_t)frame->arg2 * sizeof(BtDevInfo), true)) return -1;
+13
View File
@@ -258,6 +258,13 @@ namespace Montauk {
/* Filesystem.hpp -- paginated directory read (path, names, max, startIndex) */
static constexpr uint64_t SYS_READDIR_AT = 136;
/* Bluetooth.hpp -- set adapter BD_ADDR (6-byte buffer, addr[0] = LSB) */
static constexpr uint64_t SYS_BTSETADDR = 137;
/* Bluetooth.hpp -- list bonded (paired) devices / forget a bond */
static constexpr uint64_t SYS_BTBONDS = 138;
static constexpr uint64_t SYS_BTFORGET = 139;
// Graceful power-off request actions (SYS_POWER_REQUEST). The desktop posts
// a pending action and exits; login.elf reads it, runs the shutdown stages,
// then issues the matching SYS_SHUTDOWN / SYS_RESET.
@@ -508,6 +515,12 @@ namespace Montauk {
char name[64];
};
// Bluetooth bonded (paired) device (returned by SYS_BTBONDS)
struct BtBondInfo {
uint8_t bdAddr[6];
uint8_t _pad[2];
};
struct ThermalInfo {
char name[32]; // short zone name (e.g. "THRM", "TZ00")
int32_t temperature; // tenths of degrees Celsius, or -1 if unavailable