Win32 console output
Posted on 2005-03-13
I'm trying to write a simple console output app under Windows XP and having no luck. The WriteConsole procedure wants a handle to the console screen buffer but I can't seem to get one. CreateConsoleScreenBuffer just gives an invalid handle error when I run it (with parameters GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL) so I tried GetStdHandle with the STD_OUTPUT_HANDLE parameter, which doesn't return an error but doesn't give me a handle either. The following is the section of code (compiled with MASM 6.14 and linked with MS incremental linker 5.12). Oh and it's the first thing to run.
; get stdout handle
; eax is now 0
Anybody know why this is happening/how to do it properly?