Jump to content
Sign in to follow this  

BinaryInBin (equivalent for StringInStr)

Recommended Posts


Is there a quick way of finding a binarystream (in memory) in another one.

* Doing a byte by byte comparison is real slow.

* Isn't there an equivalent for StringInStr like BinaryInBin

Something in Pseudocode like below (only much larger images)

Image A has size @desktopwidth, @desktopheight represented in binarystream x

Image B is smaller 10 * 10 represented in binarystream y

for i = 1 to maxline of b

;BinaryInBin($x,$y) // How to do this????

next i

Ofcourse something like below( pseudocode) could work but is slower than matching a full line at once

function BinaryInBin($a,$;)

for $i=0 to BinaryLen($:D-1


for $j = 0 to BinaryLen($a)-1

if binarymid($b,$i)<>binarymid($a,$j) then







Share this post

Link to post
Share on other sites

you could do this

$binary = ;your binary code
$string = string($binary)
$g = stringinstr($string, $whatever u want)
;then convert it back to binary
$rebinary = stringtobinary($string)

global $warming = true

Share this post

Link to post
Share on other sites


I actually thought that string would break on chr(0) obviously its not

$Bin = binary("Elwin" & CHR(0) & "Wildschut")
consolewrite( $bin)
consolewrite(binarylen($bin) & @crlf)

$str = binarytostring($bin)
consolewrite($str )
consolewrite(stringlen($str) & @crlf)

$iS=stringinstr($str, "Wildschut")
consolewrite("Found at " & $is & @crlf)

$bin = stringtobinary($str)
consolewrite( $bin)
consolewrite(binarylen($bin) & @crlf)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.