1*c2c66affSColin Finck #ifndef _RDBSSSTRUC_
2*c2c66affSColin Finck #define _RDBSSSTRUC_
3*c2c66affSColin Finck
4*c2c66affSColin Finck #include "prefix.h"
5*c2c66affSColin Finck #include "lowio.h"
6*c2c66affSColin Finck #include "scavengr.h"
7*c2c66affSColin Finck #include "rxcontx.h"
8*c2c66affSColin Finck #include "fcb.h"
9*c2c66affSColin Finck
10*c2c66affSColin Finck extern RX_SPIN_LOCK RxStrucSupSpinLock;
11*c2c66affSColin Finck
12*c2c66affSColin Finck typedef struct _RDBSS_EXPORTS
13*c2c66affSColin Finck {
14*c2c66affSColin Finck PRX_SPIN_LOCK pRxStrucSupSpinLock;
15*c2c66affSColin Finck PLONG pRxDebugTraceIndent;
16*c2c66affSColin Finck } RDBSS_EXPORTS, *PRDBSS_EXPORTS;
17*c2c66affSColin Finck
18*c2c66affSColin Finck typedef enum _LOCK_HOLDING_STATE
19*c2c66affSColin Finck {
20*c2c66affSColin Finck LHS_LockNotHeld,
21*c2c66affSColin Finck LHS_SharedLockHeld,
22*c2c66affSColin Finck LHS_ExclusiveLockHeld
23*c2c66affSColin Finck } LOCK_HOLDING_STATE, *PLOCK_HOLDING_STATE;
24*c2c66affSColin Finck
25*c2c66affSColin Finck typedef struct _RDBSS_DATA
26*c2c66affSColin Finck {
27*c2c66affSColin Finck NODE_TYPE_CODE NodeTypeCode;
28*c2c66affSColin Finck NODE_BYTE_SIZE NodeByteSize;
29*c2c66affSColin Finck PDRIVER_OBJECT DriverObject;
30*c2c66affSColin Finck volatile LONG NumberOfMinirdrsStarted;
31*c2c66affSColin Finck FAST_MUTEX MinirdrRegistrationMutex;
32*c2c66affSColin Finck LIST_ENTRY RegisteredMiniRdrs;
33*c2c66affSColin Finck LONG NumberOfMinirdrsRegistered;
34*c2c66affSColin Finck PEPROCESS OurProcess;
35*c2c66affSColin Finck CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
36*c2c66affSColin Finck #if (_WIN32_WINNT < 0x0600)
37*c2c66affSColin Finck CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks;
38*c2c66affSColin Finck #endif
39*c2c66affSColin Finck ERESOURCE Resource;
40*c2c66affSColin Finck } RDBSS_DATA;
41*c2c66affSColin Finck typedef RDBSS_DATA *PRDBSS_DATA;
42*c2c66affSColin Finck
43*c2c66affSColin Finck extern RDBSS_DATA RxData;
44*c2c66affSColin Finck
45*c2c66affSColin Finck PEPROCESS
46*c2c66affSColin Finck NTAPI
47*c2c66affSColin Finck RxGetRDBSSProcess(
48*c2c66affSColin Finck VOID);
49*c2c66affSColin Finck
50*c2c66affSColin Finck typedef enum _RX_RDBSS_STATE_
51*c2c66affSColin Finck {
52*c2c66affSColin Finck RDBSS_STARTABLE = 0,
53*c2c66affSColin Finck RDBSS_STARTED,
54*c2c66affSColin Finck RDBSS_STOP_IN_PROGRESS
55*c2c66affSColin Finck } RX_RDBSS_STATE, *PRX_RDBSS_STATE;
56*c2c66affSColin Finck
57*c2c66affSColin Finck typedef struct _RDBSS_STARTSTOP_CONTEXT_
58*c2c66affSColin Finck {
59*c2c66affSColin Finck RX_RDBSS_STATE State;
60*c2c66affSColin Finck ULONG Version;
61*c2c66affSColin Finck PRX_CONTEXT pStopContext;
62*c2c66affSColin Finck } RDBSS_STARTSTOP_CONTEXT, *PRDBSS_STARTSTOP_CONTEXT;
63*c2c66affSColin Finck
64*c2c66affSColin Finck typedef struct _RX_DISPATCHER_CONTEXT_
65*c2c66affSColin Finck {
66*c2c66affSColin Finck volatile LONG NumberOfWorkerThreads;
67*c2c66affSColin Finck volatile PKEVENT pTearDownEvent;
68*c2c66affSColin Finck } RX_DISPATCHER_CONTEXT, *PRX_DISPATCHER_CONTEXT;
69*c2c66affSColin Finck
70*c2c66affSColin Finck #define RxSetRdbssState(RxDeviceObject, NewState) \
71*c2c66affSColin Finck { \
72*c2c66affSColin Finck KIRQL OldIrql; \
73*c2c66affSColin Finck KeAcquireSpinLock(&RxStrucSupSpinLock, &OldIrql); \
74*c2c66affSColin Finck RxDeviceObject->StartStopContext.State = (NewState); \
75*c2c66affSColin Finck KeReleaseSpinLock(&RxStrucSupSpinLock, OldIrql); \
76*c2c66affSColin Finck }
77*c2c66affSColin Finck
78*c2c66affSColin Finck #define RxGetRdbssState(RxDeviceObject) RxDeviceObject->StartStopContext.State
79*c2c66affSColin Finck
80*c2c66affSColin Finck typedef struct _RDBSS_DEVICE_OBJECT {
81*c2c66affSColin Finck union
82*c2c66affSColin Finck {
83*c2c66affSColin Finck DEVICE_OBJECT DeviceObject;
84*c2c66affSColin Finck DEVICE_OBJECT;
85*c2c66affSColin Finck };
86*c2c66affSColin Finck ULONG RegistrationControls;
87*c2c66affSColin Finck PRDBSS_EXPORTS RdbssExports;
88*c2c66affSColin Finck PDEVICE_OBJECT RDBSSDeviceObject;
89*c2c66affSColin Finck PMINIRDR_DISPATCH Dispatch;
90*c2c66affSColin Finck UNICODE_STRING DeviceName;
91*c2c66affSColin Finck ULONG NetworkProviderPriority;
92*c2c66affSColin Finck HANDLE MupHandle;
93*c2c66affSColin Finck BOOLEAN RegisterUncProvider;
94*c2c66affSColin Finck BOOLEAN RegisterMailSlotProvider;
95*c2c66affSColin Finck BOOLEAN RegisteredAsFileSystem;
96*c2c66affSColin Finck BOOLEAN Unused;
97*c2c66affSColin Finck LIST_ENTRY MiniRdrListLinks;
98*c2c66affSColin Finck volatile ULONG NumberOfActiveFcbs;
99*c2c66affSColin Finck volatile ULONG NumberOfActiveContexts;
100*c2c66affSColin Finck struct
101*c2c66affSColin Finck {
102*c2c66affSColin Finck LARGE_INTEGER PagingReadBytesRequested;
103*c2c66affSColin Finck LARGE_INTEGER NonPagingReadBytesRequested;
104*c2c66affSColin Finck LARGE_INTEGER CacheReadBytesRequested;
105*c2c66affSColin Finck LARGE_INTEGER FastReadBytesRequested;
106*c2c66affSColin Finck LARGE_INTEGER NetworkReadBytesRequested;
107*c2c66affSColin Finck volatile ULONG ReadOperations;
108*c2c66affSColin Finck ULONG FastReadOperations;
109*c2c66affSColin Finck volatile ULONG RandomReadOperations;
110*c2c66affSColin Finck LARGE_INTEGER PagingWriteBytesRequested;
111*c2c66affSColin Finck LARGE_INTEGER NonPagingWriteBytesRequested;
112*c2c66affSColin Finck LARGE_INTEGER CacheWriteBytesRequested;
113*c2c66affSColin Finck LARGE_INTEGER FastWriteBytesRequested;
114*c2c66affSColin Finck LARGE_INTEGER NetworkWriteBytesRequested;
115*c2c66affSColin Finck volatile ULONG WriteOperations;
116*c2c66affSColin Finck ULONG FastWriteOperations;
117*c2c66affSColin Finck volatile ULONG RandomWriteOperations;
118*c2c66affSColin Finck };
119*c2c66affSColin Finck volatile LONG PostedRequestCount[RxMaximumWorkQueue];
120*c2c66affSColin Finck LONG OverflowQueueCount[RxMaximumWorkQueue];
121*c2c66affSColin Finck LIST_ENTRY OverflowQueue[RxMaximumWorkQueue];
122*c2c66affSColin Finck RX_SPIN_LOCK OverflowQueueSpinLock;
123*c2c66affSColin Finck LONG AsynchronousRequestsPending;
124*c2c66affSColin Finck PKEVENT pAsynchronousRequestsCompletionEvent;
125*c2c66affSColin Finck RDBSS_STARTSTOP_CONTEXT StartStopContext;
126*c2c66affSColin Finck RX_DISPATCHER_CONTEXT DispatcherContext;
127*c2c66affSColin Finck PRX_PREFIX_TABLE pRxNetNameTable;
128*c2c66affSColin Finck RX_PREFIX_TABLE RxNetNameTableInDeviceObject;
129*c2c66affSColin Finck PRDBSS_SCAVENGER pRdbssScavenger;
130*c2c66affSColin Finck RDBSS_SCAVENGER RdbssScavengerInDeviceObject;
131*c2c66affSColin Finck } RDBSS_DEVICE_OBJECT, *PRDBSS_DEVICE_OBJECT;
132*c2c66affSColin Finck
133*c2c66affSColin Finck FORCEINLINE
134*c2c66affSColin Finck VOID
135*c2c66affSColin Finck NTAPI
RxUnregisterMinirdr(_In_ PRDBSS_DEVICE_OBJECT RxDeviceObject)136*c2c66affSColin Finck RxUnregisterMinirdr(
137*c2c66affSColin Finck _In_ PRDBSS_DEVICE_OBJECT RxDeviceObject)
138*c2c66affSColin Finck {
139*c2c66affSColin Finck PDEVICE_OBJECT RDBSSDeviceObject;
140*c2c66affSColin Finck
141*c2c66affSColin Finck RDBSSDeviceObject = RxDeviceObject->RDBSSDeviceObject;
142*c2c66affSColin Finck
143*c2c66affSColin Finck RxpUnregisterMinirdr(RxDeviceObject);
144*c2c66affSColin Finck
145*c2c66affSColin Finck if (RDBSSDeviceObject != NULL)
146*c2c66affSColin Finck {
147*c2c66affSColin Finck ObDereferenceObject(RDBSSDeviceObject);
148*c2c66affSColin Finck }
149*c2c66affSColin Finck }
150*c2c66affSColin Finck
151*c2c66affSColin Finck #endif
152