| View previous topic :: View next topic |
| Author |
Message |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri Jan 11, 2008 10:47 pm Post subject: [Question]Memory Scanning. |
|
|
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... 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 |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Sat Jan 12, 2008 7:10 am Post subject: |
|
|
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 |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jan 12, 2008 8:28 am Post subject: |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25948 Location: The netherlands
|
Posted: Sat Jan 12, 2008 9:18 am Post subject: |
|
|
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 |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jan 12, 2008 11:47 am Post subject: |
|
|
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...
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 |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25948 Location: The netherlands
|
Posted: Sat Jan 12, 2008 12:23 pm Post subject: |
|
|
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 |
|
 |
|