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 


Saving to my own array

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
nero1232
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2017
Posts: 65

PostPosted: Sun Mar 12, 2017 7:55 am    Post subject: Saving to my own array Reply with quote

Hi,

I have this code to save the value of EBX to my own array:

Code:


aobscanmodule(MoveChar,P.exe,44 0F 29 AB A0 01 00 00 44) // should be unique
alloc(newmem,$1000,"P.exe"+FEC8E2)
alloc(myarray,$32,"P.exe"+FFF8E2)

label(cheat)
label(myloop)
label(saveit)
label(code)
label(return)

newmem:

cheat:
  cmp [rbx+00000018],(int)3653
  jne code
  cmp [rbx+00000160],(int)2174
  jne code
  xor ecx,ecx
  mov ebx,myarray
myloop:
  cmp [ebx+ecx*4],0
  je saveit
  inc ecx
  cmp ecx,8
  jge code
  jmp myloop
saveit:
  mov [ebx+ecx*4],ebx


code:
  movaps [rbx+000001A0],xmm13
  jmp return

MoveChar:
  jmp cheat
  nop
  nop
  nop
return:
registersymbol(MoveChar)



I am getting a compile error on line :
Code:

  cmp [ebx+ecx*4],0


Does anyone know why and does this look right to save my values to the array. I am expecting 8 different values in EBX that I need to save and I want them to write every time this code is executed one after the other. [/code]
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Mar 12, 2017 8:04 am    Post subject: Reply with quote

64bit target?
Back to top
View user's profile Send private message
nero1232
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2017
Posts: 65

PostPosted: Sun Mar 12, 2017 8:06 am    Post subject: Reply with quote

++METHOS wrote:
64bit target?


Yes
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Mar 12, 2017 9:36 am    Post subject: Reply with quote

If the value you want is stored in EBX, then you can't use EBX in your other code. Otherwise, you just overwrote it.
Essentially, your code is setting EBX to your array then storing the address of the array within the array.

But yes, since it's 64-bit, you need to use RBX, not EBX.
That also means address are 8 bytes, so multiply the index by 8 and increase the array size to 64.

Also, you need to restore all register values that the game's later code is expecting to use. push/pop

Don't forget to register your myarray variable so you can use it.

Code:
aobscanmodule(MoveChar,P.exe,44 0F 29 AB A0 01 00 00 44) // should be unique
alloc(newmem,$1000,"P.exe"+FEC8E2)
alloc(myarray,$64,"P.exe"+FFF8E2)

label(cheat)
label(myloop)
label(saveit)
label(endloop)
label(code)
label(return)

newmem:

cheat:
  cmp [rbx+00000018],(int)3653
  jne code
  cmp [rbx+00000160],(int)2174
  jne code
  push rax
  push rcx
  xor rcx,rcx
  mov rax,myarray
myloop:
  cmp [rax+rcx*8],0
  je saveit
  inc rcx
  cmp rcx,8
  jge endloop
  jmp myloop
saveit:
  mov [rax+rcx*8],rbx
endloop:
  pop rcx
  pop rax

code:
  movaps [rbx+000001A0],xmm13
  jmp return

MoveChar:
  jmp cheat
  nop
  nop
  nop
return:
registersymbol(MoveChar)
registersymbol(myarray)
Back to top
View user's profile Send private message
nero1232
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2017
Posts: 65

PostPosted: Sun Mar 12, 2017 12:54 pm    Post subject: Reply with quote

Zanzer wrote:
If the value you want is stored in EBX, then you can't use EBX in your other code. Otherwise, you just overwrote it.
Essentially, your code is setting EBX to your array then storing the address of the array within the array.

But yes, since it's 64-bit, you need to use RBX, not EBX.
That also means address are 8 bytes, so multiply the index by 8 and increase the array size to 64.

Also, you need to restore all register values that the game's later code is expecting to use. push/pop

Don't forget to register your myarray variable so you can use it.

Code:
aobscanmodule(MoveChar,P.exe,44 0F 29 AB A0 01 00 00 44) // should be unique
alloc(newmem,$1000,"P.exe"+FEC8E2)
alloc(myarray,$64,"P.exe"+FFF8E2)

label(cheat)
label(myloop)
label(saveit)
label(endloop)
label(code)
label(return)

newmem:

cheat:
  cmp [rbx+00000018],(int)3653
  jne code
  cmp [rbx+00000160],(int)2174
  jne code
  push rax
  push rcx
  xor rcx,rcx
  mov rax,myarray
myloop:
  cmp [rax+rcx*8],0
  je saveit
  inc rcx
  cmp rcx,8
  jge endloop
  jmp myloop
saveit:
  mov [rax+rcx*8],rbx
endloop:
  pop rcx
  pop rax

code:
  movaps [rbx+000001A0],xmm13
  jmp return

MoveChar:
  jmp cheat
  nop
  nop
  nop
return:
registersymbol(MoveChar)
registersymbol(myarray)



Working great at the start now but I have a new problem.

The first 8 addresses fill up with each address which is perfect. However when I die or a bot dies then they get a new base address (the 8 places in the array are filled with mine and each bots base address).

So when I die or a bot dies I need to replace the old address in the array with the new one.

What would be the best way to do this? The instruction is not called in order, whenever a bot moves the instruction is hit so the bots can hit the instruction in any order.
Back to top
View user's profile Send private message
pellik
Advanced Cheater
Reputation: 0

Joined: 14 Jun 2013
Posts: 93

PostPosted: Sun Mar 12, 2017 9:04 pm    Post subject: Reply with quote

What happens to the location info in the structure you are pulling from when the bot dies?

Maybe you can remove elements from the code that reads those.
Back to top
View user's profile Send private message
nero1232
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2017
Posts: 65

PostPosted: Mon Mar 13, 2017 10:48 am    Post subject: Reply with quote

pellik wrote:
What happens to the location info in the structure you are pulling from when the bot dies?

Maybe you can remove elements from the code that reads those.


I decided in the end that once all 8 locations are filled I set them all to 0 and then read them in again, may not be efficient but it works for what I need.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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