Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

344 lines
9.6 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. mrxglbl.h
  5. Abstract:
  6. The global include file for SMB mini redirector
  7. Author:
  8. Balan Sethu Raman (SethuR) - Created 2-March-95
  9. Revision History:
  10. --*/
  11. #ifndef _MRXGLBL_H_
  12. #define _MRXGLBL_H_
  13. #define SmbCeLog(x) \
  14. RxLog(x)
  15. //
  16. // the SMB protocol tree connections are identified by a Tree Id., each
  17. // file opened on a tree connection by a File Id. and each outstanding request
  18. // on that connection by a Multiplex Id.
  19. //
  20. typedef USHORT SMB_TREE_ID;
  21. typedef USHORT SMB_FILE_ID;
  22. typedef USHORT SMB_MPX_ID;
  23. //
  24. // Each user w.r.t a particular connection is identified by a User Id. and each
  25. // process on the client side is identified by a Process id.
  26. //
  27. typedef USHORT SMB_USER_ID;
  28. typedef USHORT SMB_PROCESS_ID;
  29. //
  30. // All exchanges are identified with a unique id. assigned on creation of the exchange
  31. // which is used to track it.
  32. //
  33. typedef ULONG SMB_EXCHANGE_ID;
  34. //
  35. // Of the fields in this context the domain name is initialized during
  36. // MRxSmbSetConfiguration. The others are initialized in init.c as
  37. // parameters read from the registry
  38. //
  39. typedef struct _SMBCE_CONTEXT_ {
  40. UNICODE_STRING DomainName;
  41. UNICODE_STRING ComputerName;
  42. UNICODE_STRING OperatingSystem;
  43. UNICODE_STRING LanmanType;
  44. UNICODE_STRING Transports;
  45. UNICODE_STRING ServersWithExtendedSessTimeout;
  46. } SMBCE_CONTEXT,*PSMBCE_CONTEXT;
  47. extern SMBCE_CONTEXT SmbCeContext;
  48. extern RXCE_ADDRESS_EVENT_HANDLER MRxSmbVctAddressEventHandler;
  49. extern RXCE_CONNECTION_EVENT_HANDLER MRxSmbVctConnectionEventHandler;
  50. extern PBYTE s_pNegotiateSmb;
  51. extern PBYTE s_pNegotiateSmbRemoteBoot;
  52. extern ULONG s_NegotiateSmbLength;
  53. extern PMDL s_pNegotiateSmbBuffer;
  54. extern PBYTE s_pEchoSmb;
  55. extern ULONG s_EchoSmbLength;
  56. extern PMDL s_pEchoSmbMdl;
  57. extern FAST_MUTEX MRxSmbSerializationMutex;
  58. extern BOOLEAN MRxSmbEnableCompression;
  59. extern BOOLEAN MRxSmbObeyBindingOrder;
  60. // Miscellanous definitions
  61. extern PBYTE MRxSmb_pPaddingData;
  62. #define SMBCE_PADDING_DATA_SIZE (32)
  63. typedef struct _MRXSMB_GLOBAL_PADDING {
  64. MDL Mdl;
  65. ULONG Pages[2]; //this can't possibly span more than two pages
  66. UCHAR Pad[SMBCE_PADDING_DATA_SIZE];
  67. } MRXSMB_GLOBAL_PADDING, *PMRXSMB_GLOBAL_PADDING;
  68. extern MRXSMB_GLOBAL_PADDING MrxSmbCeGlobalPadding;
  69. extern PEPROCESS RDBSSProcessPtr;
  70. extern PRDBSS_DEVICE_OBJECT MRxSmbDeviceObject;
  71. #define RxNetNameTable (*(MRxSmbDeviceObject->pRxNetNameTable))
  72. extern LONG MRxSmbNumberOfSrvOpens;
  73. extern PVOID MRxSmbPoRegistrationState;
  74. NTKERNELAPI
  75. PVOID
  76. PoRegisterSystemState (
  77. IN PVOID StateHandle,
  78. IN EXECUTION_STATE Flags
  79. );
  80. NTKERNELAPI
  81. VOID
  82. PoUnregisterSystemState (
  83. IN PVOID StateHandle
  84. );
  85. //
  86. // MRxSmbSecurityInitialized indicates whether MRxSmbInitializeSecurity
  87. // has been called.
  88. //
  89. extern BOOLEAN MRxSmbSecurityInitialized;
  90. //
  91. // MRxSmbBootedRemotely indicates that the machine did a remote boot.
  92. //
  93. extern BOOLEAN MRxSmbBootedRemotely;
  94. //
  95. // MRxSmbUseKernelSecurity indicates that the machine should use kernel mode security APIs
  96. // during this remote boot boot.
  97. //
  98. extern BOOLEAN MRxSmbUseKernelModeSecurity;
  99. #if defined(REMOTE_BOOT)
  100. extern BOOLEAN MRxSmbOplocksDisabledOnRemoteBootClients;
  101. #endif // defined(REMOTE_BOOT)
  102. //
  103. // These variables will, in the near future, be passed from the kernel to the
  104. // redirector to tell it which share is the remote boot share and how to log on
  105. // to the server.
  106. //
  107. extern PKEY_VALUE_PARTIAL_INFORMATION MRxSmbRemoteBootRootValue;
  108. extern PKEY_VALUE_PARTIAL_INFORMATION MRxSmbRemoteBootMachineDirectoryValue;
  109. extern UNICODE_STRING MRxSmbRemoteBootShare;
  110. extern UNICODE_STRING MRxSmbRemoteBootPath;
  111. extern UNICODE_STRING MRxSmbRemoteSetupPath;
  112. extern UNICODE_STRING MRxSmbRemoteBootMachineName;
  113. extern UNICODE_STRING MRxSmbRemoteBootMachinePassword;
  114. extern UNICODE_STRING MRxSmbRemoteBootMachineDomain;
  115. extern UCHAR MRxSmbRemoteBootMachineSid[RI_SECRET_SID_SIZE];
  116. extern RI_SECRET MRxSmbRemoteBootSecret;
  117. #if defined(REMOTE_BOOT)
  118. extern BOOLEAN MRxSmbRemoteBootSecretValid;
  119. extern BOOLEAN MRxSmbRemoteBootDoMachineLogon;
  120. extern BOOLEAN MRxSmbRemoteBootUsePassword2;
  121. #endif // defined(REMOTE_BOOT)
  122. #if defined(REMOTE_BOOT)
  123. typedef struct _RBR_PREFIX {
  124. UNICODE_PREFIX_TABLE_ENTRY TableEntry;
  125. UNICODE_STRING Prefix;
  126. BOOLEAN Redirect;
  127. } RBR_PREFIX, *PRBR_PREFIX;
  128. extern UNICODE_STRING MRxSmbRemoteBootRedirectionPrefix;
  129. extern UNICODE_PREFIX_TABLE MRxSmbRemoteBootRedirectionTable;
  130. #endif // defined(REMOTE_BOOT)
  131. #define MAXIMUM_PARTIAL_BUFFER_SIZE 65535 // Maximum size of a partial MDL
  132. #define MAXIMUM_SMB_BUFFER_SIZE 4356
  133. // The following scavenge interval is in seconds
  134. #define MRXSMB_V_NETROOT_CONTEXT_SCAVENGER_INTERVAL (40)
  135. // the following default interval for timed exchanges is in seconds
  136. #define MRXSMB_DEFAULT_TIMED_EXCHANGE_EXPIRY_TIME (60)
  137. //
  138. // The following are some defines for controling name cache behavior.
  139. // -- The max number of entries in a name cache before it will stop creating new
  140. // entries.
  141. //
  142. #define NAME_CACHE_NETROOT_MAX_ENTRIES 200
  143. //
  144. // -- The expiration life times for file not found and get file attributes
  145. // in seconds.
  146. //
  147. #define NAME_CACHE_OBJ_NAME_NOT_FOUND_LIFETIME 5
  148. #define NAME_CACHE_OBJ_GET_FILE_ATTRIB_LIFETIME 7
  149. //
  150. // -- Incrementing NameCacheGFAInvalidate invalidates the contents
  151. // of the GFA name cache.
  152. //
  153. // Code.Bug: These increments need to be added on paths where dirs can be
  154. // deleted/renamed.
  155. //
  156. // Code.Improvment: Currently this is rdr wide, an improvement
  157. // would be to make it per SRV_CALL. The same is true for file not found cache
  158. // which currently uses MRxSmbStatistics.SmbsReceived.LowPart for a cache entry
  159. // validation context. I.E. any received SMB invalidates the file not found cache.
  160. //
  161. extern ULONG NameCacheGFAInvalidate;
  162. //CODE.IMPROVEMENT this should be moved up AND used consistly throughout. since this is in terms
  163. // of IoBuildPartial it would be straightforward to find them all by
  164. // undeffing RxBuildPartialMdl
  165. #define RxBuildPartialMdlUsingOffset(SourceMdl,DestinationMdl,Offset,Length) \
  166. IoBuildPartialMdl(SourceMdl,\
  167. DestinationMdl,\
  168. (PBYTE)MmGetMdlVirtualAddress(SourceMdl)+Offset,\
  169. Length)
  170. #define RxBuildPaddingPartialMdl(DestinationMdl,Length) \
  171. RxBuildPartialMdlUsingOffset(&MrxSmbCeGlobalPadding.Mdl,DestinationMdl,0,Length)
  172. //we turn away async operations that are not wait by posting. if we can wait
  173. //then we turn off the sync flag so that things will just act synchronous
  174. #define TURN_BACK_ASYNCHRONOUS_OPERATIONS() { \
  175. if (FlagOn(RxContext->Flags,RX_CONTEXT_FLAG_ASYNC_OPERATION)) { \
  176. if (FlagOn(RxContext->Flags,RX_CONTEXT_FLAG_WAIT)) { \
  177. ClearFlag(RxContext->Flags,RX_CONTEXT_FLAG_ASYNC_OPERATION); \
  178. } else { \
  179. RxContext->PostRequest = TRUE; \
  180. return(RX_MAP_STATUS(PENDING)); \
  181. } \
  182. } \
  183. }
  184. typedef struct _MRXSMB_CONFIGURATION_DATA_ {
  185. ULONG NamedPipeDataCollectionTimeInterval;
  186. ULONG NamedPipeDataCollectionSize;
  187. ULONG MaximumNumberOfCommands;
  188. ULONG SessionTimeoutInterval;
  189. ULONG LockQuota;
  190. ULONG LockIncrement;
  191. ULONG MaximumLock;
  192. ULONG PipeIncrement;
  193. ULONG PipeMaximum;
  194. ULONG CachedFileTimeout;
  195. ULONG DormantFileTimeout;
  196. ULONG DormantFileLimit;
  197. ULONG NumberOfMailslotBuffers;
  198. ULONG MaximumNumberOfThreads;
  199. ULONG ConnectionTimeoutInterval;
  200. ULONG CharBufferSize;
  201. BOOLEAN UseOplocks;
  202. BOOLEAN UseUnlocksBehind;
  203. BOOLEAN UseCloseBehind;
  204. BOOLEAN BufferNamedPipes;
  205. BOOLEAN UseLockReadUnlock;
  206. BOOLEAN UtilizeNtCaching;
  207. BOOLEAN UseRawRead;
  208. BOOLEAN UseRawWrite;
  209. BOOLEAN UseEncryption;
  210. } MRXSMB_CONFIGURATION, *PMRXSMB_CONFIGURATION;
  211. extern MRXSMB_CONFIGURATION MRxSmbConfiguration;
  212. // this is to test long net roots using the smbminirdr (which doesn't actually have 'em)
  213. // don't turn this on..........
  214. //#define ZZZ_MODE 1
  215. //
  216. // Definitions for starting stopping theSMB mini redirector
  217. //
  218. typedef enum _MRXSMB_STATE_ {
  219. MRXSMB_STARTABLE,
  220. MRXSMB_START_IN_PROGRESS,
  221. MRXSMB_STARTED,
  222. MRXSMB_STOPPED
  223. } MRXSMB_STATE,*PMRXSMB_STATE;
  224. extern MRXSMB_STATE MRxSmbState;
  225. extern
  226. NTSTATUS
  227. MRxSmbInitializeSecurity (VOID);
  228. extern
  229. NTSTATUS
  230. MRxSmbUninitializeSecurity (VOID);
  231. extern
  232. NTSTATUS
  233. MRxSmbInitializeTransport(VOID);
  234. extern
  235. NTSTATUS
  236. MRxSmbUninitializeTransport(VOID);
  237. extern
  238. NTSTATUS
  239. MRxSmbRegisterForPnpNotifications();
  240. extern
  241. NTSTATUS
  242. MRxSmbDeregisterForPnpNotifications();
  243. extern NTSTATUS
  244. MRxSmbLogonSessionTerminationHandler(
  245. PLUID LogonId);
  246. extern NTSTATUS
  247. SmbCeEstablishConnection(
  248. IN PMRX_V_NET_ROOT pVNetRoot,
  249. IN PMRX_CREATENETROOT_CONTEXT pCreateNetRootContext,
  250. IN BOOLEAN fInitializeNetRoot);
  251. extern NTSTATUS
  252. SmbCeReconnect(
  253. IN PMRX_V_NET_ROOT pVNetRoot);
  254. NTSTATUS
  255. SmbCeGetComputerName(
  256. VOID
  257. );
  258. NTSTATUS
  259. SmbCeGetOperatingSystemInformation(
  260. VOID
  261. );
  262. #endif _MRXGLBL_H_
  263.