📄 fileinfo.c
字号:
return;
}
//
// Local support routine
//
VOID
UdfQueryInternalInfo (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN OUT PFILE_INTERNAL_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine performs the query internal 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();
//
// Index number is the file Id number in the Fcb.
//
Buffer->IndexNumber = Fcb->FileId;
*Length -= sizeof( FILE_INTERNAL_INFORMATION );
return;
}
//
// Local support routine
//
VOID
UdfQueryEaInfo (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN OUT PFILE_EA_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine performs the query Ea 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();
//
// No Ea's on Udfs volumes. At least not that our EA support would understand.
//
Buffer->EaSize = 0;
*Length -= sizeof( FILE_EA_INFORMATION );
return;
}
//
// Local support routine
//
VOID
UdfQueryPositionInfo (
IN PIRP_CONTEXT IrpContext,
IN PFILE_OBJECT FileObject,
IN OUT PFILE_POSITION_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine performs the query position information function for Udfs.
Arguments:
FileObject - Supplies the File object 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();
//
// Get the current position found in the file object.
//
Buffer->CurrentByteOffset = FileObject->CurrentByteOffset;
//
// Update the length and status output variables
//
*Length -= sizeof( FILE_POSITION_INFORMATION );
return;
}
//
// Local support routine
//
NTSTATUS
UdfQueryNameInfo (
IN PIRP_CONTEXT IrpContext,
IN PFILE_OBJECT FileObject,
IN OUT PFILE_NAME_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine performs the query name information function for Udfs.
Arguments:
FileObject - Supplies the file object containing the name.
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:
NTSTATUS - STATUS_BUFFER_OVERFLOW if the entire name can't be copied.
--*/
{
NTSTATUS Status = STATUS_SUCCESS;
ULONG LengthToCopy;
PAGED_CODE();
ASSERT(*Length >= sizeof(ULONG));
//
// Simply copy the name in the file object to the user's buffer.
//
//
// Place the size of the filename in the user's buffer and reduce the remaining
// size to match.
//
Buffer->FileNameLength = LengthToCopy = FileObject->FileName.Length;
*Length -= sizeof(ULONG);
if (LengthToCopy > *Length) {
LengthToCopy = *Length;
Status = STATUS_BUFFER_OVERFLOW;
}
RtlCopyMemory( Buffer->FileName, FileObject->FileName.Buffer, LengthToCopy );
//
// Reduce the available bytes by the amount stored into this buffer. In the overflow
// case, this simply drops to zero. The returned filenamelength will indicate to the
// caller how much space is required.
//
*Length -= LengthToCopy;
return Status;
}
//
// Local support routine
//
NTSTATUS
UdfQueryAlternateNameInfo (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN PCCB Ccb,
IN OUT PFILE_NAME_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine performs the query alternate name information function.
We lookup the dirent for this file and then check if there is a
short name.
Arguments:
Fcb - Supplies the Fcb being queried, it has been verified.
Ccb - Ccb for this open handle.
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:
NTSTATUS - STATUS_SUCCESS if the whole name would fit into the user buffer,
STATUS_OBJECT_NAME_NOT_FOUND if we can't return the name,
STATUS_BUFFER_OVERFLOW otherwise.
--*/
{
NTSTATUS Status = STATUS_SUCCESS;
DIR_ENUM_CONTEXT DirContext;
PLCB Lcb;
PFCB ParentFcb;
BOOLEAN ReleaseParentFcb = FALSE;
BOOLEAN CleanupDirContext = FALSE;
BOOLEAN Result;
PUNICODE_STRING ShortName;
UNICODE_STRING LocalShortName;
WCHAR LocalShortNameBuffer[ BYTE_COUNT_8_DOT_3 / sizeof(WCHAR) ];
PAGED_CODE();
//
// Initialize the buffer length to zero.
//
Buffer->FileNameLength = 0;
//
// If there was no associated Lcb then there is no short name.
//
Lcb = Ccb->Lcb;
if (Lcb == NULL) {
return STATUS_OBJECT_NAME_NOT_FOUND;
}
//
// Use a try-finally to cleanup the structures.
//
try {
if (FlagOn( Lcb->Flags, LCB_FLAG_SHORT_NAME )) {
//
// This caller opened the file by a generated short name, so simply hand it back.
//
ShortName = &Lcb->FileName;
} else {
//
// The open occured by a regular name. Now, if this name is already 8.3 legal then
// there is no short name.
//
if (UdfIs8dot3Name( IrpContext, Lcb->FileName )) {
try_leave( Status = STATUS_OBJECT_NAME_NOT_FOUND );
}
//
// This name has a generated short name. In order to calculate this name we have to
// retrieve the FID for this file, since UDF specifies that a short name is uniquified
// with a CRC of the original in-FID byte representation of the filename.
//
// N.B.: if this is a common operation, we may wish to cache the CRC in the Lcb.
//
ParentFcb = Lcb->ParentFcb;
UdfAcquireFileShared( IrpContext, ParentFcb );
ReleaseParentFcb = TRUE;
//
// Now go find the FID for this filename in the parent.
//
UdfInitializeDirContext( IrpContext, &DirContext );
CleanupDirContext = TRUE;
Result = UdfFindDirEntry( IrpContext,
ParentFcb,
&Lcb->FileName,
BooleanFlagOn( Lcb->Flags, LCB_FLAG_IGNORE_CASE ),
FALSE,
&DirContext );
//
// We should always be able to find this entry, but don't bugcheck because
// we screwed this up.
//
ASSERT( Result );
if (!Result) {
try_leave( Status = STATUS_OBJECT_NAME_NOT_FOUND );
}
//
// Build the local unicode string to use and fill it in.
//
ShortName = &LocalShortName;
LocalShortName.Buffer = LocalShortNameBuffer;
LocalShortName.Length = 0;
LocalShortName.MaximumLength = sizeof( LocalShortNameBuffer );
UdfGenerate8dot3Name( IrpContext,
&DirContext.CaseObjectName,
ShortName );
}
//
// We now have the short name. We have left it in Unicode form so copy it directly.
//
Buffer->FileNameLength = ShortName->Length;
if (Buffer->FileNameLength + sizeof( ULONG ) > *Length) {
Buffer->FileNameLength = *Length - sizeof( ULONG );
Status = STATUS_BUFFER_OVERFLOW;
}
RtlCopyMemory( Buffer->FileName, ShortName->Buffer, Buffer->FileNameLength );
} finally {
if (CleanupDirContext) {
UdfCleanupDirContext( IrpContext, &DirContext );
}
if (ReleaseParentFcb) {
UdfReleaseFile( IrpContext, ParentFcb );
}
}
//
// Reduce the available bytes by the amount stored into this buffer.
//
if (Status != STATUS_OBJECT_NAME_NOT_FOUND) {
*Length -= sizeof( ULONG ) + Buffer->FileNameLength;
}
return Status;
}
//
// Local support routine
//
VOID
UdfQueryNetworkInfo (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN PCCB Ccb,
IN OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Description:
This routine performs the query network open 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();
//
// 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 );
//
// 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;
} else {
Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
}
//
// Update the length and status output variables
//
*Length -= sizeof( FILE_NETWORK_OPEN_INFORMATION );
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -