📄 fileinfo.c
字号:
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is for the fast query call for basic file information.
Arguments:
FileObject - Supplies the file object used in this operation
Wait - Indicates if we are allowed to wait for the information
Buffer - Supplies the output buffer to receive the basic information
IoStatus - Receives the final status of the operation
Return Value:
BOOLEAN - TRUE if the operation succeeded and FALSE if the caller
needs to take the long route.
--*/
{
BOOLEAN Result = FALSE;
TYPE_OF_OPEN TypeOfOpen;
PFCB Fcb;
PCCB Ccb;
PAGED_CODE();
ASSERT_FILE_OBJECT( FileObject );
FsRtlEnterFileSystem();
//
// Decode the file object to find the type of open and the data
// structures.
//
TypeOfOpen = UdfDecodeFileObject( FileObject, &Fcb, &Ccb );
//
// We only support this request on user file or directory objects.
//
ASSERT( FlagOn( Fcb->FcbState, FCB_STATE_INITIALIZED ));
if (TypeOfOpen != UserFileOpen && TypeOfOpen != UserDirectoryOpen) {
FsRtlExitFileSystem();
return FALSE;
}
//
// Acquire the file shared to access the Fcb.
//
if (!ExAcquireResourceShared( Fcb->Resource, Wait )) {
FsRtlExitFileSystem();
return FALSE;
}
//
// Use a try-finally to facilitate cleanup.
//
try {
//
// Only deal with 'good' Fcb's.
//
if (UdfVerifyFcbOperation( NULL, Fcb )) {
//
// Fill in the input buffer from the Fcb fields.
//
Buffer->CreationTime = Fcb->Timestamps.CreationTime;
Buffer->LastWriteTime =
Buffer->ChangeTime = Fcb->Timestamps.ModificationTime;
Buffer->LastAccessTime = Fcb->Timestamps.AccessTime;
Buffer->FileAttributes = Fcb->FileAttributes | UdfGetExtraFileAttributes( Ccb );
//
// Update the IoStatus block with the size of this data.
//
IoStatus->Status = STATUS_SUCCESS;
IoStatus->Information = sizeof( FILE_BASIC_INFORMATION );
Result = TRUE;
}
} finally {
ExReleaseResource( Fcb->Resource );
FsRtlExitFileSystem();
}
return Result;
}
BOOLEAN
UdfFastQueryStdInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
IN OUT PFILE_STANDARD_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is for the fast query call for standard file information.
Arguments:
FileObject - Supplies the file object used in this operation
Wait - Indicates if we are allowed to wait for the information
Buffer - Supplies the output buffer to receive the basic information
IoStatus - Receives the final status of the operation
Return Value:
BOOLEAN - TRUE if the operation succeeded and FALSE if the caller
needs to take the long route.
--*/
{
BOOLEAN Result = FALSE;
TYPE_OF_OPEN TypeOfOpen;
PFCB Fcb;
PAGED_CODE();
ASSERT_FILE_OBJECT( FileObject );
FsRtlEnterFileSystem();
//
// Decode the file object to find the type of open and the data
// structures.
//
TypeOfOpen = UdfFastDecodeFileObject( FileObject, &Fcb );
//
// We only support this request on initialized user file or directory objects.
//
if (TypeOfOpen != UserFileOpen && TypeOfOpen != UserDirectoryOpen) {
FsRtlExitFileSystem();
return FALSE;
}
//
// Acquire the file shared to access the Fcb.
//
if (!ExAcquireResourceShared( Fcb->Resource, Wait )) {
FsRtlExitFileSystem();
return FALSE;
}
//
// Use a try-finally to facilitate cleanup.
//
try {
//
// Only deal with 'good' Fcb's.
//
if (UdfVerifyFcbOperation( NULL, Fcb )) {
//
// Check whether this is a directory.
//
if (FlagOn( Fcb->FileAttributes, FILE_ATTRIBUTE_DIRECTORY )) {
Buffer->AllocationSize.QuadPart =
Buffer->EndOfFile.QuadPart = 0;
Buffer->Directory = TRUE;
} else {
Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
Buffer->Directory = FALSE;
}
Buffer->NumberOfLinks = Fcb->LinkCount;
Buffer->DeletePending = FALSE;
//
// Update the IoStatus block with the size of this data.
//
IoStatus->Status = STATUS_SUCCESS;
IoStatus->Information = sizeof( FILE_STANDARD_INFORMATION );
Result = TRUE;
}
} finally {
ExReleaseResource( Fcb->Resource );
FsRtlExitFileSystem();
}
return Result;
}
BOOLEAN
UdfFastQueryNetworkInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is for the fast query call for network file information.
Arguments:
FileObject - Supplies the file object used in this operation
Wait - Indicates if we are allowed to wait for the information
Buffer - Supplies the output buffer to receive the basic information
IoStatus - Receives the final status of the operation
Return Value:
BOOLEAN - TRUE if the operation succeeded and FALSE if the caller
needs to take the long route.
--*/
{
BOOLEAN Result = FALSE;
TYPE_OF_OPEN TypeOfOpen;
PFCB Fcb;
PCCB Ccb;
PAGED_CODE();
ASSERT_FILE_OBJECT( FileObject );
FsRtlEnterFileSystem();
//
// Decode the file object to find the type of open and the data
// structures.
//
TypeOfOpen = UdfDecodeFileObject( FileObject, &Fcb, &Ccb );
//
// We only support this request on user file or directory objects.
//
if (TypeOfOpen != UserFileOpen && TypeOfOpen != UserDirectoryOpen) {
FsRtlExitFileSystem();
return FALSE;
}
//
// Acquire the file shared to access the Fcb.
//
if (!ExAcquireResourceShared( Fcb->Resource, Wait )) {
FsRtlExitFileSystem();
return FALSE;
}
//
// Use a try-finally to facilitate cleanup.
//
try {
//
// Only deal with 'good' Fcb's.
//
if (UdfVerifyFcbOperation( NULL, Fcb )) {
//
// Fill in the input buffer from the Fcb fields.
//
Buffer->CreationTime = Fcb->Timestamps.CreationTime;
Buffer->LastWriteTime =
Buffer->ChangeTime = Fcb->Timestamps.ModificationTime;
Buffer->LastAccessTime = Fcb->Timestamps.AccessTime;
Buffer->FileAttributes = Fcb->FileAttributes | UdfGetExtraFileAttributes( Ccb );
//
// Check whether this is a directory.
//
if (FlagOn( Fcb->FileAttributes, FILE_ATTRIBUTE_DIRECTORY )) {
Buffer->AllocationSize.QuadPart =
Buffer->EndOfFile.QuadPart = 0;
} else {
Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
}
//
// Update the IoStatus block with the size of this data.
//
IoStatus->Status = STATUS_SUCCESS;
IoStatus->Information = sizeof( FILE_NETWORK_OPEN_INFORMATION );
Result = TRUE;
}
} finally {
ExReleaseResource( Fcb->Resource );
FsRtlExitFileSystem();
}
return Result;
}
//
// Local support routine
//
VOID
UdfQueryBasicInfo (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN PCCB Ccb,
IN OUT PFILE_BASIC_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Description:
This routine performs the query basic information function for Udfs
Arguments:
Fcb - Supplies the Fcb being queried, it has been verified
Ccb - Supplies the Ccb associated with the fileobject being queried
Buffer - Supplies a pointer to the buffer where the information is to
be returned
Length - Supplies the length of the buffer in bytes, and receives the
remaining bytes free in the buffer upon return.
Return Value:
None
--*/
{
PAGED_CODE();
//
// We support all times on Udfs.
//
Buffer->CreationTime = Fcb->Timestamps.CreationTime;
Buffer->LastWriteTime =
Buffer->ChangeTime = Fcb->Timestamps.ModificationTime;
Buffer->LastAccessTime = Fcb->Timestamps.AccessTime;
Buffer->FileAttributes = Fcb->FileAttributes | UdfGetExtraFileAttributes( Ccb );
//
// Update the length and status output variables
//
*Length -= sizeof( FILE_BASIC_INFORMATION );
return;
}
//
// Local support routine
//
VOID
UdfQueryStandardInfo (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN OUT PFILE_STANDARD_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine performs the query standard information function for Udfs.
Arguments:
Fcb - Supplies the Fcb being queried, it has been verified
Buffer - Supplies a pointer to the buffer where the information is to
be returned
Length - Supplies the length of the buffer in bytes, and receives the
remaining bytes free in the buffer upon return.
Return Value:
None
--*/
{
PAGED_CODE();
//
// Delete is never pending on a readonly file.
//
Buffer->NumberOfLinks = Fcb->LinkCount;
Buffer->DeletePending = FALSE;
//
// We get the sizes from the header. Return a size of zero
// for all directories.
//
if (FlagOn( Fcb->FileAttributes, FILE_ATTRIBUTE_DIRECTORY )) {
Buffer->AllocationSize.QuadPart =
Buffer->EndOfFile.QuadPart = 0;
Buffer->Directory = TRUE;
} else {
Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
Buffer->Directory = FALSE;
}
//
// Update the length and status output variables
//
*Length -= sizeof( FILE_STANDARD_INFORMATION );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -