Hello everyone, i need help on creating a file from console mode,
it compiles but it doesn't create an file
-----------------------
.data
fname db "text.file",0
.data?
hInstance DWORD
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke Main, hInstance
invoke ExitProcess, eax


Main proc hInst:DWORD
invoke CreateFile,fname,\
GENERIC_READ or GENERIC_WRITE ,\
FILE_SHARE_READ or FILE_SHARE_WRITE,\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
NULL

xor eax, eax
ret
Main endp
------------------------
thx
Posted on 2002-07-07 00:03:18 by b0z0
because you set it to OPEN_EXISTING, if there is no such file exists on the directory, CreateFile will fail. Look at MSDN or PSDK for these options, there are tons of 'em.
Posted on 2002-07-07 00:06:01 by stryker
Looks good on the surface, except you need to provide the ADDRESS of 'fname' not the first four bytes.... (The api will think this is an address... which would point to god knows what..)

invoke CreateFile,[b]addr fname[/b]\ 

GENERIC_READ or GENERIC_WRITE ,\
FILE_SHARE_READ or FILE_SHARE_WRITE,\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
NULL
mov hFile, eax

...

invoke CloseHandle, hFile
xor eax, eax
ret


As well Iczelion's tutorials might give you more assistance... Here!

:nAn:
Posted on 2002-07-07 00:10:44 by NaN