The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: aloha_arts on May 04, 2010, 03:16:04 PM

Title: pointer to struct
Post by: aloha_arts on May 04, 2010, 03:16:04 PM
how can i define a procedure that fills up a structure with some string fields in masm,
provided that the procedure invokes some other functions to fill each field?

i need to call the procedure from c.

example:


MYSTRUCT STRUCT
    str1 BYTE 10 dup(?)
    str2 BYTE 10 dup(?)
MYSTRUCT  ENDS


myproc PROC STDCALL pMyStruct:DWORD
    push ebx
   
    lea  ebx, pMyStruct
   
    invoke  FillStringProcedure, addr [ebx].MYSTRUCT.str1
    invoke  FillStringProcedure, addr [ebx].MYSTRUCT.str1

    pop ebx
    ret
myproc endp



FillStringProcedure fills up a string from a given pointer

thankyou.
Title: Re: pointer to struct
Post by: qWord on May 04, 2010, 03:23:29 PM
lea  ebx, pMyStruct
this load the variables address, not the content (which is the pointer)
-->
mov ebx,pMyStruct
Title: Re: pointer to struct
Post by: korte on May 05, 2010, 08:10:35 AM


MYSTRUCT STRUCT
    str1 BYTE 10 dup(?)
    str2 BYTE 10 dup(?)
MYSTRUCT  ENDS

mystruct MYSTRUCT {}


    invoke  MessageBox ,0, addr mystruct.str1, addr mystruct.str2,0