From e6fdd6bc989c1559e381636461531a7c73655443 Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Sun, 2 Feb 2020 22:55:01 +0000 Subject: [PATCH] thermosphere: fix software breakpoints --- thermosphere/src/software_breakpoints.c | 4 ++-- thermosphere/src/software_breakpoints.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/thermosphere/src/software_breakpoints.c b/thermosphere/src/software_breakpoints.c index baa62f8dc..841103eeb 100644 --- a/thermosphere/src/software_breakpoints.c +++ b/thermosphere/src/software_breakpoints.c @@ -58,7 +58,7 @@ static size_t findClosestSoftwareBreakpointSlot(uintptr_t address) static inline bool doApplySoftwareBreakpoint(size_t id) { SoftwareBreakpoint *bp = &g_softwareBreakpointManager.breakpoints[id]; - u32 brkInst = 0xF2000000 | bp->uid; + u32 brkInst = 0xD4200000 | (bp->uid << 5); size_t sz = guestReadWriteMemory(bp->address, 4, &bp->savedInstruction, &brkInst); bp->applied = sz == 4; @@ -181,7 +181,7 @@ int addSoftwareBreakpoint(uintptr_t addr, bool persistent) bp->address = addr; bp->persistent = persistent; bp->applied = false; - bp->uid = 0x2000 + g_softwareBreakpointManager.bpUniqueCounter++; + bp->uid = (u16)(0x2000 + g_softwareBreakpointManager.bpUniqueCounter++); int rc = applySoftwareBreakpoint(id) ? 0 : -EFAULT; recursiveSpinlockUnlock(&g_softwareBreakpointManager.lock); diff --git a/thermosphere/src/software_breakpoints.h b/thermosphere/src/software_breakpoints.h index d462c3560..4a19414fc 100644 --- a/thermosphere/src/software_breakpoints.h +++ b/thermosphere/src/software_breakpoints.h @@ -27,7 +27,7 @@ typedef struct SoftwareBreakpoint { uintptr_t address; // VA u32 savedInstruction; - u32 uid; + u16 uid; bool persistent; bool applied; atomic_bool triedToApplyOrRevert;