📄 udfprocs.h
字号:
(F)->Vcb->VcbCleanup -= 1; \
}
#define UdfIncrementReferenceCounts(IC,F,C,UC) { \
ASSERT_LOCKED_VCB( (F)->Vcb ); \
(F)->FcbReference += (C); \
(F)->FcbUserReference += (UC); \
(F)->Vcb->VcbReference += (C); \
(F)->Vcb->VcbUserReference += (UC); \
}
#define UdfDecrementReferenceCounts(IC,F,C,UC) { \
ASSERT_LOCKED_VCB( (F)->Vcb ); \
(F)->FcbReference -= (C); \
(F)->FcbUserReference -= (UC); \
(F)->Vcb->VcbReference -= (C); \
(F)->Vcb->VcbUserReference -= (UC); \
}
VOID
UdfTeardownStructures (
IN PIRP_CONTEXT IrpContext,
IN PFCB StartingFcb,
IN BOOLEAN Recursive,
OUT PBOOLEAN RemovedStartingFcb
);
PFCB
UdfLookupFcbTable (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN FILE_ID FileId
);
PFCB
UdfGetNextFcb (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN PVOID *RestartKey
);
PFCB
UdfCreateFcb (
IN PIRP_CONTEXT IrpContext,
IN FILE_ID FileId,
IN NODE_TYPE_CODE NodeTypeCode,
OUT PBOOLEAN FcbExisted OPTIONAL
);
VOID
UdfDeleteFcb (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb
);
VOID
UdfInitializeFcbFromIcbContext (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN PICB_SEARCH_CONTEXT IcbContext
);
PCCB
UdfCreateCcb (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN PLCB Lcb OPTIONAL,
IN ULONG Flags
);
VOID
UdfDeleteCcb (
IN PIRP_CONTEXT IrpContext,
IN PCCB Ccb
);
ULONG
UdfFindInParseTable (
IN PPARSE_KEYVALUE ParseTable,
IN PCHAR Id,
IN ULONG MaxIdLen
);
BOOLEAN
UdfVerifyDescriptor (
IN PIRP_CONTEXT IrpContext,
IN PDESTAG Descriptor,
IN USHORT Tag,
IN ULONG Size,
IN ULONG Lbn,
IN BOOLEAN ReturnError
);
VOID
UdfInitializeIcbContextFromFcb (
IN PIRP_CONTEXT IrpContext,
IN PICB_SEARCH_CONTEXT IcbContext,
IN PFCB Fcb
);
VOID
UdfInitializeIcbContext (
IN PIRP_CONTEXT IrpContext,
IN PICB_SEARCH_CONTEXT IcbContext,
IN PVCB Vcb,
IN USHORT IcbType,
IN USHORT Partition,
IN ULONG Lbn,
IN ULONG Length
);
INLINE
VOID
UdfFastInitializeIcbContext (
IN PIRP_CONTEXT IrpContext,
IN PICB_SEARCH_CONTEXT IcbContext
)
{
RtlZeroMemory( IcbContext, sizeof( ICB_SEARCH_CONTEXT ));
}
VOID
UdfLookupActiveIcb (
IN PIRP_CONTEXT IrpContext,
IN PICB_SEARCH_CONTEXT IcbContext
);
VOID
UdfCleanupIcbContext (
IN PIRP_CONTEXT IrpContext,
IN PICB_SEARCH_CONTEXT IcbContext
);
VOID
UdfInitializeAllocations (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN PICB_SEARCH_CONTEXT IcbContext
);
VOID
UdfUpdateTimestampsFromIcbContext (
IN PIRP_CONTEXT IrpContext,
IN PICB_SEARCH_CONTEXT IcbContext,
IN PTIMESTAMP_BUNDLE Timestamps
);
BOOLEAN
UdfCreateFileLock (
IN PIRP_CONTEXT IrpContext OPTIONAL,
IN PFCB Fcb,
IN BOOLEAN RaiseOnError
);
//
// The following macro converts from UDF time to NT time.
//
INLINE
VOID
UdfConvertUdfTimeToNtTime (
IN PIRP_CONTEXT IrpContext,
IN PTIMESTAMP UdfTime,
OUT PLARGE_INTEGER NtTime
)
{
TIME_FIELDS TimeField;
TimeField.Year = UdfTime->Year;
TimeField.Month = UdfTime->Month;
TimeField.Day = UdfTime->Day;
TimeField.Hour = UdfTime->Hour;
TimeField.Minute = UdfTime->Minute;
TimeField.Second = UdfTime->Second;
//
// This is where it gets hairy. For some unholy reason, ISO 13346 timestamps
// carve the right of the decimal point up into three fields of precision
// 10-2, 10-4, and 10-6, each ranging from 0-99. Lawdy.
//
// To make it easier, since they cannot cause a wrap into the next second,
// just save it all up and add it in after the conversion.
//
TimeField.Milliseconds = 0;
if (UdfTime->Type <= 1 &&
((UdfTime->Zone >= TIMESTAMP_Z_MIN && UdfTime->Zone <= TIMESTAMP_Z_MAX) ||
UdfTime->Zone == TIMESTAMP_Z_NONE) &&
RtlTimeFieldsToTime( &TimeField, NtTime )) {
//
// Now fold in the remaining sub-second "precision". Read as coversions
// through the 10-3 units, then into our 10-7 base. (centi->milli->micro,
// etc).
//
NtTime->QuadPart += ((UdfTime->CentiSecond * (10 * 1000)) +
(UdfTime->Usec100 * 100) +
UdfTime->Usec) * 10;
//
// Perform TZ normalization if this is a local time with
// specified timezone.
//
if (UdfTime->Type == 1 && UdfTime->Zone != TIMESTAMP_Z_NONE) {
NtTime->QuadPart += Int32x32To64( -UdfTime->Zone, (60 * 10 * 1000 * 1000) );
}
} else {
//
// Epoch. Malformed timestamp.
//
NtTime->QuadPart = 0;
}
}
//
// An equivalence test for Entity IDs.
//
INLINE
BOOLEAN
UdfEqualEntityId (
IN PREGID RegID,
IN PSTRING Id,
IN OPTIONAL PSTRING Suffix
)
{
return (UdfEqualCountedString( Id, RegID->Identifier ) &&
#ifndef UDF_SUPPORT_NONSTANDARD_ENTITY_STRINGTERM
//
// Allow disabling of the check that the identifier
// seems to be padded with zero.
//
// Reason: a couple samples that are otherwise useful
// padded some identifiers with junk.
//
((Id->Length == sizeof(RegID->Identifier) ||
RegID->Identifier[Id->Length] == '\0') ||
!DebugTrace(( 0, Dbg,
"UdfEqualEntityId, RegID seems to be terminated with junk!\n" ))) &&
#endif
((Suffix == NULL) || UdfEqualCountedString( Suffix, RegID->Suffix )));
}
//
// A Domain Identifier RegID is considered to be contained if the
// text string identifier matches and the revision is less than or
// equal. This is the convenient way to check that a Domain ID
// indicates a set of structures will be intelligible to a given
// implementation level.
//
INLINE
BOOLEAN
UdfDomainIdentifierContained (
IN PREGID RegID,
IN PSTRING Domain,
IN USHORT RevisionMin,
IN USHORT RevisionMax
)
{
PUDF_SUFFIX_DOMAIN DomainSuffix = (PUDF_SUFFIX_DOMAIN) RegID->Suffix;
#ifdef UDF_SUPPORT_NONSTANDARD_ALLSTOR
//
// Disable checking of the UDF revision.
//
// Reason: first drop of Allstor media recorded the version number as
// a decimal number, not hex (102 = 0x66)
//
return (UdfEqualEntityId( RegID, Domain, NULL ));
#else
return ((DomainSuffix->UdfRevision <= RevisionMax && DomainSuffix->UdfRevision >= RevisionMin) &&
UdfEqualEntityId( RegID, Domain, NULL ));
#endif
}
//
// In like fashion, we define containment for a UDF Identifier RegID.
//
INLINE
BOOLEAN
UdfUdfIdentifierContained (
IN PREGID RegID,
IN PSTRING Type,
IN USHORT RevisionMin,
IN USHORT RevisionMax,
IN UCHAR OSClass,
IN UCHAR OSIdentifier
)
{
PUDF_SUFFIX_UDF UdfSuffix = (PUDF_SUFFIX_UDF) RegID->Suffix;
return ((UdfSuffix->UdfRevision <= RevisionMax && UdfSuffix->UdfRevision >= RevisionMin) &&
(OSClass == OSCLASS_INVALID || UdfSuffix->OSClass == OSClass) &&
(OSIdentifier == OSIDENTIFIER_INVALID || UdfSuffix->OSIdentifier == OSIdentifier) &&
UdfEqualEntityId( RegID, Type, NULL ));
}
//
// Verification support routines. Contained in verfysup.c
//
BOOLEAN
UdfCheckForDismount (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN BOOLEAN Force
);
BOOLEAN
UdfDismountVcb (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb
);
VOID
UdfVerifyVcb (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb
);
BOOLEAN
UdfVerifyFcbOperation (
IN PIRP_CONTEXT IrpContext OPTIONAL,
IN PFCB Fcb
);
//
// BOOLEAN
// UdfIsRawDevice (
// IN PIRP_CONTEXT IrpContext,
// IN NTSTATUS Status
// );
//
#define UdfIsRawDevice(IC,S) ( \
((S) == STATUS_DEVICE_NOT_READY) || \
((S) == STATUS_NO_MEDIA_IN_DEVICE) \
)
//
// Volume Mapped Control Blocks routines, implemented in VmcbSup.c
//
VOID
UdfInitializeVmcb (
IN PVMCB Vmcb,
IN POOL_TYPE PoolType,
IN ULONG MaximumLbn,
IN ULONG LbSize
);
VOID
UdfUninitializeVmcb (
IN PVMCB Vmcb
);
VOID
UdfResetVmcb (
IN PVMCB Vmcb
);
VOID
UdfSetMaximumLbnVmcb (
IN PVMCB Vmcb,
IN ULONG MaximumLbn
);
BOOLEAN
UdfVmcbVbnToLbn (
IN PVMCB Vmcb,
IN VBN Vbn,
OUT PLBN Lbn,
OUT PULONG SectorCount OPTIONAL
);
BOOLEAN
UdfVmcbLbnToVbn (
IN PVMCB Vmcb,
IN LBN Lbn,
OUT PVBN Vbn,
OUT PULONG SectorCount OPTIONAL
);
BOOLEAN
UdfAddVmcbMapping (
IN PVMCB Vmcb,
IN LBN Lbn,
IN ULONG SectorCount,
IN BOOLEAN ExactEnd,
OUT PVBN Vbn,
OUT PULONG AlignedSectorCount
);
VOID
UdfRemoveVmcbMapping (
IN PVMCB Vmcb,
IN LBN Lbn,
IN ULONG SectorCount
);
//
// Routines to verify the correspondance of the underlying media, implemented in
// verfysup.c
//
NTSTATUS
UdfPerformVerify (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PDEVICE_OBJECT DeviceToVerify
);
//
// Work queue routines for posting and retrieving an Irp, implemented in
// workque.c
//
NTSTATUS
UdfFsdPostRequest(
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
VOID
UdfPrePostIrp (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
VOID
UdfOplockComplete (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
//
// Charspecs are small containers that specify a CS<N> type and a text
// string specifying a version, etc. This is a convenient way of bottling
// up equivalence checks of a charspec.
//
INLINE
BOOLEAN
UdfEqualCharspec (
IN PCHARSPEC Charspec,
IN PSTRING Identifier,
IN UCHAR Type
)
{
return ((Charspec->Type == Type) && UdfEqualCountedString( Identifier, Charspec->Info));
}
//
// The FSP level dispatch/main routine. This is the routine that takes
// IRP's off of the work queue and calls the appropriate FSP level
// work routine.
//
VOID
UdfFspDispatch ( // implemented in FspDisp.c
IN PIRP_CONTEXT IrpContext
);
VOID
UdfFspClose ( // Implemented in Close.c
IN PVCB Vcb OPTIONAL
);
//
// The following routines are the entry points for the different operations
// based on the IrpSp major functions.
//
NTSTATUS
UdfCommonCleanup ( // Implemented in Cleanup.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
UdfCommonClose ( // Implemented in Close.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
UdfCommonCreate ( // Implemented in Create.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in DevCtrl.c
UdfCommonDevControl (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in DirCtrl.c
UdfCommonDirControl (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
UdfCommonFsControl ( // Implemented in FsCtrl.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in LockCtrl.c
UdfCommonLockControl (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in Pnp.c
UdfCommonPnp (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in FileInfo.c
UdfCommonQueryInfo (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in VolInfo.c
UdfCommonQueryVolInfo (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in Read.c
UdfCommonRead (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS // Implemented in FileInfo.c
UdfCommonSetInfo (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
//
// Clean up our internal-to-the-header definitions so they do not leak out.
//
#undef BugCheckFileId
#undef Dbg
#endif // _UDFPROCS_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -