Searches a buffer for an item.
BinaryIndexBin( handle, offset, item, direction, match-case )
(i) handle: handle of buffer.
(i) offset: zero-based offset in the buffer to begin search.
(s/i) item: specifies the item to be searched for. It may be either a hex string indicating the bytes to search for (two hex characters per byte), or the handle of a binary buffer containing the bytes to search for. If "item" is a blank string or an empty binary buffer, "offset" will be returned.
(i) direction: the search direction. @FWDSCAN searches forwards, while @BACKSCAN searches backwards.
(i) match-case: specify 1 for a case-sensitive search, or 0 for a case-insensitive search.
(i) offset: offset where the item was found, or -1 if not found.
This function is like BinaryIndexEx, but can search for strings containing NULL bytes.
Note: This function performs a linear search so it is affected by very large binary buffers available to 64-bit WinBatch.
; Search a (Unicode) .REG file for a string on Windows 2000/XP regfile = "C:\TEST.REG" lookfor = "00" fs1 = FileSize( regfile ) binbuf1 = BinaryAlloc( fs1 ) a1 = BinaryRead( binbuf1, regfile ) a = BinaryIndexBin( binbuf1, 0, lookfor, @FWDSCAN ,0);find HIMEM If a == -1 Message("Hmmm", StrCat("String not found in ", regfile," file")) Else c = BinaryStrCnt( binbuf1, 0, a, @CRLF) + 1 Message("Hmmm", StrCat(lookfor," found on line ",c)) EndIf
Binary Operations, BinaryCopy, BinaryIndex, BinaryIndexNc BinaryEodGet, BinaryEodSet, BinaryStrCnt, BinaryIndex