[RXCE]
[DDK]
Add an initial implementation of the RXCE and RDBSS libraries that are used to implement mini-redirectors
The associated headers are also added to DDK

The implementation is partial (really!) and is only working for read-only operations.

It leaks memory as hell (no refcounting implemented) and thus, objects freeing is not implemented.

It was tested with NFS41 driver. With such RDBSS, it's possible for the driver to mount a remote share, to list
files, to query their properties, to query volume properties, and finally to read files (with some corruption under
specific conditions).

Please refrain from committing in this (especially for modifying whitespaces or fixing comments...), this is still WIP
and under development, it would mess with my local changes!

In itself, it doesn't bring anything to ReactOS yet, as no mini redirector is available in ReactOS source tree.
This may come later on with NFS41.

More to follow...

CORE-11327

svn path=/trunk/; revision=74674
This commit is contained in:
Pierre Schweitzer 2017-05-26 20:52:18 +00:00
parent fb1a1ab85e
commit a89c82316c
28 changed files with 15268 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#ifndef _BACKPACK_
#define _BACKPACK_
typedef struct _THROTTLING_STATE
{
LARGE_INTEGER NextTime;
volatile ULONG CurrentIncrement;
ULONG MaximumDelay;
LARGE_INTEGER Increment;
volatile ULONG NumberOfQueries;
} THROTTLING_STATE, *PTHROTTLING_STATE;
#define RxInitializeThrottlingState(BP, Inc, MaxDelay) \
{ \
if ((Inc) > 0) \
{ \
(BP)->Increment.QuadPart = (Inc) * 10000; \
(BP)->MaximumDelay = (MaxDelay) / (Inc); \
(BP)->CurrentIncrement = 0; \
} \
}
#endif

View File

@ -0,0 +1,49 @@
#ifndef __BUFFRING_H__
#define __BUFFRING_H__
typedef struct _RX_BUFFERING_MANAGER_
{
BOOLEAN DispatcherActive;
BOOLEAN HandlerInactive;
BOOLEAN LastChanceHandlerActive;
UCHAR Pad;
KSPIN_LOCK SpinLock;
volatile LONG CumulativeNumberOfBufferingChangeRequests;
LONG NumberOfUnhandledRequests;
LONG NumberOfUndispatchedRequests;
volatile LONG NumberOfOutstandingOpens;
LIST_ENTRY DispatcherList;
LIST_ENTRY HandlerList;
LIST_ENTRY LastChanceHandlerList;
RX_WORK_QUEUE_ITEM DispatcherWorkItem;
RX_WORK_QUEUE_ITEM HandlerWorkItem;
RX_WORK_QUEUE_ITEM LastChanceHandlerWorkItem;
FAST_MUTEX Mutex;
LIST_ENTRY SrvOpenLists[1];
} RX_BUFFERING_MANAGER, *PRX_BUFFERING_MANAGER;
VOID
RxProcessFcbChangeBufferingStateRequest(
_In_ PFCB Fcb);
VOID
RxCompleteSrvOpenKeyAssociation(
_Inout_ PSRV_OPEN SrvOpen);
VOID
RxInitiateSrvOpenKeyAssociation(
_Inout_ PSRV_OPEN SrvOpen);
NTSTATUS
RxInitializeBufferingManager(
_In_ PSRV_CALL SrvCall);
NTSTATUS
RxPurgeFcbInSystemCache(
_In_ PFCB Fcb,
_In_ PLARGE_INTEGER FileOffset OPTIONAL,
_In_ ULONG Length,
_In_ BOOLEAN UninitializeCacheMaps,
_In_ BOOLEAN FlushFile);
#endif

View File

@ -0,0 +1,596 @@
#ifndef _FCB_STRUCTS_DEFINED_
#define _FCB_STRUCTS_DEFINED_
#include "buffring.h"
struct _FCB_INIT_PACKET;
typedef struct _FCB_INIT_PACKET *PFCB_INIT_PACKET;
typedef struct _SRV_CALL
{
union
{
MRX_SRV_CALL;
struct
{
MRX_NORMAL_NODE_HEADER spacer;
};
};
BOOLEAN UpperFinalizationDone;
RX_PREFIX_ENTRY PrefixEntry;
RX_BLOCK_CONDITION Condition;
ULONG SerialNumberForEnum;
volatile LONG NumberOfCloseDelayedFiles;
LIST_ENTRY TransitionWaitList;
LIST_ENTRY ScavengerFinalizationList;
PURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext;
RX_BUFFERING_MANAGER BufferingManager;
} SRV_CALL, *PSRV_CALL;
typedef struct _NET_ROOT
{
union
{
MRX_NET_ROOT;
struct
{
MRX_NORMAL_NODE_HEADER spacer;
PSRV_CALL SrvCall;
};
};
BOOLEAN UpperFinalizationDone;
RX_BLOCK_CONDITION Condition;
LIST_ENTRY TransitionWaitList;
LIST_ENTRY ScavengerFinalizationList;
PURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext;
PV_NET_ROOT DefaultVNetRoot;
LIST_ENTRY VirtualNetRoots;
ULONG NumberOfVirtualNetRoots;
ULONG SerialNumberForEnum;
RX_PREFIX_ENTRY PrefixEntry;
RX_FCB_TABLE FcbTable;
} NET_ROOT, *PNET_ROOT;
typedef struct _V_NET_ROOT
{
union
{
MRX_V_NET_ROOT;
struct
{
MRX_NORMAL_NODE_HEADER spacer;
PNET_ROOT NetRoot;
};
};
BOOLEAN UpperFinalizationDone;
BOOLEAN ConnectionFinalizationDone;
RX_BLOCK_CONDITION Condition;
volatile LONG AdditionalReferenceForDeleteFsctlTaken;
RX_PREFIX_ENTRY PrefixEntry;
UNICODE_STRING NamePrefix;
ULONG PrefixOffsetInBytes;
LIST_ENTRY NetRootListEntry;
ULONG SerialNumberForEnum;
LIST_ENTRY TransitionWaitList;
LIST_ENTRY ScavengerFinalizationList;
} V_NET_ROOT, *PV_NET_ROOT;
typedef struct _NON_PAGED_FCB
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
SECTION_OBJECT_POINTERS SectionObjectPointers;
ERESOURCE HeaderResource;
ERESOURCE PagingIoResource;
#ifdef USE_FILESIZE_LOCK
FAST_MUTEX FileSizeLock;
#endif
LIST_ENTRY TransitionWaitList;
ULONG OutstandingAsyncWrites;
PKEVENT OutstandingAsyncEvent;
KEVENT TheActualEvent;
PVOID MiniRdrContext[2];
FAST_MUTEX AdvancedFcbHeaderMutex;
ERESOURCE BufferedLocksResource;
#if DBG
PFCB FcbBackPointer;
#endif
} NON_PAGED_FCB, *PNON_PAGED_FCB;
typedef enum _RX_FCBTRACKER_CASES
{
RX_FCBTRACKER_CASE_NORMAL,
RX_FCBTRACKER_CASE_NULLCONTEXT,
RX_FCBTRACKER_CASE_CBS_CONTEXT,
RX_FCBTRACKER_CASE_CBS_WAIT_CONTEXT,
RX_FCBTRACKER_CASE_MAXIMUM
} RX_FCBTRACKER_CASES;
typedef struct _FCB_LOCK
{
struct _FCB_LOCK * Next;
LARGE_INTEGER Length;
LARGE_INTEGER BytesOffset;
ULONG Key;
BOOLEAN ExclusiveLock;
} FCB_LOCK, *PFCB_LOCK;
typedef struct _FCB_BUFFERED_LOCKS
{
struct _FCB_LOCK * List;
volatile ULONG PendingLockOps;
PERESOURCE Resource;
} FCB_BUFFERED_LOCKS, *PFCB_BUFFERED_LOCKS;
typedef struct _FCB
{
union
{
MRX_FCB;
struct
{
FSRTL_ADVANCED_FCB_HEADER spacer;
PNET_ROOT NetRoot;
};
};
PV_NET_ROOT VNetRoot;
PNON_PAGED_FCB NonPaged;
LIST_ENTRY ScavengerFinalizationList;
PKEVENT pBufferingStateChangeCompletedEvent;
LONG NumberOfBufferingStateChangeWaiters;
RX_FCB_TABLE_ENTRY FcbTableEntry;
UNICODE_STRING PrivateAlreadyPrefixedName;
BOOLEAN UpperFinalizationDone;
RX_BLOCK_CONDITION Condition;
PRX_FSD_DISPATCH_VECTOR PrivateDispatchVector;
PRDBSS_DEVICE_OBJECT RxDeviceObject;
PMINIRDR_DISPATCH MRxDispatch;
PFAST_IO_DISPATCH MRxFastIoDispatch;
PSRV_OPEN InternalSrvOpen;
PFOBX InternalFobx;
SHARE_ACCESS ShareAccess;
SHARE_ACCESS ShareAccessPerSrvOpens;
ULONG NumberOfLinks;
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER LastChangeTime;
#if (_WIN32_WINNT < 0x0600)
PETHREAD CreateSectionThread;
#endif
ULONG ulFileSizeVersion;
#if (_WIN32_WINNT < 0x0600)
union
{
struct
{
#endif
FILE_LOCK FileLock;
#if (_WIN32_WINNT < 0x0600)
PVOID LazyWriteThread;
#endif
union
{
LOWIO_PER_FCB_INFO;
LOWIO_PER_FCB_INFO LowIoPerFcbInfo;
};
#ifdef USE_FILESIZE_LOCK
PFAST_MUTEX FileSizeLock;
#endif
#if (_WIN32_WINNT < 0x0600)
} Fcb;
} Specific;
#endif
ULONG EaModificationCount;
FCB_BUFFERED_LOCKS BufferedLocks;
#if DBG
PNON_PAGED_FCB CopyOfNonPaged;
#endif
#ifdef RDBSS_TRACKER
ULONG FcbAcquires[RX_FCBTRACKER_CASE_MAXIMUM];
ULONG FcbReleases[RX_FCBTRACKER_CASE_MAXIMUM];
#else
#error tracker must be defined
#endif
PCHAR PagingIoResourceFile;
ULONG PagingIoResourceLine;
} FCB, *PFCB;
#define FCB_STATE_DELETE_ON_CLOSE 0x00000001
#define FCB_STATE_PAGING_FILE 0x00000004
#define FCB_STATE_DISABLE_LOCAL_BUFFERING 0x00000010
#define FCB_STATE_TEMPORARY 0x00000020
#define FCB_STATE_BUFFERING_STATE_CHANGE_PENDING 0x00000040
#define FCB_STATE_ORPHANED 0x00000080
#define FCB_STATE_READAHEAD_DEFERRED 0x00000100
#define FCB_STATE_DELAY_CLOSE 0x00000800
#define FCB_STATE_FAKEFCB 0x00001000
#define FCB_STATE_FILE_IS_BUF_COMPRESSED 0x00004000
#define FCB_STATE_FILE_IS_DISK_COMPRESSED 0x00008000
#define FCB_STATE_FILE_IS_SHADOWED 0x00010000
#define FCB_STATE_SPECIAL_PATH 0x00020000
#define FCB_STATE_TIME_AND_SIZE_ALREADY_SET 0x00040000
#define FCB_STATE_FILESIZECACHEING_ENABLED 0x00100000
#define FCB_STATE_COLLAPSING_ENABLED 0x00400000
#define FCB_STATE_READBUFFERING_ENABLED 0x01000000
#define FCB_STATE_READCACHING_ENABLED 0x02000000
#define FCB_STATE_WRITEBUFFERING_ENABLED 0x04000000
#define FCB_STATE_WRITECACHING_ENABLED 0x08000000
#define FCB_STATE_NAME_ALREADY_REMOVED 0x10000000
#define FCB_STATE_ADDEDBACKSLASH 0x20000000
#define FCB_STATE_FOBX_USED 0x40000000
#define FCB_STATE_SRVOPEN_USED 0x80000000
typedef struct _FCB_INIT_PACKET
{
PULONG pAttributes;
PULONG pNumLinks;
PLARGE_INTEGER pCreationTime;
PLARGE_INTEGER pLastAccessTime;
PLARGE_INTEGER pLastWriteTime;
PLARGE_INTEGER pLastChangeTime;
PLARGE_INTEGER pAllocationSize;
PLARGE_INTEGER pFileSize;
PLARGE_INTEGER pValidDataLength;
} FCB_INIT_PACKET;
#define SRVOPEN_FLAG_ENCLOSED_ALLOCATED 0x10000
#define SRVOPEN_FLAG_FOBX_USED 0x20000
#define SRVOPEN_FLAG_SHAREACCESS_UPDATED 0x40000
typedef struct _SRV_OPEN
{
union
{
MRX_SRV_OPEN;
struct
{
MRX_NORMAL_NODE_HEADER spacer;
PFCB Fcb;
#if (_WIN32_WINNT >= 0x600)
PV_NET_ROOT VNetRoot;
#endif
};
};
BOOLEAN UpperFinalizationDone;
RX_BLOCK_CONDITION Condition;
volatile LONG BufferingToken;
LIST_ENTRY ScavengerFinalizationList;
LIST_ENTRY TransitionWaitList;
LIST_ENTRY FobxList;
PFOBX InternalFobx;
union
{
LIST_ENTRY SrvOpenKeyList;
ULONG SequenceNumber;
};
NTSTATUS OpenStatus;
} SRV_OPEN, *PSRV_OPEN;
#define FOBX_FLAG_MATCH_ALL 0x10000
#define FOBX_FLAG_FREE_UNICODE 0x20000
#define FOBX_FLAG_DELETE_ON_CLOSE 0x800000
#define FOBX_FLAG_UNC_NAME 0x2000000
#define FOBX_FLAG_ENCLOSED_ALLOCATED 0x4000000
typedef struct _FOBX
{
union
{
MRX_FOBX;
struct
{
MRX_NORMAL_NODE_HEADER spacer;
PSRV_OPEN SrvOpen;
};
};
volatile ULONG FobxSerialNumber;
LIST_ENTRY FobxQLinks;
LIST_ENTRY ScavengerFinalizationList;
LIST_ENTRY ClosePendingList;
LARGE_INTEGER CloseTime;
BOOLEAN UpperFinalizationDone;
BOOLEAN ContainsWildCards;
BOOLEAN fOpenCountDecremented;
union
{
struct
{
union
{
MRX_PIPE_HANDLE_INFORMATION;
MRX_PIPE_HANDLE_INFORMATION PipeHandleInformation;
};
LARGE_INTEGER CollectDataTime;
ULONG CollectDataSize;
THROTTLING_STATE ThrottlingState;
LIST_ENTRY ReadSerializationQueue;
LIST_ENTRY WriteSerializationQueue;
} NamedPipe;
struct {
RXVBO PredictedReadOffset;
RXVBO PredictedWriteOffset;
THROTTLING_STATE LockThrottlingState;
LARGE_INTEGER LastLockOffset;
LARGE_INTEGER LastLockRange;
} DiskFile;
} Specific;
PRDBSS_DEVICE_OBJECT RxDeviceObject;
} FOBX, *PFOBX;
#define RDBSS_REF_TRACK_SRVCALL 0x00000001
#define RDBSS_REF_TRACK_NETROOT 0x00000002
#define RDBSS_REF_TRACK_VNETROOT 0x00000004
#define RDBSS_REF_TRACK_NETFOBX 0x00000008
#define RDBSS_REF_TRACK_NETFCB 0x00000010
#define RDBSS_REF_TRACK_SRVOPEN 0x00000020
extern ULONG RdbssReferenceTracingValue;
VOID
RxpTrackReference(
_In_ ULONG TraceType,
_In_ PCSTR FileName,
_In_ ULONG Line,
_In_ PVOID Instance);
BOOLEAN
RxpTrackDereference(
_In_ ULONG TraceType,
_In_ PCSTR FileName,
_In_ ULONG Line,
_In_ PVOID Instance);
#define RxReferenceSrvCall(SrvCall) \
RxpTrackReference(RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall); \
RxReference(SrvCall)
#define RxDereferenceSrvCall(SrvCall, LockHoldingState) \
RxpTrackDereference(RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall); \
RxDereference(SrvCall, LockHoldingState)
#define RxReferenceNetRoot(NetRoot) \
RxpTrackReference(RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot); \
RxReference(NetRoot)
#define RxDereferenceNetRoot(NetRoot, LockHoldingState) \
RxpTrackDereference(RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot); \
RxDereference(NetRoot, LockHoldingState)
#define RxReferenceVNetRoot(VNetRoot) \
RxpTrackReference(RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot); \
RxReference(VNetRoot)
#define RxDereferenceVNetRoot(VNetRoot, LockHoldingState) \
RxpTrackDereference(RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot); \
RxDereference(VNetRoot, LockHoldingState)
#define RxDereferenceNetFobx(Fobx, LockHoldingState) \
RxpTrackDereference(RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx); \
RxDereference(Fobx, LockHoldingState)
#define RxReferenceSrvOpen(SrvOpen) \
RxpTrackReference(RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
RxReference(SrvOpen)
#define RxDereferenceSrvOpen(SrvOpen, LockHoldingState) \
RxpTrackDereference(RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
RxDereference(SrvOpen, LockHoldingState)
#define RxReferenceNetFcb(Fcb) \
(RxpTrackReference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
RxpReferenceNetFcb(Fcb))
#define RxDereferenceNetFcb(Fcb) \
((LONG)RxpTrackDereference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
RxpDereferenceNetFcb(Fcb))
#define RxDereferenceAndFinalizeNetFcb(Fcb, RxContext, RecursiveFinalize, ForceFinalize) \
(RxpTrackDereference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
RxpDereferenceAndFinalizeNetFcb(Fcb, RxContext, RecursiveFinalize, ForceFinalize))
PSRV_CALL
RxCreateSrvCall(
_In_ PRX_CONTEXT RxContext,
_In_ PUNICODE_STRING Name,
_In_opt_ PUNICODE_STRING InnerNamePrefix,
_In_ PRX_CONNECTION_ID RxConnectionId);
#define RxWaitForStableSrvCall(S, R) RxWaitForStableCondition(&(S)->Condition, &(S)->TransitionWaitList, (R), NULL)
#define RxTransitionSrvCall(S, C) RxUpdateCondition((C), &(S)->Condition, &(S)->TransitionWaitList)
#if (_WIN32_WINNT >= 0x0600)
BOOLEAN
RxFinalizeSrvCall(
_Out_ PSRV_CALL ThisSrvCall,
_In_ BOOLEAN ForceFinalize);
#else
BOOLEAN
RxFinalizeSrvCall(
_Out_ PSRV_CALL ThisSrvCall,
_In_ BOOLEAN RecursiveFinalize,
_In_ BOOLEAN ForceFinalize);
#endif
PNET_ROOT
RxCreateNetRoot(
_In_ PSRV_CALL SrvCall,
_In_ PUNICODE_STRING Name,
_In_ ULONG NetRootFlags,
_In_opt_ PRX_CONNECTION_ID RxConnectionId);
#define RxWaitForStableNetRoot(N, R) RxWaitForStableCondition(&(N)->Condition, &(N)->TransitionWaitList, (R), NULL)
#define RxTransitionNetRoot(N, C) RxUpdateCondition((C), &(N)->Condition, &(N)->TransitionWaitList)
BOOLEAN
RxFinalizeNetRoot(
_Out_ PNET_ROOT ThisNetRoot,
_In_ BOOLEAN RecursiveFinalize,
_In_ BOOLEAN ForceFinalize);
NTSTATUS
RxInitializeVNetRootParameters(
_In_ PRX_CONTEXT RxContext,
_Out_ LUID *LogonId,
_Out_ PULONG SessionId,
_Out_ PUNICODE_STRING *UserNamePtr,
_Out_ PUNICODE_STRING *UserDomainNamePtr,
_Out_ PUNICODE_STRING *PasswordPtr,
_Out_ PULONG Flags);
VOID
RxUninitializeVNetRootParameters(
_In_ PUNICODE_STRING UserName,
_In_ PUNICODE_STRING UserDomainName,
_In_ PUNICODE_STRING Password,
_Out_ PULONG Flags);
PV_NET_ROOT
RxCreateVNetRoot(
_In_ PRX_CONTEXT RxContext,
_In_ PNET_ROOT NetRoot,
_In_ PUNICODE_STRING CanonicalName,
_In_ PUNICODE_STRING LocalNetRootName,
_In_ PUNICODE_STRING FilePath,
_In_ PRX_CONNECTION_ID RxConnectionId);
#define RxWaitForStableVNetRoot(V, R) RxWaitForStableCondition(&(V)->Condition, &(V)->TransitionWaitList, (R), NULL)
#define RxTransitionVNetRoot(V, C) RxUpdateCondition((C), &(V)->Condition, &(V)->TransitionWaitList)
VOID
RxGetFileSizeWithLock(
_In_ PFCB Fcb,
_Out_ PLONGLONG FileSize);
#if (_WIN32_WINNT >= 0x0600)
RxCreateNetFcb(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ PV_NET_ROOT VNetRoot,
_In_ PUNICODE_STRING Name);
#else
PFCB
RxCreateNetFcb(
_In_ PRX_CONTEXT RxContext,
_In_ PV_NET_ROOT VNetRoot,
_In_ PUNICODE_STRING Name);
#endif
#define RxWaitForStableNetFcb(F, R) RxWaitForStableCondition(&(F)->Condition, &(F)->NonPaged->TransitionWaitList, (R), NULL )
#define RxTransitionNetFcb(F, C) RxUpdateCondition((C), &(F)->Condition, &(F)->NonPaged->TransitionWaitList)
#define RxFormInitPacket(IP, I1, I1a, I2, I3, I4a, I4b, I5, I6, I7) ( \
IP.pAttributes = I1, IP.pNumLinks = I1a, \
IP.pCreationTime = I2, IP.pLastAccessTime = I3, \
IP.pLastWriteTime = I4a, IP.pLastChangeTime = I4b, \
IP.pAllocationSize = I5, IP.pFileSize = I6, \
IP.pValidDataLength = I7, &IP)
#if DBG
#define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb) \
{ \
ASSERT(Fcb->NonPaged == Fcb->CopyOfNonPaged); \
ASSERT(Fcb->NonPaged->FcbBackPointer == Fcb); \
}
#else
#define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb)
#endif
#define ASSERT_CORRECT_FCB_STRUCTURE(Fcb) \
{ \
ASSERT(NodeTypeIsFcb(Fcb)); \
ASSERT(Fcb->NonPaged != NULL ); \
ASSERT(NodeType(Fcb->NonPaged) == RDBSS_NTC_NONPAGED_FCB); \
ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb); \
}
VOID
NTAPI
RxFinishFcbInitialization(
_In_ OUT PMRX_FCB Fcb,
_In_ RX_FILE_TYPE FileType,
_In_opt_ PFCB_INIT_PACKET InitPacket);
#define RxWaitForStableSrvOpen(S, R) RxWaitForStableCondition(&(S)->Condition, &(S)->TransitionWaitList, (R), NULL)
#define RxTransitionSrvOpen(S, C) RxUpdateCondition((C), &(S)->Condition, &(S)->TransitionWaitList)
LONG
RxpReferenceNetFcb(
_In_ PFCB Fcb);
LONG
RxpDereferenceNetFcb(
_In_ PFCB Fcb);
BOOLEAN
RxpDereferenceAndFinalizeNetFcb(
_Out_ PFCB ThisFcb,
_In_ PRX_CONTEXT RxContext,
_In_ BOOLEAN RecursiveFinalize,
_In_ BOOLEAN ForceFinalize);
PSRV_OPEN
RxCreateSrvOpen(
_In_ PV_NET_ROOT VNetRoot,
_In_ OUT PFCB Fcb);
BOOLEAN
RxFinalizeSrvOpen(
_Out_ PSRV_OPEN ThisSrvOpen,
_In_ BOOLEAN RecursiveFinalize,
_In_ BOOLEAN ForceFinalize);
extern INLINE
PUNICODE_STRING
GET_ALREADY_PREFIXED_NAME(
PMRX_SRV_OPEN SrvOpen,
PMRX_FCB Fcb)
{
PFCB ThisFcb = (PFCB)Fcb;
#if DBG
if (SrvOpen != NULL)
{
ASSERT(NodeType(SrvOpen) == RDBSS_NTC_SRVOPEN);
ASSERT(ThisFcb != NULL);
ASSERT(NodeTypeIsFcb(Fcb));
ASSERT(SrvOpen->pFcb == Fcb);
ASSERT(SrvOpen->pAlreadyPrefixedName == &ThisFcb->PrivateAlreadyPrefixedName);
}
#endif
return &ThisFcb->PrivateAlreadyPrefixedName;
}
#define GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(Rxcontext) GET_ALREADY_PREFIXED_NAME((Rxcontext)->pRelevantSrvOpen, (Rxcontext)->pFcb)
PMRX_FOBX
NTAPI
RxCreateNetFobx(
_Out_ PRX_CONTEXT RxContext,
_In_ PMRX_SRV_OPEN MrxSrvOpen);
#ifdef __REACTOS__
#define FILL_IN_FCB(Fcb, a, nl, ct, lat, lwt, lct, as, fs, vdl) \
(Fcb)->Attributes = a; \
(Fcb)->NumberOfLinks = nl; \
(Fcb)->CreationTime.QuadPart = ct; \
(Fcb)->LastAccessTime.QuadPart = lat; \
(Fcb)->LastWriteTime.QuadPart = lwt; \
(Fcb)->LastChangeTime.QuadPart = lct; \
(Fcb)->ActualAllocationLength = as; \
(Fcb)->Header.AllocationSize.QuadPart = as; \
(Fcb)->Header.FileSize.QuadPart = fs; \
(Fcb)->Header.ValidDataLength.QuadPart = vdl; \
(Fcb)->FcbState |= FCB_STATE_TIME_AND_SIZE_ALREADY_SET
#define TRACKER_ACQUIRE_FCB 0x61616161
#define TRACKER_RELEASE_FCB_NO_BUFF_PENDING 0x72727272
#define TRACKER_RELEASE_NON_EXCL_FCB_BUFF_PENDING 0x72727230
#define TRACKER_RELEASE_EXCL_FCB_BUFF_PENDING 0x72727231
#define TRACKER_RELEASE_FCB_FOR_THRD_NO_BUFF_PENDING 0x72727474
#define TRACKER_RELEASE_NON_EXCL_FCB_FOR_THRD_BUFF_PENDING 0x72727430
#define TRACKER_RELEASE_EXCL_FCB_FOR_THRD_BUFF_PENDING 0x72727431
#define TRACKER_FCB_FREE 0x72724372
#endif
#endif

