ZwReadFile failed on Vista with files on udf formated DVD

Discussion in 'Windows Vista Drivers' started by Horst, Feb 10, 2007.

  1. Horst

    Horst Guest

    The following snippet shows some calls to ZwCreateFile and ZwReadFile which
    work fine on
    2000,2003, XP. But on Vista ZwReadFile will fail with
    STATUS_INVALID_PARAMETER. It only fails, if
    the file is located on an UDF formated DVD. If file is located on a physical
    disk, USB device or CD, everything is ok.

    ntStatus = ZwCreateFile (&hDeviceFile,
    GENERIC_READ | SYNCHRONIZE,
    &oaFileAttributes,
    &IoStatusBlock,
    NULL,
    FILE_ATTRIBUTE_NORMAL |
    FILE_ATTRIBUTE_SYSTEM,
    FILE_SHARE_READ,
    FILE_OPEN,
    FILE_NO_INTERMEDIATE_BUFFERING |
    FILE_SYNCHRONOUS_IO_NONALERT,
    NULL,
    0);

    if (!NT_SUCCESS (ntStatus))
    {
    goto error;
    }


    ntStatus = ZwReadFile (hDeviceFile,
    NULL,
    NULL,
    NULL,
    &IoStatusBlock,
    ReadBuffer,
    FIRST_READ_SIZE, // means 512 * 11 = 5632
    &BaseOffset, //it's 0
    NULL);

    --->>> here ntStatus == STATUS_INVALID_PARAMETER

    I checked the Alignment Requirement with
    #if DBG
    //Alignment Requirement
    ntStatus = ZwQueryInformationFile(hDeviceFile,
    &IoStatusBlock,
    &FileAlignmentInfo,
    sizeof (FileAlignmentInfo),
    FileAlignmentInformation);
    #endif

    FileAlignmentInfo shows 1, which means Word Boundary required. I also
    changed GENERIC_READ to
    FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA but this also changed
    nothing.

    Any ideas???

    Thanks in advance

    Horst
     
    Horst, Feb 10, 2007
    #1
    1. Advertisements

  2.  
    Matthew Carter, Feb 10, 2007
    #2
    1. Advertisements

  3. It says this in the ZwReadFile documentation:

    If the preceding call to ZwCreateFile set the FILE_NO_INTERMEDIATE_BUFFERING
    flag in the CreateOptions parameter to ZwCreateFile, the Length and
    ByteOffset parameters to ZwReadFile must be multiples of the sector size.
    For more information, see ZwCreateFile.

    Perhaps the sector size is the issue. I have no idea why the sector size
    would change in Vista, but trying a sector size that is a multiple of 2048
    should rule this out as the source of the problem. Data sectors on CDs hold
    2048 bytes of data.
     
    Matthew Carter, Feb 10, 2007
    #3
  4. Horst

    Horst Guest

    Hello Matthew,

    Thanks, it realy works with buffersizes dividable by 2048. But it's only
    necessary on UDF formated DVDs on vista.
    On a CD the Physical Device Object also says Sector Size 0x800, but you can
    use any offset and any buffersize, even on vista. I'm not quite sure, if this
    vista udf behaviour is a bug/inconsistancy or a new requirement/stricter use
    of that on the vista platform.
     
    Horst, Feb 13, 2007
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.