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 


[Help] Fast method to scan through addresses

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Wed Nov 18, 2009 8:56 pm    Post subject: [Help] Fast method to scan through addresses Reply with quote

What I usually do is make a dll, and typecast and dereference addresses starting from the base address to the end region (7FFFFFFF). Each address I find, if the address is a BYTE and its value is my desired value, I return the address and put it on my .exe listbox.

Can you help me make a faster method to scan through the addresses?
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Nov 19, 2009 9:08 am    Post subject: Reply with quote

first off, don't put it into a listbox, way to slow (store it in a memory buffer or file on the disk and only display the parts visible based on the scrollposition)
Unless you intend on only getting a few results (e.g less than 100)

Quote:

if the address is a BYTE

All addresses are bytes, or do you mean if it's a readable byte?
If so, I recommend using VirtualQuery to get a list of readable memory addresses instead instead of relying on isbadreadptr or even worse, try/except

Of course, in case you do get an exception (e.g another thread freed a region) you can increase the readpointer to at least the next page (4kb) instead of going address+1 each time. Better yet, use virtualquery again to find the next readable region

_________________
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
View user's profile Send private message MSN Messenger
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Thu Nov 19, 2009 6:43 pm    Post subject: Reply with quote

Yes I mean if its a readable byte.

Also, I know that listbox is slow but I need a C++ itembox component to use, listview maybe? I read the cheat engine source and found that you used listview for listing your addresses.

Also, can you give me an example of how to use VirtualQuery to find the readable regions...

See what I usually do is:

Code:

DWORD ReadByte(BYTE Value)
{
DWORD FirstRegion = 0x00400000;
DWORD SecondRegion = 0x7FFFFFFF;

do
{
VirtualProtect((LPVOID) FirstRegion, 4, PAGE_EXECUTE_READWRITE);

DWORD Address = FirstRegion;
BYTE Found = *(BYTE*) Address;

if (Found == Value)
{
  listbox1->items->add(FirstRegion);
}

++FirstRegion;
} while (FirstRegion <= SecondRegion);
}
Back to top
View user's profile Send private message MSN Messenger
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Sat Nov 28, 2009 1:05 pm    Post subject: Reply with quote

Still waiting..
Back to top
View user's profile Send private message MSN Messenger
haha01haha01
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Jun 2007
Posts: 1233
Location: http://www.SaviourFagFails.com/

PostPosted: Sat Nov 28, 2009 2:19 pm    Post subject: Reply with quote

iPromise wrote:
Yes I mean if its a readable byte.

Also, I know that listbox is slow but I need a C++ itembox component to use, listview maybe? I read the cheat engine source and found that you used listview for listing your addresses.
It's not the control itself that is slow, it's the way you use it (adding all addresses into the list vs saving them on memory and only putting a little amount)

iPromise wrote:
Also, can you give me an example of how to use VirtualQuery to find the readable regions...

See what I usually do is:

Code:

DWORD ReadByte(BYTE Value)
{
DWORD FirstRegion = 0x00400000;
DWORD SecondRegion = 0x7FFFFFFF;

do
{
VirtualProtect((LPVOID) FirstRegion, 4, PAGE_EXECUTE_READWRITE);

DWORD Address = FirstRegion;
BYTE Found = *(BYTE*) Address;

if (Found == Value)
{
  listbox1->items->add(FirstRegion);
}

++FirstRegion;
} while (FirstRegion <= SecondRegion);
}
That's a very slow way. I believe the MSDN manual for VirtualQuery is not very hard to understand, as it only has 3 parameters.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Sat Nov 28, 2009 2:59 pm    Post subject: Reply with quote

Yes, but I dont get the API and how it would help me scan through my addresses faster. Is it globally or locally hooked on GameGuard, too, because I heard it was hooked.
Back to top
View user's profile Send private message MSN Messenger
haha01haha01
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Jun 2007
Posts: 1233
Location: http://www.SaviourFagFails.com/

PostPosted: Sat Nov 28, 2009 3:03 pm    Post subject: Reply with quote

iPromise wrote:
Yes, but I dont get the API and how it would help me scan through my addresses faster. Is it globally or locally hooked on GameGuard, too, because I heard it was hooked.
because obviously querying all the memory to get a list of allocated addresses is faster than going on every address, one by one, and using VirtualProtect on each one of them.

No idea about the hooking thing, though.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Sat Nov 28, 2009 3:06 pm    Post subject: Reply with quote

Can you show me an example code to find all the allocated addresses?
Back to top
View user's profile Send private message MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Nov 28, 2009 5:21 pm    Post subject: Reply with quote

Stop asking for source codes and start learning. Try and use that function and if you get stuck come back and ask, showing us your attempt.
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Sun Nov 29, 2009 9:17 am    Post subject: Reply with quote

Okay, this is what i'm guessing, but I dont see how it would fasten it up.

Code:

DWORD Address = 0x00400000;
DWORD Limit = 0x7FFFFFFF;
do
{
MEMORY_BASIC_INFORMATION MBI;
VirtualQueryEx(hProcess, Address, &MBI, sizeof(MEMORY_BASIC_INFORMATION));
++Address;


} while (Address <= Limit);
Back to top
View user's profile Send private message MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Nov 29, 2009 9:33 am    Post subject: Reply with quote

iPromise wrote:
Okay, this is what i'm guessing, but I dont see how it would fasten it up.

Code:

DWORD Address = 0x00400000;
DWORD Limit = 0x7FFFFFFF;
do
{
MEMORY_BASIC_INFORMATION MBI;
VirtualQueryEx(hProcess, Address, &MBI, sizeof(MEMORY_BASIC_INFORMATION));
++Address;


} while (Address <= Limit);

Where in that code are you checking the mbi structure for the memory protections associated with a particular region ? Also since VirtualQueryEx returns information about an area of memory you can read off the base address and the size of that piece of memory and in the next call to VirtualQueryEx you can skip all those addresses in-between
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Mon Nov 30, 2009 6:23 pm    Post subject: Reply with quote

Thats the thing I dont know, what should I check and how would I find all the allocated addresses?
Back to top
View user's profile Send private message MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Nov 30, 2009 6:28 pm    Post subject: Reply with quote

By checking the MEMORY_BASIC_INFORMATION structure. Look at its members. All 3 of the things I mentioned are stored within that structure
Back to top
View user's profile Send private message
Bswap
Newbie cheater
Reputation: 0

Joined: 18 Aug 2009
Posts: 21

PostPosted: Tue Dec 01, 2009 1:39 am    Post subject: re: Reply with quote

Back to top
View user's profile Send private message
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