View File

@ -0,0 +1,60 @@
#ifndef _RXFCBTABLE_
#define _RXFCBTABLE_
typedef struct _RX_FCB_TABLE_ENTRY {
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
ULONG HashValue;
UNICODE_STRING Path;
LIST_ENTRY HashLinks;
LONG Lookups;
} RX_FCB_TABLE_ENTRY, *PRX_FCB_TABLE_ENTRY;
#define RX_FCB_TABLE_NUMBER_OF_HASH_BUCKETS 32
typedef struct _RX_FCB_TABLE
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
volatile ULONG Version;
BOOLEAN CaseInsensitiveMatch;
USHORT NumberOfBuckets;
volatile LONG Lookups;
volatile LONG FailedLookups;
volatile LONG Compares;
ERESOURCE TableLock;
PRX_FCB_TABLE_ENTRY TableEntryForNull;
LIST_ENTRY HashBuckets[RX_FCB_TABLE_NUMBER_OF_HASH_BUCKETS];
} RX_FCB_TABLE, *PRX_FCB_TABLE;
VOID
RxInitializeFcbTable(
_Inout_ PRX_FCB_TABLE FcbTable,
_In_ BOOLEAN CaseInsensitiveMatch);
PFCB
RxFcbTableLookupFcb(
_In_ PRX_FCB_TABLE FcbTable,
_In_ PUNICODE_STRING Path);
NTSTATUS
RxFcbTableInsertFcb(
_Inout_ PRX_FCB_TABLE FcbTable,
_Inout_ PFCB Fcb);
NTSTATUS
RxFcbTableRemoveFcb(
_Inout_ PRX_FCB_TABLE FcbTable,
_Inout_ PFCB Fcb);
#define RxAcquireFcbTableLockShared(T, W) ExAcquireResourceSharedLite(&(T)->TableLock, W)
#define RxAcquireFcbTableLockExclusive(T, W) ExAcquireResourceExclusiveLite(&(T)->TableLock, W)
#define RxReleaseFcbTableLock(T) ExReleaseResourceLite(&(T)->TableLock)
#define RxIsFcbTableLockExclusive(T) ExIsResourceAcquiredExclusiveLite(&(T)->TableLock)
#ifdef __REACTOS__
#define FCB_HASH_BUCKET(T, H) &(T)->HashBuckets[H % (T)->NumberOfBuckets]
#endif
#endif

View File

@ -0,0 +1,76 @@
#ifndef _RXLOWIO_
#define _RXLOWIO_
#include "mrx.h"
extern FAST_MUTEX RxLowIoPagingIoSyncMutex;
#define RxLowIoIsMdlLocked(MDL) (RxMdlIsLocked((MDL)) || RxMdlSourceIsNonPaged((MDL)))
#define RxLowIoIsBufferLocked(LowIoContext) \
(((LowIoContext)->Operation > LOWIO_OP_WRITE) || \
((LowIoContext)->ParamsFor.ReadWrite.Buffer == NULL) || \
(((LowIoContext)->ParamsFor.ReadWrite.Buffer != NULL) && \
RxLowIoIsMdlLocked(((LowIoContext)->ParamsFor.ReadWrite.Buffer))))
typedef struct _LOWIO_PER_FCB_INFO
{
LIST_ENTRY PagingIoReadsOutstanding;
LIST_ENTRY PagingIoWritesOutstanding;
} LOWIO_PER_FCB_INFO, *PLOWIO_PER_FCB_INFO;
#if (_WIN32_WINNT >= 0x0600)
NTSTATUS
NTAPI
RxLowIoPopulateFsctlInfo(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp);
#else
NTSTATUS
NTAPI
RxLowIoPopulateFsctlInfo(
_In_ PRX_CONTEXT RxContext);
#endif
#if (_WIN32_WINNT >= 0x0600)
NTSTATUS
NTAPI
RxLowIoSubmit(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ PFCB Fcb,
_In_ PLOWIO_COMPLETION_ROUTINE CompletionRoutine);
#else
NTSTATUS
NTAPI
RxLowIoSubmit(
_In_ PRX_CONTEXT RxContext,
_In_ PLOWIO_COMPLETION_ROUTINE CompletionRoutine);
#endif
NTSTATUS
NTAPI
RxLowIoCompletion(
_In_ PRX_CONTEXT RxContext);
#if (_WIN32_WINNT >= 0x0600)
VOID
NTAPI
RxInitializeLowIoContext(
_In_ PRX_CONTEXT RxContext,
_In_ ULONG Operation,
_Out_ PLOWIO_CONTEXT LowIoContext);
#else
VOID
NTAPI
RxInitializeLowIoContext(
_Out_ PLOWIO_CONTEXT LowIoContext,
_In_ ULONG Operation);
#endif
VOID
RxInitializeLowIoPerFcbInfo(
_Inout_ PLOWIO_PER_FCB_INFO LowIoPerFcbInfo);
#endif

View File

