1 #ifndef _RXMINIRDR_ 2 #define _RXMINIRDR_ 3 4 #define RxSetIoStatusStatus(R, S) (R)->CurrentIrp->IoStatus.Status = (S) 5 #define RxSetIoStatusInfo(R, I) (R)->CurrentIrp->IoStatus.Information = (I) 6 7 #define RxShouldPostCompletion() ((KeGetCurrentIrql() >= DISPATCH_LEVEL)) 8 9 #define RX_REGISTERMINI_FLAG_DONT_PROVIDE_UNCS 0x00000001 10 #define RX_REGISTERMINI_FLAG_DONT_PROVIDE_MAILSLOTS 0x00000002 11 #define RX_REGISTERMINI_FLAG_DONT_INIT_DRIVER_DISPATCH 0x00000004 12 #define RX_REGISTERMINI_FLAG_DONT_INIT_PREFIX_N_SCAVENGER 0x00000008 13 14 NTSTATUS 15 NTAPI 16 RxRegisterMinirdr( 17 _Out_ PRDBSS_DEVICE_OBJECT *DeviceObject, 18 _Inout_ PDRIVER_OBJECT DriverObject, 19 _In_ PMINIRDR_DISPATCH MrdrDispatch, 20 _In_ ULONG Controls, 21 _In_ PUNICODE_STRING DeviceName, 22 _In_ ULONG DeviceExtensionSize, 23 _In_ DEVICE_TYPE DeviceType, 24 _In_ ULONG DeviceCharacteristics); 25 26 VOID 27 NTAPI 28 RxpUnregisterMinirdr( 29 _In_ PRDBSS_DEVICE_OBJECT RxDeviceObject); 30 31 NTSTATUS 32 NTAPI 33 RxStartMinirdr( 34 _In_ PRX_CONTEXT RxContext, 35 _Out_ PBOOLEAN PostToFsp); 36 37 NTSTATUS 38 NTAPI 39 RxStopMinirdr( 40 _In_ PRX_CONTEXT RxContext, 41 _Out_ PBOOLEAN PostToFsp); 42 43 NTSTATUS 44 NTAPI 45 RxFsdDispatch( 46 _In_ PRDBSS_DEVICE_OBJECT RxDeviceObject, 47 _In_ PIRP Irp); 48 49 typedef 50 NTSTATUS 51 (NTAPI *PMRX_CALLDOWN) ( 52 _Inout_ PRX_CONTEXT RxContext); 53 54 typedef 55 NTSTATUS 56 (NTAPI *PMRX_CALLDOWN_CTX) ( 57 _Inout_ PRX_CONTEXT RxContext, 58 _Inout_ PRDBSS_DEVICE_OBJECT RxDeviceObject); 59 60 typedef 61 NTSTATUS 62 (NTAPI *PMRX_CHKDIR_CALLDOWN) ( 63 _Inout_ PRX_CONTEXT RxContext, 64 _In_ PUNICODE_STRING DirectoryName); 65 66 typedef 67 NTSTATUS 68 (NTAPI *PMRX_CHKFCB_CALLDOWN) ( 69 _In_ PFCB Fcb1, 70 _In_ PFCB Fcb2); 71 72 typedef enum _RX_BLOCK_CONDITION { 73 Condition_Uninitialized = 0, 74 Condition_InTransition, 75 Condition_Closing, 76 Condition_Good, 77 Condition_Bad, 78 Condition_Closed 79 } RX_BLOCK_CONDITION, *PRX_BLOCK_CONDITION; 80 81 #define StableCondition(X) ((X) >= Condition_Good) 82 83 typedef 84 VOID 85 (NTAPI *PMRX_NETROOT_CALLBACK) ( 86 _Inout_ PMRX_CREATENETROOT_CONTEXT CreateContext); 87 88 typedef 89 VOID 90 (NTAPI *PMRX_EXTRACT_NETROOT_NAME) ( 91 _In_ PUNICODE_STRING FilePathName, 92 _In_ PMRX_SRV_CALL SrvCall, 93 _Out_ PUNICODE_STRING NetRootName, 94 _Out_opt_ PUNICODE_STRING RestOfName); 95 96 typedef struct _MRX_CREATENETROOT_CONTEXT 97 { 98 PRX_CONTEXT RxContext; 99 PV_NET_ROOT pVNetRoot; 100 KEVENT FinishEvent; 101 NTSTATUS VirtualNetRootStatus; 102 NTSTATUS NetRootStatus; 103 RX_WORK_QUEUE_ITEM WorkQueueItem; 104 PMRX_NETROOT_CALLBACK Callback; 105 } MRX_CREATENETROOT_CONTEXT, *PMRX_CREATENETROOT_CONTEXT; 106 107 typedef 108 NTSTATUS 109 (NTAPI *PMRX_CREATE_V_NET_ROOT) ( 110 _Inout_ PMRX_CREATENETROOT_CONTEXT Context); 111 112 typedef 113 NTSTATUS 114 (NTAPI *PMRX_UPDATE_NETROOT_STATE) ( 115 _Inout_ PMRX_NET_ROOT NetRoot); 116 117 typedef struct _MRX_SRVCALL_CALLBACK_CONTEXT 118 { 119 PMRX_SRVCALLDOWN_STRUCTURE SrvCalldownStructure; 120 ULONG CallbackContextOrdinal; 121 PRDBSS_DEVICE_OBJECT RxDeviceObject; 122 NTSTATUS Status; 123 PVOID RecommunicateContext; 124 } MRX_SRVCALL_CALLBACK_CONTEXT, *PMRX_SRVCALL_CALLBACK_CONTEXT; 125 126 typedef 127 VOID 128 (NTAPI *PMRX_SRVCALL_CALLBACK) ( 129 _Inout_ PMRX_SRVCALL_CALLBACK_CONTEXT Context); 130 131 typedef struct _MRX_SRVCALLDOWN_STRUCTURE 132 { 133 KEVENT FinishEvent; 134 LIST_ENTRY SrvCalldownList; 135 PRX_CONTEXT RxContext; 136 PMRX_SRV_CALL SrvCall; 137 PMRX_SRVCALL_CALLBACK CallBack; 138 BOOLEAN CalldownCancelled; 139 ULONG NumberRemaining; 140 ULONG NumberToWait; 141 ULONG BestFinisherOrdinal; 142 PRDBSS_DEVICE_OBJECT BestFinisher; 143 MRX_SRVCALL_CALLBACK_CONTEXT CallbackContexts[1]; 144 } MRX_SRVCALLDOWN_STRUCTURE, *PMRX_SRVCALLDOWN_STRUCTURE; 145 146 typedef 147 NTSTATUS 148 (NTAPI *PMRX_CREATE_SRVCALL) ( 149 _Inout_ PMRX_SRV_CALL SrvCall, 150 _Inout_ PMRX_SRVCALL_CALLBACK_CONTEXT SrvCallCallBackContext); 151 152 typedef 153 NTSTATUS 154 (NTAPI *PMRX_SRVCALL_WINNER_NOTIFY)( 155 _Inout_ PMRX_SRV_CALL SrvCall, 156 _In_ BOOLEAN ThisMinirdrIsTheWinner, 157 _Inout_ PVOID RecommunicateContext); 158 159 typedef 160 NTSTATUS 161 (NTAPI *PMRX_DEALLOCATE_FOR_FCB) ( 162 _Inout_ PMRX_FCB Fcb); 163 164 typedef 165 NTSTATUS 166 (NTAPI *PMRX_DEALLOCATE_FOR_FOBX) ( 167 _Inout_ PMRX_FOBX Fobx); 168 169 typedef 170 NTSTATUS 171 (NTAPI *PMRX_IS_LOCK_REALIZABLE) ( 172 _Inout_ PMRX_FCB Fcb, 173 _In_ PLARGE_INTEGER ByteOffset, 174 _In_ PLARGE_INTEGER Length, 175 _In_ ULONG LowIoLockFlags); 176 177 typedef 178 NTSTATUS 179 (NTAPI *PMRX_FORCECLOSED_CALLDOWN) ( 180 _Inout_ PMRX_SRV_OPEN SrvOpen); 181 182 typedef 183 NTSTATUS 184 (NTAPI *PMRX_FINALIZE_SRVCALL_CALLDOWN) ( 185 _Inout_ PMRX_SRV_CALL SrvCall, 186 _In_ BOOLEAN Force); 187 188 typedef 189 NTSTATUS 190 (NTAPI *PMRX_FINALIZE_V_NET_ROOT_CALLDOWN) ( 191 _Inout_ PMRX_V_NET_ROOT VirtualNetRoot, 192 _In_ PBOOLEAN Force); 193 194 typedef 195 NTSTATUS 196 (NTAPI *PMRX_FINALIZE_NET_ROOT_CALLDOWN) ( 197 _Inout_ PMRX_NET_ROOT NetRoot, 198 _In_ PBOOLEAN Force); 199 200 typedef 201 ULONG 202 (NTAPI *PMRX_EXTENDFILE_CALLDOWN) ( 203 _Inout_ PRX_CONTEXT RxContext, 204 _Inout_ PLARGE_INTEGER NewFileSize, 205 _Out_ PLARGE_INTEGER NewAllocationSize); 206 207 typedef 208 NTSTATUS 209 (NTAPI *PMRX_CHANGE_BUFFERING_STATE_CALLDOWN) ( 210 _Inout_ PRX_CONTEXT RxContext, 211 _Inout_ PMRX_SRV_OPEN SrvOpen, 212 _In_ PVOID MRxContext); 213 214 typedef 215 NTSTATUS 216 (NTAPI *PMRX_PREPARSE_NAME) ( 217 _Inout_ PRX_CONTEXT RxContext, 218 _In_ PUNICODE_STRING Name); 219 220 typedef 221 NTSTATUS 222 (NTAPI *PMRX_GET_CONNECTION_ID) ( 223 _Inout_ PRX_CONTEXT RxContext, 224 _Inout_ PRX_CONNECTION_ID UniqueId); 225 226 typedef 227 NTSTATUS 228 (NTAPI *PMRX_COMPUTE_NEW_BUFFERING_STATE) ( 229 _Inout_ PMRX_SRV_OPEN SrvOpen, 230 _In_ PVOID MRxContext, 231 _Out_ PULONG NewBufferingState); 232 233 typedef enum _LOWIO_OPS { 234 LOWIO_OP_READ = 0, 235 LOWIO_OP_WRITE, 236 LOWIO_OP_SHAREDLOCK, 237 LOWIO_OP_EXCLUSIVELOCK, 238 LOWIO_OP_UNLOCK, 239 LOWIO_OP_UNLOCK_MULTIPLE, 240 LOWIO_OP_FSCTL, 241 LOWIO_OP_IOCTL, 242 LOWIO_OP_NOTIFY_CHANGE_DIRECTORY, 243 LOWIO_OP_CLEAROUT, 244 LOWIO_OP_MAXIMUM 245 } LOWIO_OPS; 246 247 typedef 248 NTSTATUS 249 (NTAPI *PLOWIO_COMPLETION_ROUTINE) ( 250 _In_ PRX_CONTEXT RxContext); 251 252 typedef LONGLONG RXVBO; 253 254 typedef struct _LOWIO_LOCK_LIST 255 { 256 struct _LOWIO_LOCK_LIST * Next; 257 ULONG LockNumber; 258 RXVBO ByteOffset; 259 LONGLONG Length; 260 BOOLEAN ExclusiveLock; 261 ULONG Key; 262 } LOWIO_LOCK_LIST, *PLOWIO_LOCK_LIST; 263 264 typedef struct _XXCTL_LOWIO_COMPONENT 265 { 266 ULONG Flags; 267 union 268 { 269 ULONG FsControlCode; 270 ULONG IoControlCode; 271 }; 272 ULONG InputBufferLength; 273 PVOID pInputBuffer; 274 ULONG OutputBufferLength; 275 PVOID pOutputBuffer; 276 UCHAR MinorFunction; 277 } XXCTL_LOWIO_COMPONENT; 278 279 typedef struct _LOWIO_CONTEXT 280 { 281 USHORT Operation; 282 USHORT Flags; 283 PLOWIO_COMPLETION_ROUTINE CompletionRoutine; 284 PERESOURCE Resource; 285 ERESOURCE_THREAD ResourceThreadId; 286 union 287 { 288 struct 289 { 290 ULONG Flags; 291 PMDL Buffer; 292 RXVBO ByteOffset; 293 ULONG ByteCount; 294 ULONG Key; 295 PNON_PAGED_FCB NonPagedFcb; 296 } ReadWrite; 297 struct 298 { 299 union 300 { 301 PLOWIO_LOCK_LIST LockList; 302 LONGLONG Length; 303 }; 304 ULONG Flags; 305 RXVBO ByteOffset; 306 ULONG Key; 307 } Locks; 308 XXCTL_LOWIO_COMPONENT FsCtl; 309 XXCTL_LOWIO_COMPONENT IoCtl; 310 struct 311 { 312 BOOLEAN WatchTree; 313 ULONG CompletionFilter; 314 ULONG NotificationBufferLength; 315 PVOID pNotificationBuffer; 316 } NotifyChangeDirectory; 317 } ParamsFor; 318 } LOWIO_CONTEXT; 319 320 #define LOWIO_CONTEXT_FLAG_SYNCCALL 0x01 321 #define LOWIO_CONTEXT_FLAG_SAVEUNLOCKS 0x2 322 #define LOWIO_CONTEXT_FLAG_LOUDOPS 0x04 323 #define LOWIO_CONTEXT_FLAG_CAN_COMPLETE_AT_DPC_LEVEL 0x08 324 325 #define LOWIO_READWRITEFLAG_PAGING_IO 0x01 326 #define LOWIO_READWRITEFLAG_EXTENDING_FILESIZE 0x02 327 #define LOWIO_READWRITEFLAG_EXTENDING_VDL 0x04 328 329 #define RDBSS_MANAGE_SRV_CALL_EXTENSION 0x01 330 #define RDBSS_MANAGE_NET_ROOT_EXTENSION 0x02 331 #define RDBSS_MANAGE_V_NET_ROOT_EXTENSION 0x04 332 #define RDBSS_MANAGE_FCB_EXTENSION 0x08 333 #define RDBSS_MANAGE_SRV_OPEN_EXTENSION 0x10 334 #define RDBSS_MANAGE_FOBX_EXTENSION 0x20 335 #define RDBSS_NO_DEFERRED_CACHE_READAHEAD 0x1000 336 337 typedef struct _MINIRDR_DISPATCH 338 { 339 NODE_TYPE_CODE NodeTypeCode; 340 NODE_BYTE_SIZE NodeByteSize; 341 ULONG MRxFlags; 342 ULONG MRxSrvCallSize; 343 ULONG MRxNetRootSize; 344 ULONG MRxVNetRootSize; 345 ULONG MRxFcbSize; 346 ULONG MRxSrvOpenSize; 347 ULONG MRxFobxSize; 348 PMRX_CALLDOWN_CTX MRxStart; 349 PMRX_CALLDOWN_CTX MRxStop; 350 PMRX_CALLDOWN MRxCancel; 351 PMRX_CALLDOWN MRxCreate; 352 PMRX_CALLDOWN MRxCollapseOpen; 353 PMRX_CALLDOWN MRxShouldTryToCollapseThisOpen; 354 PMRX_CALLDOWN MRxFlush; 355 PMRX_CALLDOWN MRxZeroExtend; 356 PMRX_CALLDOWN MRxTruncate; 357 PMRX_CALLDOWN MRxCleanupFobx; 358 PMRX_CALLDOWN MRxCloseSrvOpen; 359 PMRX_DEALLOCATE_FOR_FCB MRxDeallocateForFcb; 360 PMRX_DEALLOCATE_FOR_FOBX MRxDeallocateForFobx; 361 PMRX_IS_LOCK_REALIZABLE MRxIsLockRealizable; 362 PMRX_FORCECLOSED_CALLDOWN MRxForceClosed; 363 PMRX_CHKFCB_CALLDOWN MRxAreFilesAliased; 364 PMRX_CALLDOWN MRxOpenPrintFile; 365 PMRX_CALLDOWN MRxClosePrintFile; 366 PMRX_CALLDOWN MRxWritePrintFile; 367 PMRX_CALLDOWN MRxEnumeratePrintQueue; 368 PMRX_CALLDOWN MRxClosedSrvOpenTimeOut; 369 PMRX_CALLDOWN MRxClosedFcbTimeOut; 370 PMRX_CALLDOWN MRxQueryDirectory; 371 PMRX_CALLDOWN MRxQueryFileInfo; 372 PMRX_CALLDOWN MRxSetFileInfo; 373 PMRX_CALLDOWN MRxSetFileInfoAtCleanup; 374 PMRX_CALLDOWN MRxQueryEaInfo; 375 PMRX_CALLDOWN MRxSetEaInfo; 376 PMRX_CALLDOWN MRxQuerySdInfo; 377 PMRX_CALLDOWN MRxSetSdInfo; 378 PMRX_CALLDOWN MRxQueryQuotaInfo; 379 PMRX_CALLDOWN MRxSetQuotaInfo; 380 PMRX_CALLDOWN MRxQueryVolumeInfo; 381 PMRX_CALLDOWN MRxSetVolumeInfo; 382 PMRX_CHKDIR_CALLDOWN MRxIsValidDirectory; 383 PMRX_COMPUTE_NEW_BUFFERING_STATE MRxComputeNewBufferingState; 384 PMRX_CALLDOWN MRxLowIOSubmit[LOWIO_OP_MAXIMUM+1]; 385 PMRX_EXTENDFILE_CALLDOWN MRxExtendForCache; 386 PMRX_EXTENDFILE_CALLDOWN MRxExtendForNonCache; 387 PMRX_CHANGE_BUFFERING_STATE_CALLDOWN MRxCompleteBufferingStateChangeRequest; 388 PMRX_CREATE_V_NET_ROOT MRxCreateVNetRoot; 389 PMRX_FINALIZE_V_NET_ROOT_CALLDOWN MRxFinalizeVNetRoot; 390 PMRX_FINALIZE_NET_ROOT_CALLDOWN MRxFinalizeNetRoot; 391 PMRX_UPDATE_NETROOT_STATE MRxUpdateNetRootState; 392 PMRX_EXTRACT_NETROOT_NAME MRxExtractNetRootName; 393 PMRX_CREATE_SRVCALL MRxCreateSrvCall; 394 PMRX_CREATE_SRVCALL MRxCancelCreateSrvCall; 395 PMRX_SRVCALL_WINNER_NOTIFY MRxSrvCallWinnerNotify; 396 PMRX_FINALIZE_SRVCALL_CALLDOWN MRxFinalizeSrvCall; 397 PMRX_CALLDOWN MRxDevFcbXXXControlFile; 398 PMRX_PREPARSE_NAME MRxPreparseName; 399 PMRX_GET_CONNECTION_ID MRxGetConnectionId; 400 ULONG ScavengerTimeout; 401 } MINIRDR_DISPATCH, *PMINIRDR_DISPATCH; 402 403 #endif 404