 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
agpcheatengine Newbie cheater
Reputation: 0
Joined: 07 Nov 2018 Posts: 13
|
Posted: Wed Dec 23, 2020 1:01 pm Post subject: Error writing data to unique array. |
|
|
| 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 |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4725
|
Posted: Wed Dec 23, 2020 7:05 pm Post subject: |
|
|
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 |
|
 |
Csimbi I post too much
Reputation: 98
Joined: 14 Jul 2007 Posts: 3344
|
Posted: Thu Dec 24, 2020 4:58 am Post subject: |
|
|
| Also it seems flags are not saved as DWORD either.
|
|
| Back to top |
|
 |
agpcheatengine Newbie cheater
Reputation: 0
Joined: 07 Nov 2018 Posts: 13
|
Posted: Thu Dec 24, 2020 6:37 am Post subject: |
|
|
| 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 |
|
 |
|
|
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
|
|