@ -0,0 +1,395 @@
#ifndef _RXMINIRDR_
#define _RXMINIRDR_
#define RX_REGISTERMINI_FLAG_DONT_PROVIDE_UNCS 0x00000001
#define RX_REGISTERMINI_FLAG_DONT_PROVIDE_MAILSLOTS 0x00000002
#define RX_REGISTERMINI_FLAG_DONT_INIT_DRIVER_DISPATCH 0x00000004
#define RX_REGISTERMINI_FLAG_DONT_INIT_PREFIX_N_SCAVENGER 0x00000008
NTSTATUS
NTAPI
RxRegisterMinirdr(
_Out_ PRDBSS_DEVICE_OBJECT *DeviceObject,
_Inout_ 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
NTAPI
RxpUnregisterMinirdr(
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject);
NTSTATUS
NTAPI
RxStartMinirdr(
_In_ PRX_CONTEXT RxContext,
_Out_ PBOOLEAN PostToFsp);
NTSTATUS
NTAPI
RxStopMinirdr(
_In_ PRX_CONTEXT RxContext,
_Out_ PBOOLEAN PostToFsp);
NTSTATUS
NTAPI
RxFsdDispatch(
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject,
_In_ PIRP Irp);
typedef
NTSTATUS
(NTAPI *PMRX_CALLDOWN) (
_Inout_ PRX_CONTEXT RxContext);
typedef
NTSTATUS
(NTAPI *PMRX_CALLDOWN_CTX) (
_Inout_ PRX_CONTEXT RxContext,
_Inout_ PRDBSS_DEVICE_OBJECT RxDeviceObject);
typedef
NTSTATUS
(NTAPI *PMRX_CHKDIR_CALLDOWN) (
_Inout_ PRX_CONTEXT RxContext,
_In_ PUNICODE_STRING DirectoryName);
typedef
NTSTATUS
(NTAPI *PMRX_CHKFCB_CALLDOWN) (
_In_ PFCB Fcb1,
_In_ PFCB Fcb2);
typedef enum _RX_BLOCK_CONDITION {
Condition_Uninitialized = 0,
Condition_InTransition,
Condition_Closing,
Condition_Good,
Condition_Bad,
Condition_Closed
} RX_BLOCK_CONDITION, *PRX_BLOCK_CONDITION;
#define StableCondition(X) ((X) >= Condition_Good)
typedef
VOID
(NTAPI *PMRX_NETROOT_CALLBACK) (
_Inout_ PMRX_CREATENETROOT_CONTEXT CreateContext);
typedef
VOID
(NTAPI *PMRX_EXTRACT_NETROOT_NAME) (
_In_ PUNICODE_STRING FilePathName,
_In_ PMRX_SRV_CALL SrvCall,
_Out_ PUNICODE_STRING NetRootName,
_Out_opt_ PUNICODE_STRING RestOfName);
typedef struct _MRX_CREATENETROOT_CONTEXT
{
PRX_CONTEXT RxContext;
PV_NET_ROOT pVNetRoot;
KEVENT FinishEvent;
NTSTATUS VirtualNetRootStatus;
NTSTATUS NetRootStatus;
RX_WORK_QUEUE_ITEM WorkQueueItem;
PMRX_NETROOT_CALLBACK Callback;
} MRX_CREATENETROOT_CONTEXT, *PMRX_CREATENETROOT_CONTEXT;
typedef
NTSTATUS
(NTAPI *PMRX_CREATE_V_NET_ROOT) (
_Inout_ PMRX_CREATENETROOT_CONTEXT Context);
typedef
NTSTATUS
(NTAPI *PMRX_UPDATE_NETROOT_STATE) (
_Inout_ PMRX_NET_ROOT NetRoot);
typedef struct _MRX_SRVCALL_CALLBACK_CONTEXT
{
PMRX_SRVCALLDOWN_STRUCTURE SrvCalldownStructure;
ULONG CallbackContextOrdinal;
PRDBSS_DEVICE_OBJECT RxDeviceObject;
NTSTATUS Status;
PVOID RecommunicateContext;
} MRX_SRVCALL_CALLBACK_CONTEXT, *PMRX_SRVCALL_CALLBACK_CONTEXT;
typedef
VOID
(NTAPI *PMRX_SRVCALL_CALLBACK) (
_Inout_ PMRX_SRVCALL_CALLBACK_CONTEXT Context);
typedef struct _MRX_SRVCALLDOWN_STRUCTURE
{
KEVENT FinishEvent;
LIST_ENTRY SrvCalldownList;
PRX_CONTEXT RxContext;
PMRX_SRV_CALL SrvCall;
PMRX_SRVCALL_CALLBACK CallBack;
BOOLEAN CalldownCancelled;
ULONG NumberRemaining;
ULONG NumberToWait;
ULONG BestFinisherOrdinal;
PRDBSS_DEVICE_OBJECT BestFinisher;
MRX_SRVCALL_CALLBACK_CONTEXT CallbackContexts[1];
} MRX_SRVCALLDOWN_STRUCTURE, *PMRX_SRVCALLDOWN_STRUCTURE;
typedef
NTSTATUS
(NTAPI *PMRX_CREATE_SRVCALL) (
_Inout_ PMRX_SRV_CALL SrvCall,
_Inout_ PMRX_SRVCALL_CALLBACK_CONTEXT SrvCallCallBackContext);
typedef
NTSTATUS
(NTAPI *PMRX_SRVCALL_WINNER_NOTIFY)(
_Inout_ PMRX_SRV_CALL SrvCall,
_In_ BOOLEAN ThisMinirdrIsTheWinner,
_Inout_ PVOID RecommunicateContext);
typedef
NTSTATUS
(NTAPI *PMRX_DEALLOCATE_FOR_FCB) (
_Inout_ PMRX_FCB Fcb);
typedef
NTSTATUS
(NTAPI *PMRX_DEALLOCATE_FOR_FOBX) (
_Inout_ PMRX_FOBX Fobx);
typedef
NTSTATUS
(NTAPI *PMRX_IS_LOCK_REALIZABLE) (
_Inout_ PMRX_FCB Fcb,
_In_ PLARGE_INTEGER ByteOffset,
_In_ PLARGE_INTEGER Length,
_In_ ULONG LowIoLockFlags);
typedef
NTSTATUS
(NTAPI *PMRX_FORCECLOSED_CALLDOWN) (
_Inout_ PMRX_SRV_OPEN SrvOpen);
typedef
NTSTATUS
(NTAPI *PMRX_FINALIZE_SRVCALL_CALLDOWN) (
_Inout_ PMRX_SRV_CALL SrvCall,
_In_ BOOLEAN Force);
typedef
NTSTATUS
(NTAPI *PMRX_FINALIZE_V_NET_ROOT_CALLDOWN) (
_Inout_ PMRX_V_NET_ROOT VirtualNetRoot,
_In_ PBOOLEAN Force);
typedef
NTSTATUS
(NTAPI *PMRX_FINALIZE_NET_ROOT_CALLDOWN) (
_Inout_ PMRX_NET_ROOT NetRoot,
_In_ PBOOLEAN Force);
typedef
ULONG
(NTAPI *PMRX_EXTENDFILE_CALLDOWN) (
_Inout_ PRX_CONTEXT RxContext,
_Inout_ PLARGE_INTEGER NewFileSize,
_Out_ PLARGE_INTEGER NewAllocationSize);
typedef
NTSTATUS
(NTAPI *PMRX_CHANGE_BUFFERING_STATE_CALLDOWN) (
_Inout_ PRX_CONTEXT RxContext,
_Inout_ PMRX_SRV_OPEN SrvOpen,
_In_ PVOID MRxContext);
typedef
NTSTATUS
(NTAPI *PMRX_PREPARSE_NAME) (
_Inout_ PRX_CONTEXT RxContext,
_In_ PUNICODE_STRING Name);
typedef
NTSTATUS
(NTAPI *PMRX_GET_CONNECTION_ID) (
_Inout_ PRX_CONTEXT RxContext,
_Inout_ PRX_CONNECTION_ID UniqueId);
typedef
NTSTATUS
(NTAPI *PMRX_COMPUTE_NEW_BUFFERING_STATE) (
_Inout_ PMRX_SRV_OPEN SrvOpen,
_In_ PVOID MRxContext,
_Out_ PULONG NewBufferingState);
typedef enum _LOWIO_OPS {
LOWIO_OP_READ = 0,
LOWIO_OP_WRITE,
LOWIO_OP_SHAREDLOCK,
LOWIO_OP_EXCLUSIVELOCK,
LOWIO_OP_UNLOCK,
LOWIO_OP_UNLOCK_MULTIPLE,
LOWIO_OP_FSCTL,
LOWIO_OP_IOCTL,
LOWIO_OP_NOTIFY_CHANGE_DIRECTORY,
LOWIO_OP_CLEAROUT,
LOWIO_OP_MAXIMUM
} LOWIO_OPS;
typedef
NTSTATUS
(NTAPI *PLOWIO_COMPLETION_ROUTINE) (
_In_ PRX_CONTEXT RxContext);
typedef LONGLONG RXVBO;
typedef struct _LOWIO_LOCK_LIST
{
struct _LOWIO_LOCK_LIST * Next;
ULONG LockNumber;
RXVBO ByteOffset;
LONGLONG Length;
BOOLEAN ExclusiveLock;
ULONG Key;
} LOWIO_LOCK_LIST, *PLOWIO_LOCK_LIST;
typedef struct _XXCTL_LOWIO_COMPONENT
{
ULONG Flags;
union
{
ULONG FsControlCode;
ULONG IoControlCode;
};
ULONG InputBufferLength;
PVOID pInputBuffer;
ULONG OutputBufferLength;
PVOID pOutputBuffer;
UCHAR MinorFunction;
} XXCTL_LOWIO_COMPONENT;
typedef struct _LOWIO_CONTEXT
{
USHORT Operation;
USHORT Flags;
PLOWIO_COMPLETION_ROUTINE CompletionRoutine;
PERESOURCE Resource;
ERESOURCE_THREAD ResourceThreadId;
union
{
struct
{
ULONG Flags;
PMDL Buffer;
RXVBO ByteOffset;
ULONG ByteCount;
ULONG Key;
PNON_PAGED_FCB NonPagedFcb;
} ReadWrite;
struct
{
union
{
PLOWIO_LOCK_LIST LockList;
LONGLONG Length;
};
ULONG Flags;
RXVBO ByteOffset;
ULONG Key;
} Locks;
XXCTL_LOWIO_COMPONENT FsCtl;
XXCTL_LOWIO_COMPONENT IoCtl;
struct
{
BOOLEAN WatchTree;
ULONG CompletionFilter;
ULONG NotificationBufferLength;
PVOID pNotificationBuffer;
} NotifyChangeDirectory;
} ParamsFor;
} LOWIO_CONTEXT;
#define LOWIO_CONTEXT_FLAG_SYNCCALL 0x01
#define LOWIO_CONTEXT_FLAG_LOUDOPS 0x04
#define LOWIO_CONTEXT_FLAG_CAN_COMPLETE_AT_DPC_LEVEL 0x08
#define LOWIO_READWRITEFLAG_PAGING_IO 0x01
#define RDBSS_MANAGE_SRV_CALL_EXTENSION 0x01
#define RDBSS_MANAGE_NET_ROOT_EXTENSION 0x02
#define RDBSS_MANAGE_V_NET_ROOT_EXTENSION 0x04
#define RDBSS_MANAGE_FCB_EXTENSION 0x08
#define RDBSS_MANAGE_SRV_OPEN_EXTENSION 0x10
#define RDBSS_MANAGE_FOBX_EXTENSION 0x20
#define RDBSS_NO_DEFERRED_CACHE_READAHEAD 0x1000
typedef struct _MINIRDR_DISPATCH
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
ULONG MRxFlags;
ULONG MRxSrvCallSize;
ULONG MRxNetRootSize;
ULONG MRxVNetRootSize;
ULONG MRxFcbSize;
ULONG MRxSrvOpenSize;
ULONG MRxFobxSize;
PMRX_CALLDOWN_CTX MRxStart;
PMRX_CALLDOWN_CTX MRxStop;
PMRX_CALLDOWN MRxCancel;
PMRX_CALLDOWN MRxCreate;
PMRX_CALLDOWN MRxCollapseOpen;
PMRX_CALLDOWN MRxShouldTryToCollapseThisOpen;
PMRX_CALLDOWN MRxFlush;
PMRX_CALLDOWN MRxZeroExtend;
PMRX_CALLDOWN MRxTruncate;
PMRX_CALLDOWN MRxCleanupFobx;
PMRX_CALLDOWN MRxCloseSrvOpen;
PMRX_DEALLOCATE_FOR_FCB MRxDeallocateForFcb;
PMRX_DEALLOCATE_FOR_FOBX MRxDeallocateForFobx;
PMRX_IS_LOCK_REALIZABLE MRxIsLockRealizable;
PMRX_FORCECLOSED_CALLDOWN MRxForceClosed;
PMRX_CHKFCB_CALLDOWN MRxAreFilesAliased;
PMRX_CALLDOWN MRxOpenPrintFile;
PMRX_CALLDOWN MRxClosePrintFile;
PMRX_CALLDOWN MRxWritePrintFile;
PMRX_CALLDOWN MRxEnumeratePrintQueue;
PMRX_CALLDOWN MRxClosedSrvOpenTimeOut;
PMRX_CALLDOWN MRxClosedFcbTimeOut;
PMRX_CALLDOWN MRxQueryDirectory;
PMRX_CALLDOWN MRxQueryFileInfo;
PMRX_CALLDOWN MRxSetFileInfo;
PMRX_CALLDOWN MRxSetFileInfoAtCleanup;
PMRX_CALLDOWN MRxQueryEaInfo;
PMRX_CALLDOWN MRxSetEaInfo;
PMRX_CALLDOWN MRxQuerySdInfo;
PMRX_CALLDOWN MRxSetSdInfo;
PMRX_CALLDOWN MRxQueryQuotaInfo;
PMRX_CALLDOWN MRxSetQuotaInfo;
PMRX_CALLDOWN MRxQueryVolumeInfo;
PMRX_CALLDOWN MRxSetVolumeInfo;
PMRX_CHKDIR_CALLDOWN MRxIsValidDirectory;
PMRX_COMPUTE_NEW_BUFFERING_STATE MRxComputeNewBufferingState;
PMRX_CALLDOWN MRxLowIOSubmit[LOWIO_OP_MAXIMUM+1];
PMRX_EXTENDFILE_CALLDOWN MRxExtendForCache;
PMRX_EXTENDFILE_CALLDOWN MRxExtendForNonCache;
PMRX_CHANGE_BUFFERING_STATE_CALLDOWN MRxCompleteBufferingStateChangeRequest;
PMRX_CREATE_V_NET_ROOT MRxCreateVNetRoot;
PMRX_FINALIZE_V_NET_ROOT_CALLDOWN MRxFinalizeVNetRoot;
PMRX_FINALIZE_NET_ROOT_CALLDOWN MRxFinalizeNetRoot;
PMRX_UPDATE_NETROOT_STATE MRxUpdateNetRootState;
PMRX_EXTRACT_NETROOT_NAME MRxExtractNetRootName;
PMRX_CREATE_SRVCALL MRxCreateSrvCall;
PMRX_CREATE_SRVCALL MRxCancelCreateSrvCall;
PMRX_SRVCALL_WINNER_NOTIFY MRxSrvCallWinnerNotify;
PMRX_FINALIZE_SRVCALL_CALLDOWN MRxFinalizeSrvCall;
PMRX_CALLDOWN MRxDevFcbXXXControlFile;
PMRX_PREPARSE_NAME MRxPreparseName;
PMRX_GET_CONNECTION_ID MRxGetConnectionId;
ULONG ScavengerTimeout;
} MINIRDR_DISPATCH, *PMINIRDR_DISPATCH;
#endif

View File

