AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Binary string (buffer) searching regardless of NULL

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
wOxxOm



Joined: 09 Feb 2006
Posts: 320

PostPosted: Fri Nov 23, 2007 3:51 am    Post subject: Binary string (buffer) searching regardless of NULL Reply with quote

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 Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Fri Nov 23, 2007 5:25 am    Post subject: Re: Binary string (buffer) searching regardless of NULL Reply with quote

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 Smile
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
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Fri Nov 23, 2007 6:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
wOxxOm



Joined: 09 Feb 2006
Posts: 320

PostPosted: Sat Nov 24, 2007 1:19 pm    Post subject: Reply with quote

I've coded it in asm, it turned out to be easier than I though initially - Machine code binary buffer searching regardless of NULL
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group