Modify Data

WinHex & X-Ways

Modify Data

 

Use this command to modify the data within the block or within the whole file, in case no block is defined. Either a fixed integer number is added to each element of the data, the bits are inverted, a constant is XORed with the data (a simple kind of encryption), ORed, or ANDed, bits are shifted logically, bits rotated left in a circular pattern (first byte rotated by 1 bit, second byte by 2 bits, and so on), or bytes are swapped. By shifting bits, you can simulate inserting or removing single bits at the beginning of the block. You may also shift entire bytes (currently to the left only, by entering a negative number of bytes). This is useful if you wish to cut bytes from a very huge file in in-place mode, which would otherwise require the creation of a huge temporary file.

 

Swap Bytes

 

This command assumes all data to consist of 16-bit elements (32-bit elements resp.) and swaps high-order and low-order bytes (and high-order and low-order words resp.). Use it in order to convert big-endian into little-endian data and vice versa.

 

Addition

 

Specify a positive or negative, decimal or hexadecimal number, which is to be added to each element of the current block. An integer format defines size (1, 2 or 4 bytes) and type (signed or unsigned) of an element.

 

There are two ways how to proceed if the result of the addition is out of the range of the selected integer format. Either the range limit is assumed to be the new value (I) or the carry is ignored (II).

 

Example: unsigned 8-bit format

I.                FF + 1 -> FF                (255 + 1 -> 255)

II.                FF + 1 -> 00                (255 + 1 -> 0)

 

Example: signed 8-bit format

I.                80 - 1 -> 80                (-128 - 1 -> -128)

II.                80 - 1 -> 7F                (-128 - 1 -> +127)

 

 

• If you decide to use the first method, WinHex will tell you how often the range limit has been exceeded.

 

• The second method makes sure the operation is reversible. Simply add -x instead of x based on the same integer format to recreate the original data.

 

• When using the second method it does not make a difference whether you choose a signed or an unsigned format.