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 


Faster RPM array of bytes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ShurikeN
Advanced Cheater
Reputation: 0

Joined: 09 Jan 2008
Posts: 84

PostPosted: Mon May 19, 2008 7:24 am    Post subject: Faster RPM array of bytes Reply with quote

im using this code to scan array of bytes but the problem is it's taking hours to complete scan which is very annoying!!
Code:

BYTE byArray[] = { 0x68, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0xA1, 0x00, 0x00, 0x00, 0xA2, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00 };
BYTE byBuffer[ sizeof(byArray) ];

int currentAddress = 0x01000000;
int endAddress = 0x0F000000;

do{
   ReadProcessMemory( hProcess, (void*)currentAddress, (void*)byBuffer, sizeof( byBuffer ), 0 );
   if( memcmp( byBuffer, byArray, sizeof( byArray )) == 0 )
      {
          //found
      }
  ++currentAddress;
}while( currentAddress != endAddress );



how do i make the scanning faster? like CE does.

_________________
Code:
XXXXXX      XXXXXX
   XXXXX  XXXXX
     XXXXXXXX
    D I R E C T
     XXXXXXXX
   XXXXX  XXXXX
XXXXXX      XXXXXX
      GameDev
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

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

PostPosted: Mon May 19, 2008 7:33 am    Post subject: Reply with quote

read as much as possible with readprocessmemory at a time and then scan the buffer you get
Do not call readprocessmemory repeatedly with a small buffer. It'll be really slow.

e.g.
read a big block and then
Code:

for (i=0; i<totalmemoryread-sizeof(mybuffer); i++)
   if( memcmp( &byBuffer[i], byArray, sizeof( byArray )) == 0 )
      {
          //found
      }


virtualqueryex helps finding out the size of that block

_________________
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
ShurikeN
Advanced Cheater
Reputation: 0

Joined: 09 Jan 2008
Posts: 84

PostPosted: Mon May 19, 2008 8:04 am    Post subject: Reply with quote

ok i get it, but how do i get the address after finding the array inside the buffer??

Code:

int address;
for (i=0; i<totalmemoryread-sizeof(mybuffer); i++)
   if( memcmp( &byBuffer[i], byArray, sizeof( byArray )) == 0 )
      {
          address = ????    // address of the array found.
      }

sorry for being so noob. Embarassed

_________________
Code:
XXXXXX      XXXXXX
   XXXXX  XXXXX
     XXXXXXXX
    D I R E C T
     XXXXXXXX
   XXXXX  XXXXX
XXXXXX      XXXXXX
      GameDev
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon May 19, 2008 8:09 am    Post subject: Reply with quote

Code:
address = i;
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon May 19, 2008 8:19 am    Post subject: Reply with quote

rEakW0n wrote:
Code:
address = i;


No, i is just the current value in the for loop where the address was found. More or less so, an offset in the block of memory.

Code:
address = StartAddress + i;

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
ShurikeN
Advanced Cheater
Reputation: 0

Joined: 09 Jan 2008
Posts: 84

PostPosted: Mon May 19, 2008 7:19 pm    Post subject: Reply with quote

i tried using VirtualQueryEx but i really can't get it work, so i tried experimenting other ways. is this ok???
Code:

BYTE* byBuffer[4096];
startAddress = 0x00400000;
endAddress = 0x7FFFFFFF;
for( int size = startAddress; size < endAddress; size += 4096 )
    {
         if( ReadProcessMemory( hProcess, (void*)startAddress, (void*)byBuffer, 4096, 0 ) == 0 )
              {
                    startAddress += 4096;
               }
         else
              {
                   for( int z = 0; z < 4096; ++z )
                        {
                            if( memcmp( &byBuffer[z], byArray, sizeof( byArray )) == 0 )
                                {
                                      //found
                                }
                        }
                   startAddress += 4096;
               }
    }


if you can show me how VirtualQueryEx is properly used pls do Embarassed

_________________
Code:
XXXXXX      XXXXXX
   XXXXX  XXXXX
     XXXXXXXX
    D I R E C T
     XXXXXXXX
   XXXXX  XXXXX
XXXXXX      XXXXXX
      GameDev
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