Joined: 20 Mar 2015 Posts: 2 Location: San Jose, California
Posted: Wed Mar 13, 2024 3:45 pm Post subject: I can't figure out how to read/write to R8W
Hi, I'm writing a script to nullify damage against the player but allow damage against enemies. I wrote the script successfully in assembly with the auto assembler but now I would like to try the same cheat using LUA. The issue I have is that when I try to read from or write to R8W it fails. This is what I have at the breakpoint, should be pretty simple so i know I must be missing something:
Code:
function debugger_onBreakpoint()
if (dec2Hex(RIP) == damageBP) then
local targetBase = getAddress(RCX)
local playerBase = getAddressSafe'[playerBasePtr]'
if (targetBase == playerBase) then
local fufu = writeSmallInteger(R8W, 0)
print('fufu ' .. tostring(fufu))
end
end
debug_continueFromBreakpoint(co_run)
return 1
end
I had also tried using getaddress to get the R8W address to read/write but that fails as well, or at least I'm using it wrong. Anyhow, I'm a bit stuck so any advice would be appreciated
r8w is just the lower 16 bits of the 64-bit r8 register.
writeSmallInteger takes an address. R8W is a 16-bit value- not an address. If you want to change the register, then modify the variable and CE will change the thread context after the Lua function returns.
Use debug_setBreakpoint callback, not debugger_onBreakpoint. No need to return anything or use debug_continueFromBreakpoint either with the callback.
Code:
debug_setBreakpoint(damageBP, function()
local targetBase = RCX
local playerBase = readPointer'playerBasePtr'
if (targetBase == playerBase) then
R8 = 0
end
end)
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Joined: 20 Mar 2015 Posts: 2 Location: San Jose, California
Posted: Wed Mar 13, 2024 4:34 pm Post subject:
Aha! Yes, I was just trying to learn about the R8-R15 registers. But I was thinking I would need an offset from R8 to write to R8W.
Also, I appreciate your advice on how to write this more efficiently. Thank you! This really does help me understand the problem and I appreciate your time
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum