The mmioAdvance function does not change the current file position of the file represented by the hmmio parameter, that is, pchNext of the MMIOINFO structure passed in the pmmioinfo parameter will correspond to the same data position before and after mmioAdvance is called, hence pointing to the same piece of data that is now located at the beginning of the buffer. mmioAdvance simply makes available as much buffer space as possible for doing direct buffer reading or writing.
When mmioAdvance returns from a call where the MMIO_READ flag was specified, there will be at least n bytes of data available to be read in the I/O buffer (that is, n bytes between pchNext and pchEndRead), where n is the lesser of the I/O buffer size and the number of remaining bytes of data.
When mmioAdvance returns from a call where the MMIO_WRITE flag was specified, at least n bytes of free space in the I/O buffer (that is, n bytes between pchNext and pchEndWrite) where n is specified in the aulInfo[0] field of the MMIOINFO structure passed on an mmioOpen called if the file is a memory file, or the size of the I/O buffer if the file is not a memory file.
If the file is opened for reading, the I/O buffer is filled from the disk. If the file is opened for writing and the MMIO_DIRTY flag is set in the ulFlags field of the MMIOINFO structure, the buffer is written to disk. The pchNext, pchEndRead, and pchEndWrite fields of the MMIOINFO structure are updated to reflect the new state of the I/O buffer.
If the file was opened for both reading and writing, and the I/O buffer was written to, the contents of the I/O buffer are written to disk before the next buffer is read.
If you have written to the I/O buffer, you must set the MMIO_DIRTY flag of the ulFlags field of the MMIOINFO structure before calling mmioAdvance. Otherwise, the buffer will not be written to disk.
The pchNext field must also be updated to reflect the data written in the I/O buffer. The I/O buffer will be written up to (but not including) the position indicated by the pchNext field of MMIOINFO.