Page 1 of 1
How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 12:03 am
by MartaLabieniec
Hello.
I have a problem with writing a script.
The problem is with saving and restoring bytes - I don't know how to do it.
I have static green address, but in this address the bytes are constantly changing after every restart the game so I can't make normal AOB or CJ script because after resetting the game, they bytes will be totally new and my script will not find anymore the bytes.
If anyone can share any example and explain it, i will be very thankful.
Best regards,
Marta
Re: How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 12:38 am
by GreenHouse
You can always try (if you didn't already) to do an AOB of nearby bytes that are not changing.
Re: How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 1:29 am
by MartaLabieniec
You don't understand. I must use the address with changing dynamic Bytes. I just wanna know how to save Bytes to restore them after disable script
Re: How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 2:16 am
by cfemen
alloc some bytes+registersymbol and use [Link] to this symbol, also readMem this symbol at [DISABLE]
Re: How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 6:10 am
by MartaLabieniec
Can you share any example? I need to see full script
Re: How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 11:18 am
by cfemen
Code: Select all
aobscanmodule(aobSetEff,noita.exe,23 8D ?? ?? ?? ?? 3B C8) // should be unique
alloc(newmem,$1000)
alloc(origSet,6)
registersymbol(origSet)
label(code)
label(return)
origSet:
readmem(aobSetEff,6)
newmem:
code:
db 23 8D
readmem(aobSetEff+2,4)
jmp return
aobSetEff:
jmp newmem
nop
return:
registersymbol(aobSetEff)
[DISABLE]
aobSetEff:
readmem(origSet,6)
unregistersymbol(aobSetEff)
dealloc(newmem)
Example from one of my scripts.
Re: How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 1:46 pm
by MartaLabieniec
Ok, thanks for the example. I have 2 questions
You have in your example: aobscanmodule(aobSetEff,noita.exe,23 8D ?? ?? ?? ?? 3B C8)
and also you have: readmem(aobSetEff+2,4) <---- this means that it will save 4 BYTES in place in memory = aobscanmodule(aobSetEff,noita.exe,23 8D ?? ?? ?? ?? 3B C8) + 2 BYTES next? Am I right?
If you will have for example : readmem(aobSetEff+4F,23) <--- this will mean that it will save 23 BYTES in place in memory = aobscanmodule(aobSetEff,noita.exe,23 8D ?? ?? ?? ?? 3B C8) + 79 BYTES next? Am I right? [79 bytes because it is the same number like 4F in HEX)
Re: How to save and restore constantly changing bytes in static address?
Posted: Sat Nov 30, 2019 2:21 pm
by cfemen
readmem(aobSetEff+2,4)
copies 4 bytes to the allocated mem to restore the stolen bytes
aobSetEff = 23
aobSetEff+1 = 8D
aobSetEff+2 = ?? - - - > first byte copie
Am I right? [79 bytes because it is the same number like 4F in HEX)
yes
definition of readMem:
readMem(Address, Size)
the first parameter is the address to start reading(and you can give an offset+) , second one is size.
aob_address+4F = start 79 bytes next to it yes.
Edit : readmem will only work if the address is absolute.
if its something like jump equal / jump not equal +5 then it wont work coz you are jumping in the allocated memory.
but for cases like this you can use
[Link] or with an another aob to find the address to recreate the jump.