views:

70

answers:

4

I can't seem to figure out what eax contains after this peice of assembly:

mov     edi, [edi+4]
lea     eax, [edi+88h]

With edi pointing to a class

A: 

A long shot, since I know nothing about your class, but here goes anyway.

Do you have multiple inheritance? Perhaps edi+4 is the second virtual table, and [edi+4]+88h is a function pointer you wish to call? Or depending on your compiler, it might be that the virtual table is located at +4, in either case eax contains the address of the virtual function to call.

roe
+1  A: 

Load Effective Address gets the actual address of the reference. For some arcane reason, the symbolic assembly is written as if it references the content of edi+88h, but what the instruction actually does is loading the value of the edi register plus the constant 088h (equivalent to mov eax, edi; add eax, 088h). I doubt edi+4 is a function pointer: more likely, it's a vtbl pointer or an array.

Pontus Gagge
Wait, isn't a class similar to a vftable? Well actually, edi points to vftable and edi+4 points to a function in the vftable
kotarou3
If there is multiple inheritance involved, the compiler may implement it via multiple vtable pointers (http://en.wikipedia.org/wiki/Virtual_method_table). [edi+4] may be loading a secondary vtable, in which there's a function at offset 088h. Perhaps you should say why you're so sure edi+4 is a function pointer?
Pontus Gagge
Actually, as I think about it more... It might not be a pointer to a function
kotarou3
A: 

Based on the use of edi, it probably ends up pointing to a memory location, but lea isn't always used like this: http://en.wikipedia.org/wiki/Addressing_mode#Useful_side_effect.

altie
A: 
mov     edi, [edi+4]
lea     eax, [edi+88h]

    edi points here after 'mov'
    .
    xxxx....................
    |                      ^
xxxx....                   eax points here after 'lea'
^
edi pointed here before 'mov'

char* edi;
void* eax;

edi = *(char**)(edi+4);
eax = edi+0x88;

It looks like some record is just getting accessed there.

Cheery