I'm trying to figure out how to pass the address of a structure to a procedure and have it fill out the structure. This is what I have been trying:


teststruct STRUCTURE <>

...

invoke Function, ADDR teststruct

...

Function proc structaddr:DWORD

...

mov .STRUCTURE.member, eax
ret
Function endp
Posted on 2001-07-23 14:38:05 by rdaneel
You could try MASM's assume directive. Check this:

Function proc structaddr:DWORD

MOV EDI,structaddr
assume edi:ptr ANYSTRUCT

MOV .anyMember,EAX
RET

Function endp

Hope it helps! :alright:

Bye!

Latigo
Posted on 2001-07-23 15:45:24 by latigo
I kinda like to use a little pattern for structures. I use ecx for the struct pointer, eax for the data, and if need be (ie, for a 2nd struct) I keep edx in reserve.

So the proc might go like so:



Function proc structaddr:DWORD
mov ecx, structaddr

mov eax, FirstElementVal
mov [ecx].STRUCTURE.member, eax

add ecx, SIZEOF DWORD

mov eax, SecondElementVal
mov [ecx].STRUCTURE.member, eax

; and so on
ret
Function endp
Posted on 2001-07-23 18:28:04 by Ernie
when using asm i use the assume directive, as mentioned above

assume edi:ptr STRUCT_NAME

mov .MEMBER_NAME, VALUE

if you use tasm i think you can do it like this:

mov (STRUCT_NAME .MEMBER_VALUE), VALUE

(assuming edi holds the address of the thing)
Posted on 2001-07-23 20:49:51 by SubHuman
I have a good discussion on my Web-site (ripped from the old board about 4 months ago) on stuctures.... Its definitely worth the read (which i why i kept it :) ) should look it over, there is alot simple examples being discussed...

Read It here....

Anywho... good luck..

:alright:
NaN
Posted on 2001-07-23 23:33:49 by NaN