flat assembler
Message board for the users of flat assembler.

Index > Windows > wsprintf

Author
Thread Post new topic Reply to topic
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
having trouble with this, crashes when it reaches wsprintf call:

Code:

buffer rb 10

proc wndproc ...
  ...
        call        showmsg    
endp

proc showmsg ...
        mov      ecx,[lparam]  ;structure: im interested in dword value at [ecx+4]
        lea        eax,[buffer]
        cinvoke  wsprintf,eax,"%d", dword [ecx+4]
        invoke   MessageBox,0,eax,eax,0
        return
endp
    


what i want to do is display in a msgbox the value of [ecx+4]. im trying to use wsprintf to convert dword to string, but i guess im calling it wrong. any help would be great
Post 28 Mar 2005, 02:36
View user's profile Send private message Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy
if "dword [ecx+4]" is a pointer to a string, use "%s" instead of "%d"... btw: have you passed the argument(s) correctly to showmsg?
Post 28 Mar 2005, 07:18
View user's profile Send private message Visit poster's website Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
yes it is in fact a callback function, so i can assume the parameters will always be correct. lparam holds a structure of dword values, the second member is the one i want to convert to a string and display. perhaps i can just use a dwtoa function?
Post 28 Mar 2005, 11:37
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld
lparam is actually an EQU like EBP+???, but when you call showmsg, ebp value is changed so [lparam] isn't what you expect. You better try to mov lparam to ecx inside wndproc Wink
Post 28 Mar 2005, 12:26
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Also, remember that the return value of wsprintf is the number of characters written to the buffer, so the msgbox call on the next line will not do what you expect it to. a "dwtoa" or "itoa" function would indeed do the trick, and most likely be faster. If you want hexadecimal output, such a routine can be made very fast.
Post 28 Mar 2005, 16:14
View user's profile Send private message Visit poster's website Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
well actually its a standard windows hook callback, gets called whenever certain mouse/keyboard events occur so i think ebp will be ok. in this case im trying to display a messagebox of the virtual keycode pressed. the KBDLLHOOKSTRUCT.vkCode is at [lparam+4]

f0dder do you have an example of dwtoa or itoa?
Post 28 Mar 2005, 17:35
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 GitHub, YouTube, Twitter.

Website powered by rwasa.