@ -0,0 +1,211 @@
#ifndef __MRXFCB_H__
#define __MRXFCB_H__
typedef struct _MRX_NORMAL_NODE_HEADER
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
volatile ULONG NodeReferenceCount;
} MRX_NORMAL_NODE_HEADER;
#define SRVCALL_FLAG_CASE_INSENSITIVE_NETROOTS 0x4
#define SRVCALL_FLAG_CASE_INSENSITIVE_FILENAMES 0x8
#define SRVCALL_FLAG_DFS_AWARE_SERVER 0x10
typedef struct _MRX_SRV_CALL_
{
MRX_NORMAL_NODE_HEADER;
PVOID Context;
PVOID Context2;
PRDBSS_DEVICE_OBJECT RxDeviceObject;
PUNICODE_STRING pSrvCallName;
PUNICODE_STRING pPrincipalName;
PUNICODE_STRING pDomainName;
ULONG Flags;
LONG MaximumNumberOfCloseDelayedFiles;
NTSTATUS Status;
} MRX_SRV_CALL, *PMRX_SRV_CALL;
#define NET_ROOT_DISK ((UCHAR)0)
#define NET_ROOT_PIPE ((UCHAR)1)
#define NET_ROOT_PRINT ((UCHAR)3)
#define NET_ROOT_WILD ((UCHAR)4)
typedef UCHAR NET_ROOT_TYPE, *PNET_ROOT_TYPE;
#define MRX_NET_ROOT_STATE_GOOD ((UCHAR)0)
typedef UCHAR MRX_NET_ROOT_STATE, *PMRX_NET_ROOT_STATE;
typedef UCHAR MRX_PURGE_RELATIONSHIP, *PMRX_PURGE_RELATIONSHIP;
typedef UCHAR MRX_PURGE_SYNCLOCATION, *PMRX_PURGE_SYNCLOCATION;
#define NETROOT_FLAG_SUPPORTS_SYMBOLIC_LINKS 0x1
#define NETROOT_FLAG_DFS_AWARE_NETROOT 0x2
typedef struct _NETROOT_THROTTLING_PARAMETERS
{
ULONG Increment;
ULONG MaximumDelay;
} NETROOT_THROTTLING_PARAMETERS, *PNETROOT_THROTTLING_PARAMETERS;
typedef struct _MRX_NET_ROOT_
{
MRX_NORMAL_NODE_HEADER;
PMRX_SRV_CALL pSrvCall;
PVOID Context;
PVOID Context2;
ULONG Flags;
volatile ULONG NumberOfFcbs;
volatile ULONG NumberOfSrvOpens;
MRX_NET_ROOT_STATE MRxNetRootState;
NET_ROOT_TYPE Type;
MRX_PURGE_RELATIONSHIP PurgeRelationship;
MRX_PURGE_SYNCLOCATION PurgeSyncLocation;
DEVICE_TYPE DeviceType;
PUNICODE_STRING pNetRootName;
UNICODE_STRING InnerNamePrefix;
ULONG ParameterValidationStamp;
union
{
struct
{
ULONG DataCollectionSize;
NETROOT_THROTTLING_PARAMETERS PipeReadThrottlingParameters;
} NamedPipeParameters;
struct
{
ULONG ClusterSize;
ULONG ReadAheadGranularity;
NETROOT_THROTTLING_PARAMETERS LockThrottlingParameters;
ULONG RenameInfoOverallocationSize;
GUID VolumeId;
} DiskParameters;
};
} MRX_NET_ROOT, *PMRX_NET_ROOT;
#define VNETROOT_FLAG_CSCAGENT_INSTANCE 0x00000001
typedef struct _MRX_V_NET_ROOT_
{
MRX_NORMAL_NODE_HEADER;
PMRX_NET_ROOT pNetRoot;
PVOID Context;
PVOID Context2;
ULONG Flags;
ULONG NumberOfOpens;
volatile ULONG NumberOfFobxs;
LUID LogonId;
PUNICODE_STRING pUserDomainName;
PUNICODE_STRING pUserName;
PUNICODE_STRING pPassword;
ULONG SessionId;
NTSTATUS ConstructionStatus;
BOOLEAN IsExplicitConnection;
} MRX_V_NET_ROOT, *PMRX_V_NET_ROOT;
typedef struct _MRX_FCB_
{
FSRTL_ADVANCED_FCB_HEADER Header;
PMRX_NET_ROOT pNetRoot;
PVOID Context;
PVOID Context2;
volatile ULONG NodeReferenceCount;
ULONG FcbState;
volatile CLONG UncleanCount;
CLONG UncachedUncleanCount;
volatile CLONG OpenCount;
volatile ULONG OutstandingLockOperationsCount;
ULONGLONG ActualAllocationLength;
ULONG Attributes;
BOOLEAN IsFileWritten;
BOOLEAN fShouldBeOrphaned;
BOOLEAN fMiniInited;
UCHAR CachedNetRootType;
LIST_ENTRY SrvOpenList;
ULONG SrvOpenListVersion;
} MRX_FCB, *PMRX_FCB;
#define SRVOPEN_FLAG_DONTUSE_READ_CACHING 0x1
#define SRVOPEN_FLAG_DONTUSE_WRITE_CACHING 0x2
#define SRVOPEN_FLAG_CLOSED 0x4
#define SRVOPEN_FLAG_CLOSE_DELAYED 0x8
#define SRVOPEN_FLAG_FILE_RENAMED 0x10
#define SRVOPEN_FLAG_FILE_DELETED 0x20
#define SRVOPEN_FLAG_COLLAPSING_DISABLED 0x80
#define SRVOPEN_FLAG_NO_BUFFERING_STATE_CHANGE 0x200
#define SRVOPEN_FLAG_ORPHANED 0x400
typedef
NTSTATUS
(NTAPI *PMRX_SHADOW_CALLDOWN) (
IN OUT PRX_CONTEXT RxContext
);
typedef struct
{
PFILE_OBJECT UnderlyingFileObject;
PDEVICE_OBJECT UnderlyingDeviceObject;
ULONG LockKey;
PFAST_IO_READ FastIoRead;
PFAST_IO_WRITE FastIoWrite;
PMRX_SHADOW_CALLDOWN DispatchRoutine;
} MRXSHADOW_SRV_OPEN, *PMRXSHADOW_SRV_OPEN;
typedef struct _MRX_SRV_OPEN_
{
MRX_NORMAL_NODE_HEADER;
PMRX_FCB pFcb;
PMRX_V_NET_ROOT pVNetRoot;
PVOID Context;
PVOID Context2;
#if (_WIN32_WINNT >= 0x0600)
PMRXSHADOW_SRV_OPEN ShadowContext;
#endif
ULONG Flags;
PUNICODE_STRING pAlreadyPrefixedName;
CLONG UncleanFobxCount;
CLONG OpenCount;
PVOID Key;
ACCESS_MASK DesiredAccess;
ULONG ShareAccess;
ULONG CreateOptions;
ULONG BufferingFlags;
ULONG ulFileSizeVersion;
LIST_ENTRY SrvOpenQLinks;
} MRX_SRV_OPEN, *PMRX_SRV_OPEN;
#define FOBX_FLAG_DFS_OPEN 0x0001
#define FOBX_FLAG_BACKUP_INTENT 0x0004
typedef struct _MRX_PIPE_HANDLE_INFORMATION
{
ULONG TypeOfPipe;
ULONG ReadMode;
ULONG CompletionMode;
} MRX_PIPE_HANDLE_INFORMATION, *PMRX_PIPE_HANDLE_INFORMATION;
typedef struct _MRX_FOBX_
{
MRX_NORMAL_NODE_HEADER;
PMRX_SRV_OPEN pSrvOpen;
PFILE_OBJECT AssociatedFileObject;
PVOID Context;
PVOID Context2;
ULONG Flags;
union
{
struct
{
UNICODE_STRING UnicodeQueryTemplate;
};
PMRX_PIPE_HANDLE_INFORMATION PipeHandleInformation;
};
ULONG OffsetOfNextEaToReturn;
} MRX_FOBX, *PMRX_FOBX;
NTSTATUS
NTAPI
RxAcquireExclusiveFcbResourceInMRx(
_Inout_ PMRX_FCB Fcb);
#endif

View File

@ -0,0 +1,85 @@
#ifndef _NODETYPE_INCLUDED_
#define _NODETYPE_INCLUDED_
typedef USHORT NODE_TYPE_CODE;
typedef NODE_TYPE_CODE *PNODE_TYPE_CODE;
typedef CSHORT NODE_BYTE_SIZE;
#ifndef NodeType
#define NodeType(Ptr) (*((PNODE_TYPE_CODE)(Ptr)))
#endif
typedef struct _NODE_TYPE_CODE_AND_SIZE_NO_REFCOUNT
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
} NODE_TYPE_CODE_AND_SIZE_NO_REFCOUNT;
typedef struct _NODE_TYPE_CODE_AND_SIZE
{
NODE_TYPE_CODE_AND_SIZE_NO_REFCOUNT;
volatile ULONG NodeReferenceCount;
} NODE_TYPE_CODE_AND_SIZE, *PNODE_TYPE_AND_SIZE;
#define ZeroAndInitializeNodeType(Node, Type, Size) \
{ \
RtlZeroMemory(Node, Size); \
((NODE_TYPE_CODE_AND_SIZE *)(Node))->NodeTypeCode = Type; \
((NODE_TYPE_CODE_AND_SIZE *)(Node))->NodeByteSize = (CSHORT)Size; \
}
#define RDBSS_STORAGE_NTC(x) (0xec00 + (x))
typedef enum _RX_FILE_TYPE
{
FileTypeNotYetKnown = 0,
FileTypeDirectory = 2,
FileTypeFile = 3
} RX_FILE_TYPE;
#define RDBSS_NTC_STORAGE_TYPE_UNKNOWN ((NODE_TYPE_CODE)0xec00)
#define RDBSS_NTC_STORAGE_TYPE_DIRECTORY ((NODE_TYPE_CODE)0xec02)
#define RDBSS_NTC_STORAGE_TYPE_FILE ((NODE_TYPE_CODE)0xec03)
#define RDBSS_NTC_OPENTARGETDIR_FCB ((NODE_TYPE_CODE)0xecff)
#define RDBSS_NTC_MAILSLOT ((NODE_TYPE_CODE)0xecfd)
#define RDBSS_NTC_SPOOLFILE ((NODE_TYPE_CODE)0xecfc)
#define RDBSS_NTC_SRVCALL ((NODE_TYPE_CODE)0xeb10)
#define RDBSS_NTC_NETROOT ((NODE_TYPE_CODE)0xeb11)
#define RDBSS_NTC_V_NETROOT ((NODE_TYPE_CODE)0xeb12)
#define RDBSS_NTC_VOLUME_FCB ((NODE_TYPE_CODE)0xeb1f)
#define RDBSS_NTC_SRVOPEN ((NODE_TYPE_CODE)0xeb1c)
#define RDBSS_NTC_INTERNAL_SRVOPEN ((NODE_TYPE_CODE)0xeb1d)
#define RDBSS_NTC_DEVICE_FCB ((NODE_TYPE_CODE)0xeb9a)
#define RDBSS_NTC_DATA_HEADER ((NODE_TYPE_CODE)0xeb00)
#define RDBSS_NTC_VCB ((NODE_TYPE_CODE)0xeb01)
#define RDBSS_NTC_FOBX ((NODE_TYPE_CODE)0xeb07)
#define RDBSS_NTC_RX_CONTEXT ((NODE_TYPE_CODE)0xeb08)
#define RDBSS_NTC_PREFIX_TABLE ((NODE_TYPE_CODE)0xeb0d)
#define RDBSS_NTC_PREFIX_ENTRY ((NODE_TYPE_CODE)0xeb0e)
#define RDBSS_NTC_FCB_TABLE ((NODE_TYPE_CODE)0xeb09)
#define RDBSS_NTC_FCB_TABLE_ENTRY ((NODE_TYPE_CODE)0xeb0a)
#define RDBSS_NTC_NONPAGED_FCB ((NODE_TYPE_CODE)0xebfd)
#define RDBSS_NTC_MINIRDR_DISPATCH ((NODE_TYPE_CODE)0xebff)
#define NodeTypeIsFcb(FCB) ((((NodeType(FCB) & 0xff00) == RDBSS_NTC_STORAGE_TYPE_UNKNOWN)) || ((NodeType(FCB) & 0xfff0) == 0xeb90))
#define RX_SCAVENGER_MASK (0x1000)
typedef enum _RDBSS_BUG_CHECK_CODES
{
RDBSS_BUG_CHECK_FCBSTRUC = 0xfcb00000,
RDBSS_BUG_CHECK_CACHESUP = 0xca550000,
RDBSS_BUG_CHECK_CLEANUP = 0xc1ee0000,
RDBSS_BUG_CHECK_CLOSE = 0xc10e0000,
RDBSS_BUG_CHECK_NTEXCEPT = 0xbaad0000,
#ifdef __REACTOS__
RDBSS_BUG_CHECK_ASSERT = 0xa55a0000,
#endif
} RDBSS_BUG_CHECK_CODES;
#define RDBSS_FILE_SYSTEM RDR_FILE_SYSTEM
#define RxBugCheck(A, B, C) KeBugCheckEx(RDBSS_FILE_SYSTEM, BugCheckFileId | ((ULONG)(__LINE__)), A, B, C)
#endif

View File

@ -0,0 +1,28 @@
#ifndef _RX_NTDEFS_DEFINED_
#define _RX_NTDEFS_DEFINED_
#define INLINE __inline
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
#endif
#define RxAllocatePoolWithTag ExAllocatePoolWithTag
#define RxFreePool ExFreePool
#define RxMdlIsLocked(Mdl) ((Mdl)->MdlFlags & MDL_PAGES_LOCKED)
#define RxMdlSourceIsNonPaged(Mdl) ((Mdl)->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL)
#define RxAdjustAllocationSizeforCC(Fcb) \
{ \
if ((Fcb)->Header.FileSize.QuadPart > (Fcb)->Header.AllocationSize.QuadPart) \
{ \
PMRX_NET_ROOT NetRoot = (Fcb)->pNetRoot; \
ULONGLONG ClusterSize = NetRoot->DiskParameters.ClusterSize; \
ULONGLONG FileSize = (Fcb)->Header.FileSize.QuadPart; \
ASSERT(ClusterSize != 0); \
(Fcb)->Header.AllocationSize.QuadPart = (FileSize + ClusterSize) &~ (ClusterSize - 1); \
} \
ASSERT ((Fcb)->Header.ValidDataLength.QuadPart <= (Fcb)->Header.FileSize.QuadPart); \
}
#endif

View File

@ -0,0 +1,111 @@
#ifndef _RXPREFIX_
#define _RXPREFIX_
typedef struct _RX_CONNECTION_ID
{
union
{
ULONG SessionID;
LUID Luid;
};
} RX_CONNECTION_ID, *PRX_CONNECTION_ID;
ULONG
RxTableComputeHashValue(
_In_ PUNICODE_STRING Name);
PVOID
RxPrefixTableLookupName(
_In_ PRX_PREFIX_TABLE ThisTable,
_In_ PUNICODE_STRING CanonicalName,
_Out_ PUNICODE_STRING RemainingName,
_In_ PRX_CONNECTION_ID ConnectionId);
PRX_PREFIX_ENTRY
RxPrefixTableInsertName(
_Inout_ PRX_PREFIX_TABLE ThisTable,
_Inout_ PRX_PREFIX_ENTRY ThisEntry,
_In_ PVOID Container,
_In_ PULONG ContainerRefCount,
_In_ USHORT CaseInsensitiveLength,
_In_ PRX_CONNECTION_ID ConnectionId);
VOID
RxInitializePrefixTable(
_Inout_ PRX_PREFIX_TABLE ThisTable,
_In_opt_ ULONG TableSize,
_In_ BOOLEAN CaseInsensitiveMatch);
typedef struct _RX_PREFIX_ENTRY
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
USHORT CaseInsensitiveLength;
USHORT Spare1;
ULONG SavedHashValue;
LIST_ENTRY HashLinks;
LIST_ENTRY MemberQLinks;
UNICODE_STRING Prefix;
PULONG ContainerRefCount;
PVOID ContainingRecord;
PVOID Context;
RX_CONNECTION_ID ConnectionId;
} RX_PREFIX_ENTRY, *PRX_PREFIX_ENTRY;
#define RX_PREFIX_TABLE_DEFAULT_LENGTH 32
typedef struct _RX_PREFIX_TABLE {
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
ULONG Version;
LIST_ENTRY MemberQueue;
ERESOURCE TableLock;
PRX_PREFIX_ENTRY TableEntryForNull;
BOOLEAN CaseInsensitiveMatch;
BOOLEAN IsNetNameTable;
ULONG TableSize;
#if DBG
ULONG Lookups;
ULONG FailedLookups;
ULONG Considers;
ULONG Compares;
#endif
LIST_ENTRY HashBuckets[RX_PREFIX_TABLE_DEFAULT_LENGTH];
} RX_PREFIX_TABLE, *PRX_PREFIX_TABLE;
#if (_WIN32_WINNT < 0x0600)
#define RxAcquirePrefixTableLockShared(T, W) RxpAcquirePrefixTableLockShared((T),(W),TRUE)
#define RxAcquirePrefixTableLockExclusive(T, W) RxpAcquirePrefixTableLockExclusive((T), (W), TRUE)
#define RxReleasePrefixTableLock(T) RxpReleasePrefixTableLock((T), TRUE)
BOOLEAN
RxpAcquirePrefixTableLockShared(
_In_ PRX_PREFIX_TABLE pTable,
_In_ BOOLEAN Wait,
_In_ BOOLEAN ProcessBufferingStateChangeRequests);
BOOLEAN
RxpAcquirePrefixTableLockExclusive(
_In_ PRX_PREFIX_TABLE pTable,
_In_ BOOLEAN Wait,
_In_ BOOLEAN ProcessBufferingStateChangeRequests);
VOID
RxpReleasePrefixTableLock(
_In_ PRX_PREFIX_TABLE pTable,
_In_ BOOLEAN ProcessBufferingStateChangeRequests);
#endif
VOID
RxExclusivePrefixTableLockToShared(
_In_ PRX_PREFIX_TABLE Table);
#define RxIsPrefixTableLockExclusive(T) ExIsResourceAcquiredExclusiveLite(&(T)->TableLock)
#define RxIsPrefixTableLockAcquired(T) (ExIsResourceAcquiredSharedLite(&(T)->TableLock) || \
ExIsResourceAcquiredExclusiveLite(&(T)->TableLock))
#ifdef __REACTOS__
#define HASH_BUCKET(T, H) &(T)->HashBuckets[H % (T)->TableSize]
#endif
#endif

View File

@ -0,0 +1,46 @@
#ifndef _RX_
#define _RX_
#include "rxovride.h"
#include "ntifs.h"
#ifndef BooleanFlagOn
#define BooleanFlagOn(Flags, SingleFlag) ((BOOLEAN)((((Flags) & (SingleFlag)) != 0)))
#endif
#ifndef SetFlag
#define SetFlag(Flags, SetOfFlags) \
{ \
(Flags) |= (SetOfFlags); \
}
#endif
#ifndef ClearFlag
#define ClearFlag(Flags, SetOfFlags) \
{ \
(Flags) &= ~(SetOfFlags); \
}
#endif
#define Add2Ptr(Ptr, Inc) ((PVOID)((PUCHAR)(Ptr) + (Inc)))
#define INLINE __inline
#include "rxtypes.h"
#ifndef MINIRDR__NAME
#include "rxpooltg.h"
#endif
#include "ntrxdef.h"
#include "fcbtable.h"
#include "mrxfcb.h"
#include "rxworkq.h"
#include "rxprocs.h"
#ifndef MINIRDR__NAME
#include "rxdata.h"
#include "buffring.h"
#endif
#endif

View File

@ -0,0 +1,475 @@
#ifndef _RX_CONTEXT_STRUCT_DEFINED_
#define _RX_CONTEXT_STRUCT_DEFINED_
#define RX_TOPLEVELIRP_CONTEXT_SIGNATURE 'LTxR'
typedef struct _RX_TOPLEVELIRP_CONTEXT
{
union
{
#ifndef __cplusplus
LIST_ENTRY;
#endif
LIST_ENTRY ListEntry;
};
ULONG Signature;
PRDBSS_DEVICE_OBJECT RxDeviceObject;
PRX_CONTEXT RxContext;
PIRP Irp;
ULONG Flags;
PVOID Previous;
PETHREAD Thread;
} RX_TOPLEVELIRP_CONTEXT, *PRX_TOPLEVELIRP_CONTEXT;
BOOLEAN
RxTryToBecomeTheTopLevelIrp(
_Inout_ PRX_TOPLEVELIRP_CONTEXT TopLevelContext,
_In_ PIRP Irp,
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject,
_In_ BOOLEAN ForceTopLevel);
VOID
__RxInitializeTopLevelIrpContext(
_Inout_ PRX_TOPLEVELIRP_CONTEXT TopLevelContext,
_In_ PIRP Irp,
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject,
_In_ ULONG Flags);
#define RxInitializeTopLevelIrpContext(a,b,c) __RxInitializeTopLevelIrpContext(a,b,c,0)
PRDBSS_DEVICE_OBJECT
RxGetTopDeviceObjectIfRdbssIrp(
VOID);
VOID
RxUnwindTopLevelIrp(
_Inout_ PRX_TOPLEVELIRP_CONTEXT TopLevelContext);
BOOLEAN
RxIsThisTheTopLevelIrp(
_In_ PIRP Irp);
#ifdef RDBSS_TRACKER
typedef struct _RX_FCBTRACKER_CALLINFO
{
ULONG AcquireRelease;
USHORT SavedTrackerValue;
USHORT LineNumber;
PSZ FileName;
ULONG Flags;
} RX_FCBTRACKER_CALLINFO, *PRX_FCBTRACKER_CALLINFO;
#define RDBSS_TRACKER_HISTORY_SIZE 32
#endif
#define MRX_CONTEXT_FIELD_COUNT 4
#if (_WIN32_WINNT >= 0x0600)
typedef
NTSTATUS
(NTAPI *PRX_DISPATCH) (
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp);
#else
typedef
NTSTATUS
(NTAPI *PRX_DISPATCH) (
_In_ PRX_CONTEXT RxContext);
#endif
typedef struct _DFS_NAME_CONTEXT_ *PDFS_NAME_CONTEXT;
typedef struct _NT_CREATE_PARAMETERS
{
ACCESS_MASK DesiredAccess;
LARGE_INTEGER AllocationSize;
ULONG FileAttributes;
ULONG ShareAccess;
ULONG Disposition;
ULONG CreateOptions;
PIO_SECURITY_CONTEXT SecurityContext;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
PVOID DfsContext;
PDFS_NAME_CONTEXT DfsNameContext;
} NT_CREATE_PARAMETERS, *PNT_CREATE_PARAMETERS;
typedef struct _RX_CONTEXT
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
volatile ULONG ReferenceCount;
LIST_ENTRY ContextListEntry;
UCHAR MajorFunction;
UCHAR MinorFunction;
BOOLEAN PendingReturned;
BOOLEAN PostRequest;
PDEVICE_OBJECT RealDevice;
PIRP CurrentIrp;
PIO_STACK_LOCATION CurrentIrpSp;
PMRX_FCB pFcb;
PMRX_FOBX pFobx;
PMRX_SRV_OPEN pRelevantSrvOpen;
PNON_PAGED_FCB NonPagedFcb;
PRDBSS_DEVICE_OBJECT RxDeviceObject;
PETHREAD OriginalThread;
PETHREAD LastExecutionThread;
volatile PVOID LockManagerContext;
PVOID RdbssDbgExtension;
RX_SCAVENGER_ENTRY ScavengerEntry;
ULONG SerialNumber;
ULONG FobxSerialNumber;
ULONG Flags;
BOOLEAN FcbResourceAcquired;
BOOLEAN FcbPagingIoResourceAcquired;
UCHAR MustSucceedDescriptorNumber;
union
{
struct
{
union
{
NTSTATUS StoredStatus;
PVOID StoredStatusAlignment;
};
ULONG_PTR InformationToReturn;
};
IO_STATUS_BLOCK IoStatusBlock;
};
union
{
ULONGLONG ForceLonglongAligmentDummyField;
PVOID MRxContext[MRX_CONTEXT_FIELD_COUNT];
};
PVOID WriteOnlyOpenRetryContext;
PMRX_CALLDOWN MRxCancelRoutine;
PRX_DISPATCH ResumeRoutine;
RX_WORK_QUEUE_ITEM WorkQueueItem;
LIST_ENTRY OverflowListEntry;
KEVENT SyncEvent;
LIST_ENTRY BlockedOperations;
PFAST_MUTEX BlockedOpsMutex;
LIST_ENTRY RxContextSerializationQLinks;
union
{
struct
{
union
{
FS_INFORMATION_CLASS FsInformationClass;
FILE_INFORMATION_CLASS FileInformationClass;
};
PVOID Buffer;
union
{
LONG Length;
LONG LengthRemaining;
};
BOOLEAN ReplaceIfExists;
BOOLEAN AdvanceOnly;
} Info;
struct
{
UNICODE_STRING SuppliedPathName;
NET_ROOT_TYPE NetRootType;
PIO_SECURITY_CONTEXT pSecurityContext;
} PrefixClaim;
};
union
{
struct
{
NT_CREATE_PARAMETERS NtCreateParameters;
ULONG ReturnedCreateInformation;
PWCH CanonicalNameBuffer;
PRX_PREFIX_ENTRY NetNamePrefixEntry;
PMRX_SRV_CALL pSrvCall;
PMRX_NET_ROOT pNetRoot;
PMRX_V_NET_ROOT pVNetRoot;
PVOID EaBuffer;
ULONG EaLength;
ULONG SdLength;
ULONG PipeType;
ULONG PipeReadMode;
ULONG PipeCompletionMode;
USHORT Flags;
NET_ROOT_TYPE Type;
UCHAR RdrFlags;
BOOLEAN FcbAcquired;
BOOLEAN TryForScavengingOnSharingViolation;
BOOLEAN ScavengingAlreadyTried;
BOOLEAN ThisIsATreeConnectOpen;
BOOLEAN TreeConnectOpenDeferred;
UNICODE_STRING TransportName;
UNICODE_STRING UserName;
UNICODE_STRING Password;
UNICODE_STRING UserDomainName;
} Create;
struct
{
ULONG FileIndex;
BOOLEAN RestartScan;
BOOLEAN ReturnSingleEntry;
BOOLEAN IndexSpecified;
BOOLEAN InitialQuery;
} QueryDirectory;
struct
{
PMRX_V_NET_ROOT pVNetRoot;
} NotifyChangeDirectory;
struct
{
PUCHAR UserEaList;
ULONG UserEaListLength;
ULONG UserEaIndex;
BOOLEAN RestartScan;
BOOLEAN ReturnSingleEntry;
BOOLEAN IndexSpecified;
} QueryEa;
struct
{
SECURITY_INFORMATION SecurityInformation;
ULONG Length;
} QuerySecurity;
struct
{
SECURITY_INFORMATION SecurityInformation;
PSECURITY_DESCRIPTOR SecurityDescriptor;
} SetSecurity;
struct
{
ULONG Length;
PSID StartSid;
PFILE_GET_QUOTA_INFORMATION SidList;
ULONG SidListLength;
BOOLEAN RestartScan;
BOOLEAN ReturnSingleEntry;
BOOLEAN IndexSpecified;
} QueryQuota;
struct
{
ULONG Length;
} SetQuota;
struct
{
PV_NET_ROOT VNetRoot;
PSRV_CALL SrvCall;
PNET_ROOT NetRoot;
} DosVolumeFunction;
struct {
ULONG FlagsForLowIo;
LOWIO_CONTEXT LowIoContext;
};
LUID FsdUid;
};
PWCH AlsoCanonicalNameBuffer;
PUNICODE_STRING LoudCompletionString;
#ifdef RDBSS_TRACKER
__volatile LONG AcquireReleaseFcbTrackerX;
__volatile ULONG TrackerHistoryPointer;
RX_FCBTRACKER_CALLINFO TrackerHistory[RDBSS_TRACKER_HISTORY_SIZE];
#endif
#if DBG
ULONG ShadowCritOwner;
#endif
} RX_CONTEXT, *PRX_CONTEXT;
typedef enum
{
RX_CONTEXT_FLAG_FROM_POOL = 0x00000001,
RX_CONTEXT_FLAG_WAIT = 0x00000002,
RX_CONTEXT_FLAG_WRITE_THROUGH = 0x00000004,
RX_CONTEXT_FLAG_FLOPPY = 0x00000008,
RX_CONTEXT_FLAG_RECURSIVE_CALL = 0x00000010,
RX_CONTEXT_FLAG_THIS_DEVICE_TOP_LEVEL = 0x00000020,
RX_CONTEXT_FLAG_DEFERRED_WRITE = 0x00000040,
RX_CONTEXT_FLAG_VERIFY_READ = 0x00000080,
RX_CONTEXT_FLAG_STACK_IO_CONTEZT = 0x00000100,
RX_CONTEXT_FLAG_IN_FSP = 0x00000200,
RX_CONTEXT_FLAG_CREATE_MAILSLOT = 0x00000400,
RX_CONTEXT_FLAG_MAILSLOT_REPARSE = 0x00000800,
RX_CONTEXT_FLAG_ASYNC_OPERATION = 0x00001000,
RX_CONTEXT_FLAG_NO_COMPLETE_FROM_FSP = 0x00002000,
RX_CONTEXT_FLAG_POST_ON_STABLE_CONDITION = 0x00004000,
RX_CONTEXT_FLAG_FSP_DELAYED_OVERFLOW_QUEUE = 0x00008000,
RX_CONTEXT_FLAG_FSP_CRITICAL_OVERFLOW_QUEUE = 0x00010000,
RX_CONTEXT_FLAG_MINIRDR_INVOKED = 0x00020000,
RX_CONTEXT_FLAG_WAITING_FOR_RESOURCE = 0x00040000,
RX_CONTEXT_FLAG_CANCELLED = 0x00080000,
RX_CONTEXT_FLAG_SYNC_EVENT_WAITERS = 0x00100000,
RX_CONTEXT_FLAG_NO_PREPOSTING_NEEDED = 0x00200000,
RX_CONTEXT_FLAG_BYPASS_VALIDOP_CHECK = 0x00400000,
RX_CONTEXT_FLAG_BLOCKED_PIPE_RESUME = 0x00800000,
RX_CONTEXT_FLAG_IN_SERIALIZATION_QUEUE = 0x01000000,
RX_CONTEXT_FLAG_NO_EXCEPTION_BREAKPOINT = 0x02000000,
RX_CONTEXT_FLAG_NEEDRECONNECT = 0x04000000,
RX_CONTEXT_FLAG_MUST_SUCCEED = 0x08000000,
RX_CONTEXT_FLAG_MUST_SUCCEED_NONBLOCKING = 0x10000000,
RX_CONTEXT_FLAG_MUST_SUCCEED_ALLOCATED = 0x20000000,
RX_CONTEXT_FLAG_MINIRDR_INITIATED = 0x80000000,
} RX_CONTEXT_FLAGS;
typedef enum
{
RX_CONTEXT_CREATE_FLAG_UNC_NAME = 0x1,
RX_CONTEXT_CREATE_FLAG_STRIPPED_TRAILING_BACKSLASH = 0x2,
RX_CONTEXT_CREATE_FLAG_ADDEDBACKSLASH = 0x4,
RX_CONTEXT_CREATE_FLAG_REPARSE = 0x8,
RX_CONTEXT_CREATE_FLAG_SPECIAL_PATH = 0x10,
} RX_CONTEXT_CREATE_FLAGS;
typedef enum {
RXCONTEXT_FLAG4LOWIO_PIPE_OPERATION = 0x1,
RXCONTEXT_FLAG4LOWIO_PIPE_SYNC_OPERATION = 0x2,
RXCONTEXT_FLAG4LOWIO_READAHEAD = 0x4,
RXCONTEXT_FLAG4LOWIO_THIS_READ_ENLARGED = 0x8,
RXCONTEXT_FLAG4LOWIO_THIS_IO_BUFFERED = 0x10,
RXCONTEXT_FLAG4LOWIO_LOCK_FCB_RESOURCE_HELD = 0x20,
RXCONTEXT_FLAG4LOWIO_LOCK_WAS_QUEUED_IN_LOCKMANAGER = 0x40,
RXCONTEXT_FLAG4LOWIO_THIS_IO_FAST = 0x80,
RXCONTEXT_FLAG4LOWIO_LOCK_OPERATION_COMPLETED = 0x100,
RXCONTEXT_FLAG4LOWIO_LOCK_BUFFERED_ON_ENTRY = 0x200
} RX_CONTEXT_LOWIO_FLAGS;
#if DBG
VOID
__RxItsTheSameContext(
_In_ PRX_CONTEXT RxContext,
_In_ ULONG CapturedRxContextSerialNumber,
_In_ ULONG Line,
_In_ PCSTR File);
#define RxItsTheSameContext() { __RxItsTheSameContext(RxContext, CapturedRxContextSerialNumber, __LINE__, __FILE__); }
#else
#define RxItsTheSameContext() { NOTHING; }
#endif
extern NPAGED_LOOKASIDE_LIST RxContextLookasideList;
#define MINIRDR_CALL_THROUGH(STATUS, DISPATCH, FUNC, ARGLIST) \
{ \
ASSERT(DISPATCH); \
ASSERT(NodeType(DISPATCH) == RDBSS_NTC_MINIRDR_DISPATCH); \
if (DISPATCH->FUNC == NULL) \
{ \
STATUS = STATUS_NOT_IMPLEMENTED; \
} \
else \
{ \
STATUS = DISPATCH->FUNC ARGLIST; \
} \
}
#define MINIRDR_CALL(STATUS, CONTEXT, DISPATCH, FUNC, ARGLIST) \
{ \
ASSERT(DISPATCH); \
ASSERT(NodeType(DISPATCH) == RDBSS_NTC_MINIRDR_DISPATCH); \
if (DISPATCH->FUNC == NULL) \
{ \
STATUS = STATUS_NOT_IMPLEMENTED; \
} \
else \
{ \
if (!BooleanFlagOn((CONTEXT)->Flags, RX_CONTEXT_FLAG_CANCELLED)) \
{ \
RtlZeroMemory(&((CONTEXT)->MRxContext[0]), \
sizeof((CONTEXT)->MRxContext)); \
STATUS = DISPATCH->FUNC ARGLIST; \
} \
else \
{ \
STATUS = STATUS_CANCELLED; \
} \
} \
}
#define RxWaitSync(RxContext) \
(RxContext)->Flags |= RX_CONTEXT_FLAG_SYNC_EVENT_WAITERS; \
KeWaitForSingleObject(&(RxContext)->SyncEvent, \
Executive, KernelMode, FALSE, NULL)
#define RxSignalSynchronousWaiter(RxContext) \
(RxContext)->Flags &= ~RX_CONTEXT_FLAG_SYNC_EVENT_WAITERS; \
KeSetEvent(&(RxContext)->SyncEvent, 0, FALSE)
#define RxInsertContextInSerializationQueue(SerializationQueue, RxContext) \
(RxContext)->Flags |= RX_CONTEXT_FLAG_IN_SERIALIZATION_QUEUE; \
InsertTailList(SerializationQueue, &((RxContext)->RxContextSerializationQLinks))
FORCEINLINE
PRX_CONTEXT
RxRemoveFirstContextFromSerializationQueue(
PLIST_ENTRY SerializationQueue)
{
if (IsListEmpty(SerializationQueue))
{
return NULL;
}
else
{
PRX_CONTEXT Context = CONTAINING_RECORD(SerializationQueue->Flink,
RX_CONTEXT,
RxContextSerializationQLinks);
RemoveEntryList(SerializationQueue->Flink);
Context->RxContextSerializationQLinks.Flink = NULL;
Context->RxContextSerializationQLinks.Blink = NULL;
return Context;
}
}
#define RxTransferList(Destination, Source) \
if (IsListEmpty((Source))) \
InitializeListHead((Destination)); \
else \
{ \
*(Destination) = *(Source); \
(Destination)->Flink->Blink = (Destination); \
(Destination)->Blink->Flink = (Destination); \
InitializeListHead((Source)); \
}
VOID
NTAPI
RxInitializeContext(
_In_ PIRP Irp,
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject,
_In_ ULONG InitialContextFlags,
_Inout_ PRX_CONTEXT RxContext);
PRX_CONTEXT
NTAPI
RxCreateRxContext(
_In_ PIRP Irp,
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject,
_In_ ULONG InitialContextFlags);
VOID
NTAPI
RxPrepareContextForReuse(
_Inout_ PRX_CONTEXT RxContext);
VOID
NTAPI
RxDereferenceAndDeleteRxContext_Real(
_In_ PRX_CONTEXT RxContext);
#if DBG
#define RxDereferenceAndDeleteRxContext(RXCONTEXT) \
{ \
RxDereferenceAndDeleteRxContext_Real((RXCONTEXT)); \
(RXCONTEXT) = NULL; \
}
#else
#define RxDereferenceAndDeleteRxContext(RXCONTEXT) \
{ \
RxDereferenceAndDeleteRxContext_Real((RXCONTEXT)); \
}
#endif
VOID
NTAPI
RxResumeBlockedOperations_Serially(
_Inout_ PRX_CONTEXT RxContext,
_Inout_ PLIST_ENTRY BlockingIoQ);
#endif

