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 


Is this faster ?

 
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: Tue Jun 29, 2010 3:32 pm    Post subject: Is this faster ? Reply with quote

Copying all of the memory regions bytes, and comparing ?

Code:

if ( MBI.Protect == PAGE_READWRITE )
{
   BYTE *Buffer;

   Buffer = new BYTE[ MBI.RegionSize ];

   memcpy( (void *) Buffer, MBI.BaseAddress, MBI.RegionSize );

   for (int i = 0; i <= (int) MBI.RegionSize; i ++)
   {
        if ( Buffer[i] == 1 ) // Example scan for 1 byte
        {
            File << (LPVOID) ( (DWORD) MBI.BaseAddress + (DWORD) i ) << endl;
        }
   }
}


Thanks for your help guys.


Last edited by iPromise on Tue Jun 29, 2010 4:11 pm; edited 1 time in total
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: Tue Jun 29, 2010 3:44 pm    Post subject: Reply with quote

for the millionth time, yes. also for the millionth time, when doing the scan, don't do something which does a disk access or makes an item in a listview.. what i would do is to make a custom windows message and in the case when there is a match, do a postmessage with the address with your custom windows message. then in the handler for that you can do your disk writes or whatever. then the heavy lifting is done by the main thread and not by the scanning thread. hence your scanning will become a concurrent action along with the disk writes.

also lolwat at your code
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Tue Jun 29, 2010 4:11 pm    Post subject: Reply with quote

i coded that on the spot, and thanks. I actually got it now and its freaking fast on 0 scans O_O
Back to top
View user's profile Send private message MSN Messenger
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Tue Jun 29, 2010 4:41 pm    Post subject: Reply with quote

How is that faster?
Code:

char Memory = 5;
char Buffer[1];
memcpy(Buffer, Memory, 1)
if( Buffer[0] == 5 ) herp();
else derp();
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Jun 29, 2010 4:43 pm    Post subject: Reply with quote

That will only make it faster if you are reading memory in another process. If you're already in the process it will make it slower (and in your case, cause the program to crash because of the gigantic memory leak).

Store results in an STL container, and then do your work on the container when scanning is complete.
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Tue Jun 29, 2010 5:07 pm    Post subject: Reply with quote

@tombana

your only copying 1 char from the memory variable. i'm copying all the chars from the memory variable, and then comparing. even if it is slow, it still is faster then the original method of checking each address one by one.
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Jun 29, 2010 5:48 pm    Post subject: Reply with quote

iPromise wrote:
@tombana

your only copying 1 char from the memory variable. i'm copying all the chars from the memory variable, and then comparing. even if it is slow, it still is faster then the original method of checking each address one by one.


You clearly do not understand how pointers work.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Jun 30, 2010 1:36 am    Post subject: Reply with quote

you should have read my post here more carefully :
http://forum.cheatengine.org/viewtopic.php?p=4989592#4989592

also @ the last poster in that thread who is learning by rce'ing your code. looooolllll

what i meant to reply to this thread was :
'yes this is faster than mem_cpy'ing smaller chunks at a time but it's still retarded and pointless. as i did say previously though, this is fine, since it just keeps consistency with the rest of the project'
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