Using Boolean Operators with MASM: The OR Operator, Error A2044: Invalid character in file
| samjeba |
|
New Member

Group: Members
Posts: 15
Member No.: 5184
Joined: 9-June 07

|
i am getting following error "error A2044: invalid character in file" and here is the code attached
| CODE | .386 .model flat,stdcall option casemap:none
include windows.inc include kernel32.inc include user32.inc
includelib kernel32.lib includelib user32.lib
.data szFile db "c:\test.bin",0h MsgBoxCaption db "pilot test",0h MsgBoxText db "gud",0h MsgBoxText1 db "bad",0h
.data? hFile HINSTANCE ?
.code start:
invoke CreateFile,addr szFile,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXI STING,FILE_ATTRIBUTE_NORMAL,NULL
.if eax==!INVALID_HANDLE_VALUE mov hFile,eax invoke MessageBox,NULL,addr MsgBoxText,addr MsgBoxCaption,MB_ICONASTERISK .else invoke MessageBox,NULL,addr MsgBoxText1,addr MsgBoxCaption,MB_ICONERROR .endif invoke ExitProcess,0h end start |
|
|
|
| samael |
|
Typo-lord
     
Group: Admins
Posts: 292
Member No.: 5187
Joined: 10-June 07

|
| CODE | | invoke CreateFile,addr szFile,GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL |
The "|" character denotes the "OR" operator in C/C++. In MASM, you just use the "or" instruction, and the MASM preprocessor will handle the rest...
To compile, change the above code to:
| CODE | invoke CreateFile,addr szFile,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
|
|
|
|
| samjeba |
|
New Member

Group: Members
Posts: 15
Member No.: 5184
Joined: 9-June 07

|
thanx samael and SeaFarer :)
in the code after CreateFile need to be executed if the function returns valid handle so is the condition should be like this ?
| CODE | .if eax!= INVALID_HANDLE_VALUE
|
|
|
|
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
|