View File

@ -0,0 +1,20 @@
#ifndef _RDBSSDATA_
#define _RDBSSDATA_
extern RX_DISPATCHER RxDispatcher;
extern RX_WORK_QUEUE_DISPATCHER RxDispatcherWorkQueues;
extern KMUTEX RxSerializationMutex;
#define RxAcquireSerializationMutex() KeWaitForSingleObject(&RxSerializationMutex, Executive, KernelMode, FALSE, NULL)
#define RxReleaseSerializationMutex() KeReleaseMutex(&RxSerializationMutex, FALSE)
extern PRDBSS_DEVICE_OBJECT RxFileSystemDeviceObject;
#if DBG
extern ULONG RxFsdEntryCount;
#endif
extern LIST_ENTRY RxSrvCalldownList;
extern LIST_ENTRY RxActiveContexts;
#endif

View File

@ -0,0 +1,36 @@
#ifndef _RDBSSLOG_INCLUDED_
#define _RDBSSLOG_INCLUDED_
VOID
NTAPI
RxDebugControlCommand(
_In_ PSTR ControlString);
NTSTATUS
NTAPI
RxInitializeLog(
VOID);
#ifdef RDBSSLOG
#if DBG
#define RxLog(Args) _RxLog##Args
#define RxLogRetail(Args) _RxLog##Args
#else
#define RxLogRetail(Args) _RxLog##Args
#define RxLog(Args) { }
#endif
#define RxPauseLog() _RxPauseLog()
#define RxResumeLog() _RxResumeLog()
#else
#define RxLog(Args) { ;}
#define RxLogRetail(Args) { ;}
#define RxPauseLog() { ; }
#define RxResumeLog() { ; }
#endif
#endif

View File

@ -0,0 +1,3 @@
#ifndef NO_RXOVRIDE_GLOBAL
#include <struchdr.h>
#endif

View File

@ -0,0 +1,13 @@
#ifndef _RXPOOLTG_H_
#define _RXPOOLTG_H_
#define RX_SRVCALL_POOLTAG ('cSxR')
#define RX_NETROOT_POOLTAG ('rNxR')
#define RX_V_NETROOT_POOLTAG ('nVxR')
#define RX_FCB_POOLTAG ('cFxR')
#define RX_NONPAGEDFCB_POOLTAG ('fNxR')
#define RX_WORKQ_POOLTAG ('qWxR')
#define RX_MISC_POOLTAG ('sMxR')
#define RX_IRPC_POOLTAG ('rIxR')
#endif

View File

