| View previous topic :: View next topic |
| Author |
Message |
cnork13 How do I cheat?
Reputation: 0
Joined: 24 Jan 2014 Posts: 1 Location: ger
|
Posted: Fri Jan 24, 2014 11:51 am Post subject: Searching good algorithm to scan Memory for strings. |
|
|
Hey there,
I recently wrote a memory scanner which scans a process memory for a certain string. But itīs still not as fast as I wish. I would like to get a similar smooth speed as CE itself. May You ppl here can suggest me some pseudocode with a better algorithm for my scans.
| Code: |
if (bytesReadSize > 0)
{
//loop through the bytes one by one to look for the values
for (int j = 0; j < memory.Length - arraysDifference; j++)
{
//if any value is equal to what we are looking for
if (memory[j] == sString[0])
{
//check char by char
for (int h = 1; h < sString.Length; h++)
{
if (memory[j + h] != sString[h])
{
break;
}
if (h == (searchedByteArrayLenght - 1))
{
Console.WriteLine(Convert.ToString(j + currentAdress, 16));
rmAdress = j + currentAdress;
}
}
}
}
}
|
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Jan 24, 2014 9:27 pm Post subject: |
|
|
Compare in chunks instead of byte by byte. Like 2 or 4 bytes at at a time. There's pretty much no reason to do single byte comparing.
_________________
- Retired. |
|
| Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Mon Jan 27, 2014 6:15 am Post subject: |
|
|
| Wiccaan wrote: | | Compare in chunks instead of byte by byte. Like 2 or 4 bytes at at a time. There's pretty much no reason to do single byte comparing. |
Reading in chunks certainly makes sense, but if you're going to support wildcards it can be a lot easier to compare bytes vs a bunch of convoluted logic and bit manipulation. I'd say that if it's still too slow maybe look into multithreading or SIMD. Or, alternatively, look to eliminate entire scan regions with logic.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Mon Jan 27, 2014 8:22 am Post subject: |
|
|
Perhaps the memory reading part of the code is just slow.
E.g. reading mapped memory, reading blocks smaller than 4KB , reading readonly memory while the string is writable, etc...
_________________
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 |
|
 |
|