This UDF solves the problem. It provide a lot of binary related functions. Furthermore, most functions in the UDF are optimized by machine code, so the speed is incredible.
Here is the function list:
_BinaryAnd($Binary1, $Binary2) _BinaryOR($Binary1, $Binary2) _BinaryXOR($Binary1, $Binary2) _BinaryNot($Binary) _BinaryShift($Binary, $Shift) _BinaryRotate($Binary, $Shift) _BinaryReverse($Binary) _BinaryInBin($Binary, $Search, $Occur = 1, $Start = 1) _BinaryReplace($Binary, $Search, $Replace, $Occur = 0) _BinarySplit($Binary, $Search) _BinaryRight($Binary, $Count) _BinaryLeft($Binary, $Count) _BinaryTrimLeft($Binary, $Count) _BinaryTrimRight($Binary, $Count)
The usage of these functions are just like the built-in StringXXXX or BitXXXX functions.
Attentions:
BinarySplit has a little bit different, it don't support flag parameter in StringSplit.
BinaryInBin and BinaryReplace also don't need casesense parameter.
_BinaryPeek($Binary, $Start, $Type = "byte") _BinaryPoke($Binary, $Start, $Value, $Type = "byte") _BinaryToInt32($Binary) _BinaryFromInt32($Value) _BinaryToInt64($Binary) _BinaryFromInt64($Value) _BinaryRandom($Length, $Start = 0, $To = 255)
These functions are some helper function.
BinaryPeek and BinaryPoke work like stardand BASIC keyword peek and poke. They can handle types defined in DllStructCreate and DllCall (include str and wstr). The $Start are also like other AutoIt functions, count from 1, not from 0.
BinaryRandom generate a random binary data for test or something. It has built-in Mersenne Twister PRNG.
BinaryToXXX and BinaryFromXXX convert variable type between binary and int32/int64.
_BitShift64($Value, $Shift) _BitRotate64($Value, $Shift) _BitNOT64($Value) _BitOR64($Value1, $Value2, [$Value3, ...]) _BitAND64($Value1, $Value2, [$Value3, ...]) _BitXOR64($Value1, $Value2, [$Value3, ...]) _Hex64($Value, $Length = 16) _Dec64($HexString)
These functions are just the same as built-in functin in the same name, but these can handle 64 bit signed integer.
(Built-in function only for 32 bit integer)
Binary UDF.zip 6.86K
253 downloads2011/09/15 Update Note:
- Add following functions:
- _BinaryRandom can specify the random seed now. $Seed = 0 mean no seed is specified.
_BinaryRandom($Length, $Start = 0, $To = 255, $Seed = 0) - Use static variable to store the binary code to avoid repeat memory allocation.
Binary UDF.zip 7.19K
801 downloads
Edited by Ward, 15 September 2011 - 06:35 AM.





