I've been working on getting a program to read input, then redisplay that on the screen only using the Windows API. I know that MASM32 comes with a macros package that I can use, and I have. It's simple and slick to use, but I just really want to learn exactly how the Windows API works and I figured this should be the simplest program to write. Here's what I have that's working:
.586
.model flat,stdcall
option casemap:none
... Include windows/kernel32/etc. ...
.const
helloText db "Hello World",0
.data?
hConsoleOutput HANDLE ?
hConsoleInput HANDLE ?
.code
program:
call main
invoke ExitProcess,0
main proc
LOCAL lpConsoleScreenBufferInfo:CONSOLE_SCREEN_BUFFER_INFO
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov hConsoleOutput,eax
invoke GetStdHandle,STD_INPUT_HANDLE
mov hConsoleInput,eax
invoke WriteConole,hConsoleOutput,addr helloText,11,0,0
ret
main endp
end program
I've tried using the ReadConsole and the ReadConsoleInput, but they just pass through without prompting. I remember reading that I'll have to tell the system to wait for a certain input (i.e. "enter"), then read the buffer to an array, but I haven't been able to figure out how to do this. I figure I'll have to use a hook, or figure out how to use raw input, but I have yet to successfully use either of these.
For everyone that's helped me so far, I thank you much. Over the last week a lot has come together because of the information that I've received here. Now, if I can just figure out how to use the Windows API the down and dirty way, I'll be happy (for now).
For working examples you might take a look at the input macro in macros.asm, and at the StdIn and StdOut procedures in m32lib\stdin.asm and m32lib\stdout.asm.
Oh, beautiful. That's just what I was looking for. Thanks. I was looking at macros.asm, and was confused where the code was coming from. That explains it.
So basically writing text to the console involves getting the 'STD_OUTPUT_HANDLE' and using that to 'WriteFile'. very intresting, and I thought that StdOut was an actual low level api call, I wish I had a list of the very bare bones windows api functions, you now the functions that don't call any other, the lowest common denominator so to speak.
Is what you want?
http://msdn.microsoft.com/en-us/library/aa383749(VS.85).aspx