Assuming I am reversing a 32bit c++ structure that has an array at some offset. I have the data layout filled up in the Local Types, and for the most part it is working great when generating the pseudocode:
element = myClass→array[stide * index];
But very often (in the same subroutine) it also does this:
element = myClass→gap0[stride * index]
actualElement = element + the array offset;
Both land at the same pointer, but the second variant is unreadable and make me falsely think that there is an array at the 0 offset (which I did believe at first and messed up my layouts ).
Is there a way to force or help IDA to prefer the proper indexing? It’s not that the layout is filled up wrong, since it does figure out 2 out of 4 structure fields.
Here is an actual example:
struct Render_Service
{
…
00090178 TextureBuffer textures_info[2048];
…
}
00000000 struct TextureBuffer // sizeof=0x10
00000000 { // XREF: Render_Service/r
00000000 _DWORD *data;
00000004 int width;
00000008 int height;
0000000C int flags;
00000010 };
and a subroutine:
int __thiscall sub_40B850(Render_Service *this, int a2, int *a3, int *a4, int *a5)
{
int width; // esi
char *v6; // eax
int v7; // ecx
int result; // eax
width = this->textures_info[a2].width;
v6 = &this->gap0[16 * a2];
*a4 = this->textures_info[a2].height;
v7 = *((_DWORD *)v6 + 147553); // ->textures_info[a2][3] = ->flags
result = *((_DWORD *)v6 + 147550); // ->textures_info[a2][0] = ->data
*a3 = width;
*a5 = v7;
return result;
}