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