I have a following problem. I'm trying to write a piece of code in assembler that will use win api functions to write the content of file.txt in console. I have a sample code that prints "hello world" but when I try to pass source of a file as an argument it displays the source instead of the content.
.586
.MODEL flat, stdcall
STD_OUTPUT_HANDLE equ -11
GetStdHandle PROTO nStdHandle:DWORD
WriteFile PROTO hFile:DWORD,
lpBuffer:NEAR32,
nNumberOfBytesToWrite:DWORD,
lpNumberOfBytesWritten:NEAR32,
lpOverlapped:NEAR32
ExitProcess PROTO dwExitCode:DWORD
PUBLIC __start
.DATA
msg DB "Hello World !", 13, 10
written DW 0
hStdOut DD 0
.CODE
__start:
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov hStdOut, eax
invoke WriteFile, hStdOut, OFFSET msg, LENGTHOF msg, OFFSET written, 0
invoke ExitProcess, 0
END
I will be very greatful for some tips.