The MASM Forum

General => The Campus => Topic started by: six_L on March 18, 2021, 07:39:35 PM

Title: wsprintf(X64)
Post by: six_L on March 18, 2021, 07:39:35 PM
Hi,all
the high dword has been disappeared.
Title: Re: wsprintf(X64)
Post by: jj2007 on March 18, 2021, 07:57:52 PM
That's unfair - values should never disappear like that ;-)
Title: Re: wsprintf(X64)
Post by: TimoVJL on March 18, 2021, 08:12:08 PM
wsprintf don't support long long in 32-bit form.
In x64 %IX is for long long / QWORD
QuoteIx, IX
    64-bit unsigned hexadecimal integer in lowercase or uppercase on 64-bit platforms, 32-bit unsigned hexadecimal integer in lowercase or uppercase on 32-bit platforms.
Try StringCbPrintf with %llX
Title: Re: wsprintf(X64)
Post by: jj2007 on March 18, 2021, 08:18:16 PM
Quote from: TimoVJL on March 18, 2021, 08:12:08 PM
wsprintf don't support long long in 32-bit form.

Under the hood, the JBasic version of Str$() is crt_sprintf
Title: Re: wsprintf(X64)
Post by: six_L on March 18, 2021, 08:47:11 PM
Hi jj2007,TimoVJL
Thanks you for the answer.
QuoteIn x64 %IX is for long long / QWORD
:thumbsup:
Title: Re: wsprintf(X64)
Post by: jj2007 on March 18, 2021, 08:59:13 PM
More precisely:
  mov rax, 0FFFFFFFFFFFFFF12h
  mov dqData, rax
  PrintLine Str$("The value is %llx", dqData)
  PrintLine Str$("The value is %llX", dqData)
  PrintLine Str$("The value is %lX", dqData)

The value is ffffffffffffff12
The value is FFFFFFFFFFFFFF12
The value is FFFFFF12
Title: Re: wsprintf(X64)
Post by: TouEnMasm on March 19, 2021, 12:21:27 AM

Not recommended by microsot wsprintf.
Quote
Note  Do not use. Consider using one of the following functions instead: StringCbPrintf, StringCbPrintfEx, StringCchPrintf, or StringCchPrintfEx. See Security Considerations.
personnaly i use sprintf who works.

Title: Re: wsprintf(X64)
Post by: TimoVJL on March 19, 2021, 01:27:17 AM
Quote from: TouEnMasm on March 19, 2021, 12:21:27 AM
personnaly i use sprintf who works.
Windows OS sprintf is limited, probably you mean same function in msvcrt.dll or in Visual C++ runtime.