 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
neofsn Newbie cheater
Reputation: 0
Joined: 19 Mar 2022 Posts: 10
|
Posted: Sun Mar 20, 2022 8:01 am Post subject: Add counter of addresses stored |
|
|
Hello, I am trying to add a counter so I can track the number of addresses in my storage and perform a reset so I can prevent overflows also to remove dead addresses.
This is what I am trying but with no luck.
Code: | alloc(counter,4)
addAddress:
mov [ebx],edx //copy address
inc [counter] //increment counter + 1??? not sure
cmp [counter],10 //if we copied 10 address then reset
jae refresh
ret
refresh:
mov [ebx],00000000 //rewrites the storage to basically empty? not sure
mov [counter],0 //rewrites the counter to zero? not sure
ret |
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25785 Location: The netherlands
|
Posted: Sun Mar 20, 2022 9:31 am Post subject: |
|
|
Keep in mind that this is not thread safe:
Code: |
alloc(addAddress,128)
alloc(counter,4)
alloc(list,1024) //so 1024/4=256 entries
registersymbol(addAddress)
registersymbol(counter)
registersymbol(list)
addAddress:
//edx contains the address
push edi
push ecx
push eax
//check if the address is already in the list
mov edi,list
mov ecx,[counter]
add ecx,1
mov eax,edx
repne scasd //run until [edi] contains the value of eax (address to add)) or ecx=0
cmp rcx,0
jne short alreadyinlist
mov edi,list
mov ecx,[counter]
add ecx,1
mov eax,0
repne scasd //run until [edi] contains the value of eax(0) or ecx=0
cmp rcx,0
je short notfound
//found an empty spot
sub edi,4
mov [edi],edx
pop eax
pop ecx
pop edi
ret
notfound:
//add to the list if possible
cmp [counter],#256
jae short listfull
mov edi,[counter]
mov [list+edi*4],edx
inc [counter]
listfull:
alreadyinlist:
pop eax
pop ecx
pop edi
ret
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25785 Location: The netherlands
|
Posted: Sun Mar 20, 2022 9:38 am Post subject: |
|
|
alternatively:
Code: |
alloc(addAddress,128)
alloc(counter,4)
alloc(list,1024) //so 1024/4=256 entries
registersymbol(addAddress)
registersymbol(counter)
registersymbol(list)
addAddress:
//edx contains the address
{$ccode address=edx}
int i;
extern unsigned int list[256];
extern int counter;
//check if address is in the list
for (i=0; i<counter; i++)
if (list[i]==address) return; //normally return is not recommended as changes to address are undone, but that's a non-issue here
//not a duplicate, scan for an empty spot
for (i=0; i<counter; i++)
if (list[i]==0)
{
list[i]=address;
return;
}
//still here so no free spot
if (counter<=255)
{
list[counter]=address;
counter++;
}
{$asm}
ret
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
neofsn Newbie cheater
Reputation: 0
Joined: 19 Mar 2022 Posts: 10
|
Posted: Sun Mar 20, 2022 11:11 am Post subject: |
|
|
Thanks dark byte, got it all working now.
|
|
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
|
|