阅读:1975回复:5
如何移动文件的指针
我已用ZwOpenFile打开C:盘的的某个文件
如何移动文件的指针。 好像没有ZwSetFilePointer? |
|
最新喜欢:aasa2
|
沙发#
发布于:2005-02-01 21:43
ZwSetInformationFile
The ZwSetInformationFile routine changes various kinds of information about a given file object. NTSTATUS ZwSetInformationFile( IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PVOID FileInformation, IN ULONG Length, IN FILE_INFORMATION_CLASS FileInformationClass ); Parameters FileHandle Handle to a file object. The handle is created by a successful call to ZwCreateFile or ZwOpenFile. IoStatusBlock Pointer to a variable that receives the final completion status and information about the operation. FileInformation Pointer to a buffer or variable containing the information to be set for the file. The contents of FileInformation are defined by the FileInformationClass parameter, described later. Setting any member of the structure in this buffer or variable to zero tells ZwSetInformationFile to leave the current information about the file for that member unchanged. Length Specifies the size in bytes of FileInformation, which the caller should set according to the given FileInformationClass. FileInformationClass Specifies the type of information, supplied in the buffer specified by FileInformation, to be reset for the file. Device and intermediate drivers, can specify any of the following. FileInformationClass Value Meaning FileBasicInformation Change information supplied in a FILE_BASIC_INFORMATION structure. The caller must have opened the file with the DesiredAccess FILE_WRITE_ATTRIBUTES flag set. FileDispositionInformation Usually, sets DeleteFile in FILE_DISPOSITION_INFORMATION to TRUE, so the file can be deleted when ZwClose is called to release the last open handle for the file object. The caller must have opened the file with the DesiredAccess DELETE flag set. FileEndOfFileInformation Change the current end-of-file information, supplied in a FILE_END_OF_FILE_INFORMATION structure, for the file: Either truncate or extend the amount of valid data in the file by moving the current end-of-file position. The caller must have opened the file with the DesiredAccess FILE_WRITE_DATA flag set. FilePositionInformation Change the current position information, supplied in a FILE_POSITION_INFORMATION structure, for the file. The caller must have opened the file with the DesiredAccess FILE_READ_DATA or FILE_WRITE_DATA flag set and with either of the CreateOptions FILE_SYNCHRONOUS_IO_ALERT or FILE_SYNCHRONOUS_IO_NONALERT. FileShortNameInformation Change the current short file name, supplied in a FILE_NAME_INFORMATION structure. File must be on an NTFS volume, and the caller must have opened the file with the DesiredAccess DELETE flag set. FileValidDataLengthInformation Change the current valid data length for the file, supplied in a FILE_VALID_DATA_LENGTH_INFORMATION structure. The file must be on an NTFS volume, and the caller must have opened the file with the DesiredAccess FILE_WRITE_DATA flag set. Nonadministrators and remote users must have the SeManageVolumePrivilege privilege. Return Value ZwSetInformationFile returns STATUS_SUCCESS or an appropriate error status. It also returns the number of bytes set on the file in the Information member of IoStatusBlock. Headers Declared in ntddk.h. Include ntddk.h. Comments ZwSetInformationFile changes information about a file. It ignores any member of a FILE_XXX_INFORMATION structure that is not supported by a particular device or file system. A caller that sets FileInformationClass to FileDispositionInformation can pass the FileHandle subsequently to ZwClose but to no other ZwXxxFile routine. On return from ZwSetInformationFile, the file has been marked for deletion. It is a programming error to attempt any subsequent operation on the open file except closing it. If the caller sets FileInformationClass to FilePositionInformation and the preceding call to ZwCreateFile set the CreateOptions flag FILE_NO_INTERMEDIATE_BUFFERING, certain restrictions on the input FILE_POSITION_INFORMATION CurrentByteOffset are enforced. For more information, see ZwCreateFile. If the caller sets FileInformationClass to FileEndOfFileInformation and the EndOfFile member of FILE_END_OF_FILE_INFORMATION specifies an offset beyond the current end-of-file mark, ZwSetInformationFile extends the file and writes pad bytes of zeros between the old and new end-of-file marks. Callers of ZwSetInformationFile must be running at IRQL = PASSIVE_LEVEL. |
|
|
驱动老牛
|
板凳#
发布于:2005-02-01 17:49
FilePositionInformation
ZwSetInformationFile |
|
地板#
发布于:2005-02-01 14:42
dui
|
|
|
地下室#
发布于:2003-06-16 13:43
同意楼上的看法!
|
|
5楼#
发布于:2003-06-16 09:50
在 ZwReadFile ZwWriteFile 时,都会提供一个 ByteOffset 相当于一个文件指针,读写操作从它开始。
|
|
|