Skip to content

Commit 857446a

Browse files
committed
Memory Watches - Adjust selected address for variables if the selected address would go out of bounds
1 parent e8f6d38 commit 857446a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ttyd-tools/rel/source/commonfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ uint32_t checkIfPointerIsValid(const void *ptr)
402402
return PTR_CACHED;
403403
}
404404

405-
// Unached memory
405+
// Uncached memory
406406
if ((ptrRaw >= 0xC0000000) && (ptrRaw < 0xC1800000))
407407
{
408408
return PTR_UNCACHED;

ttyd-tools/rel/source/memory.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,13 @@ uint32_t adjustWatchValueControls(int32_t slot)
523523
{
524524
// Modifying the address
525525
// Make sure the address is valid
526-
uint32_t tempMenuSecondaryValueUnsigned = MenuVar.MenuSecondaryValueUnsigned;
527-
if (checkIfPointerIsValid(reinterpret_cast<void *>(tempMenuSecondaryValueUnsigned)))
526+
void *tempMenuSecondaryValueUnsigned = reinterpret_cast<void *>(MenuVar.MenuSecondaryValueUnsigned);
527+
if (checkIfPointerIsValid(tempMenuSecondaryValueUnsigned))
528528
{
529-
MemoryWatch[slot].Address = tempMenuSecondaryValueUnsigned;
529+
// Make sure the address is valid for the selected variable type
530+
tempMenuSecondaryValueUnsigned = fixBaseAddress(slot, tempMenuSecondaryValueUnsigned);
531+
532+
MemoryWatch[slot].Address = reinterpret_cast<uint32_t>(tempMenuSecondaryValueUnsigned);
530533

531534
MenuVar.MenuSelectionStates = 0;
532535

0 commit comments

Comments
 (0)