![]() |
[C++] C++11 Signature Scanning
One of the more modern methods of approaching an application for modifications and relocation of specific functions, data, pointers, etc. is through signature scanning. Rather then using raw offsets or addresses, signature scanning allows you to locate data through known instructions of a function that make use of that data. I wont get into the specifics of signature scanning in this topic though for those that do not understand it.
Read this full tutorial on my personal site here: Code:
http://atom0s.com/forums/viewtopic.php?f=5&t=4PHP Code:
PHP Code:
|
Hi,
What I don't get is how your (linear) search (that uses all kinds of libraries) is faster than the linear search you say is slower at your website: Code:
bool Compare(const BYTE* pData, const BYTE* bMask, const char* szMask)Greetings EDIT: Here is a combined version of our efforts to make pattern finding easier: https://gist.github.com/mrexodia/f058868b81b2f1cb011a |
Here is a benchmark of mine vs the original typical FindPattern you posted:
Code:
FindPattern Benchmark Example- Initialize - Release - RunTest Initialize is used to simply handle the basic stuff that the test may need to prepare itself for the test to be ran. Things that are not specific to the scanning directly. Such as any object creation and so on. Release is to allow the test to cleanup anything it created etc. RunTest is to allow the test to do its work to scan for all the signature in the given test data. About The Tests The test data is the Final Fantasy XI's main game file 'FFXiMain.dll'. I load the unpacked file into memory as the raw bytes, I do not actually load the game in any manner, so these are static scans from the files raw data. Each test is given a total of 26 signatures to scan for within the same memory data. So the benchmark is entirely fair in terms of what to look for and what it is looking within. I created the C++11 / async method I use solely for this game and decided to share it since others may find it useful for faster and threaded scans. In an application where you only need to scan for a few signatures and do not need threading, then yeah mine may not be the best bet however, so far it has performed the best for me outside of some other methods I discussed on my personal site that a friend of mine (devnull) and I came up with. There is definitely room for improvement and speed increases, this is just the fastest and cleanest method that devnull and I came up with so far that was easy to read and maintain while keeping speed and performance. |
Quote:
is more about hardware and btw scanning speed won't be noticeable when the difference is measured only in millisecond plus another thing is about compiler optimization which affects most on the speed(after hardware of course) |
Quote:
|
I think both your implementations are still not perfect. Think about this: https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm
or at least https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm This algorithm is even more efficient for byte search. Skip as many bytes as possible... |
Quote:
Implementing Boyer Moore will definitely be a bit faster though. :) Comparing my FindPattern to the original posted above, mine sees a lot of improvement when the data being scanned within is large and the number of scans being done is high. For low amounts of scanning and where async is not required, then the original will tend to outperform mine. Overall it really depends on some specific factors: - The data size being scanned within. - The number of patterns being looked for. - Threading; is it required or not, (along with thread-safety). - Hardware can land up playing a roll as well etc. Another implementation that could make use of different hardware would be a GPU implementation, which could also have a handful of speed benefits depending on similar factors above. |
Quote:
BMH was second place when I checked (57ms): Code:
FindPattern benchmark |
Ah interesting, I'll take their examples and add it to my tester and see what I get out of them. I can post the results here later on too.
As for the portability / 64bit questions and comments, here is mine that should work on both now: PHP Code:
Code:
http://www.tutorialspoint.com/compile_cpp11_online.php |
Updated benchmark with atom0s' pattern finder, my pattern finder (which has nibble support, so not really a fair comparison) and atom0s' pattern finder updated with nibble support:
https://github.com/mrexodia/findpattern-bench Code:
FindPattern benchmark |
hmm probably no one need it anyway i'm have modified the algorithm by patrick and dom1n1k in my old project for x64 compatibility here it is:
Quote:
|
@DMichael: I recommend using a different algorithm, this one is the second-worst in time :D Thanks anyway.
|
Quote:
|
If anyone need a real example of signature search, I can recommend ClamAV source.
|
Quote:
|
| All times are GMT +8. The time now is 21:47. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX