Correctly using autoAssemble()?

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
Send
Table Makers
Table Makers
Posts: 523
Joined: Fri Feb 02, 2018 5:58 pm
Reputation: 344

Correctly using autoAssemble()?

Post by Send »

My script is writing my symbol to the address, but it's not executing any code in autoAssemble(). New to LUA, any tips?

Code: Select all

{$lua}
if syntaxcheck then return end

[ENABLE]
scan = "GameAssembly.dll+173031B"
registerSymbol("switch",scan)
mem = allocateMemory(0x1000)
registerSymbol("newmem",mem)


autoAssemble([[
  label(return)

  newmem:
    movss xmm8,(float)50.0
    movss [rbx+3C],xmm8
    jmp return

  switch:
    jmp newmem
    nop
  return:
  ]])


[DISABLE]
writeBytes(scan, 0xF3, 0x44, 0x0F, 0x11, 0x43, 0x3C)
unregisterSymbol("newmem")
unregisterSymbol("switch")
deAlloc(mem, 0x1000)
scan = nil
mem = nil

User avatar
SunBeam
Administration
Administration
Posts: 4810
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4432

Re: Correctly using autoAssemble()?

Post by SunBeam »

There is no assembly mnemonic that would directly write a float into a SSE2 instruction: "movss xmm8,float_val". You need a memory immediate address that holds the float you want, which you would then read it from:

Code: Select all

{$lua}
if syntaxcheck then return end

[ENABLE]
scan = "GameAssembly.dll+173031B"
registerSymbol("switch",scan)
mem = allocateMemory(0x1000)
registerSymbol("newmem",mem)

autoAssemble([[
  label(return)
  label(flVal)

  newmem:
    movss xmm8,[flVal]
    movss [rbx+3C],xmm8
    jmp return
    
  flVal:
    dd (float)50.0

  switch:
    jmp newmem
    nop
  return:
  ]])


[DISABLE]
writeBytes(scan, 0xF3, 0x44, 0x0F, 0x11, 0x43, 0x3C)
unregisterSymbol("newmem")
unregisterSymbol("switch")
deAlloc(mem, 0x1000)
scan = nil
mem = nil

User avatar
Send
Table Makers
Table Makers
Posts: 523
Joined: Fri Feb 02, 2018 5:58 pm
Reputation: 344

Re: Correctly using autoAssemble()?

Post by Send »

SunBeam wrote:
Mon May 06, 2024 9:49 pm
The one time I deviate away from the usual mov/movss xmm#,[new], lol. Appreciate ya!

The issue is, it's registering my symbol, but not executing the newmem just on this one specific address.

All of my other scripts with similar (without the direct float as in the example above) functions execute newmem. Now to figure out why they crash with lua and work with regular asm.

User avatar
SunBeam
Administration
Administration
Posts: 4810
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4432

Re: Correctly using autoAssemble()?

Post by SunBeam »

You don't need to do the last two:

Code: Select all

scan = nil
mem = nil
And this is incorrect:

Code: Select all

deAlloc(mem, 0x1000)
It's just deAlloc(getAddress("mem")) ([DISABLE] won't read the symbols from [ENABLE]; you need to declare them as global, before the [ENABLE]). No need for a size when deallocating.

User avatar
Send
Table Makers
Table Makers
Posts: 523
Joined: Fri Feb 02, 2018 5:58 pm
Reputation: 344

Re: Correctly using autoAssemble()?

Post by Send »

SunBeam wrote:
Tue May 07, 2024 1:22 am
You don't need to do the last two:

Code: Select all

scan = nil
mem = nil
And this is incorrect:

Code: Select all

deAlloc(mem, 0x1000)
It's just deAlloc(getAddress("mem")) ([DISABLE] won't read the symbols from [ENABLE]; you need to declare them as global, before the [ENABLE]). No need for a size when deallocating.
Thanks again brother, I'll keep at it.

Post Reply

Who is online

Users browsing this forum: No registered users