View previous topic :: View next topic |
Author |
Message |
Whiskeyjack How do I cheat?
Reputation: 0
Joined: 25 Jul 2010 Posts: 3
|
Posted: Sun Jul 25, 2010 11:06 pm Post subject: [C++] Creating similar scanner as CheatEngine |
|
|
Hello. I have a question as to how exactly does CheatEngine's scanner work.
Currently, my code works but it's far to slow for my tastes.
The code is basicly as follows:
Code: |
DWORD HACK_LOCATION_START = 0x1400000;
LPVOID HACK_BYTE_PATTERN = (LPVOID) 0x4D3B4A75;
LPVOID CURRENT_VALUE;
bool FOUND = false;
while(CURRENT_VALUE != HACK_BYTE_PATTERN && HACK_LOCATION_START < 0x1600000)
{
HACK_LOCATION_START++;
ReadProcessMemory(hHandle, (const void*)HACK_LOCATION_START, &CURRENT_VALUE, 4, NULL);
if (CURRENT_VALUE == HACK_BYTE_PATTERN) {
//When address is found
FOUND = true;
}
}
|
However I would like to speed it up because it's quite slow. How exactly is CheatEngine's scanner so fast? Also same with ollydbg, as in ollydbg it seems to find a hexpattern nearly instantly.
Responces would be really appreciated ^^
I was thinking that CE probbably splits up scan in two or more parts and multithreads it.
Or it copies the memory into its own process and scans it locally instead of having to ReadProcessMemory() every single time.
But I don't know. any help would be appreciated, thanks =)
|
|
Back to top |
|
 |
SwaggaJackin' Master Cheater
Reputation: 2
Joined: 06 Nov 2009 Posts: 304
|
Posted: Sun Jul 25, 2010 11:47 pm Post subject: |
|
|
You could save chunks of the game's memory into blocks and save them to temporary files and depending on the settings and have a thread scan the file or multiple threads. For example.
Assuming you saved the memory into 4MB chunks:
Thread 1 scanning mem.01
Thread 2 scanning mem.02
Thread 1 finished scanning mem.01
Thread 2 finished scanning mem.02
Thread 1 scanning mem.03
Thread 2 scanning mem.04
etc...
etc...
You could have a setting to set more threads or use only 1. I'm not sure how cheat engine does it, I don't really know Pascal and just never checked it out I guess. I'm not sure if one large file or several large files would be more efficient, that's something you may need to test.
Just an idea, I'm sure there are better ways.
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Mon Jul 26, 2010 12:16 am Post subject: |
|
|
i've seen this post alot. Instead of RPMing everytime in the loop. RPM a chunk of like 4000 and then loop through the chunk. This way you cut down on your RPM calls (which take alot of time when called that much).
This topic is ALL over Gen prog
_________________
|
|
Back to top |
|
 |
Whiskeyjack How do I cheat?
Reputation: 0
Joined: 25 Jul 2010 Posts: 3
|
Posted: Mon Jul 26, 2010 12:22 am Post subject: |
|
|
HomerSexual wrote: | i've seen this post alot. Instead of RPMing everytime in the loop. RPM a chunk of like 4000 and then loop through the chunk. This way you cut down on your RPM calls (which take alot of time when called that much).
This topic is ALL over Gen prog |
I've been looking around here and there and stuff yet I could not find any exact source code, or example code, that could replicate it.
Could you further explain how I would do this in coding or better yet, an example code?
thanks
|
|
Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon Jul 26, 2010 3:10 pm Post subject: |
|
|
Also you should use VirtuaQueryEx to get which page is readable so u won't have to read all of the addresses
_________________
Stylo |
|
Back to top |
|
 |
Whiskeyjack How do I cheat?
Reputation: 0
Joined: 25 Jul 2010 Posts: 3
|
Posted: Mon Jul 26, 2010 5:28 pm Post subject: |
|
|
Stylo wrote: | Also you should use VirtuaQueryEx to get which page is readable so u won't have to read all of the addresses |
The entire area is read and write from what I've seen.
The thing is that this game updates quite often and the addresses move around. it's always within that set of addressess however. Instead of having to rescan and find the exact position with cheatengine or ollydbg, i'd rather it do that automatically in the trainer itself (hence wanting to make it scan similiarly to CE)
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Jul 27, 2010 3:55 pm Post subject: |
|
|
Whiskeyjack wrote: | Stylo wrote: | Also you should use VirtuaQueryEx to get which page is readable so u won't have to read all of the addresses |
The entire area is read and write from what I've seen.
The thing is that this game updates quite often and the addresses move around. it's always within that set of addressess however. Instead of having to rescan and find the exact position with cheatengine or ollydbg, i'd rather it do that automatically in the trainer itself (hence wanting to make it scan similiarly to CE) |
Assuming wont work on all applications if you plan to reuse the code later on. It's better to code for the overall purpose instead of a specific application in mind.
You can use VirtualQueryEx to obtain the information of the pages and their sizes which you can use to dump the memory per-page rather then per-loop. Then you can go through the dumped memory and look for your pattern.
_________________
- Retired. |
|
Back to top |
|
 |
|