mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 02:33:43 +01:00
More memory cleanup
This commit is contained in:
1 parent
cd052ea640
commit
3bd41376da
43 files changed
+574
-527
No files matched your search
+25
-19
@@ -751,6 +751,8 @@ void CWCheatEngine::ApplyMemoryOperator(const CheatOperation &op, uint32_t(*oper
|
||||
Memory::WriteUnchecked_U16((u16)oper(Memory::ReadUnchecked_U16(op.addr), op.val),op. addr);
|
||||
else if (op.sz == 4)
|
||||
Memory::WriteUnchecked_U32((u32)oper(Memory::ReadUnchecked_U32(op.addr), op.val), op.addr);
|
||||
} else {
|
||||
// Report memory error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1046,10 +1048,10 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat,
|
||||
const CheatLine &line = cheat.lines[i++];
|
||||
switch (line.part1 >> 28) {
|
||||
case 0x1: // type copy byte
|
||||
{
|
||||
if (Memory::IsValidRange(op.addr, 4) && Memory::IsValidRange(op.addr + op.pointerCommands.baseOffset, 4)) {
|
||||
InvalidateICache(op.addr, 4); // See note at top of file
|
||||
u32 srcAddr = Memory::Read_U32(op.addr) + op.pointerCommands.offset;
|
||||
u32 dstAddr = Memory::Read_U32(op.addr + op.pointerCommands.baseOffset) + (line.part1 & 0x0FFFFFFF);
|
||||
u32 srcAddr = Memory::ReadUnchecked_U32(op.addr) + op.pointerCommands.offset;
|
||||
u32 dstAddr = Memory::ReadUnchecked_U32(op.addr + op.pointerCommands.baseOffset) + (line.part1 & 0x0FFFFFFF);
|
||||
if (Memory::IsValidRange(dstAddr, val) && Memory::IsValidRange(srcAddr, val)) {
|
||||
InvalidateICache(dstAddr, val);
|
||||
InvalidateICache(srcAddr, val); // See note at top of file
|
||||
@@ -1067,23 +1069,27 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat,
|
||||
if ((line.part1 >> 28) == 0x3) {
|
||||
walkOffset = -walkOffset;
|
||||
}
|
||||
// TODO: I've seen crashes here. Presumably an unaligned pointer just off the edge of memory.
|
||||
// We should probably check pointer validity and invalidate the cheat if this happens.
|
||||
base = Memory::Read_U32(base + walkOffset);
|
||||
switch (line.part2 >> 28) {
|
||||
case 0x2:
|
||||
case 0x3: // type pointer walk
|
||||
walkOffset = line.part2 & 0x0FFFFFFF;
|
||||
if ((line.part2 >> 28) == 0x3) {
|
||||
walkOffset = -walkOffset;
|
||||
}
|
||||
InvalidateICache(base + walkOffset, 4); // See note at top of file
|
||||
base = Memory::Read_U32(base + walkOffset);
|
||||
break;
|
||||
if (Memory::IsValidRange(base + walkOffset, 4)) {
|
||||
// TODO: I've seen crashes here. Presumably an unaligned pointer just off the edge of memory.
|
||||
// We should probably check pointer validity and invalidate the cheat if this happens.
|
||||
base = Memory::ReadUnchecked_U32(base + walkOffset);
|
||||
switch (line.part2 >> 28) {
|
||||
case 0x2:
|
||||
case 0x3: // type pointer walk
|
||||
walkOffset = line.part2 & 0x0FFFFFFF;
|
||||
if ((line.part2 >> 28) == 0x3) {
|
||||
walkOffset = -walkOffset;
|
||||
}
|
||||
if (Memory::IsValidRange(base + walkOffset, 4)) {
|
||||
InvalidateICache(base + walkOffset, 4); // See note at top of file
|
||||
base = Memory::ReadUnchecked_U32(base + walkOffset);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unexpected value in cheat line?
|
||||
break;
|
||||
default:
|
||||
// Unexpected value in cheat line?
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user