 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
wOxxOm
Joined: 09 Feb 2006 Posts: 320
|
Posted: Fri Nov 23, 2007 3:51 am Post subject: Binary string (buffer) searching regardless of NULL |
|
|
A built-in function of searching binary data buffer (haystack) for occurence of another binary sequence (needle) without stopping at \x00 (NULL) chars is a blessing and it would execute about 1000000 (million) times faster than current spoofing of zeroes with spaces, which is crucial for even 100k files. Especially if it's written using asm 'scasb' + subsequent 'repe cmpsd', cx=len>>2, and final 'repe cmpsb', cx=len&&3 (IMHO)
something like:
InBuf(haystackVar-or-addr, needleVar-or-addr, uint haystackSize, uint needleSize, [ StartingPos = 1 ])
also BufGetPos
p.s. I'm not great at asm but having just written this wish I thought that I can take some on-the-fly-asm-in-AHK examples from the forum and try to make the asm code myself  |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2739 Location: Australia, Qld
|
Posted: Fri Nov 23, 2007 5:25 am Post subject: Re: Binary string (buffer) searching regardless of NULL |
|
|
| wOxxOm wrote: | p.s. I'm not great at asm but having just written this wish I thought that I can take some on-the-fly-asm-in-AHK examples from the forum and try to make the asm code myself  | If you're referring to the "machine code functions", some of them are written in C++. "disasm" can be used to get the machine code of a function exported from a dll.
Have you posted a request in the machine code functions thread? |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Fri Nov 23, 2007 6:09 pm Post subject: |
|
|
| If the search pattern is short, a simple search loop programmed in C gives you fast code. This can be included in an AHK script as a machine code function. Otherwise you need complex code for high speed search, so you might be better off using an external dll. If you cannot find a suitable one, a simple approach gives you short code at reasonable speed: compute the checksum S of the search pattern of length L, and then scan the data, updating a running checksum of the current L words. If their checksum C = S, check if the current L words are equal to the search pattern, otherwise shift your attention one word to the right in the data, by adding the newly included word to C and subtracting the leaving word (to update C). You could use more complex checksums, or randomized ones, to avoid rare problems, where many false positives are found in the data (C = S with not matching patterns). |
|
| Back to top |
|
 |
wOxxOm
Joined: 09 Feb 2006 Posts: 320
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|