add DCv2 item loss prevention patch

This commit is contained in:
Martin Michelsen
2024-05-09 00:24:50 -07:00
parent f7c847bcf0
commit c7cb81e0fc
7 changed files with 252 additions and 9 deletions
@@ -1,21 +1,23 @@
mova r0, [first_patch_header]
mov r7, r0 # r7 = read ptr
mov r7, r0 # r7 = read ptr
xor r3, r3
dec r3
shl r3, 2 # r3 = 0xFFFFFFFC (mask for aligning r7)
shl r3, 2 # r3 = 0xFFFFFFFC (mask for aligning r7)
apply_patch:
add r7, 3
and r7, r3 # r7 = (r7 + 3) & (~3) (align to 4-byte boundary)
mov.l r4, [r7]+ # r4 = dest addr
and r7, r3 # r7 = (r7 + 3) & (~3) (align to 4-byte boundary)
mov.l r4, [r7]+ # r4 = dest addr
mov.l r5, [r7]+
add r5, r4 # r5 = dest end ptr (dest addr + size)
add r5, r4 # r5 = dest end ptr (dest addr + size)
cmpeq r4, r5 # if (size == 0) return
bt done
again:
cmpeq r4, r5
bt done # if (r4 == r5) break
bt apply_patch # if (r4 == r5) done with the patch; go to next header
mov.b r0, [r7]+
mov.b [r4], r0 # *(r4) = *(r7++);
bs again # r4++; continue
mov.b [r4], r0 # *(r4) = *(r7++);
bs again # r4++; continue
add r4, 1
done: