FIX: Reading Past End of Volume with FAT File Produce

Last reviewed: October 29, 1997
Article ID: Q150860
The information in this article applies to:
  • Microsoft Windows NT version 3.51

SYMPTOMS

Windows NT allows access to partitions by opening a volume using the "\\.\x:" nomenclature. When an application reads beyond the end of a volume formatted with the FAT file system, Windows NT causes the read operation to fail and GetLastError to return ERROR_INVALID_PARAMETER. This behavior is incorrect.

When an application reads beyond the end of a volume, the read operation should complete successfully, and the number of bytes read will be the count of bytes from the starting location of the read up to the end of the volume. This number may be less the number that was actually requested. Subsequent reads should also succeed, but with zero bytes actually read. This indicates the End-Of_File (EOF) condition. This is the correct behavior.

RESOLUTION

To work around the behavior of ReadFile on volumes formatted with the FAT file system, do not perform read operations that extend beyond the length of the volume. The length of the volume is determined by examining the results of the DeviceIoControl function when called with the IOCTL_DISK_GET_PARTITION_INFO control code. The PartitionLength member of the PARTITION_INFORMATION structure filled out by the IOCTL contains a pair of DWORDS that indicate the size of the volume in bytes.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Windows NT, version 4.0.

Keywords          : BseFileio buglist3.51 kbprg fixlist4.00 kbbuglist kbfixlist
Version           : 3.51
Platform          : NT WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.