flat assembler
Message board for the users of flat assembler.

Index > Windows > swprintf double precision format in ntdll

Author
Thread Post new topic Reply to topic
AE



Joined: 07 Apr 2022
Posts: 70
AE 02 Feb 2023, 22:43
Code:
            proc Debug
                local  buf[512]:BYTE
                local  frm  du 'Value %1.9f',0
                local  val  dq 4.99999
                ;
                lea     rcx, [buf]
                lea     rdx, [frm]
                cinvoke swprintf,  rcx, rdx, [val]   ; ntdll  import!
                invoke  OutputDebugString, addr buf
                ret
            endp    
Out: Value f


What is wrong with this case? Other types works fine.

And BTW what macros do you use to debug values mixed with the strings?
Post 02 Feb 2023, 22:43
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1521
Location: Toronto, Canada
AsmGuru62 03 Feb 2023, 02:03
The function which will work is 'sprintf' from MSVCRT.DLL -- the native NTDLL does not support float point formatting.

Something like that:
Code:
; ---------------------------------------------------------------------------
section '.idata' import data readable writeable

    library kernel32,'KERNEL32.DLL',user32,'USER32.DLL',msvcrt,'MSVCRT.DLL'

    include 'API\Kernel32.Inc'
    include 'API\User32.Inc'

    import msvcrt,\
        log,'log',\
        pow,'pow',\
        atof,'atof',\
        sprintf,'sprintf'
    
Post 03 Feb 2023, 02:03
View user's profile Send private message Send e-mail Reply with quote
AE



Joined: 07 Apr 2022
Posts: 70
AE 03 Feb 2023, 07:50
True, replacing 'ntdll' to 'msvcrt' in import helps.
Thx.
Post 03 Feb 2023, 07:50
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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.