📄 fatprocs.h
字号:
);
VOID
FatFspClose ( // implemented in Close.c
IN PVCB Vcb OPTIONAL
);
NTSTATUS
FatCommonCreate ( // implemented in Create.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonDirectoryControl ( // implemented in DirCtrl.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonDeviceControl ( // implemented in DevCtrl.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonQueryEa ( // implemented in Ea.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonSetEa ( // implemented in Ea.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonQueryInformation ( // implemented in FileInfo.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonSetInformation ( // implemented in FileInfo.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonFlushBuffers ( // implemented in Flush.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonFileSystemControl ( // implemented in FsCtrl.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonLockControl ( // implemented in LockCtrl.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonPnp ( // implemented in Pnp.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonRead ( // implemented in Read.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonShutdown ( // implemented in Shutdown.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonQueryVolumeInfo ( // implemented in VolInfo.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonSetVolumeInfo ( // implemented in VolInfo.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
NTSTATUS
FatCommonWrite ( // implemented in Write.c
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
//
// The following is implemented in Flush.c, and does what is says.
//
NTSTATUS
FatFlushFile (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb,
IN FAT_FLUSH_TYPE FlushType
);
NTSTATUS
FatFlushDirectory (
IN PIRP_CONTEXT IrpContext,
IN PDCB Dcb,
IN FAT_FLUSH_TYPE FlushType
);
NTSTATUS
FatFlushFat (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb
);
NTSTATUS
FatFlushVolume (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN FAT_FLUSH_TYPE FlushType
);
NTSTATUS
FatHijackIrpAndFlushDevice (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PDEVICE_OBJECT TargetDeviceObject
);
VOID
FatFlushFatEntries (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN ULONG Cluster,
IN ULONG Count
);
VOID
FatFlushDirentForFile (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb
);
//
// The following procedure is used by the FSP and FSD routines to complete
// an IRP.
//
// Note that this macro allows either the Irp or the IrpContext to be
// null, however the only legal order to do this in is:
//
// FatCompleteRequest( NULL, Irp, Status ); // completes Irp & preserves context
// ...
// FatCompleteRequest( IrpContext, NULL, DontCare ); // deallocates context
//
// This would typically be done in order to pass a "naked" IrpContext off to
// the Fsp for post processing, such as read ahead.
//
VOID
FatCompleteRequest_Real (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN NTSTATUS Status
);
#define FatCompleteRequest(IRPCONTEXT,IRP,STATUS) { \
FatCompleteRequest_Real(IRPCONTEXT,IRP,STATUS); \
}
BOOLEAN
FatIsIrpTopLevel (
IN PIRP Irp
);
//
// The Following routine makes a popup
//
VOID
FatPopUpFileCorrupt (
IN PIRP_CONTEXT IrpContext,
IN PFCB Fcb
);
//
// Here are the callbacks used by the I/O system for checking for fast I/O or
// doing a fast query info call, or doing fast lock calls.
//
BOOLEAN
FatFastIoCheckIfPossible (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
IN BOOLEAN CheckForReadOperation,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
FatFastQueryBasicInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
IN OUT PFILE_BASIC_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
FatFastQueryStdInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
IN OUT PFILE_STANDARD_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
FatFastQueryNetworkOpenInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
IN OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
FatFastLock (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
PEPROCESS ProcessId,
ULONG Key,
BOOLEAN FailImmediately,
BOOLEAN ExclusiveLock,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
FatFastUnlockSingle (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
PEPROCESS ProcessId,
ULONG Key,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
FatFastUnlockAll (
IN PFILE_OBJECT FileObject,
PEPROCESS ProcessId,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
FatFastUnlockAllByKey (
IN PFILE_OBJECT FileObject,
PVOID ProcessId,
ULONG Key,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
VOID
FatExamineFatEntries(
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN ULONG StartIndex OPTIONAL,
IN ULONG EndIndex OPTIONAL,
IN BOOLEAN SetupWindows,
IN PFAT_WINDOW SwitchToWindow OPTIONAL,
IN PULONG BitMapBuffer OPTIONAL
);
BOOLEAN
FatScanForDataTrack(
IN PIRP_CONTEXT IrpContext,
IN PDEVICE_OBJECT TargetDeviceObject
);
//
// The following macro is used to determine is a file has been deleted.
//
// BOOLEAN
// IsFileDeleted (
// IN PIRP_CONTEXT IrpContext,
// IN PFCB Fcb
// );
//
#define IsFileDeleted(IRPCONTEXT,FCB) \
(FlagOn((FCB)->FcbState, FCB_STATE_DELETE_ON_CLOSE) && \
((FCB)->UncleanCount == 0))
//
// The following macro is used by the dispatch routines to determine if
// an operation is to be done with or without Write Through.
//
// BOOLEAN
// IsFileWriteThrough (
// IN PFILE_OBJECT FileObject,
// IN PVCB Vcb
// );
//
#define IsFileWriteThrough(FO,VCB) ( \
BooleanFlagOn((FO)->Flags, FO_WRITE_THROUGH) \
)
//
// The following macro is used to set the is fast i/o possible field in
// the common part of the nonpaged fcb
//
//
// BOOLEAN
// FatIsFastIoPossible (
// IN PFCB Fcb
// );
//
#define FatIsFastIoPossible(FCB) ((BOOLEAN) \
(((FCB)->FcbCondition != FcbGood || !FsRtlOplockIsFastIoPossible( &(FCB)->Specific.Fcb.Oplock )) ? \
FastIoIsNotPossible \
: \
(!FsRtlAreThereCurrentFileLocks( &(FCB)->Specific.Fcb.FileLock ) && \
((FCB)->NonPaged->OutstandingAsyncWrites == 0) && \
!FlagOn( (FCB)->Vcb->VcbState, VCB_STATE_FLAG_WRITE_PROTECTED ) ? \
FastIoIsPossible \
: \
FastIoIsQuestionable \
) \
) \
)
//
// The following macro is used to detemine if the file object is opened
// for read only access (i.e., it is not also opened for write access or
// delete access).
//
// BOOLEAN
// IsFileObjectReadOnly (
// IN PFILE_OBJECT FileObject
// );
//
#define IsFileObjectReadOnly(FO) (!((FO)->WriteAccess | (FO)->DeleteAccess))
//
// The following two macro are used by the Fsd/Fsp exception handlers to
// process an exception. The first macro is the exception filter used in the
// Fsd/Fsp to decide if an exception should be handled at this level.
// The second macro decides if the exception is to be finished off by
// completing the IRP, and cleaning up the Irp Context, or if we should
// bugcheck. Exception values such as STATUS_FILE_INVALID (raised by
// VerfySup.c) cause us to complete the Irp and cleanup, while exceptions
// such as accvio cause us to bugcheck.
//
// The basic structure for fsd/fsp exception handling is as follows:
//
// FatFsdXxx(...)
// {
// try {
//
// ...
//
// } except(FatExceptionFilter( IrpContext, GetExceptionCode() )) {
//
// Status = FatProcessException( IrpContext, Irp, GetExceptionCode() );
// }
//
// Return Status;
// }
//
// To explicitly raise an exception that we expect, such as
// STATUS_FILE_INVALID, use the below macro FatRaiseStatus(). To raise a
// status from an unknown origin (such as CcFlushCache()), use the macro
// FatNormalizeAndRaiseStatus. This will raise the status if it is expected,
// or raise STATUS_UNEXPECTED_IO_ERROR if it is not.
//
// If we are vicariously handling exceptions without using FatProcessException(),
// if there is the possibility that we raised that exception, one *must*
// reset the IrpContext so a subsequent raise in the course of handling this
// request that is *not* explicit, i.e. like a pagein error, does not get
// spoofed into believing that the first raise status is the reason the second
// occured. This could have really nasty consequences.
//
// It is an excellent idea to always FatResetExceptionState in these cases.
//
// Note that when using these two macros, the original status is placed in
// IrpContext->ExceptionStatus, signaling FatExceptionFilter and
// FatProcessException that the status we actually raise is by definition
// expected.
//
ULONG
FatExceptionFilter (
IN PIRP_CONTEXT IrpContext,
IN PEXCEPTION_POINTERS ExceptionPointer
);
#if DBG
ULONG
FatBugCheckExceptionFilter (
IN PEXCEPTION_POINTERS ExceptionPointer
);
#endif
NTSTATUS
FatProcessException (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN NTSTATUS ExceptionCode
);
//
// VOID
// FatRaiseStatus (
// IN PRIP_CONTEXT IrpContext,
// IN NT_STATUS Status
// );
//
//
#if DBG
#define DebugBreakOnStatus(S) { \
if (FatTestRaisedStatus) { \
if ((S) == STATUS_DISK_CORRUPT_ERROR || (S) == STATUS_FILE_CORRUPT_ERROR) { \
DbgPrint( "FAT: Breaking on interesting raised status (%08x)\n", (S) ); \
DbgPrint( "FAT: Set FatTestRaisedStatus @ %08x to 0 to disable\n", \
&FatTestRaisedStatus ); \
DbgBreakPoint(); \
} \
} \
}
#else
#define DebugBreakOnStatus(S)
#endif
#define FatRaiseStatus(IRPCONTEXT,STATUS) { \
(IRPCONTEXT)->ExceptionStatus = (STATUS); \
DebugBreakOnStatus( (STATUS) ) \
ExRaiseStatus( (STATUS) ); \
}
#define FatResetExceptionState( IRPCONTEXT ) { \
(IRPCONTEXT)->ExceptionStatus = STATUS_SUCCESS; \
}
//
// VOID
// FatNormalAndRaiseStatus (
// IN PRIP_CONTEXT IrpContext,
// IN NT_STATUS Status
// );
//
#define FatNormalizeAndRaiseStatus(IRPCONTEXT,STATUS) { \
(IRPCONTEXT)->ExceptionStatus = (STATUS); \
ExRaiseStatus(FsRtlNormalizeNtstatus((STATUS),STATUS_UNEXPECTED_IO_ERROR)); \
}
//
// The following macros are used to establish the semantics needed
// to do a return from within a try-finally clause. As a rule every
// try clause must end with a label call try_exit. For example,
//
// try {
// :
// :
//
// try_exit: NOTHING;
// } finally {
//
// :
// :
// }
//
// Every return statement executed inside of a try clause should use the
// try_return macro. If the compiler fully supports the try-finally construct
// then the macro should be
//
// #define try_return(S) { return(S); }
//
// If the compiler does not support the try-finally construct then the macro
// should be
//
// #define try_return(S) { S; goto try_exit; }
//
#define try_return(S) { S; goto try_exit; }
#define try_leave(S) { S; leave; }
CLUSTER_TYPE
FatInterpretClusterType (
IN PVCB Vcb,
IN FAT_ENTRY Entry
);
//
// These routines define the FileId for FAT. Lacking a fixed/uniquifiable
// notion, we simply come up with one which is unique in a given snapshot
// of the volume. As long as the parent directory is not moved or compacted,
// it may even be permanent.
//
//
// The internal information used to identify the fcb/dcb on the
// volume is the byte offset of the dirent of the file on disc.
// Our root always has fileid 0. FAT32 roots are chains and can
// use the LBO of the cluster, 12/16 roots use the lbo in the Vcb.
//
#define Fa
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -