aiakonai
asked on
0 terminated?
The following code outputs the first two letters of a file called test.txt.
test.txt has the letters abcd and nothing else in it.
When I display the ab with StdOut there is no error message but I have cause to wonder... shouldn't that string be null terminated?
Should I be manually placing a 0 at the end of it?
test.txt has the letters abcd and nothing else in it.
When I display the ab with StdOut there is no error message but I have cause to wonder... shouldn't that string be null terminated?
Should I be manually placing a 0 at the end of it?
.486
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\macros\macros.asm
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc.
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.data
filename db "c:\masm32\assembly projects\fopen\test.txt",0
file_handle HANDLE ?
file_buffer DWORD 256 dup (?)
readC DW ?
.code
start:
invoke CreateFile,ADDR filename,GENERIC_READ,FILE_SHARE_READ,
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
mov file_handle,eax
invoke ReadFile,file_handle,ADDR file_buffer,sizeof(BYTE)*2,ADDR readC,NULL
invoke StdOut,ADDR file_buffer
invoke CloseHandle,file_handle
exit
end start
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER