flat assembler
Message board for the users of flat assembler.

Index > Windows > Floating point to string write

Author
Thread Post new topic Reply to topic
Xeon



Joined: 14 Nov 2013
Posts: 5
Xeon
Hey! I've got a problem with conversion betweeen float to string format. I know that i can achieve this in several ways but decided use 'sprint' funcion in msvcrt.dll library. My code looks like that:

Quote:

format PE CONSOLE 4.0
entry start

Include 'win32a.inc'

section ".code" code readable writeable executable

bufor: times 20 db 0
string db "Float value:",0
szEnv db "%s %4.2f",0
valu dq 6.6


start:
cinvoke printf,szEnv, string, dword [valu], dword [valu+4]
cinvoke sprintf,bufor,8,szEnv, dword [valu], dword [valu+4]
cinvoke getchar
invoke ExitProcess,0

section '.idata' import data readable writeable

library kernel32,'kernel32.dll',\
msvcrt,'msvcrt.dll'

import kernel32,\
ExitProcess,'ExitProcess'

import msvcrt,\
getchar,'getchar',\
printf,'printf',\
sprintf,'sprintf'


And program ends with Windows error ".exe has stopped working". When i delete 'sprintf' funcion it works correctly! Could You tell me where i did mistake and what i have to change? Note, that i need write float to bufor not to output stream.
Post 14 Nov 2013, 15:56
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
Try with this:
Code:
cinvoke sprintf, bufor, szEnv, string, dword [valu], dword [valu+4]    
Post 14 Nov 2013, 17:02
View user's profile Send private message Visit poster's website Reply with quote
Xeon



Joined: 14 Nov 2013
Posts: 5
Xeon
edit: Sorry, thanks for help it works Smile
Post 14 Nov 2013, 17:54
View user's profile Send private message Reply with quote
Xeon



Joined: 14 Nov 2013
Posts: 5
Xeon
Guys one more thing - how to add icon to .exe file? What i should type in the resource? I can't find any guide with explain Sad

I added this to resource:

directory RT_ICON,icons,\
RT_GROUP_ICON,group_icons

resource icons,\
1,LANG_NEUTRAL,icon_data

resource group_icons,\
1,LANG_NEUTRAL,main_icon

icon main_icon,icon_data,'ikona1.ico'

And after compilation there appears icon but program doesn't start, and doesnt execute.
Post 14 Nov 2013, 18:52
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.