Arrays are used in IDA to represent a sequence of multiple items of the same type: basic types (byte, word, dword etc.) or complex ones (e.g. structures).
To create an array:
Step 1 is optional; if no data item exists at the current location, a byte array will be created.
Hint: if you select a range before pressing *, Array size will be pre-filled with the number of items which fits into the selected range.
Array parameters affect how the array is displayed in the listing and can be set at the time the array is first created or any time later by pressing *.
db 1, 2, 3, 4, 5, 6, 7, 8 db 9, 10, 11, 12, 13, 14, 15, 16 db 17, 18, 19, 20, 21, 22, 23, 24 db 25, 255, 255, 255, 255, 255, 255, 26 db 27, 28, 29, 30, 31, 32, 33, 34 db 35, 36, 37, 38, 39, 40, 41, 42print width 0:
db 1, 2, 3, 4, 5, 6, 7, 8 db 9, 10, 11, 12, 13, 14, 15, 16 db 17, 18, 19, 20, 21, 22, 23, 24 db 25,255,255,255,255,255,255, 26 db 27, 28, 29, 30, 31, 32, 33, 34 db 35, 36, 37, 38, 39, 40, 41, 42print width 5:
db 1, 2, 3, 4, 5, 6, 7, 8 db 9, 10, 11, 12, 13, 14, 15, 16 db 17, 18, 19, 20, 21, 22, 23, 24 db 25, 255, 255, 255, 255, 255, 255, 26 db 27, 28, 29, 30, 31, 32, 33, 34 db 35, 36, 37, 38, 39, 40, 41, 42
db 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh
db 6 dup(0FFh)
The last option in array parameters dialog can be useful when dealing with multiple string literals packed together. For example, if we have a string table like this:
First, create one string.
Then, select it and all the following strings using one of the methods described before.
Invoke Edit > Array… or press *. The array size will be set to the total length of the selection. In the dialog, uncheck “Create as array”. Click OK.
We get a nicely formatted string table!
This approach works also with Unicode (UTF-16) strings.