WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Forum
   Search    Users    Calendar    Board Help  

  Reply to this topicStart new topicStart Poll

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

samjeba
Posted: Sep 3 2007, 06:37 AM
Quote Post


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

PMEmail Poster
Top
samael
Posted: Sep 3 2007, 07:01 AM
Quote Post


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
PM
Top
SeaFarer
Posted: Sep 3 2007, 08:37 AM
Quote Post


GO NAVY!
******

Group: Admins
Posts: 757
Member No.: 1464
Joined: 2-September 05


Samjeba,

Shouldn't this...

CODE
.if eax==!INVALID_HANDLE_VALUE

Be this...

CODE
.if eax==INVALID_HANDLE_VALUE


;)
PMUsers Website
Top
samjeba
Posted: Sep 3 2007, 09:20 AM
Quote Post


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
PMEmail Poster
Top
SeaFarer
Posted: Sep 3 2007, 09:23 AM
Quote Post


GO NAVY!
******

Group: Admins
Posts: 757
Member No.: 1464
Joined: 2-September 05


Correct! ;)
PMUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll