flat assembler
Message board for the users of flat assembler.

Index > Windows > fill a member struct

Author
Thread Post new topic Reply to topic
Alessio



Joined: 26 Sep 2003
Posts: 35
Location: Viterbo, Italy
Alessio 24 Feb 2009, 09:37
Hi, suppose I have this struct...

Code:
UNKNOWN_SIZE  = 0x9

struct UNKNOWN
  char      db ?
  szUnknown db UNKNOWN_SIZE dup (?)
ends
    


...and I want to fill it, after it was reallocated dinamically...

Code:
mov [lpUnknown],eax      ; eax is pointer to reallocated memory block from HeapReAlloc
mov ebx,eax
mov edx,[iUnknownCount]  ; number of allocated structs
dec edx                  ; set to current subscriptor
mov al,[char_current]    ; char_current is a db value
virtual at ebx
unknown UNKNOWN
end virtual
mov [unknown.char+edx],al        ; put char_current to char member
invoke lstrcpy,[unknown.szUnknown+edx],szBuffer ; szBuffer is a string from WM_GETTEXT message, how to copy to szUnknown member ?
    


Thank you.
Post 24 Feb 2009, 09:37
View user's profile Send private message MSN Messenger Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 24 Feb 2009, 13:05
Hi, Alessio!
Seems to me you should use "lea" instruction here, because szUnknown is not a pointer, but array of bytes:

Code:
 lea ecx,[unknown.szUnknown+edx]
 invoke lstrcpy,ecx,szBuffer 
     


Maybe this will help.
Post 24 Feb 2009, 13:05
View user's profile Send private message Reply with quote
Alessio



Joined: 26 Sep 2003
Posts: 35
Location: Viterbo, Italy
Alessio 24 Feb 2009, 13:54
thank you, it works!
Post 24 Feb 2009, 13:54
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.