/*++ Copyright (c) 1989 Microsoft Corporation Module Name: mrx.h Abstract: This module defines the interface between the MINI Redirectors and the RDBSS. The inteface is a dispatch table for the normal file system operations. In addition routines are provided for registrations/deregistration of mini redirectors. Author: Joe Linn (JoeLinn) 8-17-94 Revision History: Notes: The interface definition between the mini redirectors and the wrapper consists of two parts, the data structures used and the dispatch vector. The data structures are defined in mrxfcb.h while the signatures of the various entries in the dispatch vector and the dispatch vector itself is defined in this file. --*/ #ifndef _RXMINIRDR_ #define _RXMINIRDR_ #include // RDBSS data structures shared with the mini redirectors // The following macros encapsulate commonly used operations in the mini redirector. // These include setting the status/information associated with the completion of // a request etc. // The following three macros are used for passing back operation status from the // minirdr to the NT wrapper. information passed back is either the open_action // for a create or the actual byte count or an operation. these should be passed // back directly in the rxcontext. #define RxSetIoStatusStatus(RXCONTEXT, STATUS) \ (RXCONTEXT)->CurrentIrp->IoStatus.Status = (STATUS) #define RxSetIoStatusInfo(RXCONTEXT, INFORMATION) \ ((RXCONTEXT))->CurrentIrp->IoStatus.Information = (INFORMATION) #define RxGetIoStatusInfo(RXCONTEXT) \ ((RXCONTEXT)->CurrentIrp->IoStatus.Information) #define RxShouldPostCompletion() ((KeGetCurrentIrql() >= DISPATCH_LEVEL)) /// /// The mini rdr's register/unregister with the RDBSS whenever they are loaded/unloaded. /// The registartion process is a two way hand shake in which the mini rdr informs the RDBSS /// by invoking the registartion routine. The RDBSS completes the initialization by invoking /// the Start routine in the dispatch vector. /// #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, //the deviceobject that was created IN OUT PDRIVER_OBJECT DriverObject, // the minirdr driver object IN PMINIRDR_DISPATCH MrdrDispatch, // the mini rdr dispatch vector IN ULONG Controls, IN PUNICODE_STRING DeviceName, IN ULONG DeviceExtensionSize, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics ); VOID NTAPI RxMakeLateDeviceAvailable( IN PRDBSS_DEVICE_OBJECT RxDeviceObject ); VOID NTAPI __RxFillAndInstallFastIoDispatch( IN PRDBSS_DEVICE_OBJECT RxDeviceObject, IN OUT PFAST_IO_DISPATCH FastIoDispatch, IN ULONG FastIoDispatchSize ); #define RxFillAndInstallFastIoDispatch(__devobj,__fastiodisp) {\ __RxFillAndInstallFastIoDispatch(&__devobj->RxDeviceObject,\ &__fastiodisp, \ sizeof(__fastiodisp)); \ } VOID NTAPI RxpUnregisterMinirdr( IN PRDBSS_DEVICE_OBJECT RxDeviceObject); NTSTATUS RxStartMinirdr ( IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp ); NTSTATUS RxStopMinirdr ( IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp ); NTSTATUS RxSetDomainForMailslotBroadcast ( IN PUNICODE_STRING DomainName ); NTSTATUS RxFsdDispatch( IN PRDBSS_DEVICE_OBJECT RxDeviceObject, IN PIRP Irp ); typedef NTSTATUS (NTAPI *PMRX_CALLDOWN) ( IN OUT struct _RX_CONTEXT * RxContext ); typedef NTSTATUS (NTAPI *PMRX_CALLDOWN_CTX) ( IN OUT struct _RX_CONTEXT * RxContext, IN OUT PRDBSS_DEVICE_OBJECT RxDeviceObject ); typedef NTSTATUS (NTAPI *PMRX_CHKDIR_CALLDOWN) ( IN OUT struct _RX_CONTEXT * RxContext, IN PUNICODE_STRING DirectoryName ); typedef NTSTATUS (NTAPI *PMRX_CHKFCB_CALLDOWN) ( IN struct _FCB * Fcb1, IN struct _FCB * Fcb2 ); // // The two important abstractions used in the interface between the mini rdr and RDBSS are // Server Calls and Net Roots. The former corresponds to the context associated with a // server with which a connection has been established and the later corresponds to a // share on a server ( This could also be viewed as a portion of the name space which has // been claimed by a mini rdr). // // The creation of Server calls and net roots typically involve atleast one network round trip. // In order to provide for asynchronous operations to continue these operations are modelled // as a two phase activity. Each calldown to a mini rdr for creating a server call and net root is // accompanied by a callup from the mini rdr to the RDBSS notifying with the completion status // of the request. Currently these are synchronous! // // The creation of Srv calls is further complicated by the fact that the RDBSS has to choose // from a number of mini rdr's to establish a connection with a server. In order to provide // the RDBSS with maximum flexibility in choosing the mini rdr's that it wishes to deploy the // creation of server calls involves a third phase in which the RDBSS notifies the mini rdr of // a winner. All the losing mini rdrs destroy the associated context. // 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) // The routine for notifying the RDBSS about the completion status of the NetRoot creation // request. typedef VOID (NTAPI *PMRX_NETROOT_CALLBACK) ( IN OUT struct _MRX_CREATENETROOT_CONTEXT *pCreateContext ); // this routine allows the minirdr to specify the netrootname. NetRootName and RestOfName are set // to point to the appropriate places within FilePathName. SrvCall is used to find the lengthof the srvcallname. typedef VOID (NTAPI *PMRX_EXTRACT_NETROOT_NAME) ( IN PUNICODE_STRING FilePathName, IN PMRX_SRV_CALL SrvCall, OUT PUNICODE_STRING NetRootName, OUT PUNICODE_STRING RestOfName OPTIONAL ); // The resumption context for the RDBSS. 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; // the calldown from RDBSS to the mini rdr for creating a netroot. typedef NTSTATUS (NTAPI *PMRX_CREATE_V_NET_ROOT)( IN OUT PMRX_CREATENETROOT_CONTEXT pContext ); // the calldown for querying a net root state. typedef NTSTATUS (NTAPI *PMRX_UPDATE_NETROOT_STATE)( IN OUT PMRX_NET_ROOT pNetRoot ); // The routine for notifying the RDBSS about the completion status of the SrvCall creation // request. typedef VOID (NTAPI *PMRX_SRVCALL_CALLBACK) ( IN OUT struct _MRX_SRVCALL_CALLBACK_CONTEXT *pContext ); // The resumption context for the RDBSS. typedef struct _MRX_SRVCALL_CALLBACK_CONTEXT { struct _MRX_SRVCALLDOWN_STRUCTURE *SrvCalldownStructure; //could be computed ULONG CallbackContextOrdinal; PRDBSS_DEVICE_OBJECT RxDeviceObject; NTSTATUS Status; PVOID RecommunicateContext; } MRX_SRVCALL_CALLBACK_CONTEXT, *PMRX_SRVCALL_CALLBACK_CONTEXT; // The context passed from the RDBSS to the mini rdr for creating a server call. 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; // the calldown from the RDBSS to the mini rdr for creating a server call typedef NTSTATUS (NTAPI *PMRX_CREATE_SRVCALL)( IN OUT PMRX_SRV_CALL pSrvCall, IN OUT PMRX_SRVCALL_CALLBACK_CONTEXT SrvCallCallBackContext ); // the calldown from the RDBSS to the mini rdr for notifying the mini rdr's of the winner. typedef NTSTATUS (NTAPI *PMRX_SRVCALL_WINNER_NOTIFY)( IN OUT PMRX_SRV_CALL SrvCall, IN BOOLEAN ThisMinirdrIsTheWinner, IN OUT PVOID RecommunicateContext ); // // The prototypes for calldown routines relating to various file system operations // typedef VOID (NTAPI *PMRX_NEWSTATE_CALLDOWN) ( IN OUT PVOID Context ); typedef NTSTATUS (NTAPI *PMRX_DEALLOCATE_FOR_FCB) ( IN OUT PMRX_FCB pFcb ); typedef NTSTATUS (NTAPI *PMRX_DEALLOCATE_FOR_FOBX) ( IN OUT PMRX_FOBX pFobx ); typedef NTSTATUS (NTAPI *PMRX_IS_LOCK_REALIZABLE) ( IN OUT PMRX_FCB pFcb, IN PLARGE_INTEGER ByteOffset, IN PLARGE_INTEGER Length, IN ULONG LowIoLockFlags ); typedef NTSTATUS (NTAPI *PMRX_FORCECLOSED_CALLDOWN) ( IN OUT PMRX_SRV_OPEN pSrvOpen ); typedef NTSTATUS (NTAPI *PMRX_FINALIZE_SRVCALL_CALLDOWN) ( IN OUT PMRX_SRV_CALL pSrvCall, IN BOOLEAN Force ); typedef NTSTATUS (NTAPI *PMRX_FINALIZE_V_NET_ROOT_CALLDOWN) ( IN OUT PMRX_V_NET_ROOT pVirtualNetRoot, IN PBOOLEAN Force ); typedef NTSTATUS (NTAPI *PMRX_FINALIZE_NET_ROOT_CALLDOWN) ( IN OUT PMRX_NET_ROOT pNetRoot, IN PBOOLEAN Force ); typedef ULONG (NTAPI *PMRX_EXTENDFILE_CALLDOWN) ( IN OUT struct _RX_CONTEXT * RxContext, IN OUT PLARGE_INTEGER pNewFileSize, OUT PLARGE_INTEGER pNewAllocationSize ); typedef BOOLEAN (*PRX_LOCK_ENUMERATOR) ( IN OUT struct _MRX_SRV_OPEN_ * SrvOpen, IN OUT PVOID *ContinuationHandle, OUT PLARGE_INTEGER FileOffset, OUT PLARGE_INTEGER LockRange, OUT PBOOLEAN IsLockExclusive ); typedef NTSTATUS (NTAPI *PMRX_CHANGE_BUFFERING_STATE_CALLDOWN) ( IN OUT struct _RX_CONTEXT * RxContext, IN OUT struct _MRX_SRV_OPEN_ * SrvOpen, IN PVOID pMRxContext ); typedef NTSTATUS (NTAPI *PMRX_PREPARSE_NAME) ( IN OUT struct _RX_CONTEXT * RxContext, IN PUNICODE_STRING Name ); typedef NTSTATUS (NTAPI *PMRX_GET_CONNECTION_ID) ( IN OUT struct _RX_CONTEXT * RxContext, IN OUT struct _RX_CONNECTION_ID * UniqueId ); // // Buffering state/Policy management TBD // typedef enum _MINIRDR_BUFSTATE_COMMANDS { MRDRBUFSTCMD__COMMAND_FORCEPURGE0, MRDRBUFSTCMD__1, MRDRBUFSTCMD__2, MRDRBUFSTCMD__3, MRDRBUFSTCMD__4, MRDRBUFSTCMD__5, MRDRBUFSTCMD__6, MRDRBUFSTCMD__7, MRDRBUFSTCMD__8, MRDRBUFSTCMD__9, MRDRBUFSTCMD__10, MRDRBUFSTCMD__11, MRDRBUFSTCMD__12, MRDRBUFSTCMD__13, MRDRBUFSTCMD__14, MRDRBUFSTCMD__15, MRDRBUFSTCMD__16, MRDRBUFSTCMD__17, MRDRBUFSTCMD__18, MRDRBUFSTCMD__19, MRDRBUFSTCMD__20, MRDRBUFSTCMD__21, MRDRBUFSTCMD__22, MRDRBUFSTCMD__23, MRDRBUFSTCMD__24, MRDRBUFSTCMD__25, MRDRBUFSTCMD__26, MRDRBUFSTCMD__27, MRDRBUFSTCMD__28, MRDRBUFSTCMD__29, MRDRBUFSTCMD__30, MRDRBUFSTCMD__31, MRDRBUFSTCMD_MAXXX } MINIRDR_BUFSTATE_COMMANDS; #define RXMakeMRDRBUFSTCMD(x) ((ULONG)(1<