3

I need to create a format string for wsprintfW, so each character should be 2 bytes, UTF-16.

I have Unicode String to print via WriteConsoleW, but format String has ASCII format and it doesn't actually print wchar but 1 bytes each.

fstr dW "DllName: %s", 13, 10, 0 cause compile error "error A2084:constant value too large"

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
mantissa
  • 132
  • 7
  • What if you use `fstr dW 'D', 'l', 'l', 'N', 'a', 'm', 'e', ':', ' ', '%', 's', 13, 10, 0` – Michael Petch Oct 26 '22 at 14:57
  • MASM doesn't allow you to use strings with `DW`, only `DB`. Over the years there have been some MASM macros created by people to handle creating Unicode strings in an easier fashion. You'd likely be able to find some through Google search. – Michael Petch Oct 26 '22 at 15:10
  • @MichaelPetch Yes it`s work, but annoying. I just wonder if exist another way – mantissa Oct 26 '22 at 15:11
  • 3
    If you are making 32-bit Windows programs you could install MASM32 at https://www.masm32.com/download.htm . It has unicode macros for handling strings by including `macros\ucmacros.asm` and using things like `WSTR` – Michael Petch Oct 26 '22 at 15:47
  • 1
    Related: [When using the MOV mnemonic to load/copy a string to a memory register in MASM, are the characters stored in reverse order?](https://stackoverflow.com/q/57427904) re: how MASM handles multi-character literals. `dd "abcd"` assembles the same as `db "dcba"`, not padding each byte to a word. And your test shows that it wouldn't allow more than 4 bytes. – Peter Cordes Oct 26 '22 at 17:55

0 Answers0