Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with multi-level pointers script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Wuschel
How do I cheat?
Reputation: 0

Joined: 26 Sep 2021
Posts: 4

PostPosted: Sun Sep 26, 2021 2:14 pm    Post subject: Help with multi-level pointers script Reply with quote

Hello everyone!

I'm struggling with a AoB script and maybe you can help.
As you can see from the attached file, what I would like to do is to copy the value of the Item4, then replace it to 0 and paste the value in Item6.
But I can't find a way to do it...

I could copy the value without problem.
But I tried many ways to move the value, and it's never the same value that appears in Item6...

What I did so far is this:

Code:

aobscanmodule(MoveValue,GameAssembly.dll,48 8B FA 48 8B D9 75 12 8B 0D) // should be unique
alloc(newmem,$1000,MoveValue)

label(code)
label(code2)
label(return)

// Structure
label(_PUI)
registersymbol(_PUI)

// Value to copy
label(_COPY_Item4)
registersymbol(_COPY_Item4)

newmem:

code:
  mov rdi,rdx
  mov rbx,rcx
  mov [_PUI],rbx

  push rbx
  mov rbx,rcx
  cmp rbx,0
  je code2
  mov rbx,[rbx+60]
  cmp rbx,0
  je code2
  mov rbx,[rbx+10]
  cmp rbx,0
  je code2

  push rax
  lea rax,[rbx+40]
  cmp rax,0
  je code2
  mov [_COPY_Item4],rax
  pop rax

  // -------------------------------
  // Not working from here

  //push rax
  //lea rax,[rbx+50]
  //cmp rax,0
  //je code2
  //mov [rax],_COPY_Item4
  //pop rax


  // not working either
  //lea rbx,[rbx+50]
  //cmp rbx,0
  //je code2
  //mov [rbx],_COPY_Item4


  // not working either
  //mov rbx,[rbx+50]
  //cmp rbx,0
  //je code2
  //mov [rbx],_COPY_Item4


  // -----------------------------

  pop rbx

  jmp return

code2:
  mov rdi,rdx
  mov rbx,rcx
  jmp return

_COPY_Item4:
  dq 0

_PUI:
  dq 0

MoveValue:
  jmp newmem
  nop
return:
registersymbol(MoveValue)

[DISABLE]

MoveValue:
  db 48 8B FA 48 8B D9

unregistersymbol(MoveValue)
unregistersymbol(_PUI)
unregistersymbol(_COPY_Item4)
dealloc(newmem)



CEscript.png
 Description:
 Filesize:  42.77 KB
 Viewed:  2383 Time(s)

CEscript.png




Last edited by Wuschel on Sun Sep 26, 2021 3:20 pm; edited 1 time in total
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Sun Sep 26, 2021 3:20 pm    Post subject: Reply with quote

This isn't Lua. It's auto assembler.
Back to top
View user's profile Send private message
Wuschel
How do I cheat?
Reputation: 0

Joined: 26 Sep 2021
Posts: 4

PostPosted: Sun Sep 26, 2021 3:28 pm    Post subject: Reply with quote

Indeed, I first tried in assembler but it's a mess kinda.
Wanted to see in lua if it could be done easily maybe

I tried using {$lua} writeBytes, using the good offsets (takes less place than in asm) and so on but it was a dead end too.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Sun Sep 26, 2021 3:42 pm    Post subject: Reply with quote

This will find the entry in the table with Lua, set its value and then remove the value from the other entry.

Code:

[ENABLE]
{$LUA}
local al = getAddressList()
local item4 = al.getMemoryRecordByDescription('Item4 (offset+40)')
local item6 = al.getMemoryRecordByDescription('Item6 (offset+50)')
if item4 ~= nil and item6 ~= nil then
  item6.value = item4.value
  item4.value = 0
end
{$ASM}
[DISABLE]
Back to top
View user's profile Send private message
Wuschel
How do I cheat?
Reputation: 0

Joined: 26 Sep 2021
Posts: 4

PostPosted: Sun Sep 26, 2021 3:56 pm    Post subject: Reply with quote

LeFiXER wrote:
This will find the entry in the table with Lua, set its value and then remove the value from the other entry.

Code:

[ENABLE]
{$LUA}
local al = getAddressList()
local item4 = al.getMemoryRecordByDescription('Item4 (offset+40)')
local item6 = al.getMemoryRecordByDescription('Item6 (offset+50)')
if item4 ~= nil and item6 ~= nil then
  item6.value = item4.value
  item4.value = 0
end
{$ASM}
[DISABLE]


Wow, thanks!
Extremely short and it works perfectly, couldn't expect better! Very Happy
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Sun Sep 26, 2021 4:16 pm    Post subject: Reply with quote

I hope it's understandable what the code is actually doing too. If you're curious about what Lua functions are available for Cheat Engine, you should check out celua.txt

celua.txt
Back to top
View user's profile Send private message
Wuschel
How do I cheat?
Reputation: 0

Joined: 26 Sep 2021
Posts: 4

PostPosted: Sun Sep 26, 2021 4:31 pm    Post subject: Reply with quote

LeFiXER wrote:
I hope it's understandable what the code is actually doing too. If you're curious about what Lua functions are available for Cheat Engine, you should check out celua.txt


Very clear, didn't think of using my local structure that way.
Was still trying to do everything, memory side lol
But yes as long as description is unique, it's a good way to extract things from the address list!
Thanks again for this method Wink
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Sun Sep 26, 2021 4:44 pm    Post subject: Reply with quote

You're most welcome! Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites