flat assembler
Message board for the users of flat assembler.

Index > Windows > I have problems reading from memory from a STRUCT

Author
Thread Post new topic Reply to topic
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
Code:
format PE GUI 4.0

include 'include\win32a.inc'

section '.code' code readable executable

invoke GetLocalTime, _mytime

invoke wsprintf, _buffer, _prefix, [_mytime.wHour]

invoke MessageBox, 0, _buffer, 0, 0
invoke ExitProcess, 0

section '.data' data readable writeable
_mytime  SYSTEMTIME
_prefix  db "%d", 0
_buffer: times 64 db 0

data import

 library kernel32,'KERNEL32.DLL',\
    user32,'USER32.DLL'

 import user32,\
     wsprintf,'wsprintfA',\
   MessageBox,'MessageBoxA'

 import kernel32,\
        GetLocalTime,'GetLocalTime',\
    ExitProcess,'ExitProcess'

end data
    


I have problems reading from memory from the struct SYSTEMTIME.
Error is:
D:\fasmc156>fasm keygen.fasm
flat assembler version 1.56
keygen.fasm [9]:
invoke wsprintf, _buffer, _prefix, [_mytime.wHour]
include\macro/stdcall.inc [81] invoke [3]:
pushd arg
error: invalid size of operand.
Post 12 Nov 2004, 12:05
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Because wHour is word, but the arguments of the wsprintf are dword always.
You have to use something like:
Code:
movzx  eax, [_mytime.wHour]   ; or maybe movsx
invoke wsprintf, _buffer, _prefix, eax
    
Post 12 Nov 2004, 12:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
Oh right, thanks, Got it Smile
Post 12 Nov 2004, 20:18
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.