Can I move a pointer in IDA pseudocode generator?

I have the following code generated from 32bit c++ dll subroutine

Submesh = GetSubmesh(&geometry_service, &vertices, &indices, mesh_id, lod_idx);
if ( Submesh->VertexCount > 0 )
{
v5 = (float *)&transformed_v_buffer;
VertexCount = Submesh->VertexCount;
p_z = &vertices->pos.z;
do
{
pos_x = *(p_z - 2); // pos.x
pos_y = *(p_z - 1); // pos.y
pos_z = *p_z; // pos.z

The issue is that the asm loads a value from a pointer with an offset +8, so in my case the pointer points to pos.z, instead of the beginning of the structrue. I cant label v6 to Vertex_Data* in such case, since its going to have an offset. And I cant seem to be able to offset the pointer so that it would land to the beginning of the array.

In asm i have the following:

.text:004187B6 lea edi, [ecx+8]. //v6
.text:004187B9 fld dword ptr [edi-8]. //pos_x
.text:004187BC fld dword ptr [edi-4]. //pos_y
.text:004187BF fld dword ptr [edi]. //pos_z

I’ve tried to use the Manual… option in the context menu in asm view, and change the code to

.text:004187B6 lea edi, [ecx].
.text:004187B9 fld dword ptr [edi].
.text:004187BC fld dword ptr [edi+4].
.text:004187BF fld dword ptr [edi+8].

But it doesnt seem to have any effect in the disassembly

you can use shifted pointers. Right-click p_z, select “Convert to struct*”, then pick Vertex_Data and fill in offset of z (8?) in the dialog.

that worked nicely, thanks @igor!

1 Like