0

我正在使用 WDK 的 FltReadFile 函数来读取文件。我只能读取 1kb 文件。如何读取超过 1kb 的文件?谢谢你。

offset.QuadPart = bytesRead = 0;
    status = FltReadFile( Instance,
                          FileObject,
                          &offset,
                          length,
                          buffer,
                          FLTFL_IO_OPERATION_NON_CACHED |
                          FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET,
                          &bytesRead,
                          NULL,
                          NULL );
4

1 回答 1

1

You are using the flag FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET which tells that do not update the current file position after reading a file (which generally happens).

If this flag is set, the offset parameter suggests to read from specified position by offset in the file.

So in your case, you have specified offset=0 and length=1024, it is correctly reading - 1 to 1024 - 1KB bytes from file. If you do same call again without changing offset parameter it will read same 1KB bytes.

Documentation from FltReadFile look at ByteOffset parameter documentation.

ByteOffset [in, optional] Pointer to a caller-allocated variable that specifies the starting byte offset within the file where the read operation is to begin.

If this offset is supplied, or if the FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET flag is specified in the Flags parameter, FltReadFile does not update the file object's CurrentByteOffset field.

于 2013-04-29T05:04:09.983 回答