|
|
#1 |
|
Junior Member
Join Date: Apr 2010
Posts: 14
|
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 |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
|
Any reason you are using that instead of FileOpen/FileRead/FileClose?
Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#3 | |
|
Junior Member
Join Date: Apr 2010
Posts: 14
|
Quote:
Chris |
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jul 2009
Posts: 33
|
My guess would be that
PHP Code:
PHP Code:
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|