ReactOS 0.4.15-dev-7942-gd23573b
rdbss.c File Reference
#include <rx.h>
#include <pseh/pseh2.h>
#include <limits.h>
#include <dfs.h>
#include <copysup.h>
#include <debug.h>
Include dependency graph for rdbss.c:

Go to the source code of this file.

Classes

struct  _RX_FSD_DISPATCH_VECTOR
 

Macros

#define NDEBUG
 
#define RX_TOPLEVELCTX_FLAG_FROM_POOL   1
 
#define ALLSCR_LENGTH   (sizeof(L"all.scr") - sizeof(UNICODE_NULL))
 
#define BugCheckFileId   RDBSS_BUG_CHECK_CLEANUP
 
#define BugCheckFileId   RDBSS_BUG_CHECK_CLOSE
 
#define SET_SIZE_AND_QUERY(AlreadyConsummed, Function)
 
#define _SEH2_TRY_RETURN(S)   S; goto try_exit
 
#define _SEH2_TRY_RETURN(S)   S; goto try_exit
 
#define BugCheckFileId   RDBSS_BUG_CHECK_CACHESUP
 
#define FILE_ATTRIBUTE_VOLUME   0x8
 
#define VALID_FILE_ATTRIBUTES
 
#define VALID_DIR_ATTRIBUTES   (VALID_FILE_ATTRIBUTES | FILE_ATTRIBUTE_DIRECTORY)
 

Typedefs

typedef NTSTATUS(NTAPIPRX_FSD_DISPATCH) (PRX_CONTEXT Context)
 
typedef struct _RX_FSD_DISPATCH_VECTOR RX_FSD_DISPATCH_VECTOR
 
typedef struct _RX_FSD_DISPATCH_VECTORPRX_FSD_DISPATCH_VECTOR
 

Functions

VOID NTAPI RxAcquireFileForNtCreateSection (PFILE_OBJECT FileObject)
 
NTSTATUS NTAPI RxAcquireForCcFlush (PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject)
 
VOID RxAddToTopLevelIrpAllocatedContextsList (PRX_TOPLEVELIRP_CONTEXT TopLevelContext)
 
VOID RxAssert (PVOID Assert, PVOID File, ULONG Line, PVOID Message)
 
