Hello everybody,

invoke GlobalAlloc,GMEM_ZEROINIT,FileSize
mov hMemory,eax
invoke GlobalLock,hMemory
mov pMemory,eax

invoke ReadFile,hFile,pMemory,0ah,\

invoke WriteFile,hFile,pMemory,FileSizeSize,ADDR WriteSize,NULL
invoke CloseHandle,hFile
invoke GlobalUnlock,pMemory
invoke GlobalFree,hMemory

So I read 10 bytes from file into memory full of nothing then write that back to the file. What I think should happen is 10 bytes are copied to file full of nulls, but this does not happen. 10 bytes are copied but the rest of the file is not nulls!

Any ideas or help much appreciated
best regards,

Posted on 2001-08-12 04:36:05 by czDrillard
What I think is happening here is that write file doesn't simply add more data to the end of a file, it deletes the origional and creates a new one.

What I suggest doing is loading the entire file into memory, make any modifications to it there and then write the whole file back to the harddisk.
Posted on 2001-08-12 05:18:43 by Eóin
or use WIN32 function SetFilePointer
Posted on 2001-08-12 15:16:37 by japheth
Thanks Zadkiel, I just read the whole file into memory then make my changes and write it. and japheth I do need to use setfilepointer and everything working great. Thanks again for your help.

best regards,

Posted on 2001-08-13 20:00:47 by czDrillard