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 


Trouble with AA arrays in assembly

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

Joined: 27 Feb 2023
Posts: 59

PostPosted: Sun Apr 16, 2023 8:20 pm    Post subject: Trouble with AA arrays in assembly Reply with quote

Hey guys,

I don't seem to be able to get arrays working in AA assembly, i keep getting this error | Error in line 17 (cmp [eax+ecx*8, 0) :This instruction can't
be compiled

alloc(newmem,2048,"myGame.exe"+1687A8)
label(returnhere)
label(originalcode)
label(exit)

// Define variables to store the values
alloc(itemBaseArray, 40) // Allocate space for 10 itemBase values (each value takes up 8 bytes)

newmem:
// Save the value from R13+88 into R10
mov r10,[r13+00000088]

// Loop through the itemBaseArray to find an empty slot
mov eax, itemBaseArray
xor ecx, ecx
begin:
cmp [eax+ecx*8], 0
je save_itemBase
inc ecx
cmp ecx, 10
jl begin
jmp originalcode

// Store the itemBase value in the itemBaseArray
save_itemBase:
mov [eax+ecx*8], r10

// Store the remaining values for this item
mov r11, [r10+0x4]
mov [eax+ecx*8+4], r11

mov r11, [r10+0x8]
mov [eax+ecx*8+8], r11

mov r11, [r10+0x10]
mov [eax+ecx*8+12], r11

mov r11, [r11+0x20]
mov [eax+ecx*8+16], r11

// Jump back to the original code
jmp originalcode

originalcode:
// Continue with the original code
mov r10,[r13+00000088]

exit:
jmp returnhere

"myGame.exe"+1687A8:
jmp newmem
nop 2
returnhere:
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sun Apr 16, 2023 9:00 pm    Post subject: Reply with quote

Use rax/rcx, not eax/ecx

Compare against an 8-byte value (use `qword ptr[...]`)

`cmp ecx, 10`- that's 0x10, or 16.

`mov [eax+ecx*8+4], r11` - r11 is an 8-byte register. Should be +8.

`mov [eax+ecx*8+12], r11` - again, 0x12, or 18

`mov [eax+ecx*8+whatever], r11` - these will access an out-of-bounds value.


Maybe try ccode instead. An example of a similar scenario:
https://forum.cheatengine.org/viewtopic.php?p=5777730#5777730

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
wulfcare
Advanced Cheater
Reputation: 0

Joined: 27 Feb 2023
Posts: 59

PostPosted: Sun Apr 16, 2023 9:03 pm    Post subject: Reply with quote

ty penguin, thats perfect
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