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 


[Question]Memory Scanning.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Jan 11, 2008 10:47 pm    Post subject: [Question]Memory Scanning. Reply with quote

Hi, I can scan really really really slow. (00010000 addresses is slower than CE's scan of 00400000 to 80000000)
I tried empty loops, such as
for (int i = 0; i < 10000; i++)
{

}

while (i < 10000)
{
i++;
}

Also slow... untill it reachs 10000 without reading memory at all, cheat engine can scan all the memory... is it because its .NET? (Its in C#)

I just tested:
Code:
var i: Integer;
s: TStringList;
begin
s := TStringList.Create;

for i := 0 to $00400000 do
s.Add(IntToStr(i));
ShowMessage('Ready to add the items?'); //To stop the application before it add the items
ListBox1.Items := s;


Code:
            List<string> List = new List<string>();
            for (int i = 0; i < 0x00400000; i++)
            {
                List.Add(i.ToString());
            }
            MessageBox.Show("Ready?"); //To stop the application before it add the items
            foreach (string s in List)
            MemoryView.Items.Add(List);


Pretty much the same... Shocked I'm pretty sure any other way will be the same speed as those.

Also checked out memscan.pas of ce's source, don't really understand much, but looks the same, a loop that reads memory...
so if I can't even finish half of the loop before ce's done scanning, how can I do it?
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Sat Jan 12, 2008 7:10 am    Post subject: Reply with quote

I quite sure that CE show doesn't load FFFFFFFF addresses in the same time.
It only shows the adresses that you look in the Memory browser (about 16 adresses).
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sat Jan 12, 2008 8:28 am    Post subject: Reply with quote

I didn't mean the memory view, I also thought thats what it does in the memory view, but I decided to make a scanner first.
My question is how does CE scan so fast?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25948
Location: The netherlands

PostPosted: Sat Jan 12, 2008 9:18 am    Post subject: Reply with quote

1:
Ce first gets the available memory regions that there are. so doesn't even bother reading memory that doesn't exist)


2:
make sure you don't call windows API's in your scanning loops

if you need to read 2 addresses that are within a 4096 byte range, do a readprocessmemory call on the whole block of 4096 bytes and then just check those 2 addresses in there. (it's a lot faster than calling readprocessmemory twice)

And in your example of "List.Add(i.ToString()); ":
for one, that's going to eat up a lot of ram, and will have a lot of memory relocations happening. (sure it has a small buffer to handle it, but I don't think it's big enough for 0x40000 items, so has to reallocate a new buffer each time. More api calls)

also:
Code:

while (i < 10000)
{
i++;
}

is certainly not slow, it finishes within a second. But if you add in a api call in that loop, it'll go slow yes

ce's scanloop: (first scan, exact value)
http://ce.colddot.nl/browser/Cheat%20Engine/memscan.pas#L1390

3:
If ce detects you have multiple cpu cores, it divides the workload between the cores

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sat Jan 12, 2008 11:47 am    Post subject: Reply with quote

Thanks, it scans much faster, only one problem is adding the items to the list... CE adds like 100,000 items in a second and mine adds 10,000 slower... Rolling Eyes
Anyway, how can I check if the memory exists? because ce shows ?? for empty memory but when I use readprocessmemory it shows 0... or maybe its null converted to 0?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25948
Location: The netherlands

PostPosted: Sat Jan 12, 2008 12:23 pm    Post subject: Reply with quote

ce doesn't really add them to the list. It only adds them to a file.

The listbox gets filled with information regarding the records visible. (thats why you may see the harddisk led turn on when dragging the results of the foundlist around, since each time the scroller moves the addresses are read from disk and values updated)

Virtualqueryex can be used to do that.
Also, in the memory browser ce doesn't read the memory for each single byte, it read it in blocks of 4096 bytes, and if a block isn't readable (e.g rpm returns false or bytesread=0) it puts a ?? instead of a value

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming 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