Ad hoc array/list like support for the datainspector (to show series of the same datatype)

Wishlists for new functionality and features.
Post Reply
Maël
Site Admin
Posts: 1454
Joined: 12 Mar 2005 14:15

Ad hoc array/list like support for the datainspector (to show series of the same datatype)

Post by Maël »

Sometimes you want to visualize a list of datatype instances, such as an integer array in a wave file, or sequence of disassembly commands, or even an array of characters/strings.

Currently there is a kind of minimal array support with the array item toolbar on top of the datainspector. This allows for datatypes that support it, to navigate back and forth in adhoc arrays, i.e., arrays that are defined inplace, without explicit boundaries. Currently it only shows one array item, this idea would extend it to show a window into an array.

The array window would be defined by the array item either being in the center, the start or the end. The already existing array navigation toolbar would function as is, and this way shift/move the array window accordingly.

The current offset in the hexeditor defines the start of the current array item, i.e., defines the synchronisation point for the array items, but it does not define the first or last array item. They are in theory only defined by the limits of the file, or the ability of the datatype to guess the start/end of the next item. For types like Int32 this is trivial, as each item has the exact same size. For types such as UTF8Char this requires analyzing lead and trail bytes, to properly synchronize to the next/previous character. But knowing the first or last item is not trivial, since it would require parsing the entire file, as the byte width of a UTF8Char varies, and can only be determined by looking at the bytes in the sequence, i.e., it would require parsing the entire file (or at least the part of the file before the current caret pos when jumping to the start, or the part of the file after the current UTF8Char to jump to the end of the file -- though you could just jump to the start of the file or end of the file, then use the self-synchronizing properties of UTF8Chars and find the closest valid UTF8Char).

For disassembly finding the previous instruction start, given the current instruction is quite complex, but it's easy to skip to the next instruction, given the current instruction, since the length of an instruction is always known.

All those properties would have to be considered in an array or list like support.

Options could be:

Specify strides, padding, and possibly end markers, such as for 0 terminated strings. See also how Spyder (Python IDE) handles arrays.

List all items starting from current caret pos and up to the maximum buffer size. Currently this is 256 or 128 bytes (for performance reasons, the datainspector will read the file each time you move the caret!). Optionally you could increase the amount of array items read, at a possible performance penality, but this should not be the default.

Automatically use self-synchronizing properites such as in UTF8Char, possibly this logic would need to be exposed explicitly, so that the datainspector can use it while scanning bytes, or it would simply scan all the read buffer, and apply the type converter in sequence.

Editing also needs to be considered. I will implement it as a kind of grid/table, such that each array item can only be edited in isolation, not the array as whole. For example a multi-line conrol (such as a multiline text control), would not allow for reordering items, just replacing the entire array. It would also raise the question on what to do with new items (= new lines) or missing item (= less lines).

We can't simply resize the file, as that would break most file formats, and padding with a value would also need to define a padding value -- this might clutter the GUI too much. At this point a fully fledged structure editor that can annotate types in many ways makes more sense, see here: https://forum.mh-nexus.de/viewtopic.php?f=4&t=889

This ad-hoc array support is meant to be quick and simple to use, however, with just a few additional controls, ideally next to the toolbar (which should occupy only a small space, not the entire horizontal space like now).
Post Reply