IDA Pro and Pascal: base one arrays

Today I have finally solved how to handle Pascals base one arrays in IDA Pro.

So if you have a fixed size array block, it will normally be packed after some other data.

pascal memory layout
pascal memory layout

you can see the stru_1DA79 is an fixed size array from it’s use.

pascal array copy
pascal array copy

But when the base-1 array is indexed into, the results are messy and confusing

pascal array index ugly
pascal array index ugly

Yes it looks like the dword is being accessed not the actual array. For a long time I have worked around this with mega ugly repeat comments like:

_dword and [+2] = unk_1DA79[i-1].byte_0 and [+3] = unk_1DA79[i-1].byte_1_

Today I read enough help to finally workout how to do it correctly.

The first steps are to see above that the structure is 3 bytes wide, and create a structure for that (already done in the snaps above thus struct_6). Then in the incorrect usage shown above @ ovr032:0B51 select dword_1DA74 then Offset (User Defined)

Offset (user-defined)
Offset (user-defined)

Then set the Target delta to -3  (-1 * the size of structure (3))

pascal-fix-03
pascal-fix-03

and like magic it shows you correctly accessing the array

pascal-array-fixed
pascal-array-fixed

This ‘issue’ has only been the bane of my reverse engineering for like the last ten years.