Problem with kernel32::ReadFile
I am having a problem with the Windows ReadFile function when executing it with the system.dll plug-in. I am able to open the file and get the file size with the kernel32 functions, so I know that the file handle is valid. When I attempt to read data from the file with the ReadFile Function it always returns 0 indicating failure and 0 bytes read. The GetLastError returns the code file already exists which is probably from when the file was opened with CreateFile. If anyone has an idea as to what might be wrong I would be bery gratefull for a response. The code snippet is below
!define OPEN_EXISTING 3
!define CREATE_NEW 1
!define CREATE_ALWAYS 2
!define FILE_ATTRIBUTES_NORMAL 128
!define GENERIC_WRITE 0x40000000
!define GENERIC_READ 0x80000000
System::Call Alloc 80 ; Allocate memory for read buffer
Pop $0 ; Pointer to Read Buffer
System::Call "kernel32::CreateFile(t '$INSTDIR\$1', ${GENERIC_READ},i 0, i 0, i ${OPEN_EXISTING}, i ${FILE_ATTRIBUTES_NORMAL}, i 0) i .r8"
System::Call "kernel32::GetFileSize(i r8, i 0) i .r6"
System::Call "kernel32::ReadFile(i r8, i r0, i 80, *i .r2, i 0) i .r3"
Chris Lustig