Writing to Win32 console - MASM 
Author Message
 Writing to Win32 console - MASM

I am aiming to write a command line tool, and so require to print text
to console.
I also require this to be as small as possible, so I am using the
GetStdHandle and WriteFile Win32 API calls to print my messages.

The following snip is from my program, which assembles and links fine,
but I do not see anything printed in the DOS session once executed.

Any hints are appreciated.

DW

;------------------------------------------------------------------------

      .386
      .model flat, stdcall
      option casemap :none

      decl_text MACRO Name, Text:VARARG
        LOCAL lbl
          jmp lbl
            Name db Text,0
          lbl:
      ENDM

;------------------------------------------------------------------------

..data
        AGENT_NAME     db "Fetch32",0

;------------------------------------------------------------------------

..code

start:
      invoke GetModuleHandle, NULL
      mov hInstance, eax

      invoke GetCommandLine
      mov CommandLine, eax

      invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
      invoke ExitProcess,eax

;------------------------------------------------------------------------

WinMain proc hInst     :DWORD,
             hPrevInst :DWORD,
             CmdLine   :DWORD,
             CmdShow   :DWORD

      LOCAL STD_OUT       :HANDLE
      LOCAL bytes_written :DWORD

      invoke GetStdHandle,STD_OUTPUT_HANDLE   ;get the stdout handle
      mov STD_OUT, eax

      decl_text msg1,"hello"
      invoke WriteFile, STD_OUT, ADDR msg1, 35, ADDR bytes_written, NULL

      return 0

WinMain endp



Mon, 18 Feb 2002 03:00:00 GMT  
 Writing to Win32 console - MASM


Quote:
> I am aiming to write a command line tool, and so require to print text
> to console.
> I also require this to be as small as possible, so I am using the
> GetStdHandle and WriteFile Win32 API calls to print my messages.

> The following snip is from my program, which assembles and links fine,
> but I do not see anything printed in the DOS session once executed.

> Any hints are appreciated.

> DW

Have you specified "console subsystem" on the link command line? If you
link as "GUI subsystem" then your program will run OK, but the console
output will go to the bit bucket.

Anthony
--

http://anthonyw.cjb.net

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Tue, 19 Feb 2002 03:00:00 GMT  
 Writing to Win32 console - MASM


   >I am aiming to write a command line tool, and so require to print
   >text to console.
   >I also require this to be as small as possible, so I am using the
   >GetStdHandle and WriteFile Win32 API calls to print my messages.
   >The following snip is from my program, which assembles and links
   >fine, but I do not see anything printed in the DOS session once
   >executed.
   >Any hints are appreciated.

Whoa.  Dude!  You can't, like, use Windoze API calls for a DOS program.
That's, like, trying to shove a Playstation CD into a Nintendo 64's
cartridge slot.  Won't work, dude.  Not compatible.



Tue, 19 Feb 2002 03:00:00 GMT  
 Writing to Win32 console - MASM
This is not real DOS application.
It is a Win32 application without GUI.

DW

Quote:


>    >I am aiming to write a command line tool, and so require to print
>    >text to console.
>    >I also require this to be as small as possible, so I am using the
>    >GetStdHandle and WriteFile Win32 API calls to print my messages.
>    >The following snip is from my program, which assembles and links
>    >fine, but I do not see anything printed in the DOS session once
>    >executed.
>    >Any hints are appreciated.

> Whoa.  Dude!  You can't, like, use Windoze API calls for a DOS program.
> That's, like, trying to shove a Playstation CD into a Nintendo 64's
> cartridge slot.  Won't work, dude.  Not compatible.



Wed, 20 Feb 2002 03:00:00 GMT  
 Writing to Win32 console - MASM
Hi

the freeware assembler PASS32 comes with a console example, maybe that
will help you...

PASS32: http://www.geocities.com/SiliconValley/Bay/3437/



Wed, 20 Feb 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. write to console from C in WIN32

2. Writing Win32-DLL with MASM

3. Q Porting HP Console-Based FORTRAN Program to Win32 Console

4. Win32 Console app -> Win32 app: help wanted

5. porting win16 masm code to win32 masm code

6. Help: Console interface with MAsm

7. i/o in console-MASM

8. WIN32 Console

9. Win32 Console in ISE.

10. Minforth in Win32 console

11. Seeking Examples of Win32 Console Programming, Any Compiler

12. Q: Clear screen in Win32 console?

 

 
Powered by phpBB® Forum Software