I have a simple string copy procedure along the lines of:
Str_copy proc src_str: PTR, dest_str: PTR
..
copy code
..
Str_copy endp
I also have some string variables defined as follows:
Str1 db 256 (?)
Str2 db 128 (?)
I can use my str copy routine like so:
Str_copy, offset Str1, offset Str2
and everything works fine. However, I have a structure with various members, including strings, like so:
MyStruc STRUC
Str_Len dd ?
Struc_Str db 256 (?)
MyStruc ends
My_Struc_Ptr dd 0
This structure is allocated on the heap via LocalAlloc and is addressed via My_Struc_Ptr
However, whenever I try to copy to Struc_Str, I get an error. My code is like this:
invoke LocalAlloc, LMEM_FIXED, SizeOf My_Struc
mov My_Struc_Ptr, eax
and further on
mov esi, My_Struc_Ptr
invoke Str_copy, Str1, (My_Struc PTR [esi]).Struc_Str
This causes an assembly error since Str_copy is expecting 2 pointers.
The question is, then, how do I address [esi].Struc_Str as a pointer?
Have you tried:
invoke Str_copy, Str1, ADDR (My_Struc PTR [esi]).Struc_Str
ADDR is like OFFSET, but can do more complicated stuff. It only works in an invoke statement though, and may generate additional code if it needs to (like an lea instruction).
Mirno
That's what I'm looking for - works perfect. :bg
Cheers :U
Please remember for structures or data types that may have nulls, you need to do your copy based on length.
Regards, P1 :8)