enabling MASM32-built apps to support msvcrt.dll

1k Views Asked by At

I have a need of building console applications in assembly language. Since I'm too lazy to reinvent the square wheel of reading strings with the help of ReadConsoleA, converting them to integers (or otherwise parsing them) manually, outputting them in the same tiresome way backwards, etc., I chose to use CRT to aid myself.
I took the masm32 package available from http://masm32.com, altered it with executables torn out from VS 2008, and started playing with it. WinAPI libraries (for example, kernel32.lib) were smooth to use, but once I linked msvcrt.lib, I got a CRT runtime error R6034 when using functions from there (wprintf(), for example).
After googling I found out that this error was causing by me not linking the manifest in my app. The only reliable link from MSDN was heavily dependent on VS and so didn't work, obviously.
So now I have 3 ways and 3 questions to ask:
1) Would it be better for me to use another assembly tool (for example, fasm) and which one?
2) How could I link msvcrt.dll to my app then?

2

There are 2 best solutions below

0
On

Problem solved. I just scrapped masm32 and used fasm.

0
On

No, problem not solved. You did not know how to use the Assembler and just gave up on it. When you need to call a function from the C Library from MASM32 code, you must prefix all the function names with crt. Not sure why Hutch did it this way, probably to prevent naming problems.

include masm32rt.inc
include msvcrt.inc
includelib msvcrt.lib

.data
fmtw      dw  "%", "l", "s", 13, 10, 0
UniString dw 'H','e','l','l','o',' ','f','r','o','m',' ','a',' ','U','N','I','C','O','D','E',' ','s','t','r','i','n','g','!','!','!','!','!',0

.code
start:

    invoke  crt_wprintf, offset fmtw, offset UniString

    inkey
    invoke  ExitProcess, 0
end start

UNICODE string output