1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-19 08:52:25 +00:00

thermosphere: fix software breakpoints

This commit is contained in:
TuxSH 2020-02-02 22:55:01 +00:00
parent 3556c12960
commit e6fdd6bc98
2 changed files with 3 additions and 3 deletions

View file

@ -58,7 +58,7 @@ static size_t findClosestSoftwareBreakpointSlot(uintptr_t address)
static inline bool doApplySoftwareBreakpoint(size_t id) static inline bool doApplySoftwareBreakpoint(size_t id)
{ {
SoftwareBreakpoint *bp = &g_softwareBreakpointManager.breakpoints[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); size_t sz = guestReadWriteMemory(bp->address, 4, &bp->savedInstruction, &brkInst);
bp->applied = sz == 4; bp->applied = sz == 4;
@ -181,7 +181,7 @@ int addSoftwareBreakpoint(uintptr_t addr, bool persistent)
bp->address = addr; bp->address = addr;
bp->persistent = persistent; bp->persistent = persistent;
bp->applied = false; bp->applied = false;
bp->uid = 0x2000 + g_softwareBreakpointManager.bpUniqueCounter++; bp->uid = (u16)(0x2000 + g_softwareBreakpointManager.bpUniqueCounter++);
int rc = applySoftwareBreakpoint(id) ? 0 : -EFAULT; int rc = applySoftwareBreakpoint(id) ? 0 : -EFAULT;
recursiveSpinlockUnlock(&g_softwareBreakpointManager.lock); recursiveSpinlockUnlock(&g_softwareBreakpointManager.lock);

View file

@ -27,7 +27,7 @@
typedef struct SoftwareBreakpoint { typedef struct SoftwareBreakpoint {
uintptr_t address; // VA uintptr_t address; // VA
u32 savedInstruction; u32 savedInstruction;
u32 uid; u16 uid;
bool persistent; bool persistent;
bool applied; bool applied;
atomic_bool triedToApplyOrRevert; atomic_bool triedToApplyOrRevert;