I want a local variable My_Variable to be a pointer to structure MY_STRUCT.
My_Function returns a pointer to MY_STRUCT and I want to store it in My_Variable.
How to do that?

My_StructMember DD 0

LOCAL My_Variable:PTR MY_STRUCT ;???

invoke My_Function
mov My_Variable, eax
mov eax, My_Variable.My_StructMember

This code doesn't work.
Posted on 2002-09-30 08:00:07 by Vaxon

I would just go like this:

mov eax, offset My_Struct
mov ecx,.My_Struct.My_Variable

or if you want to save the Pointer:

LOCAL My_Struct_Pointer:DWORD
lea eax,My_Struct
mov My_Struct_Pointer,eax

or if you want to have a fixed My_Struct_Pointer at all times:

My_Struct_Pointer dd OFFSET My_Struct
Posted on 2002-09-30 08:12:04 by JimmyClif
the way you are doing it is not correct.

structure members are referenced as an offset from the structure label(address).

you cannot do memory indirection from a memory location so...

invoke My_Function
mov My_variable,eax ;store the pointer to the structure
mov ecx,(MY_STRUCT ptr).My_StructMember
Posted on 2002-09-30 08:14:43 by MArtial_Code
Now I see...
Thanks, guys.
Posted on 2002-10-01 01:53:08 by Vaxon