@@ -508,7 +508,10 @@ uint32_t adjustWatchValueControls(int32_t slot)
508
508
case 0 :
509
509
{
510
510
// Modifying the address
511
- MemoryWatch[slot].Address = MemoryWatchSecondaryValue;
511
+ // Make sure the addresses being read does not exceed 0x817FFFFF
512
+ MemoryWatch[slot].Address = reinterpret_cast <uint32_t >(
513
+ fixBaseAddress (slot, reinterpret_cast <void *>(MemoryWatchSecondaryValue)));
514
+
512
515
MenuSelectionStates = 0 ;
513
516
514
517
FrameCounter = 1 ;
@@ -591,7 +594,10 @@ void adjustWatchTempValueAndBounds(int32_t slot, uint32_t highestDigit, int32_t
591
594
case 0 :
592
595
{
593
596
// Modifying the address
594
- UpperBoundUnsigned = 0x817FFFFF ;
597
+ // Make sure the upper bound does not exceed 0x817FFFFF
598
+ UpperBoundUnsigned = reinterpret_cast <uint32_t >(
599
+ fixBaseAddress (slot, reinterpret_cast <void *>(0x817FFFFF )));
600
+
595
601
LowerBoundUnsigned = 0x80000000 ;
596
602
597
603
if (tempMemoryWatchSecondaryValue > UpperBoundUnsigned)
@@ -635,4 +641,49 @@ void adjustWatchTempValueAndBounds(int32_t slot, uint32_t highestDigit, int32_t
635
641
}
636
642
}
637
643
644
+ void *fixBaseAddress (int32_t slot, void *address)
645
+ {
646
+ uint32_t CurrentTypeSize;
647
+ switch (MemoryWatch[slot].Type )
648
+ {
649
+ case time:
650
+ case s64:
651
+ case u64 :
652
+ case f64 :
653
+ {
654
+ CurrentTypeSize = 8 ;
655
+ break ;
656
+ }
657
+ case s32:
658
+ case u32 :
659
+ case f32 :
660
+ {
661
+ CurrentTypeSize = 4 ;
662
+ break ;
663
+ }
664
+ case s16:
665
+ case u16 :
666
+ {
667
+ CurrentTypeSize = 2 ;
668
+ break ;
669
+ }
670
+ case s8:
671
+ case u8 :
672
+ default :
673
+ {
674
+ CurrentTypeSize = 1 ;
675
+ break ;
676
+ }
677
+ }
678
+
679
+ // Make sure the address does not exceed 0x817FFFFF
680
+ uint32_t tempAddress = reinterpret_cast <uint32_t >(address);
681
+ while ((tempAddress + CurrentTypeSize - 1 ) >= 0x81800000 )
682
+ {
683
+ tempAddress--;
684
+ }
685
+
686
+ return reinterpret_cast <void *>(tempAddress);
687
+ }
688
+
638
689
}
0 commit comments