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 


Error writing data to unique array.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
agpcheatengine
Newbie cheater
Reputation: 0

Joined: 07 Nov 2018
Posts: 13

PostPosted: Wed Dec 23, 2020 1:01 pm    Post subject: Error writing data to unique array. Reply with quote

Code:

[ENABLE]
alloc(units,320)
registersymbol(units)
aobscanmodule(IArray,array.exe,E8 83 DE C5 00)
alloc(newmem,$1000)

label(code)
label(return)
label(loops)
label(func1)

newmem:
pushf
 mov ecx,[units]
 cmp ecx,0x9
 je code
loops:
 test ecx,ecx
 je func1
 cmp eax,[units+ecx*4]
 je code
 sub ecx,1
 jmp loops
func1:
 mov ecx,[units]
 add ecx,1
 mov [units],ecx
 mov [units+ecx*4],eax
code:
 popf
mov [esp+10],eax
  cmp eax,ebx
  jmp return

I want to create a unique array. I wrote the code above, but the program crashes constantly, I couldn't see an error in the code.There may be more than one thread trying to run code. What could be the cause of the error?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4725

PostPosted: Wed Dec 23, 2020 7:05 pm    Post subject: Reply with quote

You're modifying ecx and eax without backing up either.

Your code isn't thread safe whatsoever. If the injection point isn't that hot, you could probably ignore it and be fine; otherwise, the easiest thing you can do is put a spinlock around everything.
https://forum.cheatengine.org/viewtopic.php?p=5768089#5768089

_________________
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
Csimbi
I post too much
Reputation: 98

Joined: 14 Jul 2007
Posts: 3344

PostPosted: Thu Dec 24, 2020 4:58 am    Post subject: Reply with quote

Also it seems flags are not saved as DWORD either.
Back to top
View user's profile Send private message
agpcheatengine
Newbie cheater
Reputation: 0

Joined: 07 Nov 2018
Posts: 13

PostPosted: Thu Dec 24, 2020 6:37 am    Post subject: Reply with quote

ParkourPenguin wrote:
You're modifying ecx and eax without backing up either.

Your code isn't thread safe whatsoever. If the injection point isn't that hot, you could probably ignore it and be fine; otherwise, the easiest thing you can do is put a spinlock around everything.

When I spinlock the program freezes.But I got the problem. Another thread removes dead units in an array of units from the array.It seems like a crash is occurring due to the simultaneous access to units array.
Csimbi wrote:
Also it seems flags are not saved as DWORD either.


Code:
 pushfd
 pushad
code...
 popad
 popfd

Should I do the above addition?
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 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