Skip to content

Commit

Permalink
Add source code for exchange_u32
Browse files Browse the repository at this point in the history
  • Loading branch information
abaire authored and mborgerson committed Feb 11, 2022
1 parent fb04281 commit 3afc220
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def free_code():
def _exchangeU32Call(xbox, address, value):
global exchange_u32_addr
if exchange_u32_addr is None:
exchange_u32_addr = _loadBinary(xbox, bytes([0xFA, 0x8B, 0x44, 0x24, 0x04, 0x8B, 0x54, 0x24, 0x08, 0x87, 0x02, 0xFB, 0xC2, 0x08, 0x00]))

with open("exchange_u32", "rb") as infile:
data = infile.read()

exchange_u32_addr = _loadBinary(xbox, data)
print("exchange_u32 installed at 0x%08X" % exchange_u32_addr)
return xbox.call(exchange_u32_addr, struct.pack("<LL", value, address))['eax']

Expand Down
Binary file added exchange_u32
Binary file not shown.
20 changes: 20 additions & 0 deletions exchange_u32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; Construct binary using `nasm exchange_u32.asm`

bits 32

exchange_u32:

; Avoid any other CPU stuff overwriting stuff in this risky section
cli

; value
mov eax, dword [esp+4]

; address
mov edx, dword [esp+8]

xchg dword [EDX],EAX

sti

ret 0x8

0 comments on commit 3afc220

Please sign in to comment.