Dfq I'm so dumb. I have read about that function a half year ago, thought "That a very usefull function" and then totally forgot. Many thanks for the provided code and for pointing my stupidity out!ShyTwig16 wrote: ↑Tue Jan 11, 2022 11:06 pmSorry I was thinking wrong about a call address, I use some lua function I wrote (posted below) so I haven't needed to think about it in a long time. I should have also told you to use [Link].Horse4Horse wrote: ↑Tue Jan 11, 2022 5:14 pm...
I understand what you're talking about(and as I said - it was an example, real values like +26 from "INJECT", its just for simplicity), but if I try to use any other address to be "desired"(inject+5 as example) - I'm getting the same error. And I dont see any other way to read memory, subtract it and write to location in one script without heavy lifting lua commands.
As for doing it with lua, these are two functions I wrote and use regularly:Code: Select all
[ENABLE] aobscanmodule(INJECT, Exanima.exe, E8xxxxxxxx8B04248BD0A1) registersymbol(INJECT) alloc(original, 5) registersymbol(original) original: readmem(INJECT+11, 5) INJECT+11: reassemble(INJECT) [DISABLE] INJECT+11: readmem(original, 5) unregistersymbol(INJECT) unregistersymbol(original)
EDIT:Code: Select all
---- ---- Calculates the address stored in opcode if 64 bit, or reads the address if 32 bit. ---- ---- getOpcodeAddress(address) ---- ---- Parameters: ---- address : number - string : ---- The address of the opcode the stored address is. ---- Return: ---- number : ---- The address stored at the given opcode address. function getOpcodeAddress(address) address = getAddress(address) if targetIs64Bit() then local os = readInteger(address, true) or 0 return address + 4 + os else return readInteger(address) end end registerLuaFunctionHighlight('getOpcodeAddress') ---- ---- Calculates the address stored in opcode. ---- ---- getCallAddress(address) ---- ---- Parameters: ---- address : number - string : ---- The address of the opcode the stored address is. ---- Return: ---- number : ---- The address stored at the given opcode address. function getCallAddress(address) address = getAddress(address) local os = readInteger(address, true) or 0 return address + 4 + os end registerLuaFunctionHighlight('getCallAddress')
And I actually use custom auto assembler commands in the end, but these have some dependencies (3 modules for these to work) and you need to modify them to make them work. Just thought that mutch code would be more confusing, but that these might help illustrate how the above functions work.Code: Select all
local function getOpcodeAddressAA(parameters, syntaxcheck) ---- ---- getOpcodeAddress(symbol, address) ---- local symbol, address = commands.getParameters(parameters) local status, msg = commands.checkParameter(symbol, 'symbol', 'getOpcodeAddress') if not status then return nil, msg end symbol = commands.checkForLuaGlobal(symbol) status, msg = commands.checkParameter(address, 'address', 'getOpcodeAddress') if not status then return nil, msg end address, msg = commands.parseNumberOrAddress(address, 'address', 'getOpcodeAddress') if not address then return nil, msg end if syntaxcheck then return string.format('define(%s, %016X)', symbol, 0) end local addr = getOpcodeAddress(address) return string.format('define(%s, %016X)', symbol, addr or 0) end registerAutoAssemblerCommand('getOpcodeAddress', getOpcodeAddressAA) local function getCallAddressAA(parameters, syntaxcheck) ---- ---- getCallAddress(symbol, address) ---- local symbol, address = commands.getParameters(parameters) local status, msg = commands.checkParameter(symbol, 'symbol', 'getCallAddress') if not status then return nil, msg end symbol = commands.checkForLuaGlobal(symbol) status, msg = commands.checkParameter(address, 'address', 'getCallAddress') if not status then return nil, msg end address, msg = commands.parseNumberOrAddress(address, 'address', 'getCallAddress') if not address then return nil, msg end if syntaxcheck then return string.format('define(%s, %016X)', symbol, 0) end local addr = getCallAddress(address) return string.format('define(%s, %016X)', symbol, addr or 0) end registerAutoAssemblerCommand('getCallAddress', getCallAddressAA)
But one question is still bothering me - is there no way to use defined by readmem symbol in the same script? Script needs to be fully executed?