NTSTATUS NTAPI RxCommonCleanup (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonClose (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonCreate (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDevFCBCleanup (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDevFCBClose (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDevFCBFsCtl (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDevFCBIoCtl (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDevFCBQueryVolInfo (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDeviceControl (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDirectoryControl (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonDispatchProblem (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonFileSystemControl (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonFlushBuffers (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonLockControl (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonQueryEa (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonQueryInformation (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonQueryQuotaInformation (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonQuerySecurity (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonQueryVolumeInformation (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonRead (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonSetEa (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonSetInformation (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonSetQuotaInformation (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonSetSecurity (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonSetVolumeInformation (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonUnimplemented (PRX_CONTEXT Context)
 
NTSTATUS NTAPI RxCommonWrite (PRX_CONTEXT Context)
 
VOID RxCopyCreateParameters (IN PRX_CONTEXT RxContext)
 
NTSTATUS RxCreateFromNetRoot (PRX_CONTEXT Context, PUNICODE_STRING NetRootName)
 
NTSTATUS RxCreateTreeConnect (IN PRX_CONTEXT RxContext)
 
BOOLEAN NTAPI RxFastIoCheckIfPossible (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, BOOLEAN CheckForReadOperation, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI RxFastIoDeviceControl (PFILE_OBJECT FileObject, BOOLEAN Wait, PVOID InputBuffer OPTIONAL, ULONG InputBufferLength, PVOID OutputBuffer OPTIONAL, ULONG OutputBufferLength, ULONG IoControlCode, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI RxFastIoRead (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI RxFastIoWrite (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
 
NTSTATUS RxFindOrCreateFcb (PRX_CONTEXT RxContext, PUNICODE_STRING NetRootName)
 
NTSTATUS RxFirstCanonicalize (PRX_CONTEXT RxContext, PUNICODE_STRING FileName, PUNICODE_STRING CanonicalName, PNET_ROOT_TYPE NetRootType)
 
VOID RxFreeCanonicalNameBuffer (PRX_CONTEXT Context)
 
VOID NTAPI RxFspDispatch (IN PVOID Context)
 
VOID NTAPI RxGetRegistryParameters (IN PUNICODE_STRING RegistryPath)
 
NTSTATUS NTAPI RxGetStringRegistryParameter (IN HANDLE KeyHandle, IN PCWSTR KeyName, OUT PUNICODE_STRING OutString, IN PUCHAR Buffer, IN ULONG BufferLength, IN BOOLEAN LogFailure)
 
VOID NTAPI RxInitializeDebugSupport (VOID)
 
VOID NTAPI RxInitializeDispatchVectors (PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI RxInitializeRegistrationStructures (VOID)
 
VOID NTAPI RxInitializeTopLevelIrpPackage (VOID)
 
VOID NTAPI RxInitUnwind (PDRIVER_OBJECT DriverObject, USHORT State)
 
BOOLEAN RxIsThisAnRdbssTopLevelContext (PRX_TOPLEVELIRP_CONTEXT TopLevelContext)
 
NTSTATUS NTAPI RxLowIoIoCtlShellCompletion (PRX_CONTEXT RxContext)
 
NTSTATUS RxLowIoReadShell (PRX_CONTEXT RxContext)
 
NTSTATUS NTAPI RxLowIoReadShellCompletion (PRX_CONTEXT RxContext)
 
NTSTATUS RxLowIoWriteShell (IN PRX_CONTEXT RxContext)
 
NTSTATUS NTAPI RxLowIoWriteShellCompletion (PRX_CONTEXT RxContext)
 
PVOID RxNewMapUserBuffer (PRX_CONTEXT RxContext)
 
NTSTATUS RxNotifyChangeDirectory (PRX_CONTEXT RxContext)
 
VOID NTAPI RxpCancelRoutine (PVOID Context)
 
NTSTATUS RxpQueryInfoMiniRdr (PRX_CONTEXT RxContext, FILE_INFORMATION_CLASS FileInfoClass, PVOID Buffer)
 
VOID RxPurgeNetFcb (PFCB Fcb, PRX_CONTEXT LocalContext)
 
NTSTATUS RxQueryAlternateNameInfo (PRX_CONTEXT RxContext, PFILE_NAME_INFORMATION AltNameInfo)
 
NTSTATUS RxQueryBasicInfo (PRX_CONTEXT RxContext, PFILE_BASIC_INFORMATION BasicInfo)
 
NTSTATUS RxQueryCompressedInfo (PRX_CONTEXT RxContext, PFILE_COMPRESSION_INFORMATION CompressionInfo)
 
NTSTATUS RxQueryDirectory (PRX_CONTEXT RxContext)
 
NTSTATUS RxQueryEaInfo (PRX_CONTEXT RxContext, PFILE_EA_INFORMATION EaInfo)
 
NTSTATUS RxQueryInternalInfo (PRX_CONTEXT RxContext, PFILE_INTERNAL_INFORMATION InternalInfo)
 
NTSTATUS RxQueryNameInfo (PRX_CONTEXT RxContext, PFILE_NAME_INFORMATION NameInfo)
 
NTSTATUS RxQueryPipeInfo (PRX_CONTEXT RxContext, PFILE_PIPE_INFORMATION PipeInfo)
 
NTSTATUS RxQueryPositionInfo (PRX_CONTEXT RxContext, PFILE_POSITION_INFORMATION PositionInfo)
 
NTSTATUS RxQueryStandardInfo (PRX_CONTEXT RxContext, PFILE_STANDARD_INFORMATION StandardInfo)
 
VOID NTAPI RxReadRegistryParameters (VOID)
 
VOID NTAPI RxReleaseFileForNtCreateSection (PFILE_OBJECT FileObject)
 
NTSTATUS NTAPI RxReleaseForCcFlush (PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject)
 
PRX_CONTEXT RxRemoveOverflowEntry (PRDBSS_DEVICE_OBJECT DeviceObject, WORK_QUEUE_TYPE Queue)
 
NTSTATUS RxSearchForCollapsibleOpen (PRX_CONTEXT RxContext, ACCESS_MASK DesiredAccess, ULONG ShareAccess)
 
NTSTATUS RxSetAllocationInfo (PRX_CONTEXT RxContext)
 
NTSTATUS RxSetBasicInfo (PRX_CONTEXT RxContext)
 
NTSTATUS RxSetDispositionInfo (PRX_CONTEXT RxContext)
 
NTSTATUS RxSetEndOfFileInfo (PRX_CONTEXT RxContext)
 
NTSTATUS RxSetPipeInfo (PRX_CONTEXT RxContext)
 
NTSTATUS RxSetPositionInfo (PRX_CONTEXT RxContext)
 
NTSTATUS RxSetRenameInfo (PRX_CONTEXT RxContext)
 
NTSTATUS RxSetSimpleInfo (PRX_CONTEXT RxContext)
 
VOID RxSetupNetFileObject (PRX_CONTEXT RxContext)
 
NTSTATUS RxSystemControl (IN PRDBSS_DEVICE_OBJECT RxDeviceObject, IN PIRP Irp)
 
VOID RxUninitializeCacheMap (PRX_CONTEXT RxContext, PFILE_OBJECT FileObject, PLARGE_INTEGER TruncateSize)
 
VOID RxUnstart (PRX_CONTEXT Context, PRDBSS_DEVICE_OBJECT DeviceObject)
 
NTSTATUS RxXXXControlFileCallthru (PRX_CONTEXT Context)
 
PVOID NTAPI _RxAllocatePoolWithTag (_In_ POOL_TYPE PoolType, _In_ SIZE_T NumberOfBytes, _In_ ULONG Tag)
 
VOID NTAPI _RxFreePool (_In_ PVOID Buffer)
 
VOID NTAPI _RxFreePoolWithTag (_In_ PVOID Buffer, _In_ ULONG Tag)
 
 DECLARE_CONST_UNICODE_STRING (unknownId, L"???")
 
VOID CheckForLoudOperations (PRX_CONTEXT RxContext)
 
VOID __RxInitializeTopLevelIrpContext (IN OUT PRX_TOPLEVELIRP_CONTEXT TopLevelContext, IN PIRP Irp, IN PRDBSS_DEVICE_OBJECT RxDeviceObject, IN ULONG Flags)
 
VOID __RxWriteReleaseResources (PRX_CONTEXT RxContext, BOOLEAN ResourceOwnerSet, ULONG LineNumber, PCSTR FileName, ULONG SerialNumber)
 
VOID NTAPI RxAddToWorkque (IN PRX_CONTEXT RxContext, IN PIRP Irp)
 
VOID RxAdjustFileTimesAndSize (PRX_CONTEXT RxContext)
 
NTSTATUS RxAllocateCanonicalNameBuffer (PRX_CONTEXT RxContext, PUNICODE_STRING CanonicalName, USHORT CanonicalLength)
 
VOID RxCancelNotifyChangeDirectoryRequestsForFobx (PFOBX Fobx)
 
NTSTATUS RxCancelNotifyChangeDirectoryRequestsForVNetRoot (PV_NET_ROOT VNetRoot, BOOLEAN ForceFilesClosed)
 
BOOLEAN RxCancelOperationInOverflowQueue (PRX_CONTEXT RxContext)
 
VOID NTAPI RxCancelRoutine (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS RxCanonicalizeFileNameByServerSpecs (PRX_CONTEXT RxContext, PUNICODE_STRING NetRootName)
 
NTSTATUS RxCanonicalizeNameAndObtainNetRoot (PRX_CONTEXT RxContext, PUNICODE_STRING FileName, PUNICODE_STRING NetRootName)
 
VOID NTAPI RxCheckFcbStructuresForAlignment (VOID)
 
NTSTATUS RxCheckShareAccessPerSrvOpens (IN PFCB Fcb, IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess)
 
VOID RxCleanupPipeQueues (PRX_CONTEXT Context)
 
NTSTATUS RxCloseAssociatedSrvOpen (IN PFOBX Fobx, IN PRX_CONTEXT RxContext OPTIONAL)
 
NTSTATUS RxCollapseOrCreateSrvOpen (PRX_CONTEXT RxContext)
 
NTSTATUS NTAPI RxCompleteMdl (IN PRX_CONTEXT RxContext)
 
VOID RxConjureOriginalName (PFCB Fcb, PFOBX Fobx, PULONG ActualNameLength, PWCHAR OriginalName, PLONG LengthRemaining, RX_NAME_CONJURING_METHODS NameConjuringMethod)
 
VOID NTAPI RxDebugControlCommand (_In_ PSTR ControlString)
 
NTSTATUS NTAPI RxDriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
NTSTATUS RxFsdCommonDispatch (PRX_FSD_DISPATCH_VECTOR DispatchVector, UCHAR MajorFunction, PIO_STACK_LOCATION Stack, PFILE_OBJECT FileObject, PIRP Irp, PRDBSS_DEVICE_OBJECT RxDeviceObject)
 
NTSTATUS NTAPI RxFsdDispatch (IN PRDBSS_DEVICE_OBJECT RxDeviceObject, IN PIRP Irp)
 
NTSTATUS RxFsdPostRequest (IN PRX_CONTEXT RxContext)
 
ULONG RxGetNetworkProviderPriority (PUNICODE_STRING DeviceName)
 
ULONG RxGetSessionId (IN PIO_STACK_LOCATION IrpSp)
 
PRDBSS_DEVICE_OBJECT RxGetTopDeviceObjectIfRdbssIrp (VOID)
 
PIRP RxGetTopIrpIfRdbssIrp (VOID)
 
LUID RxGetUid (IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext)
 
VOID NTAPI RxIndicateChangeOfBufferingStateForSrvOpen (PMRX_SRV_CALL SrvCall, PMRX_SRV_OPEN SrvOpen, PVOID SrvOpenKey, PVOID Context)
 
NTSTATUS NTAPI RxInitializeLog (VOID)
 
VOID RxInitializeMinirdrDispatchTable (IN PDRIVER_OBJECT DriverObject)
 
BOOLEAN RxIsMemberOfTopLevelIrpAllocatedContextsList (PRX_TOPLEVELIRP_CONTEXT TopLevelContext)
 
BOOLEAN RxIsOkToPurgeFcb (PFCB Fcb)
 
BOOLEAN RxIsThisTheTopLevelIrp (IN PIRP Irp)
 
NTSTATUS NTAPI RxLockOperationCompletion (IN PVOID Context, IN PIRP Irp)
 
VOID NTAPI RxLogEventDirect (IN PRDBSS_DEVICE_OBJECT DeviceObject, IN PUNICODE_STRING OriginatorId, IN ULONG EventId, IN NTSTATUS Status, IN ULONG Line)
 
VOID NTAPI RxLogEventWithAnnotation (IN PRDBSS_DEVICE_OBJECT DeviceObject, IN ULONG EventId, IN NTSTATUS Status, IN PVOID DataBuffer, IN USHORT DataBufferLength, IN PUNICODE_STRING Annotation, IN ULONG AnnotationCount)
 
NTSTATUS NTAPI RxLowIoCompletion (PRX_CONTEXT RxContext)
 
NTSTATUS RxLowIoLockControlShell (IN PRX_CONTEXT RxContext)
 
NTSTATUS NTAPI RxLowIoNotifyChangeDirectoryCompletion (PRX_CONTEXT RxContext)
 
NTSTATUS RxPostStackOverflowRead (IN PRX_CONTEXT RxContext)
 
VOID RxpPrepareCreateContextForReuse (PRX_CONTEXT RxContext)
 
NTSTATUS RxPrefixClaim (IN PRX_CONTEXT RxContext)
 
NTSTATUS NTAPI RxPrepareToReparseSymbolicLink (PRX_CONTEXT RxContext, BOOLEAN SymbolicLinkEmbeddedInOldPath, PUNICODE_STRING NewPath, BOOLEAN NewPathIsAbsolute, PBOOLEAN ReparseRequired)
 
VOID RxPrePostIrp (IN PVOID Context, IN PIRP Irp)
 
NTSTATUS RxpSetInfoMiniRdr (PRX_CONTEXT RxContext, FILE_INFORMATION_CLASS Class)
 
VOID NTAPI RxpUnregisterMinirdr (IN PRDBSS_DEVICE_OBJECT RxDeviceObject)
 
NTSTATUS NTAPI RxRegisterMinirdr (OUT PRDBSS_DEVICE_OBJECT *DeviceObject, IN OUT PDRIVER_OBJECT DriverObject, IN PMINIRDR_DISPATCH MrdrDispatch, IN ULONG Controls, IN PUNICODE_STRING DeviceName, IN ULONG DeviceExtensionSize, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics)
 
VOID RxRemoveFromTopLevelIrpAllocatedContextsList (PRX_TOPLEVELIRP_CONTEXT TopLevelContext)
 
VOID RxRemoveShareAccessPerSrvOpens (IN OUT PSRV_OPEN SrvOpen)
 
NTSTATUS NTAPI RxStartMinirdr (IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp)
 
NTSTATUS NTAPI RxStopMinirdr (IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp)
 
BOOLEAN RxTryToBecomeTheTopLevelIrp (IN OUT PRX_TOPLEVELIRP_CONTEXT TopLevelContext, IN PIRP Irp, IN PRDBSS_DEVICE_OBJECT RxDeviceObject, IN BOOLEAN ForceTopLevel)
 
VOID NTAPI RxUnload (IN PDRIVER_OBJECT DriverObject)
 
VOID NTAPI RxUnlockOperation (IN PVOID Context, IN PFILE_LOCK_INFO LockInfo)
 
VOID RxUnwindTopLevelIrp (IN OUT PRX_TOPLEVELIRP_CONTEXT TopLevelContext)
 
VOID RxUpdateShareAccessPerSrvOpens (IN PSRV_OPEN SrvOpen)
 

Variables

WCHAR RxStarForTemplate = '*'
 
WCHAR Rx8QMdot3QM [] = L">>>>>>>>.>>>*"
 
BOOLEAN DisableByteRangeLockingOnReadOnlyFiles = FALSE
 
BOOLEAN DisableFlushOnCleanup = FALSE
 
ULONG ReadAheadGranularity = 1 << PAGE_SHIFT
 
LIST_ENTRY RxActiveContexts
 
NPAGED_LOOKASIDE_LIST RxContextLookasideList
 
RDBSS_DATA RxData
 
FCB RxDeviceFCB
 
BOOLEAN RxLoudLowIoOpsEnabled = FALSE
 
RX_FSD_DISPATCH_VECTOR RxDeviceFCBVector [IRP_MJ_MAXIMUM_FUNCTION+1]
 
RDBSS_EXPORTS RxExports
 
FAST_IO_DISPATCH RxFastIoDispatch
 
PRDBSS_DEVICE_OBJECT RxFileSystemDeviceObject
 
RX_FSD_DISPATCH_VECTOR RxFsdDispatchVector [IRP_MJ_MAXIMUM_FUNCTION+1]
 
ULONG RxFsdEntryCount
 
LIST_ENTRY RxIrpsList
 
KSPIN_LOCK RxIrpsListSpinLock
 
KMUTEX RxScavengerMutex
 
KMUTEX RxSerializationMutex
 
UCHAR RxSpaceForTheWrappersDeviceObject [sizeof(*RxFileSystemDeviceObject)]
 
KSPIN_LOCK TopLevelIrpSpinLock
 
LIST_ENTRY TopLevelIrpAllocatedContextsList
 
BOOLEAN RxForceQFIPassThrough = FALSE
 
BOOLEAN RxNoAsync = FALSE
 

Macro Definition Documentation

◆ _SEH2_TRY_RETURN [1/2]

#define _SEH2_TRY_RETURN (   S)    S; goto try_exit

◆ _SEH2_TRY_RETURN [2/2]

#define _SEH2_TRY_RETURN (   S)    S; goto try_exit

◆ ALLSCR_LENGTH

#define ALLSCR_LENGTH   (sizeof(L"all.scr") - sizeof(UNICODE_NULL))

◆ BugCheckFileId [1/3]

#define BugCheckFileId   RDBSS_BUG_CHECK_CLEANUP

◆ BugCheckFileId [2/3]

#define BugCheckFileId   RDBSS_BUG_CHECK_CLOSE

◆ BugCheckFileId [3/3]

#define BugCheckFileId   RDBSS_BUG_CHECK_CACHESUP

◆ FILE_ATTRIBUTE_VOLUME

#define FILE_ATTRIBUTE_VOLUME   0x8

◆ NDEBUG

#define NDEBUG

Definition at line 35 of file rdbss.c.

◆ RX_TOPLEVELCTX_FLAG_FROM_POOL

#define RX_TOPLEVELCTX_FLAG_FROM_POOL   1

Definition at line 38 of file rdbss.c.

◆ SET_SIZE_AND_QUERY

#define SET_SIZE_AND_QUERY (   AlreadyConsummed,
  Function 
)
Value:
Context->Info.Length = Stack->Parameters.QueryFile.Length - (AlreadyConsummed); \
Status = Function(Context, Add2Ptr(Buffer, AlreadyConsummed))
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:25
#define Add2Ptr(PTR, INC)
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639

◆ VALID_DIR_ATTRIBUTES

#define VALID_DIR_ATTRIBUTES   (VALID_FILE_ATTRIBUTES | FILE_ATTRIBUTE_DIRECTORY)

◆ VALID_FILE_ATTRIBUTES

#define VALID_FILE_ATTRIBUTES
Value:
( \
#define FILE_ATTRIBUTE_DEVICE
Definition: disk.h:27
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_OFFLINE
Definition: nt_native.h:712
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FILE_ATTRIBUTE_TEMPORARY
Definition: nt_native.h:708
#define FILE_ATTRIBUTE_ENCRYPTED
Definition: ntifs_ex.h:385
#define FILE_ATTRIBUTE_SPARSE_FILE
Definition: ntifs_ex.h:380
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
Definition: ntifs_ex.h:384
#define FILE_ATTRIBUTE_VOLUME
#define FILE_ATTRIBUTE_INTEGRITY_STREAM

Typedef Documentation

◆ PRX_FSD_DISPATCH

typedef NTSTATUS(NTAPI * PRX_FSD_DISPATCH) (PRX_CONTEXT Context)

Definition at line 41 of file rdbss.c.

◆ PRX_FSD_DISPATCH_VECTOR

◆ RX_FSD_DISPATCH_VECTOR

Function Documentation

◆ __RxInitializeTopLevelIrpContext()

VOID __RxInitializeTopLevelIrpContext ( IN OUT PRX_TOPLEVELIRP_CONTEXT  TopLevelContext,
IN PIRP  Irp,
IN PRDBSS_DEVICE_OBJECT  RxDeviceObject,
IN ULONG  Flags 
)

Definition at line 674 of file rdbss.c.

679{
680 DPRINT("__RxInitializeTopLevelIrpContext(%p, %p, %p, %u)\n", TopLevelContext, Irp, RxDeviceObject, Flags);
681
682 RtlZeroMemory(TopLevelContext, sizeof(RX_TOPLEVELIRP_CONTEXT));
683 TopLevelContext->Irp = Irp;
684 TopLevelContext->Flags = (Flags ? RX_TOPLEVELCTX_FLAG_FROM_POOL : 0);
685 TopLevelContext->Signature = RX_TOPLEVELIRP_CONTEXT_SIGNATURE;
686 TopLevelContext->RxDeviceObject = RxDeviceObject;
687 TopLevelContext->Previous = IoGetTopLevelIrp();
688 TopLevelContext->Thread = PsGetCurrentThread();
689
690 /* We cannot add to list something that'd come from stack */
691 if (BooleanFlagOn(TopLevelContext->Flags, RX_TOPLEVELCTX_FLAG_FROM_POOL))
692 {
694 }
695}
_In_ PIRP Irp
Definition: csq.h:116
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
VOID RxAddToTopLevelIrpAllocatedContextsList(PRX_TOPLEVELIRP_CONTEXT TopLevelContext)
Definition: rdbss.c:752
#define RX_TOPLEVELCTX_FLAG_FROM_POOL
Definition: rdbss.c:38
#define RX_TOPLEVELIRP_CONTEXT_SIGNATURE
Definition: rxcontx.h:4
#define DPRINT
Definition: sndvol32.h:71
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by RxTryToBecomeTheTopLevelIrp().

◆ __RxWriteReleaseResources()

VOID __RxWriteReleaseResources ( PRX_CONTEXT  RxContext,
BOOLEAN  ResourceOwnerSet,
ULONG  LineNumber,
PCSTR  FileName,
ULONG  SerialNumber 
)

Definition at line 701 of file rdbss.c.

707{
709
710 PAGED_CODE();
711
712 ASSERT(RxContext != NULL);
713 ASSERT(capFcb != NULL);
714
715 /* If FCB resource was acquired, release it */
716 if (RxContext->FcbResourceAcquired)
717 {
718 /* Taking care of owner */
719 if (ResourceOwnerSet)
720 {
722 }
723 else
724 {
725 RxReleaseFcb(RxContext, capFcb);
726 }
727
728 RxContext->FcbResourceAcquired = FALSE;
729 }
730
731 /* If FCB paging resource was acquired, release it */
732 if (RxContext->FcbPagingIoResourceAcquired)
733 {
734 /* Taking care of owner */
735 if (ResourceOwnerSet)
736 {
738 }
739 else
740 {
742 }
743
744 /* No need to release boolean here, RxReleasePagingIoResource() takes care of it */
745 }
746}
#define PAGED_CODE()
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
#define capFcb
Definition: ntrxdef.h:20
#define RxCaptureFcb
Definition: ntrxdef.h:10
#define RxReleasePagingIoResource(RxContext, Fcb)
Definition: rxprocs.h:268
#define RxReleaseFcb(R, F)
Definition: rxprocs.h:186
#define RxReleasePagingIoResourceForThread(RxContext, Fcb, Thread)
Definition: rxprocs.h:276
#define RxReleaseFcbForThread(R, F, T)
Definition: rxprocs.h:205
ERESOURCE_THREAD ResourceThreadId
Definition: mrx.h:285
BOOLEAN FcbResourceAcquired
Definition: rxcontx.h:125
LOWIO_CONTEXT LowIoContext
Definition: rxcontx.h:263
BOOLEAN FcbPagingIoResourceAcquired
Definition: rxcontx.h:126

◆ _RxAllocatePoolWithTag()

PVOID NTAPI _RxAllocatePoolWithTag ( _In_ POOL_TYPE  PoolType,
_In_ SIZE_T  NumberOfBytes,
_In_ ULONG  Tag 
)

Definition at line 8941 of file rxce.c.

8945{
8947}
PVOID NTAPI ExAllocatePoolWithTagPriority(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag, IN EX_POOL_PRIORITY Priority)
Definition: expool.c:2963
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
@ LowPoolPriority
Definition: extypes.h:40
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

◆ _RxFreePool()

VOID NTAPI _RxFreePool ( _In_ PVOID  Buffer)

Definition at line 8954 of file rxce.c.

8956{
8958}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

◆ _RxFreePoolWithTag()

VOID NTAPI _RxFreePoolWithTag ( _In_ PVOID  Buffer,
_In_ ULONG  Tag 
)

Definition at line 8965 of file rxce.c.

8968{
8970}

◆ CheckForLoudOperations()

VOID CheckForLoudOperations ( PRX_CONTEXT  RxContext)

Definition at line 647 of file rdbss.c.

649{
651
652 PAGED_CODE();
653
654#define ALLSCR_LENGTH (sizeof(L"all.scr") - sizeof(UNICODE_NULL))
655
656 /* Are loud operations enabled? */
658 {
659 /* If so, the operation will be loud only if filename ends with all.scr */
660 if (RtlCompareMemory(Add2Ptr(capFcb->PrivateAlreadyPrefixedName.Buffer,
661 (capFcb->PrivateAlreadyPrefixedName.Length - ALLSCR_LENGTH)),
662 L"all.scr", ALLSCR_LENGTH) == ALLSCR_LENGTH)
663 {
665 }
666 }
667#undef ALLSCR_LENGTH
668}
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define LOWIO_CONTEXT_FLAG_LOUDOPS
Definition: mrx.h:322
#define L(x)
Definition: ntvdm.h:50
#define ALLSCR_LENGTH
BOOLEAN RxLoudLowIoOpsEnabled
Definition: rdbss.c:539
USHORT Flags
Definition: mrx.h:282

Referenced by RxCommonRead(), and RxCommonWrite().

◆ DECLARE_CONST_UNICODE_STRING()

DECLARE_CONST_UNICODE_STRING ( unknownId  ,
L"???"   
)

◆ RxAcquireFileForNtCreateSection()

VOID NTAPI RxAcquireFileForNtCreateSection ( PFILE_OBJECT  FileObject)

Definition at line 276 of file rxce.c.

278{
280}
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by RxInitializeDispatchVectors().

◆ RxAcquireForCcFlush()

NTSTATUS NTAPI RxAcquireForCcFlush ( PFILE_OBJECT  FileObject,
PDEVICE_OBJECT  DeviceObject 
)

Definition at line 284 of file rxce.c.

287{
290}
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by RxInitializeDispatchVectors().

◆ RxAddToTopLevelIrpAllocatedContextsList()

VOID RxAddToTopLevelIrpAllocatedContextsList ( PRX_TOPLEVELIRP_CONTEXT  TopLevelContext)

Definition at line 752 of file rdbss.c.

754{
756
757 DPRINT("RxAddToTopLevelIrpAllocatedContextsList(%p)\n", TopLevelContext);
758
761
765}
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
LIST_ENTRY TopLevelIrpAllocatedContextsList
Definition: rdbss.c:612
KSPIN_LOCK TopLevelIrpSpinLock
Definition: rdbss.c:611
LIST_ENTRY ListEntry
Definition: rxcontx.h:13
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by __RxInitializeTopLevelIrpContext().

◆ RxAddToWorkque()

VOID NTAPI RxAddToWorkque ( IN PRX_CONTEXT  RxContext,
IN PIRP  Irp 
)

Definition at line 772 of file rdbss.c.

775{
776 ULONG Queued;
779
781
782 RxContext->PostRequest = FALSE;
783
784 /* First of all, select the appropriate queue - delayed for prefix claim, critical for the rest */
785 if (RxContext->MajorFunction == IRP_MJ_DEVICE_CONTROL &&
786 capPARAMS->Parameters.DeviceIoControl.IoControlCode == IOCTL_REDIR_QUERY_PATH)
787 {
790 }
791 else
792 {
795 }
796
797 /* Check for overflow */
798 if (capPARAMS->FileObject != NULL)
799 {
801
803 /* In case of an overflow, add the new queued call to the overflow list */
804 if (Queued > 1)
805 {
807 InsertTailList(&RxFileSystemDeviceObject->OverflowQueue[Queue], &RxContext->OverflowListEntry);
809
811 return;
812 }
813
815 }
816
817 ExInitializeWorkItem(&RxContext->WorkQueueItem, RxFspDispatch, RxContext);
818 ExQueueWorkItem((PWORK_QUEUE_ITEM)&RxContext->WorkQueueItem, Queue);
819}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define IOCTL_REDIR_QUERY_PATH
#define capPARAMS
Definition: ntrxdef.h:22
#define RxCaptureParamBlock
Definition: ntrxdef.h:17
VOID NTAPI RxFspDispatch(IN PVOID Context)
Definition: rdbss.c:6571
PRDBSS_DEVICE_OBJECT RxFileSystemDeviceObject
Definition: rdbss.c:573
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
@ RX_CONTEXT_FLAG_FSP_DELAYED_OVERFLOW_QUEUE
Definition: rxcontx.h:296
@ RX_CONTEXT_FLAG_FSP_CRITICAL_OVERFLOW_QUEUE
Definition: rxcontx.h:297
LONG OverflowQueueCount[RxMaximumWorkQueue]
Definition: rxstruc.h:120
LIST_ENTRY OverflowQueue[RxMaximumWorkQueue]
Definition: rxstruc.h:121
RX_SPIN_LOCK OverflowQueueSpinLock
Definition: rxstruc.h:122
volatile LONG PostedRequestCount[RxMaximumWorkQueue]
Definition: rxstruc.h:119
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:723
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
enum _WORK_QUEUE_TYPE WORK_QUEUE_TYPE
@ DelayedWorkQueue
Definition: extypes.h:190
@ CriticalWorkQueue
Definition: extypes.h:189

Referenced by RxCommonWrite(), and RxFsdPostRequest().

◆ RxAdjustFileTimesAndSize()

VOID RxAdjustFileTimesAndSize ( PRX_CONTEXT  RxContext)

Definition at line 825 of file rdbss.c.

827{
829 LARGE_INTEGER CurrentTime;
830 FILE_BASIC_INFORMATION FileBasicInfo;
832 BOOLEAN FileModified, SetLastChange, SetLastAccess, SetLastWrite, NeedUpdate;
833
838
839 PAGED_CODE();
840
841 /* If Cc isn't initialized, the file was not read nor written, nothing to do */
842 if (capFileObject->PrivateCacheMap == NULL)
843 {
844 return;
845 }
846
847 /* Get now */
848 KeQuerySystemTime(&CurrentTime);
849
850 /* Was the file modified? */
851 FileModified = BooleanFlagOn(capFileObject->Flags, FO_FILE_MODIFIED);
852 /* We'll set last write if it was modified and user didn't update yet */
853 SetLastWrite = FileModified && !BooleanFlagOn(capFobx->Flags, FOBX_FLAG_USER_SET_LAST_WRITE);
854 /* File was accessed if: written or read (fastio), we'll update last access if user didn't */
855 SetLastAccess = SetLastWrite ||
858 /* We'll set last change if it was modified and user didn't update yet */
859 SetLastChange = FileModified && !BooleanFlagOn(capFobx->Flags, FOBX_FLAG_USER_SET_LAST_CHANGE);
860
861 /* Nothing to update? Job done */
862 if (!FileModified && !SetLastWrite && !SetLastAccess && !SetLastChange)
863 {
864 return;
865 }
866
867 /* By default, we won't issue any MRxSetFileInfoAtCleanup call */
868 NeedUpdate = FALSE;
869 RtlZeroMemory(&FileBasicInfo, sizeof(FileBasicInfo));
870
871 /* Update lastwrite time if required */
872 if (SetLastWrite)
873 {
874 NeedUpdate = TRUE;
875 capFcb->LastWriteTime.QuadPart = CurrentTime.QuadPart;
876 FileBasicInfo.LastWriteTime.QuadPart = CurrentTime.QuadPart;
877 }
878
879 /* Update lastaccess time if required */
880 if (SetLastAccess)
881 {
882 NeedUpdate = TRUE;
883 capFcb->LastAccessTime.QuadPart = CurrentTime.QuadPart;
884 FileBasicInfo.LastAccessTime.QuadPart = CurrentTime.QuadPart;
885 }
886
887 /* Update lastchange time if required */
888 if (SetLastChange)
889 {
890 NeedUpdate = TRUE;
891 capFcb->LastChangeTime.QuadPart = CurrentTime.QuadPart;
892 FileBasicInfo.ChangeTime.QuadPart = CurrentTime.QuadPart;
893 }
894
895 /* If one of the date was modified, issue a call to mini-rdr */
896 if (NeedUpdate)
897 {
898 RxContext->Info.FileInformationClass = FileBasicInformation;
899 RxContext->Info.Buffer = &FileBasicInfo;
900 RxContext->Info.Length = sizeof(FileBasicInfo);
901
902 MINIRDR_CALL(Status, RxContext, capFcb->MRxDispatch, MRxSetFileInfoAtCleanup, (RxContext));
903 (void)Status;
904 }
905
906 /* If the file was modified, update its EOF */
907 if (FileModified)
908 {
909 FileEOFInfo.EndOfFile.QuadPart = capFcb->Header.FileSize.QuadPart;
910
911 RxContext->Info.FileInformationClass = FileEndOfFileInformation;
912 RxContext->Info.Buffer = &FileEOFInfo;
913 RxContext->Info.Length = sizeof(FileEOFInfo);
914
915 MINIRDR_CALL(Status, RxContext, capFcb->MRxDispatch, MRxSetFileInfoAtCleanup, (RxContext));
916 (void)Status;
917 }
918}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define FOBX_FLAG_USER_SET_LAST_CHANGE
Definition: fcb.h:294
#define FOBX_FLAG_USER_SET_LAST_WRITE
Definition: fcb.h:291
#define FOBX_FLAG_USER_SET_LAST_ACCESS
Definition: fcb.h:292
@ FileEndOfFileInformation
Definition: from_kernel.h:81
@ FileBasicInformation
Definition: from_kernel.h:65
#define capFileObject
Definition: ntrxdef.h:23
#define capFobx
Definition: ntrxdef.h:21
#define RxCaptureFileObject
Definition: ntrxdef.h:18
#define RxCaptureFobx
Definition: ntrxdef.h:11
#define MINIRDR_CALL(STATUS, CONTEXT, DISPATCH, FUNC, ARGLIST)
Definition: rxcontx.h:389
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
LARGE_INTEGER ChangeTime
Definition: nt_native.h:942
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
struct _RX_CONTEXT::@2146::@2154 Info
LONGLONG QuadPart
Definition: typedefs.h:114
#define FO_FILE_FAST_IO_READ
Definition: iotypes.h:1795
#define FO_FILE_MODIFIED
Definition: iotypes.h:1788

Referenced by RxCommonCleanup().

◆ RxAllocateCanonicalNameBuffer()

NTSTATUS RxAllocateCanonicalNameBuffer ( PRX_CONTEXT  RxContext,
PUNICODE_STRING  CanonicalName,
USHORT  CanonicalLength 
)

Definition at line 924 of file rdbss.c.

928{
929 PAGED_CODE();
930
931 DPRINT("RxContext: %p - CanonicalNameBuffer: %p\n", RxContext, RxContext->Create.CanonicalNameBuffer);
932
933 /* Context must be free of any already allocated name */
934 ASSERT(RxContext->Create.CanonicalNameBuffer == NULL);
935
936 /* Validate string length */
937 if (CanonicalLength > USHRT_MAX - 1)
938 {
939 CanonicalName->Buffer = NULL;
941 }
942
943 CanonicalName->Buffer = RxAllocatePoolWithTag(PagedPool | POOL_COLD_ALLOCATION, CanonicalLength, RX_MISC_POOLTAG);
944 if (CanonicalName->Buffer == NULL)
945 {
947 }
948
949 CanonicalName->Length = 0;
950 CanonicalName->MaximumLength = CanonicalLength;
951
952 /* Set the two places - they must always be identical */
953 RxContext->Create.CanonicalNameBuffer = CanonicalName->Buffer;
954 RxContext->AlsoCanonicalNameBuffer = CanonicalName->Buffer;
955
956 return STATUS_SUCCESS;
957}
#define PagedPool
Definition: env_spec_w32.h:308
#define USHRT_MAX
Definition: limits.h:38
#define RxAllocatePoolWithTag
Definition: ntrxdef.h:25
#define STATUS_OBJECT_PATH_INVALID
Definition: ntstatus.h:293
#define RX_MISC_POOLTAG
Definition: rxpooltg.h:10
#define STATUS_SUCCESS
Definition: shellext.h:65
PWCH AlsoCanonicalNameBuffer
Definition: rxcontx.h:267
struct _RX_CONTEXT::@2148::@2160 Create
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define POOL_COLD_ALLOCATION

Referenced by RxFirstCanonicalize().

◆ RxAssert()

VOID RxAssert ( PVOID  Assert,
PVOID  File,
ULONG  Line,
PVOID  Message 
)

Definition at line 645 of file rxce.c.

650{
651 CHAR Response[2];
653
654 /* If we're not asked to continue, just stop the system */
656 {
657 KeBugCheckEx(RDBSS_FILE_SYSTEM, RDBSS_BUG_CHECK_ASSERT | Line, 0, 0, 0);
658 }
659
660 /* Otherwise, capture context to offer the user to dump it */
662
663 /* Loop until the user hits 'i' */
664 while (TRUE)
665 {
666 /* If no file provided, use empty name */
667 if (File == NULL)
668 {
669 File = "";
670 }
671
672 /* If no message provided, use empty one */
673 if (Message == NULL)
674 {
675 Message = "";
676 }
677
678 /* Display the message */
679 DbgPrint("\n*** Assertion failed: %s%s\n*** Source File: %s, line %ld\n\n", Message, Assert, File, Line);
680 /* And ask the user */
681 DbgPrompt("Break, Ignore (bi)? ", Response, sizeof(Response));
682 /* If he asks for ignore, quit
683 * In case of invalid input, ask again
684 */
685 if (Response[0] != 'B' && Response[0] != 'b')
686 {
687 if (Response[0] == 'I' || Response[0] == 'i')
688 {
689 return;
690 }
691
692 continue;
693 }
694
695 /* Break: offer the user to dump the context and break */
696 DbgPrint("Execute '!cxr %lx' to dump context\n", &Context);
698
699 /* Continue looping, so that after dump, execution can continue (with ignore) */
700 }
701}
Definition: File.h:16
#define Assert(cond, msg)
Definition: inflate.c:41
static const WCHAR Message[]
Definition: register.c:74
#define DbgPrint
Definition: hal.h:12
NTSYSAPI void WINAPI DbgBreakPoint(void)
NTSYSAPI ULONG NTAPI DbgPrompt(_In_z_ PCCH Prompt, _Out_writes_bytes_(MaximumResponseLength) PCH Response, _In_ ULONG MaximumResponseLength)
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
BOOLEAN RxContinueFromAssert
Definition: rxce.c:137
#define RDBSS_FILE_SYSTEM
Definition: nodetype.h:84
Definition: ncftp.h:79
Definition: ncftp.h:89
char CHAR
Definition: xmlstorage.h:175

◆ RxCancelNotifyChangeDirectoryRequestsForFobx()

VOID RxCancelNotifyChangeDirectoryRequestsForFobx ( PFOBX  Fobx)

Definition at line 963 of file rdbss.c.

965{
969 LIST_ENTRY ContextsToCancel;
970
971 /* Init a list for the contexts to cancel */
972 InitializeListHead(&ContextsToCancel);
973
974 /* Lock our list lock */
976
977 /* Now, browse all the active contexts, to find the associated ones */
979 while (Entry != &RxActiveContexts)
980 {
981 Context = CONTAINING_RECORD(Entry, RX_CONTEXT, ContextListEntry);
982 Entry = Entry->Flink;
983
984 /* Not the IRP we're looking for, ignore */
985 if (Context->MajorFunction != IRP_MJ_DIRECTORY_CONTROL ||
986 Context->MinorFunction != IRP_MN_NOTIFY_CHANGE_DIRECTORY)
987 {
988 continue;
989 }
990
991 /* Not the FOBX we're looking for, ignore */
992 if ((PFOBX)Context->pFobx != Fobx)
993 {
994 continue;
995 }
996
997 /* No cancel routine (can't be cancel, then), ignore */
998 if (Context->MRxCancelRoutine == NULL)
999 {
1000 continue;
1001 }
1002
1003 /* Mark our context as cancelled */
1005
1006 /* Move it to our list */
1007 RemoveEntryList(&Context->ContextListEntry);
1008 InsertTailList(&ContextsToCancel, &Context->ContextListEntry);
1009
1010 InterlockedIncrement((volatile long *)&Context->ReferenceCount);
1011 }
1012
1013 /* Done with the contexts */
1015
1016 /* Now, handle all our "extracted" contexts */
1017 while (!IsListEmpty(&ContextsToCancel))
1018 {
1019 Entry = RemoveHeadList(&ContextsToCancel);
1020 Context = CONTAINING_RECORD(Entry, RX_CONTEXT, ContextListEntry);
1021
1022 /* If they had an associated IRP (should be always true) */
1023 if (Context->CurrentIrp != NULL)
1024 {
1025 /* Then, call cancel routine */
1026 ASSERT(Context->MRxCancelRoutine != NULL);
1027 DPRINT1("Canceling %p with %p\n", Context, Context->MRxCancelRoutine);
1028 Context->MRxCancelRoutine(Context);
1029 }
1030
1031 /* And delete the context */
1033 }
1034}
#define DPRINT1
Definition: precomp.h:8
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY RxActiveContexts
Definition: rdbss.c:535
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY
Definition: rdpdr.c:56
@ RX_CONTEXT_FLAG_CANCELLED
Definition: rxcontx.h:300
#define RxDereferenceAndDeleteRxContext(RXCONTEXT)
Definition: rxcontx.h:514
RX_SPIN_LOCK RxStrucSupSpinLock
Definition: rxce.c:123
base of all file and directory entries
Definition: entries.h:83
Definition: fcb.h:305
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by RxCommonCleanup().

◆ RxCancelNotifyChangeDirectoryRequestsForVNetRoot()

NTSTATUS RxCancelNotifyChangeDirectoryRequestsForVNetRoot ( PV_NET_ROOT  VNetRoot,
BOOLEAN  ForceFilesClosed 
)

Definition at line 1040 of file rdbss.c.

1043{
1044 KIRQL OldIrql;
1048 LIST_ENTRY ContextsToCancel;
1049
1050 /* Init a list for the contexts to cancel */
1051 InitializeListHead(&ContextsToCancel);
1052
1053 /* Lock our list lock */
1055
1056 /* Assume success */
1058
1059 /* Now, browse all the active contexts, to find the associated ones */
1061 while (Entry != &RxActiveContexts)
1062 {
1063 Context = CONTAINING_RECORD(Entry, RX_CONTEXT, ContextListEntry);
1064 Entry = Entry->Flink;
1065
1066 /* Not the IRP we're looking for, ignore */
1067 if (Context->MajorFunction != IRP_MJ_DIRECTORY_CONTROL ||
1068 Context->MinorFunction != IRP_MN_NOTIFY_CHANGE_DIRECTORY)
1069 {
1070 continue;
1071 }
1072
1073 /* Not the VNetRoot we're looking for, ignore */
1074 if (Context->pFcb == NULL ||
1075 (PV_NET_ROOT)Context->NotifyChangeDirectory.pVNetRoot != VNetRoot)
1076 {
1077 continue;
1078 }
1079
1080 /* No cancel routine (can't be cancel, then), ignore */
1081 if (Context->MRxCancelRoutine == NULL)
1082 {
1083 continue;
1084 }
1085
1086 /* At that point, we found a matching context
1087 * If we're not asked to force close, then fail - it's still open
1088 */
1089 if (!ForceFilesClosed)
1090 {
1092 break;
1093 }
1094
1095 /* Mark our context as cancelled */
1097
1098 /* Move it to our list */
1099 RemoveEntryList(&Context->ContextListEntry);
1100 InsertTailList(&ContextsToCancel, &Context->ContextListEntry);
1101
1102 InterlockedIncrement((volatile long *)&Context->ReferenceCount);
1103 }
1104
1105 /* Done with the contexts */
1107
1108 if (Status != STATUS_SUCCESS)
1109 {
1110 return Status;
1111 }
1112
1113 /* Now, handle all our "extracted" contexts */
1114 while (!IsListEmpty(&ContextsToCancel))
1115 {
1116 Entry = RemoveHeadList(&ContextsToCancel);
1117 Context = CONTAINING_RECORD(Entry, RX_CONTEXT, ContextListEntry);
1118
1119 /* If they had an associated IRP (should be always true) */
1120 if (Context->CurrentIrp != NULL)
1121 {
1122 /* Then, call cancel routine */
1123 ASSERT(Context->MRxCancelRoutine != NULL);
1124 DPRINT1("Canceling %p with %p\n", Context, Context->MRxCancelRoutine);
1125 Context->MRxCancelRoutine(Context);
1126 }
1127
1128 /* And delete the context */
1130 }
1131
1132 return Status;
1133}
#define STATUS_FILES_OPEN
Definition: ntstatus.h:499

Referenced by RxFinalizeConnection().

◆ RxCancelOperationInOverflowQueue()

BOOLEAN RxCancelOperationInOverflowQueue ( PRX_CONTEXT  RxContext)

Definition at line 1139 of file rdbss.c.

1141{
1142 KIRQL OldIrql;
1143 BOOLEAN OperationToCancel;
1144
1145 /* By default, nothing cancelled */
1146 OperationToCancel = FALSE;
1147
1148 /* Acquire the overflow spinlock */
1150
1151 /* Is our context in any queue? */
1153 {
1154 /* Make sure flag is consistent with facts... */
1155 if (RxContext->OverflowListEntry.Flink != NULL)
1156 {
1157 /* Remove it from the list */
1159 RxContext->OverflowListEntry.Flink = NULL;
1160
1161 /* Decrement appropriate count */
1163 {
1165 }
1166 else
1167 {
1169 }
1170
1171 /* Clear the flag */
1173
1174 /* Time to cancel! */
1175 OperationToCancel = TRUE;
1176 }
1177 }
1178
1180
1181 /* We have something to cancel & complete */
1182 if (OperationToCancel)
1183 {
1186 }
1187
1188 return OperationToCancel;
1189}
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
VOID RxRemoveOperationFromBlockingQueue(_Inout_ PRX_CONTEXT RxContext)
NTSTATUS RxCompleteRequest(_In_ PRX_CONTEXT pContext, _In_ NTSTATUS Status)
LIST_ENTRY OverflowListEntry
Definition: rxcontx.h:150
ULONG Flags
Definition: rxcontx.h:124
#define STATUS_CANCELLED
Definition: udferr_usr.h:170

Referenced by RxpCancelRoutine().

◆ RxCancelRoutine()

VOID NTAPI RxCancelRoutine ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1196 of file rdbss.c.

1199{
1200 KIRQL OldIrql;
1202 PRX_CONTEXT RxContext;
1203
1204 /* Lock our contexts list */
1206
1207 /* Now, find a context that matches the cancelled IRP */
1209 while (Entry != &RxActiveContexts)
1210 {
1211 RxContext = CONTAINING_RECORD(Entry, RX_CONTEXT, ContextListEntry);
1212 Entry = Entry->Flink;
1213
1214 /* Found! */
1215 if (RxContext->CurrentIrp == Irp)
1216 {
1217 break;
1218 }
1219 }
1220
1221 /* If we reached the end of the list, we didn't find any context, so zero the buffer
1222 * If the context is already under cancellation, forget about it too
1223 */
1225 {
1226 RxContext = NULL;
1227 }
1228 else
1229 {
1230 /* Otherwise, reference it and mark it cancelled */
1232 InterlockedIncrement((volatile long *)&RxContext->ReferenceCount);
1233 }
1234
1235 /* Done with the contexts list */
1237
1238 /* And done with the cancellation, we'll do it now */
1239 IoReleaseCancelSpinLock(Irp->CancelIrql);
1240
1241 /* If we have a context to cancel */
1242 if (RxContext != NULL)
1243 {
1244 /* We cannot executed at dispatch, so queue a deferred cancel */
1246 {
1248 }
1249 /* Cancel now! */
1250 else
1251 {
1252 RxpCancelRoutine(RxContext);
1253 }
1254 }
1255}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
VOID NTAPI RxpCancelRoutine(PVOID Context)
Definition: rdbss.c:7616
NTSTATUS NTAPI RxDispatchToWorkerThread(_In_ PRDBSS_DEVICE_OBJECT pMRxDeviceObject, _In_ WORK_QUEUE_TYPE WorkQueueType, _In_ PRX_WORKERTHREAD_ROUTINE Routine, _In_ PVOID pContext)
PIRP CurrentIrp
Definition: rxcontx.h:110
volatile ULONG ReferenceCount
Definition: rxcontx.h:103

Referenced by RxFsdCommonDispatch().

◆ RxCanonicalizeFileNameByServerSpecs()

NTSTATUS RxCanonicalizeFileNameByServerSpecs ( PRX_CONTEXT  RxContext,
PUNICODE_STRING  NetRootName 
)

Definition at line 1261 of file rdbss.c.

1264{
1265 USHORT NextChar, CurChar;
1266 USHORT MaxChars;
1267
1268 PAGED_CODE();
1269
1270 /* Validate file name is not empty */
1271 MaxChars = NetRootName->Length / sizeof(WCHAR);
1272 if (MaxChars == 0)
1273 {
1275 }
1276
1277 /* Validate name is correct */
1278 for (NextChar = 0, CurChar = 0; CurChar + 1 < MaxChars; NextChar = CurChar + 1)
1279 {
1280 USHORT i;
1281
1282 for (i = NextChar + 1; i < MaxChars; ++i)
1283 {
1284 if (NetRootName->Buffer[i] == '\\' || NetRootName->Buffer[i] == ':')
1285 {
1286 break;
1287 }
1288 }
1289
1290 CurChar = i - 1;
1291 if (CurChar == NextChar)
1292 {
1293 if (((NetRootName->Buffer[NextChar] != '\\' && NetRootName->Buffer[NextChar] != ':') || NextChar == (MaxChars - 1)) && NetRootName->Buffer[NextChar] != '.')
1294 {
1295 continue;
1296 }
1297
1298 if (CurChar != 0)
1299 {
1300 if (CurChar >= MaxChars - 1)
1301 {
1302 continue;
1303 }
1304
1305 if (NetRootName->Buffer[CurChar + 1] != ':')
1306 {
1308 }
1309 }
1310 else
1311 {
1312 if (NetRootName->Buffer[1] != ':')
1313 {
1315 }
1316 }
1317 }
1318 else
1319 {
1320 if ((CurChar - NextChar) == 1)
1321 {
1322 if (NetRootName->Buffer[NextChar + 2] != '.')
1323 {
1324 continue;
1325 }
1326
1327 if (NetRootName->Buffer[NextChar] == '\\' || NetRootName->Buffer[NextChar] == ':' || NetRootName->Buffer[NextChar] == '.')
1328 {
1330 }
1331 }
1332 else
1333 {
1334 if ((CurChar - NextChar) != 2 || (NetRootName->Buffer[NextChar] != '\\' && NetRootName->Buffer[NextChar] != ':')
1335 || NetRootName->Buffer[NextChar + 1] != '.')
1336 {
1337 continue;
1338 }
1339
1340 if (NetRootName->Buffer[NextChar + 2] == '.')
1341 {
1343 }
1344 }
1345 }
1346 }
1347
1349}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:295
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by RxCanonicalizeNameAndObtainNetRoot().

◆ RxCanonicalizeNameAndObtainNetRoot()

NTSTATUS RxCanonicalizeNameAndObtainNetRoot ( PRX_CONTEXT  RxContext,
PUNICODE_STRING  FileName,
PUNICODE_STRING  NetRootName 
)

Definition at line 1352 of file rdbss.c.

1356{
1358 NET_ROOT_TYPE NetRootType;
1359 UNICODE_STRING CanonicalName;
1360
1363
1364 PAGED_CODE();
1365
1366 NetRootType = NET_ROOT_WILD;
1367
1368 RtlInitEmptyUnicodeString(NetRootName, NULL, 0);
1369 RtlInitEmptyUnicodeString(&CanonicalName, NULL, 0);
1370
1371 /* if not relative opening, just handle the passed name */
1372 if (capFileObject->RelatedFileObject == NULL)
1373 {
1374 Status = RxFirstCanonicalize(RxContext, FileName, &CanonicalName, &NetRootType);
1375 if (!NT_SUCCESS(Status))
1376 {
1377 return Status;
1378 }
1379 }
1380 else
1381 {
1382 PFCB Fcb;
1383
1384 /* Make sure we have a valid FCB and a FOBX */
1385 Fcb = capFileObject->RelatedFileObject->FsContext;
1386 if (Fcb == NULL || capFileObject->RelatedFileObject->FsContext2 == NULL)
1387 {
1389 }
1390
1391 if (!NodeTypeIsFcb(Fcb))
1392 {
1394 }
1395
1397 }
1398
1399 /* Get/Create the associated VNetRoot for opening */
1400 Status = RxFindOrConstructVirtualNetRoot(RxContext, &CanonicalName, NetRootType, NetRootName);
1401 if (!NT_SUCCESS(Status) && Status != STATUS_PENDING &&
1403 {
1404 ASSERT(CanonicalName.Buffer == RxContext->Create.CanonicalNameBuffer);
1405
1406 RxFreeCanonicalNameBuffer(RxContext);
1407 Status = RxFirstCanonicalize(RxContext, FileName, &CanonicalName, &NetRootType);
1408 if (NT_SUCCESS(Status))
1409 {
1410 Status = RxFindOrConstructVirtualNetRoot(RxContext, &CanonicalName, NetRootType, NetRootName);
1411 }
1412 }
1413
1414 /* Filename cannot contain wildcards */
1415 if (FsRtlDoesNameContainWildCards(NetRootName))
1416 {
1418 }
1419
1420 /* Make sure file name is correct */
1421 if (NT_SUCCESS(Status))
1422 {
1423 Status = RxCanonicalizeFileNameByServerSpecs(RxContext, NetRootName);
1424 }
1425
1426 /* Give the mini-redirector a chance to prepare the name */
1428 {
1429 if (RxContext->Create.pNetRoot != NULL)
1430 {
1431 NTSTATUS IgnoredStatus;
1432
1433 MINIRDR_CALL(IgnoredStatus, RxContext, RxContext->Create.pNetRoot->pSrvCall->RxDeviceObject->Dispatch,
1434 MRxPreparseName, (RxContext, NetRootName));
1435 (void)IgnoredStatus;
1436 }
1437 }
1438
1439 return Status;
1440}
_In_ PFCB Fcb
Definition: cdprocs.h:159
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NET_ROOT_WILD
Definition: mrxfcb.h:33
UCHAR NET_ROOT_TYPE
Definition: mrxfcb.h:36
BOOLEAN NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
Definition: name.c:464
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID RxFreeCanonicalNameBuffer(PRX_CONTEXT Context)
Definition: rdbss.c:6159
NTSTATUS RxCanonicalizeFileNameByServerSpecs(PRX_CONTEXT RxContext, PUNICODE_STRING NetRootName)
Definition: rdbss.c:1261
NTSTATUS RxFirstCanonicalize(PRX_CONTEXT RxContext, PUNICODE_STRING FileName, PUNICODE_STRING CanonicalName, PNET_ROOT_TYPE NetRootType)
Definition: rdbss.c:6010
@ RX_CONTEXT_FLAG_MAILSLOT_REPARSE
Definition: rxcontx.h:292
NTSTATUS RxFindOrConstructVirtualNetRoot(_In_ PRX_CONTEXT RxContext, _In_ PUNICODE_STRING CanonicalName, _In_ NET_ROOT_TYPE NetRootType, _In_ PUNICODE_STRING RemainingName)
#define NodeTypeIsFcb(FCB)
Definition: nodetype.h:68
Definition: cdstruc.h:902
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148

Referenced by RxCommonCreate().

◆ RxCheckFcbStructuresForAlignment()

VOID NTAPI RxCheckFcbStructuresForAlignment ( VOID  )

Definition at line 1447 of file rdbss.c.

1449{
1450 PAGED_CODE();
1451}

Referenced by RxDriverEntry().

◆ RxCheckShareAccessPerSrvOpens()

NTSTATUS RxCheckShareAccessPerSrvOpens ( IN PFCB  Fcb,
IN ACCESS_MASK  DesiredAccess,
IN ULONG  DesiredShareAccess 
)

Definition at line 1477 of file rdbss.c.

1481{
1484 BOOLEAN DeleteAccess;
1486
1487 PAGED_CODE();
1488
1490
1491 RxDumpWantedAccess("RxCheckShareAccessPerSrvOpens", "", "RxCheckShareAccessPerSrvOpens", DesiredAccess, DesiredShareAccess);
1492 RxDumpCurrentAccess("RxCheckShareAccessPerSrvOpens", "", "RxCheckShareAccessPerSrvOpens", ShareAccess);
1493
1494 /* Check if any access wanted */
1497 DeleteAccess = (DesiredAccess & DELETE) != 0;
1498
1499 if (ReadAccess || WriteAccess || DeleteAccess)
1500 {
1501 BOOLEAN SharedRead = (DesiredShareAccess & FILE_SHARE_READ) != 0;
1502 BOOLEAN SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE) != 0;
1503 BOOLEAN SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE) != 0;
1504
1505 /* Check whether there's a violation */
1506 if ((ReadAccess &&
1507 (ShareAccess->SharedRead < ShareAccess->OpenCount)) ||
1508 (WriteAccess &&
1509 (ShareAccess->SharedWrite < ShareAccess->OpenCount)) ||
1510 (DeleteAccess &&
1511 (ShareAccess->SharedDelete < ShareAccess->OpenCount)) ||
1512 ((ShareAccess->Readers != 0) && !SharedRead) ||
1513 ((ShareAccess->Writers != 0) && !SharedWrite) ||
1514 ((ShareAccess->Deleters != 0) && !SharedDelete))
1515 {
1517 }
1518 }
1519
1520 return STATUS_SUCCESS;
1521}
#define FILE_SHARE_READ
Definition: compat.h:136
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4147
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_EXECUTE
Definition: nt_native.h:642
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define DELETE
Definition: nt_native.h:57
#define RxDumpWantedAccess(w1, w2, wlt, DA, DSA)
Definition: rxprocs.h:526
#define RxDumpCurrentAccess(w1, w2, wlt, SA)
Definition: rxprocs.h:527
SHARE_ACCESS ShareAccessPerSrvOpens
Definition: fcb.h:155
#define STATUS_SHARING_VIOLATION
Definition: udferr_usr.h:154
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ ULONG DesiredShareAccess
Definition: iofuncs.h:781
@ ReadAccess
Definition: iotypes.h:424
@ WriteAccess
Definition: iotypes.h:425

Referenced by RxSearchForCollapsibleOpen().

◆ RxCleanupPipeQueues()

VOID RxCleanupPipeQueues ( PRX_CONTEXT  Context)

Definition at line 1524 of file rdbss.c.

1526{
1528}

Referenced by RxCommonCleanup().

◆ RxCloseAssociatedSrvOpen()

NTSTATUS RxCloseAssociatedSrvOpen ( IN PFOBX  Fobx,
IN PRX_CONTEXT RxContext  OPTIONAL 
)

Definition at line 1534 of file rdbss.c.

1537{
1538 PFCB Fcb;
1540 PSRV_OPEN SrvOpen;
1541 BOOLEAN CloseSrvOpen;
1542 PRX_CONTEXT LocalContext;
1543
1544 PAGED_CODE();
1545
1546 /* Assume SRV_OPEN is already closed */
1547 CloseSrvOpen = FALSE;
1548 /* If we have a FOBX, we'll have to close it */
1549 if (Fobx != NULL)
1550 {
1551 /* If the FOBX isn't closed yet */
1552 if (!BooleanFlagOn(Fobx->Flags, FOBX_FLAG_SRVOPEN_CLOSED))
1553 {
1554 SrvOpen = Fobx->SrvOpen;
1555 Fcb = (PFCB)SrvOpen->pFcb;
1556 /* Check whether we've to close SRV_OPEN first */
1557 if (!BooleanFlagOn(SrvOpen->Flags, SRVOPEN_FLAG_CLOSED))
1558 {
1559 CloseSrvOpen = TRUE;
1560 }
1561 else
1562 {
1564
1565 /* Not much to do */
1566 SetFlag(Fobx->Flags, FOBX_FLAG_SRVOPEN_CLOSED);
1567
1568 if (SrvOpen->OpenCount > 0)
1569 {
1570 --SrvOpen->OpenCount;
1571 }
1572 }
1573 }
1574
1575 /* No need to close SRV_OPEN, so close FOBX */
1576 if (!CloseSrvOpen)
1577 {
1578 RxMarkFobxOnClose(Fobx);
1579
1580 return STATUS_SUCCESS;
1581 }
1582 }
1583 else
1584 {
1585 /* No FOBX? No RX_CONTEXT, ok, job done! */
1586 if (RxContext == NULL)
1587 {
1588 return STATUS_SUCCESS;
1589 }
1590
1591 /* Get the FCB from RX_CONTEXT */
1592 Fcb = (PFCB)RxContext->pFcb;
1593 SrvOpen = NULL;
1594 }
1595
1596 /* If we don't have RX_CONTEXT, allocte one, we'll need it */
1597 if (RxContext == NULL)
1598 {
1599 ASSERT(Fobx != NULL);
1600
1602 if (LocalContext == NULL)
1603 {
1605 }
1606
1607 LocalContext->MajorFunction = 2;
1608 LocalContext->pFcb = RX_GET_MRX_FCB(Fcb);
1609 LocalContext->pFobx = (PMRX_FOBX)Fobx;
1610 LocalContext->pRelevantSrvOpen = (PMRX_SRV_OPEN)Fobx->SrvOpen;
1611 }
1612 else
1613 {
1614 LocalContext = RxContext;
1615 }
1616
1618
1619 /* Now, close the FOBX */
1620 if (Fobx != NULL)
1621 {
1622 RxMarkFobxOnClose(Fobx);
1623 }
1624 else
1625 {
1626 InterlockedDecrement((volatile long *)&Fcb->OpenCount);
1627 }
1628
1629 /* If not a "standard" file, SRV_OPEN can be null */
1630 if (SrvOpen == NULL)
1631 {
1634
1635 if (LocalContext != RxContext)
1636 {
1637 RxDereferenceAndDeleteRxContext(LocalContext);
1638 }
1639
1640 return STATUS_SUCCESS;
1641 }
1642
1643 /* If SRV_OPEN isn't in a good condition, nothing to close */
1644 if (SrvOpen->Condition != Condition_Good)
1645 {
1646 if (LocalContext != RxContext)
1647 {
1648 RxDereferenceAndDeleteRxContext(LocalContext);
1649 }
1650
1651 return STATUS_SUCCESS;
1652 }
1653
1654 /* Decrease open count */
1655 if (SrvOpen->OpenCount > 0)
1656 {
1657 --SrvOpen->OpenCount;
1658 }
1659
1660 /* If we're the only one left, is there a FOBX handled by Scavenger? */
1661 if (SrvOpen->OpenCount == 1)
1662 {
1663 if (!IsListEmpty(&SrvOpen->FobxList))
1664 {
1665 if (!IsListEmpty(&CONTAINING_RECORD(SrvOpen->FobxList.Flink, FOBX, FobxQLinks)->ScavengerFinalizationList))
1666 {
1667 SetFlag(SrvOpen->Flags, SRVOPEN_FLAG_CLOSE_DELAYED);
1668 }
1669 }
1670 }
1671
1672 /* Nothing left, purge FCB */
1673 if (SrvOpen->OpenCount == 0 && RxContext == NULL)
1674 {
1675 RxPurgeNetFcb(Fcb, LocalContext);
1676 }
1677
1678 /* Already closed? Job done! */
1679 SrvOpen = Fobx->SrvOpen;
1680 if (SrvOpen == NULL ||
1681 (SrvOpen->OpenCount != 0 && !BooleanFlagOn(SrvOpen->Flags, SRVOPEN_FLAG_BUFFERING_STATE_CHANGE_PENDING)) ||
1682 BooleanFlagOn(SrvOpen->Flags, SRVOPEN_FLAG_CLOSED))
1683 {
1684 SetFlag(Fobx->Flags, FOBX_FLAG_SRVOPEN_CLOSED);
1685 if (LocalContext != RxContext)
1686 {
1687 RxDereferenceAndDeleteRxContext(LocalContext);
1688 }
1689
1690 return STATUS_SUCCESS;
1691 }
1692
1694
1695 /* Inform mini-rdr about closing */
1696 MINIRDR_CALL(Status, LocalContext, Fcb->MRxDispatch, MRxCloseSrvOpen, (LocalContext));
1697 DPRINT("MRxCloseSrvOpen returned: %lx, called with RX_CONTEXT %p for FOBX %p (FCB %p, SRV_OPEN %p)\n ",
1698 Status, RxContext, Fobx, Fcb, SrvOpen);
1699
1700 /* And mark as such */
1701 SetFlag(SrvOpen->Flags, SRVOPEN_FLAG_CLOSED);
1702 SrvOpen->Key = (PVOID)-1;
1703
1704 /* If we were delayed, we're not! */
1705 if (BooleanFlagOn(SrvOpen->Flags, SRVOPEN_FLAG_CLOSE_DELAYED))
1706 {
1707 InterlockedDecrement(&((PSRV_CALL)Fcb->pNetRoot->pSrvCall)->NumberOfCloseDelayedFiles);
1708 }
1709
1710 /* Clear access */
1713
1714 /* Dereference */
1716
1717 /* Mark the FOBX closed as well */
1718 SetFlag(Fobx->Flags, FOBX_FLAG_SRVOPEN_CLOSED);
1719
1720 if (LocalContext != RxContext)
1721 {
1722 RxDereferenceAndDeleteRxContext(LocalContext);
1723 }
1724
1725 return Status;
1726}
VOID RxPurgeChangeBufferingStateRequestsForSrvOpen(_In_ PSRV_OPEN SrvOpen)
FCB * PFCB
Definition: cdstruc.h:1040
#define NodeType(P)
Definition: nodetype.h:51
#define RxDereferenceSrvOpen(SrvOpen, LockHoldingState)
Definition: fcb.h:427
#define RxDereferenceNetFcb(Fcb)
Definition: fcb.h:435
#define FOBX_FLAG_SRVOPEN_CLOSED
Definition: fcb.h:296
if(dx< 0)
Definition: linetemp.h:194
@ Condition_Good
Definition: mrx.h:76
struct _MRX_SRV_OPEN_ * PMRX_SRV_OPEN
struct _MRX_FOBX_ * PMRX_FOBX
#define SRVOPEN_FLAG_BUFFERING_STATE_CHANGE_PENDING
Definition: mrxfcb.h:136
#define SRVOPEN_FLAG_CLOSED
Definition: mrxfcb.h:132
#define SRVOPEN_FLAG_CLOSE_DELAYED
Definition: mrxfcb.h:133
VOID RxRemoveShareAccessPerSrvOpens(IN OUT PSRV_OPEN SrvOpen)
Definition: rdbss.c:8635
VOID RxPurgeNetFcb(PFCB Fcb, PRX_CONTEXT LocalContext)
Definition: rdbss.c:7995
@ RX_CONTEXT_FLAG_MUST_SUCCEED_NONBLOCKING
Definition: rxcontx.h:309
@ RX_CONTEXT_FLAG_WAIT
Definition: rxcontx.h:282
PRX_CONTEXT NTAPI RxCreateRxContext(_In_ PIRP Irp, _In_ PRDBSS_DEVICE_OBJECT RxDeviceObject, _In_ ULONG InitialContextFlags)
#define RxIsFcbAcquiredExclusive(Fcb)
Definition: rxprocs.h:229
#define RX_GET_MRX_FCB(F)
Definition: rxprocs.h:157
@ LHS_ExclusiveLockHeld
Definition: rxstruc.h:22
VOID RxMarkFobxOnClose(_In_ PFOBX Fobx)
#define RDBSS_NTC_OPENTARGETDIR_FCB
Definition: nodetype.h:44
#define RDBSS_NTC_MAILSLOT
Definition: nodetype.h:46
#define RDBSS_NTC_IPC_SHARE
Definition: nodetype.h:45
PMINIRDR_DISPATCH MRxDispatch
Definition: fcb.h:150
CLONG OpenCount
Definition: fatstruc.h:881
PRDBSS_DEVICE_OBJECT RxDeviceObject
Definition: fcb.h:149
PMRX_FOBX pFobx
Definition: rxcontx.h:113
UCHAR MajorFunction
Definition: rxcontx.h:105
PMRX_SRV_OPEN pRelevantSrvOpen
Definition: rxcontx.h:114
PMRX_FCB pFcb
Definition: rxcontx.h:112
Definition: fcb.h:10
Definition: fcb.h:261
LIST_ENTRY FobxList
Definition: fcb.h:279
RX_BLOCK_CONDITION Condition
Definition: fcb.h:275
void * PVOID
Definition: typedefs.h:50

Referenced by RxCommonClose().

◆ RxCollapseOrCreateSrvOpen()

NTSTATUS RxCollapseOrCreateSrvOpen ( PRX_CONTEXT  RxContext)

Definition at line 1732 of file rdbss.c.

1734{
1737 PSRV_OPEN SrvOpen;
1740 RX_BLOCK_CONDITION FcbCondition;
1741
1744
1745 PAGED_CODE();
1746
1747 DPRINT("RxCollapseOrCreateSrvOpen(%p)\n", RxContext);
1748
1750 ++capFcb->UncleanCount;
1751
1752 DesiredAccess = capPARAMS->Parameters.Create.SecurityContext->DesiredAccess & FILE_ALL_ACCESS;
1753 ShareAccess = capPARAMS->Parameters.Create.ShareAccess & FILE_SHARE_VALID_FLAGS;
1754
1755 Disposition = RxContext->Create.NtCreateParameters.Disposition;
1756
1757 /* Try to find a reusable SRV_OPEN */
1759 if (Status == STATUS_NOT_FOUND)
1760 {
1761 /* If none found, create one */
1762 SrvOpen = RxCreateSrvOpen((PV_NET_ROOT)RxContext->Create.pVNetRoot, capFcb);
1763 if (SrvOpen == NULL)
1764 {
1766 }
1767 else
1768 {
1769 SrvOpen->DesiredAccess = DesiredAccess;
1770 SrvOpen->ShareAccess = ShareAccess;
1772 }
1773
1774 RxContext->pRelevantSrvOpen = (PMRX_SRV_OPEN)SrvOpen;
1775
1776 if (Status != STATUS_SUCCESS)
1777 {
1778 FcbCondition = Condition_Bad;
1779 }
1780 else
1781 {
1783
1784 /* Cookie to check the mini-rdr doesn't mess with RX_CONTEXT */
1785 RxContext->CurrentIrp->IoStatus.Information = 0xABCDEF;
1786 /* Inform the mini-rdr we're handling a create */
1787 MINIRDR_CALL(Status, RxContext, capFcb->MRxDispatch, MRxCreate, (RxContext));
1788 ASSERT(RxContext->CurrentIrp->IoStatus.Information == 0xABCDEF);
1789
1790 DPRINT("MRxCreate returned: %x\n", Status);
1791 if (Status == STATUS_SUCCESS)
1792 {
1793 /* In case of overwrite, reset file size */
1795 {
1797 capFcb->Header.AllocationSize.QuadPart = 0LL;
1798 capFcb->Header.FileSize.QuadPart = 0LL;
1799 capFcb->Header.ValidDataLength.QuadPart = 0LL;
1800 RxContext->CurrentIrpSp->FileObject->SectionObjectPointer = &capFcb->NonPaged->SectionObjectPointers;
1801 CcSetFileSizes(RxContext->CurrentIrpSp->FileObject, (PCC_FILE_SIZES)&capFcb->Header.AllocationSize);
1803 }
1804 else
1805 {
1806 /* Otherwise, adjust sizes */
1807 RxContext->CurrentIrpSp->FileObject->SectionObjectPointer = &capFcb->NonPaged->SectionObjectPointers;
1808 if (CcIsFileCached(RxContext->CurrentIrpSp->FileObject))
1809 {
1811 }
1812 CcSetFileSizes(RxContext->CurrentIrpSp->FileObject, (PCC_FILE_SIZES)&capFcb->Header.AllocationSize);
1813 }
1814 }
1815
1816 /* Set the IoStatus with information returned by mini-rdr */
1817 RxContext->CurrentIrp->IoStatus.Information = RxContext->Create.ReturnedCreateInformation;
1818
1819 SrvOpen->OpenStatus = Status;
1820 /* Set SRV_OPEN state - good or bad - depending on whether create succeed */
1822
1824
1826
1827 if (Status == STATUS_SUCCESS)
1828 {
1829 if (BooleanFlagOn(capPARAMS->Parameters.Create.Options, FILE_DELETE_ON_CLOSE))
1830 {
1832 }
1833 SrvOpen->CreateOptions = RxContext->Create.NtCreateParameters.CreateOptions;
1834 FcbCondition = Condition_Good;
1835 }
1836 else
1837 {
1838 FcbCondition = Condition_Bad;
1840 RxContext->pRelevantSrvOpen = NULL;
1841
1842 if (RxContext->pFobx != NULL)
1843 {
1845 RxContext->pFobx = NULL;
1846 }
1847 }
1848 }
1849
1850 /* Set FCB state - good or bad - depending on whether create succeed */
1851 DPRINT("Transitioning FCB %p to condition %lx\n", capFcb, capFcb->Condition);
1852 RxTransitionNetFcb(capFcb, FcbCondition);
1853 }
1854 else if (Status == STATUS_SUCCESS)
1855 {
1856 BOOLEAN IsGood, ExtraOpen;
1857
1858 /* A reusable SRV_OPEN was found */
1860 ExtraOpen = FALSE;
1861
1862 SrvOpen = (PSRV_OPEN)RxContext->pRelevantSrvOpen;
1863
1864 IsGood = (SrvOpen->Condition == Condition_Good);
1865 /* If the SRV_OPEN isn't in a stable situation, wait for it to become stable */
1866 if (!StableCondition(SrvOpen->Condition))
1867 {
1868 RxReferenceSrvOpen(SrvOpen);
1869 ++SrvOpen->OpenCount;
1870 ExtraOpen = TRUE;
1871
1872 RxReleaseFcb(RxContext, capFcb);
1873 RxContext->Create.FcbAcquired = FALSE;
1874
1875 RxWaitForStableSrvOpen(SrvOpen, RxContext);
1876
1877 if (NT_SUCCESS(RxAcquireExclusiveFcb(RxContext, capFcb)))
1878 {
1879 RxContext->Create.FcbAcquired = TRUE;
1880 }
1881
1882 IsGood = (SrvOpen->Condition == Condition_Good);
1883 }
1884
1885 /* Inform the mini-rdr we do an opening with a reused SRV_OPEN */
1886 if (IsGood)
1887 {
1888 MINIRDR_CALL(Status, RxContext, capFcb->MRxDispatch, MRxCollapseOpen, (RxContext));
1889
1891 }
1892 else
1893 {
1894 Status = SrvOpen->OpenStatus;
1895 }
1896
1897 if (ExtraOpen)
1898 {
1899 --SrvOpen->OpenCount;
1901 }
1902 }
1903
1904 --capFcb->UncleanCount;
1905
1906 DPRINT("Status: %x\n", Status);
1907 return Status;
1908}
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
VOID RxCompleteSrvOpenKeyAssociation(_Inout_ PSRV_OPEN SrvOpen)
VOID RxInitiateSrvOpenKeyAssociation(_Inout_ PSRV_OPEN SrvOpen)
#define CcIsFileCached(FO)
#define RxTransitionNetFcb(F, C)
Definition: fcb.h:543
#define RxTransitionSrvOpen(S, C)
Definition: fcb.h:578
PSRV_OPEN RxCreateSrvOpen(_In_ PV_NET_ROOT VNetRoot, _In_ OUT PFCB Fcb)
struct _SRV_OPEN * PSRV_OPEN
#define RxReferenceSrvOpen(SrvOpen)
Definition: fcb.h:423
#define FCB_STATE_COLLAPSING_ENABLED
Definition: fcb.h:221
#define RxWaitForStableSrvOpen(S, R)
Definition: fcb.h:577
#define RxDereferenceNetFobx(Fobx, LockHoldingState)
Definition: fcb.h:419
#define FILE_OVERWRITE_IF
Definition: from_kernel.h:58
#define FILE_OVERWRITE
Definition: from_kernel.h:57
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:356
enum _RX_BLOCK_CONDITION RX_BLOCK_CONDITION
@ Condition_Bad
Definition: mrx.h:77
#define StableCondition(X)
Definition: mrx.h:81
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define FILE_SHARE_VALID_FLAGS
Definition: nt_native.h:683
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define FILE_OPENED
Definition: nt_native.h:769
#define RxAdjustAllocationSizeforCC(Fcb)
Definition: ntrxdef.h:35
NTSTATUS RxSearchForCollapsibleOpen(PRX_CONTEXT RxContext, ACCESS_MASK DesiredAccess, ULONG ShareAccess)
Definition: rdbss.c:8679
#define RxAcquireExclusiveFcb(R, F)
Definition: rxprocs.h:154
#define RxAcquirePagingIoResource(RxContext, Fcb)
Definition: rxprocs.h:233
#define STATUS_NOT_FOUND
Definition: shellext.h:72
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
IO_STATUS_BLOCK IoStatus
PIO_STACK_LOCATION CurrentIrpSp
Definition: rxcontx.h:111
NTSTATUS OpenStatus
Definition: fcb.h:286
#define LL
Definition: tui.h:167

Referenced by RxCreateFromNetRoot().

◆ RxCommonCleanup()

NTSTATUS NTAPI RxCommonCleanup ( PRX_CONTEXT  Context)

Definition at line 1915 of file rdbss.c.

1917{
1918#define BugCheckFileId RDBSS_BUG_CHECK_CLEANUP
1919 PFCB Fcb;
1920 PFOBX Fobx;
1923 PNET_ROOT NetRoot;
1925 LARGE_INTEGER TruncateSize;
1926 PLARGE_INTEGER TruncateSizePtr;
1927 BOOLEAN NeedPurge, FcbTableAcquired, OneLeft, IsFile, FcbAcquired, LeftForDelete;
1928
1929 PAGED_CODE();
1930
1931 Fcb = (PFCB)Context->pFcb;
1932 Fobx = (PFOBX)Context->pFobx;
1933 DPRINT("RxCommonCleanup(%p); FOBX: %p, FCB: %p\n", Context, Fobx, Fcb);
1934
1935 /* File system closing, it's OK */
1936 if (Fobx == NULL)
1937 {
1938 if (Fcb->UncleanCount > 0)
1939 {
1940 InterlockedDecrement((volatile long *)&Fcb->UncleanCount);
1941 }
1942
1943 return STATUS_SUCCESS;
1944 }
1945
1946 /* Check we have a correct FCB type */
1951 {
1952 DPRINT1("Invalid Fcb type for %p\n", Fcb);
1953 RxBugCheck(Fcb->Header.NodeTypeCode, 0, 0);
1954 }
1955
1956 FileObject = Context->CurrentIrpSp->FileObject;
1958
1959 RxMarkFobxOnCleanup(Fobx, &NeedPurge);
1960
1962 if (!NT_SUCCESS(Status))
1963 {
1964 return Status;
1965 }
1966
1967 FcbAcquired = TRUE;
1968
1969 Fobx->AssociatedFileObject = NULL;
1970
1971 /* In case it was already orphaned */
1973 {
1974 ASSERT(Fcb->UncleanCount != 0);
1975 InterlockedDecrement((volatile long *)&Fcb->UncleanCount);
1976
1978 {
1979 --Fcb->UncachedUncleanCount;
1980 }
1981
1982 /* Inform mini-rdr */
1983 MINIRDR_CALL(Status, Context, Fcb->MRxDispatch, MRxCleanupFobx, (Context));
1984
1985 ASSERT(Fobx->SrvOpen->UncleanFobxCount != 0);
1986 --Fobx->SrvOpen->UncleanFobxCount;
1987
1989
1991
1992 return STATUS_SUCCESS;
1993 }
1994
1995 /* Report the fact that file could be set as delete on close */
1996 if (BooleanFlagOn(Fobx->Flags, FOBX_FLAG_DELETE_ON_CLOSE))
1997 {
1999 }
2000
2001 /* Cancel any pending notification */
2003
2004 /* Backup open count before we start playing with it */
2006
2007 NetRoot = (PNET_ROOT)Fcb->pNetRoot;
2008 FcbTableAcquired = FALSE;
2009 LeftForDelete = FALSE;
2010 OneLeft = (Fcb->UncleanCount == 1);
2011
2012 _SEH2_TRY
2013 {
2014 /* Unclean count and delete on close? Verify whether we're the one */
2016 {
2018 {
2019 FcbTableAcquired = TRUE;
2020 }
2021 else
2022 {
2024
2026
2028 if (Status != STATUS_SUCCESS)
2029 {
2031 return Status;
2032 }
2033
2034 FcbTableAcquired = TRUE;
2035 }
2036
2037 /* That means we'll perform the delete on close! */
2038 if (Fcb->UncleanCount == 1)
2039 {
2040 LeftForDelete = TRUE;
2041 }
2042 else
2043 {
2045 FcbTableAcquired = FALSE;
2046 }
2047 }
2048
2049 IsFile = FALSE;
2050 TruncateSizePtr = NULL;
2051 /* Handle cleanup for pipes and printers */
2052 if (NetRoot->Type == NET_ROOT_PIPE || NetRoot->Type == NET_ROOT_PRINT)
2053 {
2055 }
2056 /* Handle cleanup for files */
2057 else if (NetRoot->Type == NET_ROOT_DISK || NetRoot->Type == NET_ROOT_WILD)
2058 {
2059 Context->LowIoContext.Flags |= LOWIO_CONTEXT_FLAG_SAVEUNLOCKS;
2061 {
2062 /* First, unlock */
2064
2065 /* If there are still locks to release, proceed */
2066 if (Context->LowIoContext.ParamsFor.Locks.LockList != NULL)
2067 {
2069 Context->LowIoContext.ParamsFor.Locks.Flags = 0;
2071 }
2072
2073 /* Fix times and size */
2075
2076 /* If we're the only one left... */
2077 if (OneLeft)
2078 {
2079 /* And if we're supposed to delete on close */
2080 if (LeftForDelete)
2081 {
2082 /* Update the sizes */
2084 Fcb->Header.FileSize.QuadPart = 0;
2085 Fcb->Header.ValidDataLength.QuadPart = 0;
2087 }
2088 /* Otherwise, call the mini-rdr to adjust sizes */
2089 else
2090 {
2091 /* File got grown up, fill with zeroes */
2093 (Fcb->Header.ValidDataLength.QuadPart < Fcb->Header.FileSize.QuadPart))
2094 {
2095 MINIRDR_CALL(Status, Context, Fcb->MRxDispatch, MRxZeroExtend, (Context));
2096 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
2097 }
2098
2099 /* File was truncated, let mini-rdr proceed */
2101 {
2102 MINIRDR_CALL(Status, Context, Fcb->MRxDispatch, MRxTruncate, (Context));
2104
2105 /* Keep track of file change for Cc uninit */
2106 TruncateSize.QuadPart = Fcb->Header.FileSize.QuadPart;
2107 TruncateSizePtr = &TruncateSize;
2108 }
2109 }
2110 }
2111
2112 /* If RxMarkFobxOnCleanup() asked for purge, make sure we're the only one left first */
2113 if (NeedPurge)
2114 {
2115 if (!OneLeft)
2116 {
2117 NeedPurge = FALSE;
2118 }
2119 }
2120 /* Otherwise, try to see whether we can purge */
2121 else
2122 {
2123 NeedPurge = (OneLeft && (LeftForDelete || !BooleanFlagOn(Fcb->FcbState, FCB_STATE_COLLAPSING_ENABLED)));
2124 }
2125
2126 IsFile = TRUE;
2127 }
2128 }
2129
2130 /* We have to still be there! */
2131 ASSERT(Fcb->UncleanCount != 0);
2132 InterlockedDecrement((volatile long *)&Fcb->UncleanCount);
2133
2135 {
2136 --Fcb->UncachedUncleanCount;
2137 }
2138
2139 /* Inform mini-rdr about ongoing cleanup */
2140 MINIRDR_CALL(Status, Context, Fcb->MRxDispatch, MRxCleanupFobx, (Context));
2141
2142 ASSERT(Fobx->SrvOpen->UncleanFobxCount != 0);
2143 --Fobx->SrvOpen->UncleanFobxCount;
2144
2145 /* Flush cache */
2147 {
2148 /* Only if we're the last standing */
2150 Fcb->UncleanCount == Fcb->UncachedUncleanCount)
2151 {
2152 DPRINT("Flushing %p due to last cached handle cleanup\n", Context);
2154 }
2155 }
2156 else
2157 {
2158 /* Always */
2160 {
2161 DPRINT("Flushing %p on cleanup\n", Context);
2163 }
2164 }
2165
2166 /* If only remaining uncached & unclean, then flush and purge */
2168 {
2169 if (Fcb->UncachedUncleanCount != 0)
2170 {
2171 if (Fcb->UncachedUncleanCount == Fcb->UncleanCount &&
2173 {
2174 DPRINT("Flushing FCB in system cache for %p\n", Context);
2176 }
2177 }
2178 }
2179
2180 /* If purge required, and not about to delete, flush */
2181 if (!LeftForDelete && NeedPurge)
2182 {
2183 DPRINT("Flushing FCB in system cache for %p\n", Context);
2185 }
2186
2187 /* If it was a file, drop cache */
2188 if (IsFile)
2189 {
2190 DPRINT("Uninit cache map for file\n");
2191 RxUninitializeCacheMap(Context, FileObject, TruncateSizePtr);
2192 }
2193
2194 /* If that's the one left for deletion, or if it needs purge, flush */
2195 if (LeftForDelete || NeedPurge)
2196 {
2197 RxPurgeFcbInSystemCache(Fcb, NULL, 0, FALSE, !LeftForDelete);
2198 /* If that's for deletion, also remove from FCB table */
2199 if (LeftForDelete)
2200 {
2203 FcbTableAcquired = FALSE;
2204 }
2205 }
2206
2207 /* Remove any share access */
2208 if (OpenCount != 0 && NetRoot->Type == NET_ROOT_DISK)
2209 {
2210 RxRemoveShareAccess(FileObject, &Fcb->ShareAccess, "Cleanup the share access", "ClnUpShr");
2211 }
2212
2213 /* In case there's caching, on a file, and we were asked to drop collapsing, handle it */
2214 if (NodeType(Fcb) == RDBSS_NTC_STORAGE_TYPE_FILE && BooleanFlagOn(Fobx->Flags, FOBX_FLAG_DISABLE_COLLAPSING) &&
2215 RxWriteCacheingAllowed(Fcb, Fobx->pSrvOpen))
2216 {
2217 NTSTATUS InternalStatus;
2218 PRX_CONTEXT InternalContext;
2219
2220 /* If we can properly set EOF, there's no need to drop collapsing, try to do it */
2221 InternalStatus = STATUS_UNSUCCESSFUL;
2222 InternalContext = RxCreateRxContext(Context->CurrentIrp,
2225 if (InternalContext != NULL)
2226 {
2228
2229 InternalStatus = STATUS_SUCCESS;
2230
2231 /* Initialize the context for file information set */
2232 InternalContext->pFcb = RX_GET_MRX_FCB(Fcb);
2233 InternalContext->pFobx = (PMRX_FOBX)Fobx;
2234 InternalContext->pRelevantSrvOpen = Fobx->pSrvOpen;
2235
2236 /* Get EOF from the FCB */
2237 FileEOF.EndOfFile.QuadPart = Fcb->Header.FileSize.QuadPart;
2238 InternalContext->Info.FileInformationClass = FileEndOfFileInformation;
2239 InternalContext->Info.Buffer = &FileEOF;
2240 InternalContext->Info.Length = sizeof(FileEOF);
2241
2242 /* Call the mini-rdr */
2243 MINIRDR_CALL_THROUGH(InternalStatus, Fcb->MRxDispatch, MRxSetFileInfo, (InternalContext));
2244
2245 /* We're done */
2246 RxDereferenceAndDeleteRxContext(InternalContext);
2247 }
2248
2249 /* We tried, so, clean the FOBX flag */
2250 ClearFlag(Fobx->Flags, FOBX_FLAG_DISABLE_COLLAPSING);
2251 /* If it failed, then, disable collapsing on the FCB */
2252 if (!NT_SUCCESS(InternalStatus))
2253 {
2255 }
2256 }
2257
2258 /* We're clean! */
2260
2261 FcbAcquired = FALSE;
2263 }
2265 {
2266 if (FcbAcquired)
2267 {
2269 }
2270
2271 if (FcbTableAcquired)
2272 {
2274 }
2275 }
2276 _SEH2_END;
2277
2278 return Status;
2279#undef BugCheckFileId
2280}
NTSTATUS RxPurgeFcbInSystemCache(_In_ PFCB Fcb, _In_ PLARGE_INTEGER FileOffset OPTIONAL, _In_ ULONG Length, _In_ BOOLEAN UninitializeCacheMaps, _In_ BOOLEAN FlushFile)
NTSTATUS RxFlushFcbInSystemCache(_In_ PFCB Fcb, _In_ BOOLEAN SynchronizeWithLazyWriter)
DWORD OpenCount
Definition: legacy.c:25
#define FCB_STATE_DELETE_ON_CLOSE
Definition: fatstruc.h:1193
#define FCB_STATE_TRUNCATE_ON_CLOSE
Definition: fatstruc.h:1194
#define FCB_STATE_PAGING_FILE
Definition: fatstruc.h:1195
#define FCB_STATE_ORPHANED
Definition: fcb.h:208
#define FOBX_FLAG_DELETE_ON_CLOSE
Definition: fcb.h:295
struct _NET_ROOT * PNET_ROOT
VOID RxRemoveNameNetFcb(_Out_ PFCB ThisFcb)
#define RxAcquireFcbTableLockExclusive(T, W)
Definition: fcbtable.h:55
#define RxReleaseFcbTableLock(T)
Definition: fcbtable.h:56
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
Definition: filelock.c:1025
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
VOID NTAPI RxInitializeLowIoContext(_Out_ PLOWIO_CONTEXT LowIoContext, _In_ ULONG Operation)
#define LOWIO_CONTEXT_FLAG_SAVEUNLOCKS
Definition: mrx.h:321
@ LOWIO_OP_UNLOCK_MULTIPLE
Definition: mrx.h:239
#define NET_ROOT_PIPE
Definition: mrxfcb.h:31
#define NET_ROOT_DISK
Definition: mrxfcb.h:30
#define NET_ROOT_PRINT
Definition: mrxfcb.h:32
#define RxGetRequestorProcess(RxContext)
Definition: ntrxdef.h:33
BOOLEAN DisableFlushOnCleanup
Definition: rdbss.c:533
VOID RxAdjustFileTimesAndSize(PRX_CONTEXT RxContext)
Definition: rdbss.c:825
VOID RxUninitializeCacheMap(PRX_CONTEXT RxContext, PFILE_OBJECT FileObject, PLARGE_INTEGER TruncateSize)
Definition: rdbss.c:9414
NTSTATUS RxLowIoLockControlShell(IN PRX_CONTEXT RxContext)
Definition: rdbss.c:7212
VOID RxCleanupPipeQueues(PRX_CONTEXT Context)
Definition: rdbss.c:1524
VOID RxCancelNotifyChangeDirectoryRequestsForFobx(PFOBX Fobx)
Definition: rdbss.c:963
#define MINIRDR_CALL_THROUGH(STATUS, DISPATCH, FUNC, ARGLIST)
Definition: rxcontx.h:375
#define RxRemoveShareAccess(a1, a2, a3, a4)
Definition: rxprocs.h:579
VOID RxMarkFobxOnCleanup(_In_ PFOBX pFobx, _Out_ PBOOLEAN NeedPurge)
#define RDBSS_NTC_STORAGE_TYPE_UNKNOWN
Definition: nodetype.h:41
#define RDBSS_NTC_STORAGE_TYPE_DIRECTORY
Definition: nodetype.h:42
#define RDBSS_NTC_STORAGE_TYPE_FILE
Definition: nodetype.h:43
#define RDBSS_NTC_SPOOLFILE
Definition: nodetype.h:47
#define RxBugCheck(A, B, C)
Definition: nodetype.h:86
union _FCB::@720 Specific
SHARE_ACCESS ShareAccess
Definition: cdstruc.h:1009
struct _FCB::@720::@723 Fcb
CLONG UncleanCount
Definition: fatstruc.h:873
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:925
ULONG FcbState
Definition: cdstruc.h:971
PNON_PAGED_FCB NonPaged
Definition: fatstruc.h:811
PSRV_OPEN SrvOpen
Definition: fcb.h:312
Definition: fcb.h:34
RX_FCB_TABLE FcbTable
Definition: fcb.h:54
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: fatstruc.h:729
ULONG OpenCount
Definition: iotypes.h:525
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define FO_CLEANUP_COMPLETE
Definition: iotypes.h:1790
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FO_NO_INTERMEDIATE_BUFFERING
Definition: iotypes.h:1778

◆ RxCommonClose()

NTSTATUS NTAPI RxCommonClose ( PRX_CONTEXT  Context)

Definition at line 2284 of file rdbss.c.

2286{
2287#define BugCheckFileId RDBSS_BUG_CHECK_CLOSE
2288 PFCB Fcb;
2289 PFOBX Fobx;
2292 BOOLEAN DereferenceFobx, AcquiredFcb;
2293
2294 PAGED_CODE();
2295
2296 Fcb = (PFCB)Context->pFcb;
2297 Fobx = (PFOBX)Context->pFobx;
2298 FileObject = Context->CurrentIrpSp->FileObject;
2299 DPRINT("RxCommonClose(%p); FOBX: %p, FCB: %p, FO: %p\n", Context, Fobx, Fcb, FileObject);
2300
2302 if (!NT_SUCCESS(Status))
2303 {
2304 return Status;
2305 }
2306
2307 AcquiredFcb = TRUE;
2308 _SEH2_TRY
2309 {
2310 BOOLEAN Freed;
2311
2312 /* Check our FCB type is expected */
2316 {
2317 RxBugCheck(NodeType(Fcb), 0, 0);
2318 }
2319
2321
2322 DereferenceFobx = FALSE;
2323 /* If we're not closing FS */
2324 if (Fobx != NULL)
2325 {
2326 PSRV_OPEN SrvOpen;
2327 PSRV_CALL SrvCall;
2328
2329 SrvOpen = (PSRV_OPEN)Fobx->pSrvOpen;
2330 SrvCall = (PSRV_CALL)Fcb->pNetRoot->pSrvCall;
2331 /* Handle delayed close */
2333 {
2335 {
2337 {
2338 DPRINT("Delay close for FOBX: %p, SrvOpen %p\n", Fobx, SrvOpen);
2339
2340 if (SrvOpen->OpenCount == 1 && !BooleanFlagOn(SrvOpen->Flags, SRVOPEN_FLAG_COLLAPSING_DISABLED))
2341 {
2342 if (InterlockedIncrement(&SrvCall->NumberOfCloseDelayedFiles) >= SrvCall->MaximumNumberOfCloseDelayedFiles)
2343 {
2345 }
2346 else
2347 {
2348 DereferenceFobx = TRUE;
2349 SetFlag(SrvOpen->Flags, SRVOPEN_FLAG_CLOSE_DELAYED);
2350 }
2351 }
2352 }
2353 }
2354 }
2355
2356 /* If we reach maximum of delayed close/or if there are no delayed close */
2357 if (!DereferenceFobx)
2358 {
2359 PNET_ROOT NetRoot;
2360
2361 NetRoot = (PNET_ROOT)Fcb->pNetRoot;
2362 if (NetRoot->Type != NET_ROOT_PRINT)
2363 {
2364 /* Delete if asked */
2365 if (BooleanFlagOn(Fobx->Flags, FOBX_FLAG_DELETE_ON_CLOSE))
2366 {
2369
2371
2375
2378 }
2379 }
2380 }
2381
2382 RxMarkFobxOnClose(Fobx);
2383 }
2384
2385 if (DereferenceFobx)
2386 {
2387 ASSERT(Fobx != NULL);
2389 }
2390 else
2391 {
2393 if (Fobx != NULL)
2394 {
2396 }
2397 }
2398
2400 AcquiredFcb = !Freed;
2401
2402 FileObject->FsContext = (PVOID)-1;
2403
2404 if (Freed)
2405 {
2406 RxTrackerUpdateHistory(Context, NULL, TRACKER_FCB_FREE, __LINE__, __FILE__, 0);
2407 }
2408 else
2409 {
2411 AcquiredFcb = FALSE;
2412 }
2413 }
2415 {
2417 {
2418 if (AcquiredFcb)
2419 {
2421 }
2422 }
2423 else
2424 {
2425 ASSERT(!AcquiredFcb);
2426 }
2427 }
2428 _SEH2_END;
2429
2430 DPRINT("Status: %x\n", Status);
2431 return Status;
2432#undef BugCheckFileId
2433}
#define RxReferenceNetFcb(Fcb)
Definition: fcb.h:431
#define RxDereferenceAndFinalizeNetFcb(Fcb, RxContext, RecursiveFinalize, ForceFinalize)
Definition: fcb.h:439
#define SRVOPEN_FLAG_COLLAPSING_DISABLED
Definition: mrxfcb.h:137
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:160
NTSTATUS RxCloseAssociatedSrvOpen(IN PFOBX Fobx, IN PRX_CONTEXT RxContext OPTIONAL)
Definition: rdbss.c:1534
VOID RxOrphanThisFcb(_In_ PFCB Fcb)
#define RxTrackerUpdateHistory(R, F, O, L, F, S)
Definition: rxprocs.h:218
@ LHS_SharedLockHeld
Definition: rxstruc.h:21
VOID RxSynchronizeWithScavenger(_In_ PRX_CONTEXT RxContext)
BOOLEAN RxScavengeRelatedFobxs(_In_ PFCB Fcb)
volatile LONG NumberOfCloseDelayedFiles
Definition: fcb.h:23

◆ RxCommonCreate()

NTSTATUS NTAPI RxCommonCreate ( PRX_CONTEXT  Context)

Definition at line 2440 of file rdbss.c.

2442{
2443 PIRP Irp;
2447
2448 PAGED_CODE();
2449
2450 DPRINT("RxCommonCreate(%p)\n", Context);
2451
2452 Irp = Context->CurrentIrp;
2453 Stack = Context->CurrentIrpSp;
2454 FileObject = Stack->FileObject;
2455
2456 /* Check whether that's a device opening */
2457 if (FileObject->FileName.Length == 0 && FileObject->RelatedFileObject == NULL)
2458 {
2459 FileObject->FsContext = &RxDeviceFCB;
2460 FileObject->FsContext2 = NULL;
2461
2462 ++RxDeviceFCB.NodeReferenceCount;
2464
2465 Irp->IoStatus.Information = FILE_OPENED;
2466 DPRINT("Device opening FO: %p, DO: %p, Name: %wZ\n", FileObject, Context->RxDeviceObject, &Context->RxDeviceObject->DeviceName);
2467
2469 }
2470 else
2471 {
2472 PFCB RelatedFcb = NULL;
2473
2474 /* Make sure caller is consistent */
2477 {
2478 DPRINT1("Create.Options: %x\n", Stack->Parameters.Create.Options);
2480 }
2481
2482 DPRINT("Ctxt: %p, FO: %p, Options: %lx, Flags: %lx, Attr: %lx, ShareAccess: %lx, DesiredAccess: %lx\n",
2483 Context, FileObject, Stack->Parameters.Create.Options, Stack->Flags, Stack->Parameters.Create.FileAttributes,
2484 Stack->Parameters.Create.ShareAccess, Stack->Parameters.Create.SecurityContext->DesiredAccess);
2485 DPRINT("FileName: %wZ\n", &FileObject->FileName);
2486
2487 if (FileObject->RelatedFileObject != NULL)
2488 {
2489 RelatedFcb = FileObject->RelatedFileObject->FsContext;
2490 DPRINT("Rel FO: %p, path: %wZ\n", FileObject->RelatedFileObject, RelatedFcb->FcbTableEntry.Path);
2491 }
2492
2493 /* Going to rename? */
2495 {
2496 DPRINT("TargetDir!\n");
2497 }
2498
2499 /* Copy create parameters to the context */
2501
2502 /* If the caller wants to establish a connection, go ahead */
2503 if (BooleanFlagOn(Stack->Parameters.Create.Options, FILE_CREATE_TREE_CONNECTION))
2504 {
2506 }
2507 else
2508 {
2509 /* Validate file name */
2510 if (FileObject->FileName.Length > sizeof(WCHAR) &&
2511 FileObject->FileName.Buffer[1] == OBJ_NAME_PATH_SEPARATOR &&
2512 FileObject->FileName.Buffer[0] == OBJ_NAME_PATH_SEPARATOR)
2513 {
2514 FileObject->FileName.Length -= sizeof(WCHAR);
2515 RtlMoveMemory(&FileObject->FileName.Buffer[0], &FileObject->FileName.Buffer[1],
2516 FileObject->FileName.Length);
2517
2518 if (FileObject->FileName.Length > sizeof(WCHAR) &&
2519 FileObject->FileName.Buffer[1] == OBJ_NAME_PATH_SEPARATOR &&
2520 FileObject->FileName.Buffer[0] == OBJ_NAME_PATH_SEPARATOR)
2521 {
2523 }
2524 }
2525
2526 /* Attempt to open the file */
2527 do
2528 {
2529 UNICODE_STRING NetRootName;
2530
2531 /* Strip last \ if required */
2532 if (FileObject->FileName.Length != 0 &&
2533 FileObject->FileName.Buffer[FileObject->FileName.Length / sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR)
2534 {
2535 if (BooleanFlagOn(Stack->Parameters.Create.Options, FILE_NON_DIRECTORY_FILE))
2536 {
2538 }
2539
2540 FileObject->FileName.Length -= sizeof(WCHAR);
2542 }
2543
2545 {
2546 FileObject->Flags |= FO_WRITE_THROUGH;
2547 }
2548
2549 /* Get the associated net root to opening */
2550 Status = RxCanonicalizeNameAndObtainNetRoot(Context, &FileObject->FileName, &NetRootName);
2552 {
2553 break;
2554 }
2555
2556 /* And attempt to open */
2557 Status = RxCreateFromNetRoot(Context, &NetRootName);
2559 {
2561
2562 /* If that happens for file creation, fail for real */
2563 if (Context->Create.NtCreateParameters.Disposition == FILE_CREATE)
2564 {
2566 }
2567 else
2568 {
2569 /* Otherwise, if possible, attempt to scavenger current FOBX
2570 * to check whether a dormant FOBX is the reason for sharing violation
2571 */
2572 if (Context->Create.TryForScavengingOnSharingViolation &&
2573 !Context->Create.ScavengingAlreadyTried)
2574 {
2575 /* Only doable with a VNetRoot */
2576 if (Context->Create.pVNetRoot != NULL)
2577 {
2578 PV_NET_ROOT VNetRoot;
2579 NT_CREATE_PARAMETERS SavedParameters;
2580
2581 /* Save create parameters */
2582 RtlCopyMemory(&SavedParameters, &Context->Create.NtCreateParameters, sizeof(NT_CREATE_PARAMETERS));
2583
2584 /* Reference the VNetRoot for the scavenging time */
2585 VNetRoot = (PV_NET_ROOT)Context->Create.pVNetRoot;
2586 RxReferenceVNetRoot(VNetRoot);
2587
2588 /* Prepare the RX_CONTEXT for reuse */
2591
2592 /* Copy what we saved */
2593 RtlCopyMemory(&Context->Create.NtCreateParameters, &SavedParameters, sizeof(NT_CREATE_PARAMETERS));
2594
2595 /* And recopy what can be */
2597
2598 /* And start purging, then scavenging FOBX */
2599 RxPurgeRelatedFobxs((PNET_ROOT)VNetRoot->pNetRoot, Context,
2601 RxScavengeFobxsForNetRoot((PNET_ROOT)VNetRoot->pNetRoot,
2602 NULL, TRUE);
2603
2604 /* Ask for a second round */
2606
2607 /* Keep track we already scavenged */
2608 Context->Create.ScavengingAlreadyTried = TRUE;
2609
2610 /* Reference our SRV_CALL for CBS handling */
2611 RxReferenceSrvCall(VNetRoot->pNetRoot->pSrvCall);
2612 RxpProcessChangeBufferingStateRequests((PSRV_CALL)VNetRoot->pNetRoot->pSrvCall, FALSE);
2613
2614 /* Drop our extra reference */
2616 }
2617 }
2618 }
2619 }
2620 else if (Status == STATUS_REPARSE)
2621 {
2622 Context->CurrentIrp->IoStatus.Information = 0;
2623 }
2624 else
2625 {
2627 }
2628 }
2630 }
2631
2632 if (Status == STATUS_RETRY)
2633 {
2635 }
2637 }
2638
2639 DPRINT("Status: %lx\n", Status);
2640 return Status;
2641}
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
VOID RxpProcessChangeBufferingStateRequests(PSRV_CALL SrvCall, BOOLEAN UpdateHandlerState)
Definition: rxce.c:6417
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define RxReferenceVNetRoot(VNetRoot)
Definition: fcb.h:407
struct _V_NET_ROOT * PV_NET_ROOT
#define RxReferenceSrvCall(SrvCall)
Definition: fcb.h:391
#define RxDereferenceVNetRoot(VNetRoot, LockHoldingState)
Definition: fcb.h:411
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_OPEN_REMOTE_INSTANCE
Definition: from_kernel.h:37
#define FILE_CREATE_TREE_CONNECTION
Definition: from_kernel.h:33
#define STATUS_REPARSE
Definition: ntstatus.h:83
FCB RxDeviceFCB
Definition: rdbss.c:538
VOID RxpPrepareCreateContextForReuse(PRX_CONTEXT RxContext)
Definition: rdbss.c:7654
VOID RxCopyCreateParameters(IN PRX_CONTEXT RxContext)
Definition: rdbss.c:5039
NTSTATUS RxCreateFromNetRoot(PRX_CONTEXT Context, PUNICODE_STRING NetRootName)
Definition: rdbss.c:5114
NTSTATUS RxCreateTreeConnect(IN PRX_CONTEXT RxContext)
Definition: rdbss.c:5409
NTSTATUS RxCanonicalizeNameAndObtainNetRoot(PRX_CONTEXT RxContext, PUNICODE_STRING FileName, PUNICODE_STRING NetRootName)
Definition: rdbss.c:1352
@ RX_CONTEXT_FLAG_WRITE_THROUGH
Definition: rxcontx.h:283
VOID NTAPI RxReinitializeContext(_Inout_ PRX_CONTEXT RxContext)
@ RX_CONTEXT_CREATE_FLAG_REPARSE
Definition: rxcontx.h:327
@ RX_CONTEXT_CREATE_FLAG_STRIPPED_TRAILING_BACKSLASH
Definition: rxcontx.h:325
@ LHS_LockNotHeld
Definition: rxstruc.h:20
VOID RxScavengeFobxsForNetRoot(PNET_ROOT NetRoot, PFCB PurgingFcb, BOOLEAN SynchronizeWithScavenger)
Definition: rxce.c:7798
NTSTATUS RxPurgeRelatedFobxs(PNET_ROOT NetRoot, PRX_CONTEXT RxContext, BOOLEAN AttemptFinalization, PFCB PurgingFcb)
Definition: rxce.c:7133
#define DONT_ATTEMPT_FINALIZE_ON_PURGE
Definition: scavengr.h:45
RX_FCB_TABLE_ENTRY FcbTableEntry
Definition: fcb.h:144
UNICODE_STRING Path
Definition: fcbtable.h:8
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_RETRY
Definition: udferr_usr.h:182
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define FO_WRITE_THROUGH
Definition: iotypes.h:1779
#define SL_OPEN_TARGET_DIRECTORY
Definition: iotypes.h:1818

◆ RxCommonDevFCBCleanup()

NTSTATUS NTAPI RxCommonDevFCBCleanup ( PRX_CONTEXT  Context)

Definition at line 2648 of file rdbss.c.

2650{
2651 PMRX_FCB Fcb;
2653
2654 PAGED_CODE();
2655
2656 DPRINT("RxCommonDevFCBCleanup(%p)\n", Context);
2657
2658 Fcb = Context->pFcb;
2661
2662 /* Our FOBX if set, has to be a VNetRoot */
2663 if (Context->pFobx != NULL)
2664 {
2665 RxAcquirePrefixTableLockShared(Context->RxDeviceObject->pRxNetNameTable, TRUE);
2666 if (Context->pFobx->NodeTypeCode != RDBSS_NTC_V_NETROOT)
2667 {
2669 }
2670 RxReleasePrefixTableLock(Context->RxDeviceObject->pRxNetNameTable);
2671 }
2672 else
2673 {
2674 --Fcb->UncleanCount;
2675 }
2676
2677 return Status;
2678}
#define RxAcquirePrefixTableLockShared(T, W)
Definition: prefix.h:82
#define RxReleasePrefixTableLock(T)
Definition: prefix.h:84
#define RDBSS_NTC_DEVICE_FCB
Definition: nodetype.h:54
#define RDBSS_NTC_V_NETROOT
Definition: nodetype.h:50
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138

◆ RxCommonDevFCBClose()

NTSTATUS NTAPI RxCommonDevFCBClose ( PRX_CONTEXT  Context)

Definition at line 2685 of file rdbss.c.

2687{
2688 PMRX_FCB Fcb;
2690 PMRX_V_NET_ROOT NetRoot;
2691
2692 PAGED_CODE();
2693
2694 DPRINT("RxCommonDevFCBClose(%p)\n", Context);
2695
2696 Fcb = Context->pFcb;
2697 NetRoot = (PMRX_V_NET_ROOT)Context->pFobx;
2700
2701 /* Our FOBX if set, has to be a VNetRoot */
2702 if (NetRoot != NULL)
2703 {
2704 RxAcquirePrefixTableLockExclusive(Context->RxDeviceObject->pRxNetNameTable, TRUE);
2705 if (NetRoot->NodeTypeCode == RDBSS_NTC_V_NETROOT)
2706 {
2707 --NetRoot->NumberOfOpens;
2709 }
2710 else
2711 {
2713 }
2714 RxReleasePrefixTableLock(Context->RxDeviceObject->pRxNetNameTable);
2715 }
2716 else
2717 {
2718 --Fcb->OpenCount;
2719 }
2720
2721 return Status;
2722}
struct _MRX_V_NET_ROOT_ * PMRX_V_NET_ROOT
#define RxAcquirePrefixTableLockExclusive(T, W)
Definition: prefix.h:83
ULONG NumberOfOpens
Definition: mrxfcb.h:97

◆ RxCommonDevFCBFsCtl()

NTSTATUS NTAPI RxCommonDevFCBFsCtl ( PRX_CONTEXT  Context)

Definition at line 2726 of file rdbss.c.

2728{
2731}

◆ RxCommonDevFCBIoCtl()

NTSTATUS NTAPI RxCommonDevFCBIoCtl ( PRX_CONTEXT  Context)

Definition at line 2738 of file rdbss.c.

2740{
2742
2743 PAGED_CODE();
2744
2745 DPRINT("RxCommonDevFCBIoCtl(%p)\n", Context);
2746
2747 if (Context->pFobx != NULL)
2748 {
2749 return STATUS_INVALID_HANDLE;
2750 }
2751
2752 /* Is that a prefix claim from MUP? */
2753 if (Context->CurrentIrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_REDIR_QUERY_PATH)
2754 {
2755 return RxPrefixClaim(Context);
2756 }
2757
2758 /* Otherwise, pass through the mini-rdr */
2760 if (Status != STATUS_PENDING)
2761 {
2762 if (Context->PostRequest)
2763 {
2764 Context->ResumeRoutine = RxCommonDevFCBIoCtl;
2766 }
2767 }
2768
2769 DPRINT("Status: %lx\n", Status);
2770 return Status;
2771}
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
NTSTATUS RxFsdPostRequest(IN PRX_CONTEXT RxContext)
Definition: rdbss.c:6548
NTSTATUS RxPrefixClaim(IN PRX_CONTEXT RxContext)
Definition: rdbss.c:7714
NTSTATUS RxXXXControlFileCallthru(PRX_CONTEXT Context)
Definition: rdbss.c:9561
NTSTATUS NTAPI RxCommonDevFCBIoCtl(PRX_CONTEXT Context)
Definition: rdbss.c:2738

Referenced by RxCommonDevFCBIoCtl().

◆ RxCommonDevFCBQueryVolInfo()

NTSTATUS NTAPI RxCommonDevFCBQueryVolInfo ( PRX_CONTEXT  Context)

Definition at line 2775 of file rdbss.c.

2777{
2780}

◆ RxCommonDeviceControl()

NTSTATUS NTAPI RxCommonDeviceControl ( PRX_CONTEXT  Context)

Definition at line 2787 of file rdbss.c.

2789{
2791
2792 PAGED_CODE();
2793
2794 /* Prefix claim is only allowed for device, not files */
2795 if (Context->CurrentIrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_REDIR_QUERY_PATH)
2796 {
2798 }
2799
2800 /* Submit to mini-rdr */
2803 if (Status == STATUS_PENDING)
2804 {
2806 }
2807
2808 return Status;
2809}
NTSTATUS NTAPI RxLowIoSubmit(_In_ PRX_CONTEXT RxContext, _In_ PLOWIO_COMPLETION_ROUTINE CompletionRoutine)
@ LOWIO_OP_IOCTL
Definition: mrx.h:241
NTSTATUS NTAPI RxLowIoIoCtlShellCompletion(PRX_CONTEXT RxContext)
Definition: rdbss.c:7187
VOID NTAPI RxDereferenceAndDeleteRxContext_Real(_In_ PRX_CONTEXT RxContext)

◆ RxCommonDirectoryControl()

NTSTATUS NTAPI RxCommonDirectoryControl ( PRX_CONTEXT  Context)

Definition at line 2816 of file rdbss.c.

2818{
2819 PFCB Fcb;
2820 PFOBX Fobx;
2823
2824 PAGED_CODE();
2825
2826 Fcb = (PFCB)Context->pFcb;
2827 Fobx = (PFOBX)Context->pFobx;
2828 Stack = Context->CurrentIrpSp;
2829 DPRINT("RxCommonDirectoryControl(%p) FOBX: %p, FCB: %p, Minor: %d\n", Context, Fobx, Fcb, Stack->MinorFunction);
2830
2831 /* Call the appropriate helper */
2832 if (Stack->MinorFunction == IRP_MN_QUERY_DIRECTORY)
2833 {
2835 }
2836 else if (Stack->MinorFunction == IRP_MN_NOTIFY_CHANGE_DIRECTORY)
2837 {
2839 if (Status == STATUS_PENDING)
2840 {
2842 }
2843 }
2844 else
2845 {
2847 }
2848
2849 return Status;
2850}
NTSTATUS RxQueryDirectory(PRX_CONTEXT RxContext)
Definition: rdbss.c:8052
NTSTATUS RxNotifyChangeDirectory(PRX_CONTEXT RxContext)
Definition: rdbss.c:7556
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55

◆ RxCommonDispatchProblem()

NTSTATUS NTAPI RxCommonDispatchProblem ( PRX_CONTEXT  Context)

Definition at line 2854 of file rdbss.c.

2856{
2859}

◆ RxCommonFileSystemControl()

NTSTATUS NTAPI RxCommonFileSystemControl ( PRX_CONTEXT  Context)

Definition at line 2863 of file rdbss.c.

2865{
2866 PIRP Irp;
2869
2870 PAGED_CODE();
2871
2872 Irp = Context->CurrentIrp;
2873 Stack = Context->CurrentIrpSp;
2874 ControlCode = Stack->Parameters.FileSystemControl.FsControlCode;
2875
2876 DPRINT1("RxCommonFileSystemControl: %p, %p, %d, %lx\n", Context, Irp, Stack->MinorFunction, ControlCode);
2877
2880}
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55

◆ RxCommonFlushBuffers()

NTSTATUS NTAPI RxCommonFlushBuffers ( PRX_CONTEXT  Context)

Definition at line 2884 of file rdbss.c.

2886{
2889}

◆ RxCommonLockControl()

NTSTATUS NTAPI RxCommonLockControl ( PRX_CONTEXT  Context)

Definition at line 2893 of file rdbss.c.

2895{
2898}

◆ RxCommonQueryEa()

NTSTATUS NTAPI RxCommonQueryEa ( PRX_CONTEXT  Context)

Definition at line 2902 of file rdbss.c.

2904{
2907}

◆ RxCommonQueryInformation()

NTSTATUS NTAPI RxCommonQueryInformation ( PRX_CONTEXT  Context)

Definition at line 2914 of file rdbss.c.

2916{
2917#define SET_SIZE_AND_QUERY(AlreadyConsummed, Function) \
2918 Context->Info.Length = Stack->Parameters.QueryFile.Length - (AlreadyConsummed); \
2919 Status = Function(Context, Add2Ptr(Buffer, AlreadyConsummed))
2920
2921 PFCB Fcb;
2922 PIRP Irp;
2923 PFOBX Fobx;
2927 FILE_INFORMATION_CLASS FileInfoClass;
2928
2929 PAGED_CODE();
2930
2931 Fcb = (PFCB)Context->pFcb;
2932 Fobx = (PFOBX)Context->pFobx;
2933 DPRINT("RxCommonQueryInformation(%p) FCB: %p, FOBX: %p\n", Context, Fcb, Fobx);
2934
2935 Irp = Context->CurrentIrp;
2936 Stack = Context->CurrentIrpSp;
2937 DPRINT("Buffer: %p, Length: %lx, Class: %ld\n", Irp->AssociatedIrp.SystemBuffer,
2938 Stack->Parameters.QueryFile.Length, Stack->Parameters.QueryFile.FileInformationClass);
2939
2940 Context->Info.Length = Stack->Parameters.QueryFile.Length;
2941 FileInfoClass = Stack->Parameters.QueryFile.FileInformationClass;
2942
2943 Locked = FALSE;
2944 _SEH2_TRY
2945 {
2946 PVOID Buffer;
2947
2948 /* Get a writable buffer */
2950 if (Buffer == NULL)
2951 {
2954 }
2955 /* Zero it */
2956 RtlZeroMemory(Buffer, Context->Info.Length);
2957
2958 /* Validate file type */
2960 {
2962 {
2965 }
2967 {
2969 {
2971 }
2972 else
2973 {
2975 }
2976
2978 }
2979 }
2980
2981 /* Acquire the right lock */
2983 FileInfoClass != FileNameInformation)
2984 {
2985 if (FileInfoClass == FileCompressionInformation)
2986 {
2988 }
2989 else
2990 {
2992 }
2993
2995 {
2998 }
2999 else if (!NT_SUCCESS(Status))
3000 {
3002 }
3003
3004 Locked = TRUE;
3005 }
3006
3007 /* Dispatch to the right helper */
3008 switch (FileInfoClass)
3009 {
3012 break;
3013
3016 break;
3017
3020 break;
3021
3022 case FileEaInformation:
3024 break;
3025
3028 break;
3029
3030 case FileAllInformation:
3032 if (!NT_SUCCESS(Status))
3033 {
3034 break;
3035 }
3036
3038 if (!NT_SUCCESS(Status))
3039 {
3040 break;
3041 }
3042
3045 if (!NT_SUCCESS(Status))
3046 {
3047 break;
3048 }
3049
3053 if (!NT_SUCCESS(Status))
3054 {
3055 break;
3056 }
3057
3062 if (!NT_SUCCESS(Status))
3063 {
3064 break;
3065 }
3066
3070 sizeof(FILE_EA_INFORMATION) +
3072 break;
3073
3076 break;
3077
3082 break;
3083
3086 break;
3087
3088 default:
3089 Context->IoStatusBlock.Status = RxpQueryInfoMiniRdr(Context, FileInfoClass, Buffer);
3090 Status = Context->IoStatusBlock.Status;
3091 break;
3092 }
3093
3094 if (Context->Info.Length < 0)
3095 {
3097 Context->Info.Length = Stack->Parameters.QueryFile.Length;
3098 }
3099
3100 Irp->IoStatus.Information = Stack->Parameters.QueryFile.Length - Context->Info.Length;
3101 }
3103 {
3104 if (Locked)
3105 {
3107 }
3108 }
3109 _SEH2_END;
3110
3111 DPRINT("Status: %x\n", Status);
3112 return Status;
3113
3114#undef SET_SIZE_AND_QUERY
3115}
#define _SEH2_LEAVE
Definition: filesup.c:20
@ FilePipeLocalInformation
Definition: from_kernel.h:85
@ FileCompressionInformation
Definition: from_kernel.h:89
@ FileAllInformation
Definition: from_kernel.h:79
@ FilePipeRemoteInformation
Definition: from_kernel.h:86
@ FileInternalInformation
Definition: from_kernel.h:67
@ FileEaInformation
Definition: from_kernel.h:68
@ FilePipeInformation
Definition: from_kernel.h:84
@ FileAlternateNameInformation
Definition: from_kernel.h:82
@ FileNameInformation
Definition: from_kernel.h:70
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:209
#define STATUS_LOCK_NOT_GRANTED
Definition: ntstatus.h:321
#define FileStandardInformation
Definition: propsheet.cpp:61
NTSTATUS RxQueryInternalInfo(PRX_CONTEXT RxContext, PFILE_INTERNAL_INFORMATION InternalInfo)
Definition: rdbss.c:8274
NTSTATUS RxQueryBasicInfo(PRX_CONTEXT RxContext, PFILE_BASIC_INFORMATION BasicInfo)
Definition: rdbss.c:8026
NTSTATUS RxQueryCompressedInfo(PRX_CONTEXT RxContext, PFILE_COMPRESSION_INFORMATION CompressionInfo)
Definition: rdbss.c:8040
#define SET_SIZE_AND_QUERY(AlreadyConsummed, Function)
NTSTATUS RxQueryNameInfo(PRX_CONTEXT RxContext, PFILE_NAME_INFORMATION NameInfo)
Definition: rdbss.c:8286
NTSTATUS RxQueryStandardInfo(PRX_CONTEXT RxContext, PFILE_STANDARD_INFORMATION StandardInfo)
Definition: rdbss.c:8358
NTSTATUS RxQueryEaInfo(PRX_CONTEXT RxContext, PFILE_EA_INFORMATION EaInfo)
Definition: rdbss.c:8265
NTSTATUS RxQueryAlternateNameInfo(PRX_CONTEXT RxContext, PFILE_NAME_INFORMATION AltNameInfo)
Definition: rdbss.c:8014
NTSTATUS RxQueryPipeInfo(PRX_CONTEXT RxContext, PFILE_PIPE_INFORMATION PipeInfo)
Definition: rdbss.c:8337
NTSTATUS RxpQueryInfoMiniRdr(PRX_CONTEXT RxContext, FILE_INFORMATION_CLASS FileInfoClass, PVOID Buffer)
Definition: rdbss.c:7690
NTSTATUS RxQueryPositionInfo(PRX_CONTEXT RxContext, PFILE_POSITION_INFORMATION PositionInfo)
Definition: rdbss.c:8346
PVOID RxMapSystemBuffer(_In_ PRX_CONTEXT RxContext)
#define RxAcquireSharedFcb(R, F)
Definition: rxprocs.h:162
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66

◆ RxCommonQueryQuotaInformation()

NTSTATUS NTAPI RxCommonQueryQuotaInformation ( PRX_CONTEXT  Context)

Definition at line 3119 of file rdbss.c.

3121{
3124}

◆ RxCommonQuerySecurity()

NTSTATUS NTAPI RxCommonQuerySecurity ( PRX_CONTEXT  Context)

Definition at line 3128 of file rdbss.c.

3130{
3133}

◆ RxCommonQueryVolumeInformation()

NTSTATUS NTAPI RxCommonQueryVolumeInformation ( PRX_CONTEXT  Context)

Definition at line 3140 of file rdbss.c.

3142{
3143 PIRP Irp;
3144 PFCB Fcb;
3145 PFOBX Fobx;
3148
3149 PAGED_CODE();
3150
3151 Fcb = (PFCB)Context->pFcb;
3152 Fobx = (PFOBX)Context->pFobx;
3153
3154 DPRINT("RxCommonQueryVolumeInformation(%p) FCB: %p, FOBX: %p\n", Context, Fcb, Fobx);
3155
3156 Irp = Context->CurrentIrp;
3157 Stack = Context->CurrentIrpSp;
3158 DPRINT("Length: %lx, Class: %lx, Buffer %p\n", Stack->Parameters.QueryVolume.Length,
3159 Stack->Parameters.QueryVolume.FsInformationClass, Irp->AssociatedIrp.SystemBuffer);
3160
3161 Context->Info.FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
3162 Context->Info.Buffer = Irp->AssociatedIrp.SystemBuffer;
3163 Context->Info.Length = Stack->Parameters.QueryVolume.Length;
3164
3165 /* Forward to mini-rdr */
3166 MINIRDR_CALL(Status, Context, Fcb->MRxDispatch, MRxQueryVolumeInfo, (Context));
3167
3168 /* Post request if mini-rdr asked to */
3169 if (Context->PostRequest)
3170 {
3172 }
3173 else
3174 {
3175 Irp->IoStatus.Information = Stack->Parameters.QueryVolume.Length - Context->Info.Length;
3176 }
3177
3178 DPRINT("Status: %x\n", Status);
3179 return Status;
3180}

◆ RxCommonRead()

NTSTATUS NTAPI RxCommonRead ( PRX_CONTEXT  Context)

Definition at line 3184 of file rdbss.c.

3186{
3187 PFCB Fcb;
3188 PIRP Irp;
3189 PFOBX Fobx;
3191 PNET_ROOT NetRoot;
3192 PVOID SystemBuffer;
3196 PLOWIO_CONTEXT LowIoContext;
3197 PRDBSS_DEVICE_OBJECT RxDeviceObject;
3198 ULONG ReadLength, CapturedRxContextSerialNumber = RxContext->SerialNumber;
3199 BOOLEAN CanWait, PagingIo, NoCache, Sync, PostRequest, IsPipe, ReadCachingEnabled, ReadCachingDisabled, InFsp, OwnerSet;
3200
3201 PAGED_CODE();
3202
3203 Fcb = (PFCB)RxContext->pFcb;
3204 Fobx = (PFOBX)RxContext->pFobx;
3205 DPRINT("RxCommonRead(%p) FOBX: %p, FCB: %p\n", RxContext, Fobx, Fcb);
3206
3207 /* Get some parameters */
3208 Irp = RxContext->CurrentIrp;
3209 Stack = RxContext->CurrentIrpSp;
3210 CanWait = BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_WAIT);
3211 PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
3212 NoCache = BooleanFlagOn(Irp->Flags, IRP_NOCACHE);
3213 Sync = !BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_ASYNC_OPERATION);
3214 InFsp = BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_IN_FSP);
3215 ReadLength = Stack->Parameters.Read.Length;
3216 ByteOffset.QuadPart = Stack->Parameters.Read.ByteOffset.QuadPart;
3217 DPRINT("Reading: %lx@%I64x %s %s %s %s\n", ReadLength, ByteOffset.QuadPart,
3218 (CanWait ? "CW" : "!CW"), (PagingIo ? "PI" : "!PI"), (NoCache ? "NC" : "!NC"), (Sync ? "S" : "!S"));
3219
3221
3222 Irp->IoStatus.Information = 0;
3223
3224 /* Should the read be loud - so far, it's just ignored on ReactOS:
3225 * s/DPRINT/DPRINT1/g will make it loud
3226 */
3227 LowIoContext = &RxContext->LowIoContext;
3228 CheckForLoudOperations(RxContext);
3230 {
3231 DPRINT("LoudRead %I64x/%lx on %lx vdl/size/alloc %I64x/%I64x/%I64x\n",
3233 Fcb, Fcb->Header.ValidDataLength, Fcb->Header.FileSize, Fcb->Header.AllocationSize);
3234 }
3235
3236 RxDeviceObject = RxContext->RxDeviceObject;
3237 /* Update stats */
3238 if (!BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_IN_FSP) && Fcb->CachedNetRootType == NET_ROOT_DISK)
3239 {
3240 InterlockedIncrement((volatile long *)&RxDeviceObject->ReadOperations);
3241
3242 if (ByteOffset.QuadPart != Fobx->Specific.DiskFile.PredictedReadOffset)
3243 {
3244 InterlockedIncrement((volatile long *)&RxDeviceObject->RandomReadOperations);
3245 }
3246 Fobx->Specific.DiskFile.PredictedReadOffset = ByteOffset.QuadPart + ReadLength;
3247
3248 if (PagingIo)
3249 {
3251 }
3252 else if (NoCache)
3253 {
3255 }
3256 else
3257 {
3259 }
3260 }
3261
3262 /* A pagefile cannot be a pipe */
3263 IsPipe = Fcb->NetRoot->Type == NET_ROOT_PIPE;
3264 if (IsPipe && PagingIo)
3265 {
3267 }
3268
3269 /* Null-length read is no-op */
3270 if (ReadLength == 0)
3271 {
3272 return STATUS_SUCCESS;
3273 }
3274
3275 /* Validate FCB type */
3277 {
3279 }
3280
3281 /* Init the lowio context for possible forward */
3283
3284 PostRequest = FALSE;
3285 ReadCachingDisabled = FALSE;
3286 OwnerSet = FALSE;
3288 FileObject = Stack->FileObject;
3289 NetRoot = (PNET_ROOT)Fcb->pNetRoot;
3290 _SEH2_TRY
3291 {
3293
3294 /* If no caching, make sure current Cc data have been flushed */
3295 if (!PagingIo && NoCache && !ReadCachingEnabled && FileObject->SectionObjectPointer != NULL)
3296 {
3297 Status = RxAcquireExclusiveFcb(RxContext, Fcb);
3299 {
3300 PostRequest = TRUE;
3302 }
3303 else if (Status != STATUS_SUCCESS)
3304 {
3306 }
3307
3308 ExAcquireResourceSharedLite(Fcb->Header.PagingIoResource, TRUE);
3309 CcFlushCache(FileObject->SectionObjectPointer, &ByteOffset, ReadLength, &Irp->IoStatus);
3310 RxReleasePagingIoResource(RxContext, Fcb);
3311
3312 if (!NT_SUCCESS(Irp->IoStatus.Status))
3313 {
3314 Status = Irp->IoStatus.Status;
3316 }
3317
3318 RxAcquirePagingIoResource(RxContext, Fcb);
3319 RxReleasePagingIoResource(RxContext, Fcb);
3320 }
3321
3322 /* Acquire the appropriate lock */
3323 if (PagingIo && !ReadCachingEnabled)
3324 {
3325 ASSERT(!IsPipe);
3326
3327 if (!ExAcquireResourceSharedLite(Fcb->Header.PagingIoResource, CanWait))
3328 {
3329 PostRequest = TRUE;
3331 }
3332
3333 if (!CanWait)
3334 {
3335 LowIoContext->Resource = Fcb->Header.PagingIoResource;
3336 }
3337 }
3338 else
3339 {
3340 if (!ReadCachingEnabled)
3341 {
3342 if (!CanWait && NoCache)
3343 {
3346 {
3347 DPRINT1("RdAsyLNG %x\n", RxContext);
3348 PostRequest = TRUE;
3350 }
3351 if (Status != STATUS_SUCCESS)
3352 {
3353 DPRINT1("RdAsyOthr %x\n", RxContext);
3355 }
3356
3357 if (RxIsFcbAcquiredShared(Fcb) <= 0xF000)
3358 {
3359 LowIoContext->Resource = Fcb->Header.Resource;
3360 }
3361 else
3362 {
3363 PostRequest = TRUE;
3365 }
3366 }
3367 else
3368 {
3369 Status = RxAcquireSharedFcb(RxContext, Fcb);
3371 {
3372 PostRequest = TRUE;
3374 }
3375 else if (Status != STATUS_SUCCESS)
3376 {
3378 }
3379 }
3380 }
3381 }
3382
3384
3385 ReadCachingDisabled = (ReadCachingEnabled == FALSE);
3386 if (IsPipe)
3387 {
3389 }
3390
3392
3393 /* Make sure FLOCK doesn't conflict */
3394 if (!PagingIo)
3395 {
3397 {
3400 }
3401 }
3402
3403 /* Validate byteoffset vs length */
3405 {
3406 if (ByteOffset.QuadPart >= FileSize)
3407 {
3410 }
3411
3412 if (ReadLength > FileSize - ByteOffset.QuadPart)
3413 {
3414 ReadLength = FileSize - ByteOffset.QuadPart;
3415 }
3416 }
3417
3418 /* Read with Cc! */
3419 if (!PagingIo && !NoCache && ReadCachingEnabled &&
3420 !BooleanFlagOn(Fobx->pSrvOpen->Flags, SRVOPEN_FLAG_DONTUSE_READ_CACHING))
3421 {
3422 /* File was not cached yet, do it */
3423 if (FileObject->PrivateCacheMap == NULL)
3424 {
3426 {
3429 }
3430
3432
3435
3437 {
3439 }
3440 else
3441 {
3444 }
3445
3446 CcSetReadAheadGranularity(FileObject, NetRoot->DiskParameters.ReadAheadGranularity);
3447 }
3448
3449 /* This should never happen - fix your RDR */
3450 if (BooleanFlagOn(RxContext->MinorFunction, IRP_MN_MDL))
3451 {
3452 ASSERT(FALSE);
3453 ASSERT(CanWait);
3454
3455 CcMdlRead(FileObject, &ByteOffset, ReadLength, &Irp->MdlAddress, &Irp->IoStatus);
3456 Status = Irp->IoStatus.Status;
3458 }
3459 else
3460 {
3461 /* Map buffer */
3462 SystemBuffer = RxNewMapUserBuffer(RxContext);
3463 if (SystemBuffer == NULL)
3464 {
3467 }
3468
3470
3472
3473 /* Perform the read */
3474 if (!CcCopyRead(FileObject, &ByteOffset, ReadLength, CanWait, SystemBuffer, &Irp->IoStatus))
3475 {
3476 if (!ReadCachingEnabled)
3477 {
3479 }
3480
3482
3483 PostRequest = TRUE;
3485 }
3486
3487 if (!ReadCachingEnabled)
3488 {
3490 }
3491
3492 Status = Irp->IoStatus.Status;
3494 }
3495 }
3496 else
3497 {
3498 /* Validate the reading */
3499 if (FileObject->PrivateCacheMap != NULL && BooleanFlagOn(Fcb->FcbState, FCB_STATE_READAHEAD_DEFERRED) &&
3500 ByteOffset.QuadPart >= 4096)
3501 {
3504 }
3505
3506 /* If it's consistent, forward to mini-rdr */
3507 if (Fcb->CachedNetRootType != NET_ROOT_DISK || BooleanFlagOn(Fcb->FcbState, FCB_STATE_READAHEAD_DEFERRED) ||
3508 ByteOffset.QuadPart < Fcb->Header.ValidDataLength.QuadPart)
3509 {
3510 LowIoContext->ParamsFor.ReadWrite.ByteCount = ReadLength;
3511 LowIoContext->ParamsFor.ReadWrite.ByteOffset = ByteOffset.QuadPart;
3512
3514
3515 if (InFsp && ReadCachingDisabled)
3516 {
3517 ExSetResourceOwnerPointer((PagingIo ? Fcb->Header.PagingIoResource : Fcb->Header.Resource),
3518 (PVOID)((ULONG_PTR)RxContext | 3));
3519 OwnerSet = TRUE;
3520 }
3521
3522 Status = RxLowIoReadShell(RxContext);
3523
3525 }
3526 else
3527 {
3528 if (ByteOffset.QuadPart > FileSize)
3529 {
3530 ReadLength = 0;
3531 Irp->IoStatus.Information = ReadLength;
3533 }
3534
3535 if (ByteOffset.QuadPart + ReadLength > FileSize)
3536 {
3537 ReadLength = FileSize - ByteOffset.QuadPart;
3538 }
3539
3540 SystemBuffer = RxNewMapUserBuffer(RxContext);
3541 RtlZeroMemory(SystemBuffer, ReadLength);
3542 Irp->IoStatus.Information = ReadLength;
3543 }
3544 }
3545 }
3547 {
3549
3550 /* Post if required */
3551 if (PostRequest)
3552 {
3553 InterlockedIncrement((volatile long *)&RxContext->ReferenceCount);
3554 Status = RxFsdPostRequest(RxContext);
3555 }
3556 else
3557 {
3558 /* Update FO in case of sync IO */
3559 if (!IsPipe && !PagingIo)
3560 {
3562 {
3563 FileObject->CurrentByteOffset.QuadPart = ByteOffset.QuadPart + Irp->IoStatus.Information;
3564 }
3565 }
3566 }
3567
3568 /* Set FastIo if read was a success */
3570 {
3571 if (!IsPipe && !PagingIo)
3572 {
3574 }
3575 }
3576
3577 /* In case we're done (not expected any further processing */
3578 if (_SEH2_AbnormalTermination() || Status != STATUS_PENDING || PostRequest)
3579 {
3580 /* Release everything that can be */
3581 if (ReadCachingDisabled)
3582 {
3583 if (PagingIo)
3584 {
3585 if (OwnerSet)
3586 {
3587 RxReleasePagingIoResourceForThread(RxContext, Fcb, LowIoContext->ResourceThreadId);
3588 }
3589 else
3590 {
3591 RxReleasePagingIoResource(RxContext, Fcb);
3592 }
3593 }
3594 else
3595 {
3596 if (OwnerSet)
3597 {
3598 RxReleaseFcbForThread(RxContext, Fcb, LowIoContext->ResourceThreadId);
3599 }
3600 else
3601 {
3602 RxReleaseFcb(RxContext, Fcb);
3603 }
3604 }
3605 }
3606
3607 /* Dereference/Delete context */
3608 if (PostRequest)
3609 {
3611 }
3612 else
3613 {
3614 if (BooleanFlagOn(RxContext->FlagsForLowIo, RXCONTEXT_FLAG4LOWIO_PIPE_SYNC_OPERATION))
3615 {
3616 RxResumeBlockedOperations_Serially(RxContext, &Fobx->Specific.NamedPipe.ReadSerializationQueue);
3617 }
3618 }
3619
3620 /* We cannot return more than asked */
3621 if (Status == STATUS_SUCCESS)
3622 {
3623 ASSERT(Irp->IoStatus.Information <= Stack->Parameters.Read.Length);
3624 }
3625 }
3626 else
3627 {
3628 ASSERT(!Sync);
3629
3631 }
3632 }
3633 _SEH2_END;
3634
3635 return Status;
3636}
ULONG ReadLength
VOID NTAPI CcMdlRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus)
Definition: mdlsup.c:64
VOID NTAPI CcSetReadAheadGranularity(IN PFILE_OBJECT FileObject, IN ULONG Granularity)
Definition: cachesub.c:36
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:731
VOID RxGetFileSizeWithLock(_In_ PFCB Fcb, _Out_ PLONGLONG FileSize)
#define FCB_STATE_READCACHING_ENABLED
Definition: fcb.h:224
#define FCB_STATE_READAHEAD_DEFERRED
Definition: fcb.h:209
BOOLEAN NTAPI FsRtlCheckLockForReadAccess(IN PFILE_LOCK FileLock, IN PIRP Irp)
Definition: filelock.c:672
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:195
VOID NTAPI CcSetAdditionalCacheAttributes(IN PFILE_OBJECT FileObject, IN BOOLEAN DisableReadAhead, IN BOOLEAN DisableWriteBehind)
Definition: logsup.c:22
@ LOWIO_OP_READ
Definition: mrx.h:234
#define RDBSS_NO_DEFERRED_CACHE_READAHEAD
Definition: mrx.h:335
#define SRVOPEN_FLAG_DONTUSE_READ_CACHING
Definition: mrxfcb.h:130
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43
VOID NTAPI ExSetResourceOwnerPointer(IN PERESOURCE Resource, IN PVOID OwnerPointer)
Definition: resource.c:2050
#define STATUS_FILE_LOCK_CONFLICT
Definition: ntstatus.h:320
#define STATUS_FILE_CLOSED
Definition: ntstatus.h:532
RDBSS_DATA RxData
Definition: rdbss.c:537
PVOID RxNewMapUserBuffer(PRX_CONTEXT RxContext)
Definition: rxce.c:5775
VOID CheckForLoudOperations(PRX_CONTEXT RxContext)
Definition: rdbss.c:647
NTSTATUS RxLowIoReadShell(PRX_CONTEXT RxContext)
Definition: rdbss.c:7242
@ RX_CONTEXT_FLAG_IN_FSP
Definition: rxcontx.h:290
@ RX_CONTEXT_FLAG_ASYNC_OPERATION
Definition: rxcontx.h:293
@ RXCONTEXT_FLAG4LOWIO_PIPE_SYNC_OPERATION
Definition: rxcontx.h:333
VOID NTAPI RxResumeBlockedOperations_Serially(_Inout_ PRX_CONTEXT RxContext, _Inout_ PLIST_ENTRY BlockingIoQ)
#define RxItsTheSameContext()
Definition: rxcontx.h:370
#define RxIsFcbAcquiredShared(Fcb)
Definition: rxprocs.h:228
#define RxAcquireSharedFcbWaitForEx(R, F)
Definition: rxprocs.h:168
#define RDBSS_NTC_VOLUME_FCB
Definition: nodetype.h:51
#define STATUS_END_OF_FILE
Definition: shellext.h:67
PNET_ROOT NetRoot
Definition: fcb.h:136
struct _FOBX::@1958::@1962 DiskFile
struct _FOBX::@1958::@1961 NamedPipe
union _FOBX::@1958 Specific
struct _LOWIO_CONTEXT::@2065::@2066 ReadWrite
union _LOWIO_CONTEXT::@2065 ParamsFor
PERESOURCE Resource
Definition: mrx.h:284
ULONG MRxFlags
Definition: mrx.h:341
CACHE_MANAGER_CALLBACKS CacheManagerCallbacks
Definition: rxstruc.h:35
volatile ULONG RandomReadOperations
Definition: rxstruc.h:109
volatile ULONG ReadOperations
Definition: rxstruc.h:107
LARGE_INTEGER CacheReadBytesRequested
Definition: rxstruc.h:104
LARGE_INTEGER PagingReadBytesRequested
Definition: rxstruc.h:102
LARGE_INTEGER NonPagingReadBytesRequested
Definition: rxstruc.h:103
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG_PTR
Definition: typedefs.h:65
static const unsigned short IsPipe
Definition: typegen.c:75
#define ExInterlockedAddLargeStatistic(Addend, Increment)
Definition: exfuncs.h:850
#define IRP_PAGING_IO
#define IRP_MN_MDL
Definition: iotypes.h:4419
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1776
#define IRP_NOCACHE

◆ RxCommonSetEa()

NTSTATUS NTAPI RxCommonSetEa ( PRX_CONTEXT  Context)

Definition at line 3640 of file rdbss.c.

3642{
3645}

◆ RxCommonSetInformation()

NTSTATUS NTAPI RxCommonSetInformation ( PRX_CONTEXT  Context)

Definition at line 3652 of file rdbss.c.

3654{
3655 PIRP Irp;
3656 PFCB Fcb;
3657 PFOBX Fobx;
3659 PNET_ROOT NetRoot;
3662 BOOLEAN CanWait, FcbTableAcquired, FcbAcquired;
3663
3664 PAGED_CODE();
3665
3666 Fcb = (PFCB)Context->pFcb;
3667 Fobx = (PFOBX)Context->pFobx;
3668 DPRINT("RxCommonSetInformation(%p), FCB: %p, FOBX: %p\n", Context, Fcb, Fobx);
3669
3670 Irp = Context->CurrentIrp;
3671 Stack = Context->CurrentIrpSp;
3672 Class = Stack->Parameters.SetFile.FileInformationClass;
3673 DPRINT("Buffer: %p, Length: %lx, Class: %ld, ReplaceIfExists: %d\n",
3674 Irp->AssociatedIrp.SystemBuffer, Stack->Parameters.SetFile.Length,
3675 Class, Stack->Parameters.SetFile.ReplaceIfExists);
3676
3678 CanWait = BooleanFlagOn(Context->Flags, RX_CONTEXT_FLAG_WAIT);
3679 FcbTableAcquired = FALSE;
3680 FcbAcquired = FALSE;
3681 NetRoot = (PNET_ROOT)Fcb->pNetRoot;
3682
3683#define _SEH2_TRY_RETURN(S) S; goto try_exit
3684
3685 _SEH2_TRY
3686 {
3687 /* Valide the node type first */
3690 {
3692 {
3694 {
3696 }
3697 }
3698 else if (NodeType(Fcb) != RDBSS_NTC_SPOOLFILE)
3699 {
3701 {
3703 }
3704 else
3705 {
3706 DPRINT1("Illegal type of file provided: %x\n", NodeType(Fcb));
3708 }
3709 }
3710 }
3711
3712 /* We don't autorize advance operation */
3713 if (Class == FileEndOfFileInformation && Stack->Parameters.SetFile.AdvanceOnly)
3714 {
3715 DPRINT1("Not allowed\n");
3716
3718 }
3719
3720 /* For these to classes, we'll have to deal with the FCB table (removal)
3721 * We thus need the exclusive FCB table lock
3722 */
3724 {
3725 RxPurgeRelatedFobxs(NetRoot, Context, TRUE, Fcb);
3727
3728 if (!RxAcquireFcbTableLockExclusive(&NetRoot->FcbTable, CanWait))
3729 {
3730 Context->PostRequest = TRUE;
3732 }
3733
3734 FcbTableAcquired = TRUE;
3735 }
3736
3737 /* Finally, if not paging file, we need exclusive FCB lock */
3739 {
3742 {
3743 Context->PostRequest = TRUE;
3745 }
3746 else if (Status != STATUS_SUCCESS)
3747 {
3749 }
3750
3751 FcbAcquired = TRUE;
3752 }
3753
3755
3756 /* And now, perform the job! */
3757 switch (Class)
3758 {
3761 break;
3762
3764 {
3766
3767 /* Check whether user wants deletion */
3768 FDI = Irp->AssociatedIrp.SystemBuffer;
3769 if (FDI->DeleteFile)
3770 {
3771 /* If so, check whether it's doable */
3772 if (!MmFlushImageSection(&Fcb->NonPaged->SectionObjectPointers, MmFlushForDelete))
3773 {
3775 }
3776
3777 /* And if doable, already remove from FCB table */
3778 if (Status == STATUS_SUCCESS)
3779 {
3780 ASSERT(FcbAcquired && FcbTableAcquired);
3782
3784 FcbTableAcquired = FALSE;
3785 }
3786 }
3787
3788 /* If it succeed, perform the operation */
3789 if (Status == STATUS_SUCCESS)
3790 {
3792 }
3793
3794 break;
3795 }
3796
3799 break;
3800
3803 break;
3804
3807 break;
3808
3813 break;
3814
3818 /* If we can wait, try to perform the operation right now */
3819 if (CanWait)
3820 {
3821 /* Of course, collapsing is not doable anymore, file is
3822 * in an inbetween state
3823 */
3825
3826 /* Set the information */
3828 /* If it succeed, drop the current entry from FCB table */
3830 {
3831 ASSERT(FcbAcquired && FcbTableAcquired);
3833 }
3835 }
3836 /* Can't wait? Post for async retry */
3837 else
3838 {
3841 }
3842 break;
3843
3846 {
3848 }
3849 break;
3850
3853 break;
3854
3855 default:
3856 DPRINT1("Insupported class: %x\n", Class);
3858
3859 break;
3860 }
3861
3862try_exit: NOTHING;
3863 /* If mini-rdr was OK and wants a re-post on this, do it */
3864 if (Status == STATUS_SUCCESS)
3865 {
3866 if (Context->PostRequest)
3867 {
3869 }
3870 }
3871 }
3873 {
3874 /* Release any acquired lock */
3875 if (FcbAcquired)
3876 {
3878 }
3879
3880 if (FcbTableAcquired)
3881 {
3883 }
3884 }
3885 _SEH2_END;
3886
3887#undef _SEH2_TRY_RETURN
3888
3889 return Status;
3890}
@ FilePositionInformation
Definition: from_kernel.h:75
@ FileMoveClusterInformation
Definition: from_kernel.h:92
@ FileRenameInformation
Definition: from_kernel.h:71
@ FileLinkInformation
Definition: from_kernel.h:72
@ FileValidDataLengthInformation
Definition: from_kernel.h:100
@ FileAllocationInformation
Definition: from_kernel.h:80
@ FileDispositionInformation
Definition: from_kernel.h:74
@ FileShortNameInformation
Definition: from_kernel.h:101
#define NOTHING
Definition: input_list.c:10
#define STATUS_USER_MAPPED_FILE
Definition: ntstatus.h:711
NTSTATUS RxSetEndOfFileInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:9018
NTSTATUS RxSetAllocationInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:8864
NTSTATUS RxSetDispositionInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:8978
NTSTATUS RxSetRenameInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:9045
#define _SEH2_TRY_RETURN(S)
NTSTATUS RxSetBasicInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:8875
NTSTATUS RxSetPositionInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:9034
NTSTATUS RxSetSimpleInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:9136
NTSTATUS RxSetPipeInfo(PRX_CONTEXT RxContext)
Definition: rdbss.c:9026
#define S(x)
Definition: test.h:217
BOOLEAN NTAPI MmCanFileBeTruncated(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER NewFileSize)
Definition: section.c:4255
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4356
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
Definition: movable.cpp:9

◆ RxCommonSetQuotaInformation()

NTSTATUS NTAPI RxCommonSetQuotaInformation ( PRX_CONTEXT  Context)

Definition at line 3894 of file rdbss.c.

3896{
3899}

◆ RxCommonSetSecurity()

NTSTATUS NTAPI RxCommonSetSecurity ( PRX_CONTEXT  Context)

Definition at line 3903 of file rdbss.c.

3905{
3908}

◆ RxCommonSetVolumeInformation()

NTSTATUS NTAPI RxCommonSetVolumeInformation ( PRX_CONTEXT  Context)

Definition at line 3912 of file rdbss.c.

3914{
3917}

◆ RxCommonUnimplemented()

NTSTATUS NTAPI RxCommonUnimplemented ( PRX_CONTEXT  Context)

Definition at line 3921 of file rdbss.c.

3923{
3926}

◆ RxCommonWrite()

NTSTATUS NTAPI RxCommonWrite ( PRX_CONTEXT  Context)

Definition at line 3930 of file rdbss.c.

3932{
3933 PIRP Irp;
3934 PFCB Fcb;
3935 PFOBX Fobx;
3937 PNET_ROOT NetRoot;
3938 PSRV_OPEN SrvOpen;
3942 NODE_TYPE_CODE NodeTypeCode;
3943 PLOWIO_CONTEXT LowIoContext;
3944 PRDBSS_DEVICE_OBJECT RxDeviceObject;
3945 ULONG WriteLength, CapturedRxContextSerialNumber = RxContext->SerialNumber;
3946 LONGLONG FileSize, ValidDataLength, InitialFileSize, InitialValidDataLength;
3947 BOOLEAN CanWait, PagingIo, NoCache, Sync, NormalFile, WriteToEof, IsPipe, NoPreposting, InFsp, RecursiveWriteThrough, CalledByLazyWriter, SwitchBackToAsync, ExtendingFile, ExtendingValidData, UnwindOutstandingAsync, ResourceOwnerSet, PostIrp, ContextReferenced;
3948
3949 PAGED_CODE();
3950
3951 Fcb = (PFCB)RxContext->pFcb;
3952 NodeTypeCode = NodeType(Fcb);
3953 /* Validate FCB type */
3954 if (NodeTypeCode != RDBSS_NTC_STORAGE_TYPE_FILE && NodeTypeCode != RDBSS_NTC_VOLUME_FCB &&
3955 NodeTypeCode != RDBSS_NTC_SPOOLFILE && NodeTypeCode != RDBSS_NTC_MAILSLOT)
3956 {
3958 }
3959
3960 /* We'll write to file, keep track of it */
3961 Fcb->IsFileWritten = TRUE;
3962
3963 Stack = RxContext->CurrentIrpSp;
3964 /* Set write through if asked */
3966 {
3967 SetFlag(RxContext->Flags, RX_CONTEXT_FLAG_WRITE_THROUGH);
3968 }
3969
3970 Fobx = (PFOBX)RxContext->pFobx;
3971 DPRINT("RxCommonWrite(%p) FOBX: %p, FCB: %p\n", RxContext, Fobx, Fcb);
3972
3973 /* Get some parameters */
3974 Irp = RxContext->CurrentIrp;
3975 NoPreposting = BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_NO_PREPOSTING_NEEDED);
3976 InFsp = BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_IN_FSP);
3977 CanWait = BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_WAIT);
3978 PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
3979 NoCache =