hi, can someone tell me, what i dod wrong ?
the createt file doesnt contain "HUHU !"

.386
.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE

INCLUDE ..\Include\WINDOWS.INC
INCLUDE ..\Include\MASM32.INC
INCLUDE ..\Include\KERNEL32.INC
INCLUDELIB ..\Library\MASM32.LIB
INCLUDELIB ..\Library\KERNEL32.LIB

.data
DWORDh_file DWORD 0
DB_data1 DB "Huhu !", 0
DB_File DB "text.txt", 0
DB_len DB 7
DWORD_bytes_written DWORD 0

.code
start:
INVOKE CreateFile, ADDR DB_File, GENERIC_READ OR GENERIC_WRITE, NULL, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
MOV DWORDh_file, EAX

INVOKE SetFilePointer, DWORDh_file, NULL, NULL, FILE_END
INVOKE WriteFile, DWORDh_file, ADDR DB_data1, DB_len, ADDR DWORD_bytes_written, NULL

INVOKE ExitProcess, 0
END start
Posted on 2003-03-03 11:19:53 by Forginforcer
you forgot to close the File handler.

invoke CloseHandle,DWORDh_file
Posted on 2003-03-03 12:16:47 by wizzra
Moved from Algo & Source.

Please read the forum description under the forum names before you post in the wrong section again.
Posted on 2003-03-03 12:17:24 by bazik
the svin posted a nice error description routine not long ago. use that when you seem to get stuck and you don't know why :)

edit: here you go :) http://www.asmcommunity.net/board/index.php?topic=626&highlight=GetErrDescription
Posted on 2003-03-03 12:29:40 by Hiroshimator
tahnks for your help !
Posted on 2003-03-03 12:32:01 by Forginforcer

DB_len DB 7
...
INVOKE WriteFile, DWORDh_file, ADDR DB_data1, DB_len, ADDR DWORD_bytes_written, NULL


DB_len is defined as byte, so changed it do dd, as parameters must be 32-bit.
Posted on 2003-03-03 16:25:22 by comrade
First you have to do CreateFile then a ReadFile looks like this:

invoke ReadFile,Filehdl,addr Filebuff,10h,addr bytesread,0

Filehdle comes from CreateFile. After you do this it is possible to freely read and write to the file buffer. All you need is the address of the pointer to the address buffer. In this case it is Filebuff in the .data section. In NT it is a bit tricky to get that address.
Posted on 2003-03-04 00:20:17 by mrgone
Thanks again.
I got it !
Posted on 2003-03-04 01:57:40 by Forginforcer