Search code examples
winapiunicodemasmmasm32

How to translate these pseudo unicode data declaration code into MASM style code?


I have some pseudo asm code generated from IDA Pro like this:

aR6033AttemptTo:
unicode 0, <R6033>
dw 0Dh, 0Ah
unicode 0, <- Attempt to use MSIL code >
unicode 0, <from this assembly during n>
unicode 0, <ative code initialization>

and this variable is used in this way:

dd offset aR6033AttemptTo  

I know if there is an one line unicode declaration, I can use this :

include \masm32\macros\macros.asm
....
WSTR aNull_0, "this is a unicode string"

But how can I deal with multilines declaration? Especially there are dw 0Dh, 0Ah, could anyone give me some help? Thank you!


Solution

  • Create the UNICODE string yourself?!?!

    A normal string is ASCII - 1 byte per character (declared as BYTE), a UNICODE string is 2 bytes per character (declared as WORD)

    UniString       word    'I', 13, 10, \
                            'a','m', 13, 10, \
                            'a', 13, 10, \
                            'M','u','l','t','i', ' ', 'l','i','n','e', 13, 10, \
                            'U','N','I','C','O','D','E', ' ', 's','t','r','i', 'n', 'g','!',0, 0
    

    Let's test it with a Unicode MessageBox

    Invoke MessageBoxW, 0, offset UniString, NULL, MB_ICONINFORMATION
    

    enter image description here

    Now, all that typing can be tedious, I sure didn't type all that out. I have a program with source, that when you input a variable name, some ASCII text, and it will output your string as a UNICODE defined string. Unicode String Variable Creator The one at the link, will only do single line strings. You can modify it to create multi line strings as I did. Change the bottom 2 edit controls to richtext controls modify the conversion loop to add the 13 an 10 for Carriage Return and Line Feeds.