i wrote this in TASM and it did exactly what i wanted. however in MASM it isnt working. invoke CreateFile,ADDR inipath,GENERIC_READ + GENERIC_WRITE,FILE_SHARE_READ + FILE_SHARE_WRITE,0,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0 it is returning INVALID_HANDLE_VALUE it should create the file if it is not there and open it if it is. however regardless of whether it is there or not it is not returning a handle. i have tried replacing the "+"'s with "OR"'s (thx comrade) but it still isnt working. grrr. any help appreciated. skud.
.....hummmmm.......if you retrieved inifile, and it's in a buffer, try leaving off the ADDR. I found that when you use something in .DATA, you should use ADDR; and when you use something in .DATA?, you should not. ;) This worked for me:
.....hope that helps.......
.data ... Path db "C:\WINDOWS\DESKTOP\FILE.EXE",0 .code start: ... invoke CreateFile, ADDR Path, GENERIC_READ + GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
I think you have to use CREATE_ALWAYS something like that. anyway this works with masm, I use it to open a new if the file does not exist otherwise it opens an existing file. invoke CreateFile,addr INIPath,\ GENERIC_WRITE , FILE_SHARE_WRITE ,\ NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL
ok thanks. but its still failing :( whats that about not using .data? im not using it anyway, but i just wondered. all i want to do is create the file and obtain its handle if it doesnt exist; and if it does then get its handle. thats it. i have done it before in TASM but using that code in the MASM way doesnt seem to work. this is the TASM code: push 0 push FILE_ATTRIBUTE_NORMAL push OPEN_ALWAYS push 0 push FILE_SHARE_READ + FILE_SHARE_WRITE push GENERIC_READ + GENERIC_WRITE push offset inipath call CreateFileA why the hell does this work but not the MASM version??? invoke CreateFile, ADDR inipath, GENERIC_READ + GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 more help please ... skud. This message was edited by skud, on 4/30/2001 2:59:46 AM
Hmmmm.. try using NULL instead of "0".. That's the only diffrence between my own code I'm looking at right now and yours =) You could try GENERIC_READ & GENERIC_WRITE instead of GENERIC_READ + GENERIC_WRITE too. Can't remember if that's valid tho.. it's 2 am and I've just got home from a party =)) //Phrekie
i have solved this problem there is nothing wrong with the code there; however the path was incorrect (inipath). o well. thanks anyway. skud.