My PROC to create an xml file does not return an error, nor does it create Configuration.xml - any ideas?


CreateXML PROC
; Local Variables
LOCAL hXMLConf :DWORD ; File Handle
LOCAL fSize :DWORD ; File Size
LOCAL BWRTN :DWORD ; Bytes Written
LOCAL hMem :DWORD ; Memory Handle
; Create XML Configuration File
INVOKE CreateFile,ADDR szXMLConf,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_ARCHIVE,
NULL
; Place the XML File Handle in hXMLConf
MOV hXMLConf, EAX
; Get The XML Configuration File Size
INVOKE GetFileSize, hXMLConf, NULL
MOV fSize, EAX
SUB fSize, 1
; Allocate enough memory for the file
INVOKE GlobalAlloc, GMEM_FIXED, fSize
MOV hMem, EAX
INVOKE ReadFile, hXMLConf, hMem, fSize, ADDR BWRTN, NULL
INVOKE MessageBox, 0, hMem, ADDR szCaption, 0
; Close The File Handle
INVOKE CloseHandle, hXMLConf
; Free the Allocated Memory
INVOKE GlobalFree, hMem
RET
CreateXML ENDP
Posted on 2006-07-23 16:30:48 by p0wder
It can't create a file because of "OPEN_EXISTING" flag, replace it with "OPEN_ALWAYS" flag
Posted on 2006-07-23 16:54:50 by Dite
There's a lot of problems with your code.

#1 - no error checking/handling
#2 - assuming the XML file exists (OPEN_EXISTING)
#3 - dangerous code: fsize-1 will be BAD if the file exists and is 0 bytes.

Posted on 2006-07-24 05:39:56 by f0dder