@ -0,0 +1,679 @@
#ifndef _RDBSSPROCS_
#define _RDBSSPROCS_
#include "backpack.h"
#include "rxlog.h"
#include "rxtimer.h"
#include "rxstruc.h"
extern PVOID RxNull;
#define RxLogFailure(DO, Originator, Event, Status) \
RxLogEventDirect(DO, Originator, Event, Status, __LINE__)
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
RxPrefixClaim(
_In_ PRX_CONTEXT RxContext);
VOID
RxpPrepareCreateContextForReuse(
_In_ PRX_CONTEXT RxContext);
NTSTATUS
RxLowIoCompletionTail(
_In_ PRX_CONTEXT RxContext);
LUID
RxGetUid(
_In_ PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext);
ULONG
RxGetSessionId(
_In_ PIO_STACK_LOCATION IrpSp);
#if (_WIN32_WINNT >= 0x0600)
NTSTATUS
RxFindOrCreateConnections(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ PUNICODE_STRING CanonicalName,
_In_ NET_ROOT_TYPE NetRootType,
_In_ BOOLEAN TreeConnect,
_Out_ PUNICODE_STRING LocalNetRootName,
_Out_ PUNICODE_STRING FilePathName,
_Inout_ PLOCK_HOLDING_STATE LockState,
_In_ PRX_CONNECTION_ID RxConnectionId);
#else
NTSTATUS
RxFindOrCreateConnections(
_In_ PRX_CONTEXT RxContext,
_In_ PUNICODE_STRING CanonicalName,
_In_ NET_ROOT_TYPE NetRootType,
_Out_ PUNICODE_STRING LocalNetRootName,
_Out_ PUNICODE_STRING FilePathName,
_Inout_ PLOCK_HOLDING_STATE LockState,
_In_ PRX_CONNECTION_ID RxConnectionId);
#endif
#if (_WIN32_WINNT >= 0x0600)
NTSTATUS
RxCompleteMdl(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp);
#else
NTSTATUS
NTAPI
RxCompleteMdl(
_In_ PRX_CONTEXT RxContext);
#endif
#if (_WIN32_WINNT >= 0x0600)
VOID
RxLockUserBuffer(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ LOCK_OPERATION Operation,
_In_ ULONG BufferLength);
PVOID
RxMapSystemBuffer(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp);
#else
VOID
RxLockUserBuffer(
_In_ PRX_CONTEXT RxContext,
_In_ LOCK_OPERATION Operation,
_In_ ULONG BufferLength);
PVOID
RxMapSystemBuffer(
_In_ PRX_CONTEXT RxContext);
#endif
#define FCB_MODE_EXCLUSIVE 1
#define FCB_MODE_SHARED 2
#define FCB_MODE_SHARED_WAIT_FOR_EXCLUSIVE 3
#define FCB_MODE_SHARED_STARVE_EXCLUSIVE 4
NTSTATUS
__RxAcquireFcb(
_Inout_ PFCB Fcb,
_Inout_opt_ PRX_CONTEXT RxContext,
_In_ ULONG Mode
#ifdef RDBSS_TRACKER
,
_In_ ULONG LineNumber,
_In_ PCSTR FileName,
_In_ ULONG SerialNumber
#endif
);
#ifdef RDBSS_TRACKER
#define RxAcquireExclusiveFcb(R, F) __RxAcquireFcb((F), (R), FCB_MODE_EXCLUSIVE, __LINE__, __FILE__, 0)
#else
#define RxAcquireExclusiveFcb(R, F) __RxAcquireFcb((F), (R), FCB_MODE_EXCLUSIVE)
#endif
#define RX_GET_MRX_FCB(F) ((PMRX_FCB)((F)))
#ifdef RDBSS_TRACKER
#define RxAcquireSharedFcb(R, F) __RxAcquireFcb((F), (R), FCB_MODE_SHARED, __LINE__, __FILE__, 0)
#else
#define RxAcquireSharedFcb(R, F) __RxAcquireFcb((F), (R), FCB_MODE_SHARED)
#endif
#ifdef RDBSS_TRACKER
#define RxAcquireSharedFcbWaitForEx(R, F) __RxAcquireFcb((F),(R), FCB_MODE_SHARED_WAIT_FOR_EXCLUSIVE, __LINE__, __FILE__,0)
#else
#define RxAcquireSharedFcbWaitForEx(R, F) __RxAcquireFcb((F), (R), FCB_MODE_SHARED_WAIT_FOR_EXCLUSIVE)
#endif
VOID
__RxReleaseFcb(
_Inout_opt_ PRX_CONTEXT RxContext,
_Inout_ PMRX_FCB MrxFcb
#ifdef RDBSS_TRACKER
,
_In_ ULONG LineNumber,
_In_ PCSTR FileName,
_In_ ULONG SerialNumber
#endif
);
#ifdef RDBSS_TRACKER
#define RxReleaseFcb(R, F) __RxReleaseFcb((R), RX_GET_MRX_FCB(F), __LINE__, __FILE__, 0)
#else
#define RxReleaseFcb(R, F) __RxReleaseFcb((R), RX_GET_MRX_FCB(F))
#endif
VOID
__RxReleaseFcbForThread(
_Inout_opt_ PRX_CONTEXT RxContext,
_Inout_ PMRX_FCB MrxFcb,
_In_ ERESOURCE_THREAD ResourceThreadId
#ifdef RDBSS_TRACKER
,
_In_ ULONG LineNumber,
_In_ PCSTR FileName,
_In_ ULONG SerialNumber
#endif
);
#ifdef RDBSS_TRACKER
#define RxReleaseFcbForThread(R, F, T) __RxReleaseFcbForThread((R), RX_GET_MRX_FCB(F), (T), __LINE__, __FILE__, 0)
#else
#define RxReleaseFcbForThread(R, F, T) __RxReleaseFcbForThread((R), RX_GET_MRX_FCB(F), (T))
#endif
#ifdef RDBSS_TRACKER
VOID
RxTrackerUpdateHistory(
_Inout_opt_ PRX_CONTEXT RxContext,
_Inout_ PMRX_FCB MrxFcb,
_In_ ULONG Operation,
_In_ ULONG LineNumber,
_In_ PCSTR FileName,
_In_ ULONG SerialNumber);
#else
#define RxTrackerUpdateHistory(R, F, O, L, F, S) { NOTHING; }
#endif
VOID
RxTrackPagingIoResource(
_Inout_ PVOID Instance,
_In_ ULONG Type,
_In_ ULONG Line,
_In_ PCSTR File);
#define RxIsFcbAcquiredShared(Fcb) ExIsResourceAcquiredSharedLite((Fcb)->Header.Resource)
#define RxIsFcbAcquiredExclusive(Fcb) ExIsResourceAcquiredExclusiveLite((Fcb)->Header.Resource)
#define RxIsFcbAcquired(Fcb) (ExIsResourceAcquiredSharedLite((Fcb)->Header.Resource) || \
ExIsResourceAcquiredExclusiveLite((Fcb)->Header.Resource))
#define RxAcquirePagingIoResource(RxContext, Fcb) \
ExAcquireResourceExclusiveLite((Fcb)->Header.PagingIoResource, TRUE); \
if (RxContext != NULL) \
{ \
(RxContext)->FcbPagingIoResourceAcquired = TRUE; \
} \
RxTrackPagingIoResource(Fcb, 1, __LINE__, __FILE__)
#define RxAcquirePagingIoResourceShared(RxContext, Fcb, Flag) \
ExAcquireResourceSharedLite((Fcb)->Header.PagingIoResource, Flag); \
if (AcquiredFile) \
{ \
if (RxContext != NULL) \
{ \
((PRX_CONTEXT)RxContext)->FcbPagingIoResourceAcquired = TRUE; \
} \
RxTrackPagingIoResource(Fcb, 2, __LINE__, __FILE__); \
}
#define RxReleasePagingIoResource(RxContext, Fcb) \
RxTrackPagingIoResource(Fcb, 3, __LINE__, __FILE__); \
if (RxContext != NULL) \
{ \
(RxContext)->FcbPagingIoResourceAcquired = FALSE; \
} \
ExReleaseResourceLite((Fcb)->Header.PagingIoResource)
#define RxReleasePagingIoResourceForThread(RxContext, Fcb, Thread) \
RxTrackPagingIoResource(Fcb, 3, __LINE__, __FILE__); \
if (RxContext != NULL) \
{ \
(RxContext)->FcbPagingIoResourceAcquired = FALSE; \
} \
ExReleaseResourceForThreadLite((Fcb)->Header.PagingIoResource, (Thread))
BOOLEAN
NTAPI
RxAcquireFcbForLazyWrite(
_In_ PVOID Null,
_In_ BOOLEAN Wait);
VOID
NTAPI
RxReleaseFcbFromLazyWrite(
_In_ PVOID Null);
BOOLEAN
NTAPI
RxAcquireFcbForReadAhead(
_In_ PVOID Null,
_In_ BOOLEAN Wait);
VOID
NTAPI
RxReleaseFcbFromReadAhead(
_In_ PVOID Null);
BOOLEAN
NTAPI
RxNoOpAcquire(
_In_ PVOID Fcb,
_In_ BOOLEAN Wait);
VOID
NTAPI
RxNoOpRelease(
_In_ PVOID Fcb);
#define RxConvertToSharedFcb(R, F) ExConvertExclusiveToSharedLite(RX_GET_MRX_FCB(F)->Header.Resource)
VOID
RxVerifyOperationIsLegal(
_In_ PRX_CONTEXT RxContext);
VOID
RxPrePostIrp(
_In_ PVOID Context,
_In_ PIRP Irp);
VOID
RxAddToWorkque(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp);
NTSTATUS
RxFsdPostRequest(
_In_ PRX_CONTEXT RxContext);
#define QuadAlign(V) (ALIGN_UP(V, ULONGLONG))
VOID
RxCompleteRequest_Real(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ NTSTATUS Status);
NTSTATUS
RxCompleteRequest(
_In_ PRX_CONTEXT pContext,
_In_ NTSTATUS Status);
#if (_WIN32_WINNT >= 0x600)
NTSTATUS
RxConstructSrvCall(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ PSRV_CALL SrvCall,
_Out_ PLOCK_HOLDING_STATE LockHoldingState);
#else
NTSTATUS
RxConstructSrvCall(
_In_ PRX_CONTEXT RxContext,
_In_ PSRV_CALL SrvCall,
_Out_ PLOCK_HOLDING_STATE LockHoldingState);
#endif
#define RxCompleteAsynchronousRequest(C, S) RxCompleteRequest(C, S)
NTSTATUS
RxConstructNetRoot(
_In_ PRX_CONTEXT RxContext,
_In_ PSRV_CALL SrvCall,
_In_ PNET_ROOT NetRoot,
_In_ PV_NET_ROOT VirtualNetRoot,
_Out_ PLOCK_HOLDING_STATE LockHoldingState);
#if (_WIN32_WINNT >= 0x0600)
NTSTATUS
RxConstructVirtualNetRoot(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ PUNICODE_STRING CanonicalName,
_In_ NET_ROOT_TYPE NetRootType,
_In_ BOOLEAN TreeConnect,
_Out_ PV_NET_ROOT *VirtualNetRootPointer,
_Out_ PLOCK_HOLDING_STATE LockHoldingState,
_Out_ PRX_CONNECTION_ID RxConnectionId);
NTSTATUS
RxFindOrConstructVirtualNetRoot(
_In_ PRX_CONTEXT RxContext,
_In_ PIRP Irp,
_In_ PUNICODE_STRING CanonicalName,
_In_ NET_ROOT_TYPE NetRootType,
_In_ PUNICODE_STRING RemainingName);
#else
NTSTATUS
RxConstructVirtualNetRoot(
_In_ PRX_CONTEXT RxContext,
_In_ PUNICODE_STRING CanonicalName,
_In_ NET_ROOT_TYPE NetRootType,
_Out_ PV_NET_ROOT *VirtualNetRootPointer,
_Out_ PLOCK_HOLDING_STATE LockHoldingState,
_Out_ PRX_CONNECTION_ID RxConnectionId);
NTSTATUS
RxFindOrConstructVirtualNetRoot(
_In_ PRX_CONTEXT RxContext,
_In_ PUNICODE_STRING CanonicalName,
_In_ NET_ROOT_TYPE NetRootType,
_In_ PUNICODE_STRING RemainingName);
#endif
NTSTATUS
NTAPI
RxChangeBufferingState(
PSRV_OPEN SrvOpen,
PVOID Context,
BOOLEAN ComputeNewState);
VOID
NTAPI
RxIndicateChangeOfBufferingStateForSrvOpen(
PMRX_SRV_CALL SrvCall,
PMRX_SRV_OPEN SrvOpen,
PVOID SrvOpenKey,
PVOID Context);
NTSTATUS
NTAPI
RxPrepareToReparseSymbolicLink(
PRX_CONTEXT RxContext,
BOOLEAN SymbolicLinkEmbeddedInOldPath,
PUNICODE_STRING NewPath,
BOOLEAN NewPathIsAbsolute,
PBOOLEAN ReparseRequired);
VOID
RxReference(
_Inout_ PVOID Instance);
VOID
RxDereference(
_Inout_ PVOID Instance,
_In_ LOCK_HOLDING_STATE LockHoldingState);
VOID
RxWaitForStableCondition(
_In_ PRX_BLOCK_CONDITION Condition,
_Inout_ PLIST_ENTRY TransitionWaitList,
_Inout_ PRX_CONTEXT RxContext,
_Out_opt_ NTSTATUS *AsyncStatus);
VOID
RxUpdateCondition(
_In_ RX_BLOCK_CONDITION NewConditionValue,
_Out_ PRX_BLOCK_CONDITION Condition,
_In_ OUT PLIST_ENTRY TransitionWaitList);
#if (_WIN32_WINNT >= 0x0600)
NTSTATUS
RxCloseAssociatedSrvOpen(
_In_opt_ PRX_CONTEXT RxContext,
_In_ PFOBX Fobx);
#else
NTSTATUS
RxCloseAssociatedSrvOpen(
_In_ PFOBX Fobx,
_In_opt_ PRX_CONTEXT RxContext);
#endif
NTSTATUS
NTAPI
RxFinalizeConnection(
_Inout_ PNET_ROOT NetRoot,
_Inout_opt_ PV_NET_ROOT VNetRoot,
_In_ LOGICAL ForceFilesClosed);
#if DBG
VOID
RxDumpWantedAccess(
_In_ PSZ where1,
_In_ PSZ where2,
_In_ PSZ wherelogtag,
_In_ ACCESS_MASK DesiredAccess,
_In_ ULONG DesiredShareAccess);
VOID
RxDumpCurrentAccess(
_In_ PSZ where1,
_In_ PSZ where2,
_In_ PSZ wherelogtag,
_In_ PSHARE_ACCESS ShareAccess);
#else
#define RxDumpWantedAccess(w1,w2,wlt,DA,DSA) {NOTHING;}
#define RxDumpCurrentAccess(w1,w2,wlt,SA) {NOTHING;}
#endif
NTSTATUS
RxCheckShareAccessPerSrvOpens(
_In_ PFCB Fcb,
_In_ ACCESS_MASK DesiredAccess,
_In_ ULONG DesiredShareAccess);
VOID
RxUpdateShareAccessPerSrvOpens(
_In_ PSRV_OPEN SrvOpen);
#if DBG
NTSTATUS
RxCheckShareAccess(
_In_ ACCESS_MASK DesiredAccess,
_In_ ULONG DesiredShareAccess,
_Inout_ PFILE_OBJECT FileObject,
_Inout_ PSHARE_ACCESS ShareAccess,
_In_ BOOLEAN Update,
_In_ PSZ where,
_In_ PSZ wherelogtag);
VOID
RxRemoveShareAccess(
_Inout_ PFILE_OBJECT FileObject,
_Inout_ PSHARE_ACCESS ShareAccess,
_In_ PSZ where,
_In_ PSZ wherelogtag);
VOID
RxSetShareAccess(
_In_ ACCESS_MASK DesiredAccess,
_In_ ULONG DesiredShareAccess,
_Inout_ PFILE_OBJECT FileObject,
_Out_ PSHARE_ACCESS ShareAccess,
_In_ PSZ where,
_In_ PSZ wherelogtag);
VOID
RxUpdateShareAccess(
_Inout_ PFILE_OBJECT FileObject,
_Inout_ PSHARE_ACCESS ShareAccess,
_In_ PSZ where,
_In_ PSZ wherelogtag);
#else
#define RxCheckShareAccess(a1, a2, a3, a4, a5, a6, a7) IoCheckShareAccess(a1, a2, a3, a4, a5)
#define RxRemoveShareAccess(a1, a2, a3, a4) IoRemoveShareAccess(a1, a2)
#define RxSetShareAccess(a1, a2, a3, a4, a5, a6) IoSetShareAccess(a1, a2, a3, a4)
#define RxUpdateShareAccess(a1, a2, a3, a4) IoUpdateShareAccess(a1, a2)
#endif
NTSTATUS
NTAPI
RxDriverEntry(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath);
VOID
NTAPI
RxUnload(
_In_ PDRIVER_OBJECT DriverObject);
VOID
RxInitializeMinirdrDispatchTable(
_In_ PDRIVER_OBJECT DriverObject);
ULONG
RxGetNetworkProviderPriority(
_In_ PUNICODE_STRING DeviceName);
ULONG
RxTableComputePathHashValue(
_In_ PUNICODE_STRING Name);
VOID
RxExtractServerName(
_In_ PUNICODE_STRING FilePathName,
_Out_ PUNICODE_STRING SrvCallName,
_Out_ PUNICODE_STRING RestOfName);
VOID
NTAPI
RxCreateNetRootCallBack(
_In_ PMRX_CREATENETROOT_CONTEXT CreateNetRootContext);
PVOID
RxAllocateObject(
_In_ NODE_TYPE_CODE NodeType,
_In_opt_ PMINIRDR_DISPATCH MRxDispatch,
_In_ ULONG NameLength);
VOID
RxFreeObject(
_In_ PVOID pObject);
NTSTATUS
RxInitializeSrvCallParameters(
_In_ PRX_CONTEXT RxContext,
_Inout_ PSRV_CALL SrvCall);
VOID
RxAddVirtualNetRootToNetRoot(
_In_ PNET_ROOT NetRoot,
_In_ PV_NET_ROOT VNetRoot);
PVOID
RxAllocateFcbObject(
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject,
_In_ NODE_TYPE_CODE NodeType,
_In_ POOL_TYPE PoolType,
_In_ ULONG NameSize,
_In_opt_ PVOID AlreadyAllocatedObject);
VOID
RxFreeFcbObject(
_In_ PVOID Object);
BOOLEAN
RxFinalizeNetFcb(
_Out_ PFCB ThisFcb,
_In_ BOOLEAN RecursiveFinalize,
_In_ BOOLEAN ForceFinalize,
_In_ LONG ReferenceCount);
BOOLEAN
RxIsThisACscAgentOpen(
_In_ PRX_CONTEXT RxContext);
VOID
NTAPI
RxCheckFcbStructuresForAlignment(
VOID);
NTSTATUS
RxInitializeWorkQueueDispatcher(
_In_ PRX_WORK_QUEUE_DISPATCHER Dispatcher);
VOID
RxInitializeWorkQueue(
_In_ PRX_WORK_QUEUE WorkQueue,
_In_ WORK_QUEUE_TYPE WorkQueueType,
_In_ ULONG MaximumNumberOfWorkerThreads,
_In_ ULONG MinimumNumberOfWorkerThreads);
NTSTATUS
RxSpinUpWorkerThread(
_In_ PRX_WORK_QUEUE WorkQueue,
_In_ PRX_WORKERTHREAD_ROUTINE Routine,
_In_ PVOID Parameter);
VOID
RxSpinUpWorkerThreads(
_In_ PRX_WORK_QUEUE WorkQueue);
VOID
NTAPI
RxSpinUpRequestsDispatcher(
_In_ PVOID Dispatcher);
VOID
RxpWorkerThreadDispatcher(
_In_ PRX_WORK_QUEUE WorkQueue,
_In_ PLARGE_INTEGER WaitInterval);
VOID
NTAPI
RxBootstrapWorkerThreadDispatcher(
_In_ PVOID WorkQueue);
PRX_PREFIX_ENTRY
RxTableLookupName_ExactLengthMatch(
_In_ PRX_PREFIX_TABLE ThisTable,
_In_ PUNICODE_STRING Name,
_In_ ULONG HashValue,
_In_opt_ PRX_CONNECTION_ID RxConnectionId);
PVOID
RxTableLookupName(
_In_ PRX_PREFIX_TABLE ThisTable,
_In_ PUNICODE_STRING Name,
_Out_ PUNICODE_STRING RemainingName,
_In_opt_ PRX_CONNECTION_ID RxConnectionId);
VOID
RxOrphanThisFcb(
_In_ PFCB Fcb);
#define RxEqualConnectionId(C1, C2) RtlEqualMemory(C1, C2, sizeof(RX_CONNECTION_ID))
NTSTATUS
NTAPI
RxLockOperationCompletion(
_In_ PVOID Context,
_In_ PIRP Irp);
VOID
NTAPI
RxUnlockOperation(
_In_ PVOID Context,
_In_ PFILE_LOCK_INFO LockInfo);
#if (_WIN32_WINNT >= 0x0600)
NTSTATUS
RxPostStackOverflowRead(
_In_ PRX_CONTEXT RxContext,
_In_ PFCB Fcb);
#else
NTSTATUS
RxPostStackOverflowRead(
_In_ PRX_CONTEXT RxContext);
#endif
VOID
NTAPI
RxCancelRoutine(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp);
#endif

View File

@ -0,0 +1,151 @@
#ifndef _RDBSSSTRUC_
#define _RDBSSSTRUC_
#include "prefix.h"
#include "lowio.h"
#include "scavengr.h"
#include "rxcontx.h"
#include "fcb.h"
extern RX_SPIN_LOCK RxStrucSupSpinLock;
typedef struct _RDBSS_EXPORTS
{
PRX_SPIN_LOCK pRxStrucSupSpinLock;
PLONG pRxDebugTraceIndent;
} RDBSS_EXPORTS, *PRDBSS_EXPORTS;
typedef enum _LOCK_HOLDING_STATE
{
LHS_LockNotHeld,
LHS_SharedLockHeld,
LHS_ExclusiveLockHeld
} LOCK_HOLDING_STATE, *PLOCK_HOLDING_STATE;
typedef struct _RDBSS_DATA
{
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
PDRIVER_OBJECT DriverObject;
volatile LONG NumberOfMinirdrsStarted;
FAST_MUTEX MinirdrRegistrationMutex;
LIST_ENTRY RegisteredMiniRdrs;
LONG NumberOfMinirdrsRegistered;
PEPROCESS OurProcess;
CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
#if (_WIN32_WINNT < 0x0600)
CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks;
#endif
ERESOURCE Resource;
} RDBSS_DATA;
typedef RDBSS_DATA *PRDBSS_DATA;
extern RDBSS_DATA RxData;
PEPROCESS
NTAPI
RxGetRDBSSProcess(
VOID);
typedef enum _RX_RDBSS_STATE_
{
RDBSS_STARTABLE = 0,
RDBSS_STARTED,
RDBSS_STOP_IN_PROGRESS
} RX_RDBSS_STATE, *PRX_RDBSS_STATE;
typedef struct _RDBSS_STARTSTOP_CONTEXT_
{
RX_RDBSS_STATE State;
ULONG Version;
PRX_CONTEXT pStopContext;
} RDBSS_STARTSTOP_CONTEXT, *PRDBSS_STARTSTOP_CONTEXT;
typedef struct _RX_DISPATCHER_CONTEXT_
{
volatile LONG NumberOfWorkerThreads;
volatile PKEVENT pTearDownEvent;
} RX_DISPATCHER_CONTEXT, *PRX_DISPATCHER_CONTEXT;
#define RxSetRdbssState(RxDeviceObject, NewState) \
{ \
KIRQL OldIrql; \
KeAcquireSpinLock(&RxStrucSupSpinLock, &OldIrql); \
RxDeviceObject->StartStopContext.State = (NewState); \
KeReleaseSpinLock(&RxStrucSupSpinLock, OldIrql); \
}
#define RxGetRdbssState(RxDeviceObject) RxDeviceObject->StartStopContext.State
typedef struct _RDBSS_DEVICE_OBJECT {
union
{
DEVICE_OBJECT DeviceObject;
DEVICE_OBJECT;
};
ULONG RegistrationControls;
PRDBSS_EXPORTS RdbssExports;
PDEVICE_OBJECT RDBSSDeviceObject;
PMINIRDR_DISPATCH Dispatch;
UNICODE_STRING DeviceName;
ULONG NetworkProviderPriority;
HANDLE MupHandle;
BOOLEAN RegisterUncProvider;
BOOLEAN RegisterMailSlotProvider;
BOOLEAN RegisteredAsFileSystem;
BOOLEAN Unused;
LIST_ENTRY MiniRdrListLinks;
volatile ULONG NumberOfActiveFcbs;
volatile ULONG NumberOfActiveContexts;
struct
{
LARGE_INTEGER PagingReadBytesRequested;
LARGE_INTEGER NonPagingReadBytesRequested;
LARGE_INTEGER CacheReadBytesRequested;
LARGE_INTEGER FastReadBytesRequested;
LARGE_INTEGER NetworkReadBytesRequested;
volatile ULONG ReadOperations;
ULONG FastReadOperations;
volatile ULONG RandomReadOperations;
LARGE_INTEGER PagingWriteBytesRequested;
LARGE_INTEGER NonPagingWriteBytesRequested;
LARGE_INTEGER CacheWriteBytesRequested;
LARGE_INTEGER FastWriteBytesRequested;
LARGE_INTEGER NetworkWriteBytesRequested;
volatile ULONG WriteOperations;
ULONG FastWriteOperations;
volatile ULONG RandomWriteOperations;
};
volatile LONG PostedRequestCount[RxMaximumWorkQueue];
LONG OverflowQueueCount[RxMaximumWorkQueue];
LIST_ENTRY OverflowQueue[RxMaximumWorkQueue];
RX_SPIN_LOCK OverflowQueueSpinLock;
LONG AsynchronousRequestsPending;
PKEVENT pAsynchronousRequestsCompletionEvent;
RDBSS_STARTSTOP_CONTEXT StartStopContext;
RX_DISPATCHER_CONTEXT DispatcherContext;
PRX_PREFIX_TABLE pRxNetNameTable;
RX_PREFIX_TABLE RxNetNameTableInDeviceObject;
PRDBSS_SCAVENGER pRdbssScavenger;
RDBSS_SCAVENGER RdbssScavengerInDeviceObject;
} RDBSS_DEVICE_OBJECT, *PRDBSS_DEVICE_OBJECT;
extern INLINE
VOID
NTAPI
RxUnregisterMinirdr(
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject)
{
PDEVICE_OBJECT RDBSSDeviceObject;
RDBSSDeviceObject = RxDeviceObject->RDBSSDeviceObject;
RxpUnregisterMinirdr(RxDeviceObject);
if (RDBSSDeviceObject != NULL)
{
ObDereferenceObject(RDBSSDeviceObject);
}
}
#endif

