Archive: Win32 ReadFile buffer question


Win32 ReadFile buffer question
Hi, I am using this script to read a piece of a binary file into a buffer for later decompression:

FileOpen $R2 "${COMP_PATH}\${COMP_FILE}" r
FileSeek $R2 ${OFFSET} SET
System::Alloc 512
System::Call 'Kernel32::ReadFile(i R2, i sr4, i 512, *i 0 r5, i 0)'

But the decompression call needs an extra 8 bytes (0) in the end of the buffer ($4)

How can I do this? Thanks a lot.


Just allocate 520 bytes. System::Alloc uses GlobalAlloc with GPTR, so the memory is zeroed.


Thanks a lot :) I will try it.