flat assembler
Message board for the users of flat assembler.

Index > Main > Specify string encoding.

Author
Thread Post new topic Reply to topic
thetrick



Joined: 19 Feb 2020
Posts: 18
thetrick 09 Oct 2021, 19:55
Hello everyone.

How to specify the encoding when i pass a string using invoke macro?

For example:
Code:
invoke MessageBox,HWND_DESKTOP,"Message","Caption",MB_OK    


How to specify explicitly the strings encoding? If i use w-extended header it always uses UNICODE, if a - ANSI. How to pass an UNICODE string using a - header, or ANSI using w header (for example to using GetProcAddress)?
Post 09 Oct 2021, 19:55
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1040
Location: Russia
macomics 09 Oct 2021, 20:28
alternatively, you can declare
Code:
 IMPORT64.INC [62]:
            db string,0
  load test byte from ($ - 2)
            rb RVA $ and 1
   if test = "W"
    define label#.TCHAR du
    define label#.sizeof.TCHAR 2
  else
    define label#.TCHAR db
    define label#.sizeof.TCHAR 1
  end if    
in the import macro, and check for the corresponding value in the invoke macro
Code:
PROC64.INC [50]:
  if defined proc#.sizeof.TCHAR & defined proc#.TCHAR
           align proc#.sizeof.TCHAR
           ..string proc#.TCHAR definition@param,0
  else
           align sizeof.TCHAR
           ..string TCHAR definition@param,0
  end if
    

Code:
 PROC64.INC [42]:
  if defined proc#.sizeof.TCHAR & defined proc#.TCHAR
           align proc#.sizeof.TCHAR
           ..string proc#.TCHAR definition@param,0
  else
           align sizeof.TCHAR
           ..string TCHAR definition@param,0
  end if
    
well, etc. I have already rewritten my own for a long time, so I don't have such a problem
Post 09 Oct 2021, 20:28
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 10 Oct 2021, 07:45
invoke MessageBoxW,...
invoke MessageBoxA,...

Use the full name of api, not shorter one.
Post 10 Oct 2021, 07:45
View user's profile Send private message Visit poster's website Reply with quote
thetrick



Joined: 19 Feb 2020
Posts: 18
thetrick 11 Oct 2021, 17:12
Thank you all guys!
Post 11 Oct 2021, 17:12
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.