Page 1 of 1

[Help] Using Address pointer in symbol as a new label?

Posted: Fri Mar 12, 2021 1:06 am
by Removed9
Lets say I grab an address from an instruction that leads to the exact location of a dynamic inventory storage that I can later null out with DB 00 00 00 00 or add my own sequence of default items in bytes. The address is stored in inventory, but to gain access to the exact address I need to use [inventory]. Using it in the table is fine and dandy, but wasn't there a way to do this in assembler? Why does this not work as simple as:

Code: Select all

[inventory]:
db 00 00 00 00

Code: Select all

label(code)
label(return)

label(inventory)
registersymbol(inventory)

newmem:

code:
  mov ecx,rdi
  add ecx,38A10
  mov [inventory],ecx
  mov ecx,[rdi+000000A0]
  jmp return

inventory:
  db 0

gGiveAllItems:
  jmp newmem
  nop
return:

registersymbol(gGiveAllItems)
What is the best way going about this, or did I over complicate it and there is an easy way?

Re: [Help] Using Address pointer in symbol as a new label?

Posted: Fri Mar 12, 2021 1:31 am
by TimFun13
It's just the way CE works, and it's not ASM. You can use lua to do it, but it needs to be allocated in another script. You could just nest a "reset" script under the main one.

Also if "inventory" is to be an address (which you use it that way) you should make it 64 bits. It would probable work fine but if you only allocate 1 byte, you can run into problems.

Code: Select all

label(code)
label(return)

label(inventory)
registersymbol(inventory)

newmem:

code:
  mov rcx,rdi
  add rcx,38A10
  mov [inventory],rcx
  mov ecx,[rdi+000000A0]
  jmp return

inventory:
  dq 0 // "data quad" is 64 bits

gGiveAllItems:
  jmp newmem
  nop
return:

registersymbol(gGiveAllItems)

Code: Select all

{$lua}
[ENABLE]
if syntaxcheck then return end
writeInteger('[inventory]', 0) // this will write a 32 bit integer to the address stored at "inventory".
[DISABLE]

Re: [Help] Using Address pointer in symbol as a new label?

Posted: Fri Mar 12, 2021 1:48 am
by SunBeam
People have this convoluted impression that CE Lua is something scary. All it takes is practice and doing everything you were used to do in ASM.. in Lua. Or even combine the two. Exit your "comfort" zone. See it as learning something new. If you wanna stay at that same boring knowledge level, so be it :P