View File

@ -0,0 +1,16 @@
#ifndef _RXTIMER_H_
#define _RXTIMER_H_
typedef struct _RX_WORK_ITEM_
{
RX_WORK_QUEUE_ITEM WorkQueueItem;
ULONG LastTick;
ULONG Options;
} RX_WORK_ITEM, *PRX_WORK_ITEM;
NTSTATUS
NTAPI
RxInitializeRxTimer(
VOID);
#endif

View File

@ -0,0 +1,11 @@
#ifndef _RXTYPES_INCL
#define _RXTYPES_INCL
#include "nodetype.h"
#define RxMaximumWorkQueue 3
typedef KSPIN_LOCK RX_SPIN_LOCK;
typedef PKSPIN_LOCK PRX_SPIN_LOCK;
#endif

View File

@ -0,0 +1,100 @@
#ifndef _RXWORKQ_H_
#define _RXWORKQ_H_
typedef
VOID
(NTAPI *PRX_WORKERTHREAD_ROUTINE) (
_In_ PVOID Context);
typedef struct _RX_WORK_QUEUE_ITEM_
{
WORK_QUEUE_ITEM;
PRDBSS_DEVICE_OBJECT pDeviceObject;
} RX_WORK_QUEUE_ITEM, *PRX_WORK_QUEUE_ITEM;
typedef struct _RX_WORK_DISPATCH_ITEM_
{
RX_WORK_QUEUE_ITEM WorkQueueItem;
PRX_WORKERTHREAD_ROUTINE DispatchRoutine;
PVOID DispatchRoutineParameter;
} RX_WORK_DISPATCH_ITEM, *PRX_WORK_DISPATCH_ITEM;
typedef enum _RX_WORK_QUEUE_STATE_
{
RxWorkQueueActive,
RxWorkQueueInactive,
RxWorkQueueRundownInProgress
} RX_WORK_QUEUE_STATE, *PRX_WORK_QUEUE_STATE;
typedef struct _RX_WORK_QUEUE_RUNDOWN_CONTEXT_
{
KEVENT RundownCompletionEvent;
LONG NumberOfThreadsSpunDown;
PETHREAD *ThreadPointers;
} RX_WORK_QUEUE_RUNDOWN_CONTEXT, *PRX_WORK_QUEUE_RUNDOWN_CONTEXT;
typedef struct _RX_WORK_QUEUE_
{
USHORT State;
BOOLEAN SpinUpRequestPending;
UCHAR Type;
KSPIN_LOCK SpinLock;
PRX_WORK_QUEUE_RUNDOWN_CONTEXT pRundownContext;
__volatile LONG NumberOfWorkItemsDispatched;
__volatile LONG NumberOfWorkItemsToBeDispatched;
LONG CumulativeQueueLength;
LONG NumberOfSpinUpRequests;
LONG MaximumNumberOfWorkerThreads;
LONG MinimumNumberOfWorkerThreads;
__volatile LONG NumberOfActiveWorkerThreads;
__volatile LONG NumberOfIdleWorkerThreads;
LONG NumberOfFailedSpinUpRequests;
__volatile LONG WorkQueueItemForSpinUpWorkerThreadInUse;
RX_WORK_QUEUE_ITEM WorkQueueItemForTearDownWorkQueue;
RX_WORK_QUEUE_ITEM WorkQueueItemForSpinUpWorkerThread;
RX_WORK_QUEUE_ITEM WorkQueueItemForSpinDownWorkerThread;
KQUEUE Queue;
PETHREAD *ThreadPointers;
} RX_WORK_QUEUE, *PRX_WORK_QUEUE;
typedef struct _RX_WORK_QUEUE_DISPATCHER_
{
RX_WORK_QUEUE WorkQueue[RxMaximumWorkQueue];
} RX_WORK_QUEUE_DISPATCHER, *PRX_WORK_QUEUE_DISPATCHER;
typedef enum _RX_DISPATCHER_STATE_
{
RxDispatcherActive,
RxDispatcherInactive
} RX_DISPATCHER_STATE, *PRX_DISPATCHER_STATE;
typedef struct _RX_DISPATCHER_
{
LONG NumberOfProcessors;
PEPROCESS OwnerProcess;
PRX_WORK_QUEUE_DISPATCHER pWorkQueueDispatcher;
RX_DISPATCHER_STATE State;
LIST_ENTRY SpinUpRequests;
KSPIN_LOCK SpinUpRequestsLock;
KEVENT SpinUpRequestsEvent;
KEVENT SpinUpRequestsTearDownEvent;
} RX_DISPATCHER, *PRX_DISPATCHER;
NTSTATUS
NTAPI
RxDispatchToWorkerThread(
_In_ PRDBSS_DEVICE_OBJECT pMRxDeviceObject,
_In_ WORK_QUEUE_TYPE WorkQueueType,
_In_ PRX_WORKERTHREAD_ROUTINE Routine,
_In_ PVOID pContext);
NTSTATUS
NTAPI
RxInitializeDispatcher(
VOID);
NTSTATUS
RxInitializeMRxDispatcher(
_Inout_ PRDBSS_DEVICE_OBJECT pMRxDeviceObject);
#endif

View File

@ -0,0 +1,138 @@
#ifndef _SCAVENGR_H_
#define _SCAVENGR_H_
extern KMUTEX RxScavengerMutex;
#define RX_SCAVENGER_FINALIZATION_TIME_INTERVAL (10 * 1000 * 1000 * 10)
typedef struct _RX_SCAVENGER_ENTRY
{
LIST_ENTRY List;
UCHAR Type;
UCHAR Operation;
UCHAR State;
UCHAR Flags;
struct _RX_SCAVENGER_ENTRY *pContinuationEntry;
} RX_SCAVENGER_ENTRY, *PRX_SCAVENGER_ENTRY;
#define RxInitializeScavengerEntry(ScavengerEntry) \
(ScavengerEntry)->State = 0; \
(ScavengerEntry)->Flags = 0; \
(ScavengerEntry)->Type = 0; \
(ScavengerEntry)->Operation = 0; \
InitializeListHead(&(ScavengerEntry)->List); \
(ScavengerEntry)->pContinuationEntry = NULL
#define RxAcquireScavengerMutex() KeWaitForSingleObject(&RxScavengerMutex, Executive, KernelMode, FALSE, NULL)
#define RxReleaseScavengerMutex() KeReleaseMutex(&RxScavengerMutex, FALSE)
VOID
RxMarkFobxOnCleanup(
_In_ PFOBX pFobx,
_Out_ PBOOLEAN NeedPurge);
VOID
RxMarkFobxOnClose(
_In_ PFOBX Fobx);
typedef enum _RDBSS_SCAVENGER_STATE
{
RDBSS_SCAVENGER_INACTIVE,
RDBSS_SCAVENGER_DORMANT,
RDBSS_SCAVENGER_ACTIVE,
RDBSS_SCAVENGER_SUSPENDED
} RDBSS_SCAVENGER_STATE, *PRDBSS_SCAVENGER_STATE;
typedef struct _RDBSS_SCAVENGER
{
RDBSS_SCAVENGER_STATE State;
LONG MaximumNumberOfDormantFiles;
volatile LONG NumberOfDormantFiles;
LARGE_INTEGER TimeLimit;
ULONG SrvCallsToBeFinalized;
ULONG NetRootsToBeFinalized;
ULONG VNetRootsToBeFinalized;
ULONG FcbsToBeFinalized;
ULONG SrvOpensToBeFinalized;
ULONG FobxsToBeFinalized;
LIST_ENTRY SrvCallFinalizationList;
LIST_ENTRY NetRootFinalizationList;
LIST_ENTRY VNetRootFinalizationList;
LIST_ENTRY FcbFinalizationList;
LIST_ENTRY SrvOpenFinalizationList;
LIST_ENTRY FobxFinalizationList;
LIST_ENTRY ClosePendingFobxsList;
RX_WORK_ITEM WorkItem;
KEVENT SyncEvent;
KEVENT ScavengeEvent;
PETHREAD CurrentScavengerThread;
PNET_ROOT CurrentNetRootForClosePendingProcessing;
PFCB CurrentFcbForClosePendingProcessing;
KEVENT ClosePendingProcessingSyncEvent;
} RDBSS_SCAVENGER, *PRDBSS_SCAVENGER;
#define RxInitializeRdbssScavenger(Scavenger, ScavengerTimeLimit) \
(Scavenger)->State = RDBSS_SCAVENGER_INACTIVE; \
(Scavenger)->SrvCallsToBeFinalized = 0; \
(Scavenger)->NetRootsToBeFinalized = 0; \
(Scavenger)->VNetRootsToBeFinalized = 0; \
(Scavenger)->FcbsToBeFinalized = 0; \
(Scavenger)->SrvOpensToBeFinalized = 0; \
(Scavenger)->FobxsToBeFinalized = 0; \
(Scavenger)->NumberOfDormantFiles = 0; \
(Scavenger)->MaximumNumberOfDormantFiles = 50; \
(Scavenger)->CurrentFcbForClosePendingProcessing = NULL; \
(Scavenger)->CurrentNetRootForClosePendingProcessing = NULL; \
if ((ScavengerTimeLimit).QuadPart == 0) \
{ \
(Scavenger)->TimeLimit.QuadPart = RX_SCAVENGER_FINALIZATION_TIME_INTERVAL; \
} \
else \
{ \
(Scavenger)->TimeLimit.QuadPart = (ScavengerTimeLimit).QuadPart; \
} \
KeInitializeEvent(&((Scavenger)->SyncEvent), NotificationEvent, FALSE); \
KeInitializeEvent(&((Scavenger)->ScavengeEvent), SynchronizationEvent, TRUE); \
KeInitializeEvent(&((Scavenger)->ClosePendingProcessingSyncEvent), NotificationEvent, FALSE); \
InitializeListHead(&(Scavenger)->SrvCallFinalizationList); \
InitializeListHead(&(Scavenger)->NetRootFinalizationList); \
InitializeListHead(&(Scavenger)->VNetRootFinalizationList); \
InitializeListHead(&(Scavenger)->SrvOpenFinalizationList); \
InitializeListHead(&(Scavenger)->FcbFinalizationList); \
InitializeListHead(&(Scavenger)->FobxFinalizationList); \
InitializeListHead(&(Scavenger)->ClosePendingFobxsList)
typedef struct _PURGE_SYNCHRONIZATION_CONTEXT
{
LIST_ENTRY ContextsAwaitingPurgeCompletion;
BOOLEAN PurgeInProgress;
} PURGE_SYNCHRONIZATION_CONTEXT, *PPURGE_SYNCHRONIZATION_CONTEXT;
VOID
RxInitializePurgeSyncronizationContext(
_In_ PPURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext);
BOOLEAN
RxScavengeRelatedFobxs(
_In_ PFCB Fcb);
VOID
RxpUndoScavengerFinalizationMarking(
_In_ PVOID Instance);
BOOLEAN
RxScavengeVNetRoots(
_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject);
#if (_WIN32_WINNT >= 0x0600)
VOID
RxSynchronizeWithScavenger(
_In_ PRX_CONTEXT RxContext,
_In_ PFCB Fcb);
#else
VOID
RxSynchronizeWithScavenger(
_In_ PRX_CONTEXT RxContext);
#endif
#endif

View File

@ -0,0 +1,21 @@
#ifndef _RDBSSSTRUCHDR_
#define _RDBSSSTRUCHDR_
typedef struct _RX_PREFIX_ENTRY *PRX_PREFIX_ENTRY;
typedef struct _RX_PREFIX_TABLE *PRX_PREFIX_TABLE;
typedef struct _RX_FSD_DISPATCH_VECTOR *PRX_FSD_DISPATCH_VECTOR;
typedef struct _RDBSS_DEVICE_OBJECT *PRDBSS_DEVICE_OBJECT;
typedef struct _SRV_CALL *PSRV_CALL;
typedef struct _NET_ROOT *PNET_ROOT;
typedef struct _V_NET_ROOT *PV_NET_ROOT;
typedef struct _NON_PAGED_FCB *PNON_PAGED_FCB;
typedef struct _FCB *PFCB;
typedef struct _SRV_OPEN *PSRV_OPEN;
typedef struct _FOBX *PFOBX;
typedef struct _RX_CONTEXT *PRX_CONTEXT;
typedef struct _LOWIO_CONTEXT *PLOWIO_CONTEXT;
typedef struct _MINIRDR_DISPATCH *PMINIRDR_DISPATCH;
typedef struct _MRX_SRVCALLDOWN_STRUCTURE *PMRX_SRVCALLDOWN_STRUCTURE;
typedef struct _MRX_CREATENETROOT_CONTEXT *PMRX_CREATENETROOT_CONTEXT;
#endif

View File

@ -6,5 +6,7 @@ add_subdirectory(ip)
add_subdirectory(libusb)
add_subdirectory(lwip)
add_subdirectory(ntoskrnl_vista)
add_subdirectory(rdbsslib)
add_subdirectory(rtlver)
add_subdirectory(rxce)
add_subdirectory(sound)

View File

@ -0,0 +1,10 @@
add_definitions(-DUNICODE -D_UNICODE -D__NTOSKRNL__ -D_NTOSKRNL_ -DRDBSS_TRACKER)
include_directories(${REACTOS_SOURCE_DIR}/drivers/filesystems/mup)
list(APPEND SOURCE
rdbss.c)
add_library(rdbsslib ${SOURCE})
target_link_libraries(rdbsslib rxce)
add_dependencies(rdbsslib rxce bugcodes xdk)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
add_definitions(-DUNICODE -D_UNICODE -D__NTOSKRNL__ -D_NTOSKRNL_ -DRDBSS_TRACKER)
include_directories(${REACTOS_SOURCE_DIR}/drivers/filesystems/mup)
list(APPEND SOURCE
rxce.c)
add_library(rxce ${SOURCE})
target_link_libraries(rxce ntoskrnl memcmp)
add_dependencies(rxce bugcodes xdk ntoskrnl)

File diff suppressed because it is too large Load Diff