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
teststruct STRUCTURE <>
...
invoke Function, ADDR teststruct
...
Function proc structaddr:DWORD
...
mov .STRUCTURE.member, eax
ret
Function endp
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
Function proc structaddr:DWORD
MOV EDI,structaddr
assume edi:ptr ANYSTRUCT
MOV .anyMember,EAX
RET
Function endp
Hope it helps! :alright:
Bye!
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:
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
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)
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)
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
Read It here....
Anywho... good luck..
:alright:
NaN