Open Wall-AF opened 6 days ago
Changing the packing of the structure solved the problem of the 3 missing charaacters ?AV
!
A trailing flexable array member is expected to be declared with a 0-element count. In addition, it it best to enable packing on the structure when this is done. Any references to the member will be treated as a reference beyond the structure bounds. Below is an example which shows both the listing and structure editor for a similar case:
The decompiler will not render as a reference the last zero-length structure member (e.g., name) since its offset falls outside the bounds of the structure. It would require special logic within the decompiler to recognize as a structure member access.
The decompiler will not render as a reference the last zero-length structure member (e.g., name) since its offset falls outside the bounds of the structure. It would require special logic within the decompiler to recognize as a structure member access.
That is the point (for this simple case), I believe some kind of speciality could be used to ensure that the decompiler could see that an array is specified and (maybe give a user option to) reference that member.
Alternatively, use a size of 1
in the type definition to enable the decompiler to see the member and reference that, and add a per instance attribute to provide the actual size of the array member based upon its deployed location.
Is your feature request related to a problem? Please describe. When structures can be defined as having their (last) element(s) as a variable size array(s), as in the simple case of the
struct type_info
used to represent the C++ class, assigning those types to memory in the data segment is incomplete as invariably the dataype manager only allows for a static definition of your type. Illustrating this using thetype_info
, the structure is defined as:meaning that when it is assigned to some data where the name contains 17 elements (
char
s in this case), you see something akin to:Describe the solution you'd like With the ability to parameterise the number of elements in each array within the datatype, the same type would be usable in multiple places which is more appropriate. For the example above you would then see:
Notice that the 3 characters
?AV
are completely missing from the initial data display due to only a single character being shown and data between1000b039-1000b03b
being ignored.Describe alternatives you've considered Using size of
0
for the member: but this breaks other dissasembly as references to the zero'd member become references to the next element of an array, of in this casetype_info
structures, which don't exist as it is a single instance; also you then can have the correctly sized array of elements but they become disjoint from their owner. Using size of1
for the member: this solves the dissaasembly issue above, but you're left with the example illustrated in this request. Using multiple copies of the datatype: this has consistancy problems etc.