Binary Operations

 
File manipulation in fast RAM memory.

WIL contains a number of functions designed to allow direct access to areas - buffers - of computer memory. By managing and working with these buffers using the assorted Binary functions provided, you can implement a number of operations that otherwise would be tedious and time consuming. Using the Binary functions, you can perform edits on any sort of file, build new files, build data structures, and do high-speed editing of multiple files. If you understand the structure of a data file, you can perform fast look-ups of data with these functions.

The principal, required Binary functions are BinaryAlloc and BinaryFree. The BinaryAlloc function allows you to allocate a buffer of almost any size. You may have up to 128 separate buffers allocated at one time. When operations are complete with a particular buffer, the BinaryFree function is used to return it to the system.

There are BinaryRead and BinaryWrite functions to read files into allocated buffers, and to write the contents of buffers back to files. A BinaryCopy function can move sections of one buffer to another one, allowing buffers to be broken up and re-combined in different fashions.

A set of peek and poke functions, BinaryPeek, BinaryPeekStr, BinaryPoke, and BinaryPokeStr allow direct editing and modification of the buffers. These functions can initialize a buffer that can be passed to a third party Dll via the DllCall function.

A BinaryIndex function is available to assist in searching buffers for known data patterns. Some of these functions require you pass an offset parameter. Please note: The offset is a 'pointer' that represents some distance from the start of the binary buffer (which is zero). The BinaryStrCnt function can quickly scan a buffer and return the number of occurrences of particular data patterns. A couple of functions to get and set the End-of-Data point of each buffer (which is automatically tracked), BinaryEodGet and BinaryEodSet, and the average unreconstructed hacker has all the tools necessary to become a real hazard to the community at large.

Binary buffer size is limited by a process's available virtual memory. WIL scripts executed using 32-bit WinBatch or scripts compiled with the 32-bit WinBatch Compiler are limited to approximately 800 MB in size. However, WIL scripts executed using 64-bit WinBatch or scripts compiled with the 64-bit WinBatch Compiler support much larger binary buffers. The maximum size depends on a combination of the amount of physical memory, page file size, and the memory demands of other processes. A few binary functions are also limited to accepting buffer sizes that are less than the maximum size possible using BinaryAlloc because of system restrictions. These additional per function limitations are noted in the documentation for the individual functions.