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 


Problem with arrays and indexes in assembly

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

Joined: 03 Mar 2020
Posts: 7

PostPosted: Thu Jun 22, 2023 12:24 pm    Post subject: Problem with arrays and indexes in assembly Reply with quote

So, I have this code
Code:

[ENABLE]

aobscanmodule(GetPlayerInv,nvar.mfx,8B 42 44 5E 5D) // should be unique
alloc(newmem,$1000)

alloc(invPtr, 24)
registersymbol(invPtr)

alloc(indexPtr, 4)
registersymbol(indexPtr)

label(code)
label(return)
label(initIndex)
label(setAddressAtIndex)

indexPtr:
  db 6 0 0 0

newmem:
  cmp [indexPtr], 5
  jg initIndex
  jmp setAddressAtIndex

initIndex:
  cmp [edx+10], 'Inv1'
  jne code
  mov [indexPtr], 0
  jmp setAddressAtIndex

setAddressAtIndex:
//Crashes here
//mov [invPtr + indexPtr * 4], edx
  add [indexPtr], 1
  jmp code

code:
  mov eax,[edx+44]
  pop esi
  pop ebp
  jmp return

GetPlayerInv:
  jmp newmem
return:
registersymbol(GetPlayerInv)

[DISABLE]

GetPlayerInv:
  db 8B 42 44 5E 5D

unregistersymbol(GetPlayerInv)
dealloc(newmem)

dealloc(invPtr)
unregistersymbol(invPtr)

dealloc(indexPtr)
unregistersymbol(indexPtr)


But it crashes at the label "setAddressAtIndex".
What I want to do is put the address `edx` into the array `invPtr` at index `indexPtr`, can someone help me with that?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Thu Jun 22, 2023 5:41 pm    Post subject: Reply with quote

`mov [invPtr + indexPtr * 4], edx` - this instruction doesn't do what you think it does. `invPtr` and `indexPtr` are both addresses. Treating `invPtr` as an address is probably correct, but you almost certainly want the value at `indexPtr` instead of the address `indexPtr`.
Code:
mov ecx,[indexPtr]
mov [invPtr+ecx*4],edx


Also, this is `jmp` instruction does nothing:
Code:
  jmp setAddressAtIndex

setAddressAtIndex:

_________________
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
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