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.

570 lines
15 KiB

  1. /*++
  2. Copyright (c) 1989 - 1999 Microsoft Corporation
  3. Module Name:
  4. mrxprocs.h
  5. Abstract:
  6. The global include file for SMB mini redirector
  7. --*/
  8. #ifndef _MRXPROCS_H_
  9. #define _MRXPROCS_H_
  10. #define INCLUDE_SMB_ALL
  11. #include "cifs.h" // contains all things SMB
  12. #include "mrxglbl.h" // global data declarations/defines etc.
  13. #include "smbpoolt.h" // Pool tag definitions
  14. // If Count is not already aligned, then
  15. // round Count up to an even multiple of "Pow2". "Pow2" must be a power of 2.
  16. //
  17. // DWORD
  18. // ROUND_UP_COUNT(
  19. // IN DWORD Count,
  20. // IN DWORD Pow2
  21. // );
  22. #define ROUND_UP_COUNT(Count,Pow2) \
  23. ( ((Count)+(Pow2)-1) & (~(((LONG)(Pow2))-1)) )
  24. // LPVOID
  25. // ROUND_UP_POINTER(
  26. // IN LPVOID Ptr,
  27. // IN DWORD Pow2
  28. // );
  29. // If Ptr is not already aligned, then round it up until it is.
  30. #define ROUND_UP_POINTER(Ptr,Pow2) \
  31. ( (LPVOID) ( (((ULONG_PTR)(Ptr))+(Pow2)-1) & (~(((LONG)(Pow2))-1)) ) )
  32. #define SMBMRX_CONFIG_CURRENT_WINDOWS_VERSION \
  33. L"\\REGISTRY\\Machine\\Software\\Microsoft\\Windows Nt\\CurrentVersion"
  34. #define SMBMRX_CONFIG_OPERATING_SYSTEM \
  35. L"CurrentBuildNumber"
  36. #define SMBMRX_CONFIG_OPERATING_SYSTEM_VERSION \
  37. L"CurrentVersion"
  38. #define SMBMRX_CONFIG_OPERATING_SYSTEM_NAME \
  39. L"Windows 2000 "
  40. #define SMBMRX_MINIRDR_PARAMETERS \
  41. L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\SmbMRx\\Parameters"
  42. #define EVENTLOG_MRXSMB_PARAMETERS \
  43. L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\EventLog\\System\\SmbMRx"
  44. //mini's does use these
  45. #undef RxCaptureRequestPacket
  46. #undef RxCaptureParamBlock
  47. //
  48. // A pointer to an instance of MRX_SMB_FCB is stored in the context field of
  49. // MRX_FCBs handled by the SMB mini rdr.
  50. //
  51. typedef struct _MRX_SMB_FCB_ {
  52. //M for Minirdr
  53. ULONG MFlags;
  54. USHORT WriteOnlySrvOpenCount;
  55. SMB_TREE_ID Tid;
  56. USHORT LastOplockLevel;
  57. ULONG dwFileAttributes;
  58. LARGE_INTEGER ExpireTime; // It's time for get attributs from server
  59. } MRX_SMB_FCB, *PMRX_SMB_FCB;
  60. #define AttributesSyncInterval 10 // Number of seconds before local file attributes expired
  61. #define MRxSmbGetFcbExtension(pFcb) \
  62. (((pFcb) == NULL) ? NULL : (PMRX_SMB_FCB)((pFcb)->Context))
  63. #define SMB_FCB_FLAG_SENT_DISPOSITION_INFO 0x00000001
  64. #define SMB_FCB_FLAG_WRITES_PERFORMED 0x00000002
  65. #define SMB_FCB_FLAG_LONG_FILE_NAME 0x00000004
  66. typedef struct _SMBPSE_FILEINFO_BUNDLE {
  67. FILE_BASIC_INFORMATION Basic;
  68. FILE_STANDARD_INFORMATION Standard;
  69. } SMBPSE_FILEINFO_BUNDLE, *PSMBPSE_FILEINFO_BUNDLE;
  70. typedef struct _MRXSMB_CREATE_PARAMETERS {
  71. ULONG Pid;
  72. UCHAR SecurityFlags;
  73. } MRXSMB_CREATE_PARAMETERS, *PMRXSMB_CREATE_PARAMETERS;
  74. typedef struct _MRX_SMB_DEFERRED_OPEN_CONTEXT {
  75. NT_CREATE_PARAMETERS NtCreateParameters; // a copy of the createparameters
  76. ULONG RxContextFlags;
  77. MRXSMB_CREATE_PARAMETERS SmbCp;
  78. USHORT RxContextCreateFlags;
  79. } MRX_SMB_DEFERRED_OPEN_CONTEXT, *PMRX_SMB_DEFERRED_OPEN_CONTEXT;
  80. //
  81. // A pointer to an instance of MRX_SMB_SRV_OPEN is stored in the context fields
  82. // of MRX_SRV_OPEN handled by the SMB mini rdr. This encapsulates the FID used
  83. // to identify open files/directories in the SMB protocol.
  84. typedef struct _MRX_SMB_SRV_OPEN_ {
  85. ULONG Flags;
  86. ULONG Version;
  87. SMB_FILE_ID Fid;
  88. UCHAR OplockLevel;
  89. ACCESS_MASK MaximalAccessRights;
  90. ACCESS_MASK GuestMaximalAccessRights;
  91. PMRX_SMB_DEFERRED_OPEN_CONTEXT DeferredOpenContext;
  92. // the following fields are used for to save the results of a GetFileAttributes
  93. // and to validate whether the fields should be reused or not
  94. ULONG RxContextSerialNumber;
  95. LARGE_INTEGER TimeStampInTicks;
  96. SMBPSE_FILEINFO_BUNDLE FileInfo;
  97. BOOLEAN NumOfSrvOpenAdded; // debug only
  98. BOOLEAN DeferredOpenInProgress;
  99. LIST_ENTRY DeferredOpenSyncContexts;
  100. USHORT FileStatusFlags;
  101. BOOLEAN IsNtCreate;
  102. } MRX_SMB_SRV_OPEN, *PMRX_SMB_SRV_OPEN;
  103. typedef struct _DEFERRED_OPEN_SYNC_CONTEXT_ {
  104. LIST_ENTRY ListHead;
  105. PRX_CONTEXT RxContext;
  106. NTSTATUS Status;
  107. } DEFERRED_OPEN_SYNC_CONTEXT, *PDEFERRED_OPEN_SYNC_CONTEXT;
  108. typedef struct _PAGING_FILE_CONTEXT_ {
  109. PMRX_SRV_OPEN pSrvOpen;
  110. PMRX_FOBX pFobx;
  111. // The following LIST_ENTRY is used for two purposes.
  112. // while a reconnect is not in progress it is threaded together to maintain
  113. // a list of all SRV_OPEN instances corresponding to paging files. Note
  114. // that this is not done for non paging files.
  115. // When a reconnect is in progress the field is used to ensure that
  116. // there is atmost one reconnect request in progress for any given SRV_OPEN
  117. // instance at the server
  118. // All manipulation of this list is done while owning the SmbCeSpinLock,
  119. LIST_ENTRY ContextList;
  120. } PAGING_FILE_CONTEXT, *PPAGING_FILE_CONTEXT;
  121. #define SMB_SRVOPEN_FLAG_NOT_REALLY_OPEN 0x00000001
  122. #define SMB_SRVOPEN_FLAG_SUCCESSFUL_OPEN 0x00000002
  123. #define SMB_SRVOPEN_FLAG_CANT_GETATTRIBS 0x00000004
  124. #define SMB_SRVOPEN_FLAG_DEFERRED_OPEN 0x00000008
  125. #define SMB_SRVOPEN_FLAG_WRITE_ONLY_HANDLE 0x00000010
  126. #define SMB_SRVOPEN_FLAG_FILE_DELETED 0x00000100
  127. #define SMB_SRVOPEN_FLAG_LOCAL_OPEN 0x00000200
  128. #define MRxSmbGetSrvOpenExtension(pSrvOpen) \
  129. (((pSrvOpen) == NULL) ? NULL : (PMRX_SMB_SRV_OPEN)((pSrvOpen)->Context))
  130. typedef USHORT SMB_SEARCH_HANDLE;
  131. typedef struct _MRX_SMB_DIRECTORY_RESUME_INFO {
  132. REQ_FIND_NEXT2 FindNext2_Request;
  133. //now we have to include space for a resume name........
  134. WCHAR NameSpace[MAXIMUM_FILENAME_LENGTH+1]; //trailing null
  135. USHORT ParametersLength;
  136. } MRX_SMB_DIRECTORY_RESUME_INFO, *PMRX_SMB_DIRECTORY_RESUME_INFO;
  137. // A pointer to an instance of MRX_SMB_FOBX is stored in the context field
  138. // of MRX_FOBXs handled by the SMB mini rdr. Depending upon the file type
  139. // i.e., file or directory the appropriate context information is stored.
  140. typedef struct _MRX_SMB_FOBX_ {
  141. union {
  142. struct {
  143. struct {
  144. SMB_SEARCH_HANDLE SearchHandle;
  145. ULONG Version;
  146. union {
  147. //the close code will try to free this!
  148. PMRX_SMB_DIRECTORY_RESUME_INFO ResumeInfo;
  149. PSMB_RESUME_KEY CoreResumeKey;
  150. };
  151. struct {
  152. //unaligned direntry sidebuffering params
  153. PBYTE UnalignedDirEntrySideBuffer; //close will try to free this too
  154. ULONG SerialNumber;
  155. BOOLEAN EndOfSearchReached;
  156. BOOLEAN IsUnicode;
  157. BOOLEAN IsNonNtT2Find;
  158. ULONG FilesReturned;
  159. ULONG EntryOffset;
  160. ULONG TotalDataBytesReturned;
  161. //ULONG ReturnedEntryOffset;
  162. };
  163. };
  164. NTSTATUS ErrorStatus;
  165. USHORT Flags;
  166. USHORT FileNameOffset;
  167. USHORT FileNameLengthOffset;
  168. BOOLEAN WildCardsFound;
  169. } Enumeration;
  170. };
  171. union {
  172. struct {
  173. //dont do this yet
  174. //ULONG MaximumReadBufferLength;
  175. //ULONG MaximumWriteBufferLength;
  176. USHORT Flags;
  177. } File;
  178. };
  179. } MRX_SMB_FOBX, *PMRX_SMB_FOBX;
  180. #define MRxSmbGetFileObjectExtension(pFobx) \
  181. (((pFobx) == NULL) ? NULL : (PMRX_SMB_FOBX)((pFobx)->Context))
  182. #define SMBFOBX_ENUMFLAG_SEARCH_NOT_THE_FIRST 0x0001
  183. #define SMBFOBX_ENUMFLAG_SEARCH_HANDLE_OPEN 0x0002
  184. #define SMBFOBX_ENUMFLAG_FAST_RESUME 0x0004
  185. #define SMBFOBX_ENUMFLAG_CORE_SEARCH_IN_PROGRESS 0x0008
  186. #define SMBFOBX_ENUMFLAG_LOUD_FINALIZE 0x0010
  187. #define SMBFOBX_ENUMFLAG_READ_FROM_CACHE 0x0020
  188. #define SMBFOBX_ENUMFLAG_NO_WILDCARD 0x0200
  189. typedef
  190. NTSTATUS
  191. (NTAPI *PMRXSMB_CANCEL_ROUTINE) (
  192. PRX_CONTEXT pRxContext);
  193. // The RX_CONTEXT instance has four fields ( ULONG's ) provided by the wrapper
  194. // which can be used by the mini rdr to store its context. This is used by
  195. // the SMB mini rdr to identify the parameters for request cancellation
  196. typedef struct _MRXSMB_RX_CONTEXT {
  197. PMRXSMB_CANCEL_ROUTINE pCancelRoutine;
  198. PVOID pCancelContext;
  199. struct _SMB_EXCHANGE *pExchange;
  200. struct _SMBSTUFFER_BUFFER_STATE *pStufferState;
  201. } MRXSMB_RX_CONTEXT, *PMRXSMB_RX_CONTEXT;
  202. #define MRxSmbGetMinirdrContext(pRxContext) \
  203. ((PMRXSMB_RX_CONTEXT)(&(pRxContext)->MRxContext[0]))
  204. #define MRxSmbMakeSrvOpenKey(Tid,Fid) \
  205. ULongToPtr(((ULONG)(Tid) << 16) | (ULONG)(Fid))
  206. typedef struct _SECURITY_RESPONSE_CONTEXT {
  207. struct {
  208. PVOID pResponseBuffer;
  209. } LanmanSetup;
  210. } SECURITY_RESPONSE_CONTEXT,*PSECURITY_RESPONSE_CONTEXT;
  211. //
  212. // forward declarations for all dispatch vector methods.
  213. //
  214. extern NTSTATUS
  215. MRxSmbStart (
  216. IN OUT struct _RX_CONTEXT * RxContext,
  217. IN OUT PRDBSS_DEVICE_OBJECT RxDeviceObject
  218. );
  219. extern NTSTATUS
  220. MRxSmbStop (
  221. IN OUT struct _RX_CONTEXT * RxContext,
  222. IN OUT PRDBSS_DEVICE_OBJECT RxDeviceObject
  223. );
  224. extern NTSTATUS
  225. MRxSmbMinirdrControl (
  226. IN OUT PRX_CONTEXT RxContext,
  227. IN OUT PVOID pContext,
  228. IN OUT PUCHAR SharedBuffer,
  229. IN ULONG InputBufferLength,
  230. IN ULONG OutputBufferLength,
  231. OUT PULONG CopyBackLength
  232. );
  233. extern NTSTATUS
  234. MRxSmbDevFcb (
  235. IN OUT PRX_CONTEXT RxContext
  236. );
  237. extern NTSTATUS
  238. MRxSmbDevFcbXXXControlFile (
  239. IN OUT PRX_CONTEXT RxContext
  240. );
  241. extern NTSTATUS
  242. MRxSmbCreate (
  243. IN OUT PRX_CONTEXT RxContext
  244. );
  245. extern NTSTATUS
  246. MRxSmbCollapseOpen (
  247. IN OUT PRX_CONTEXT RxContext
  248. );
  249. extern NTSTATUS
  250. MRxSmbShouldTryToCollapseThisOpen (
  251. IN OUT PRX_CONTEXT RxContext
  252. );
  253. extern NTSTATUS
  254. MRxSmbRead (
  255. IN OUT PRX_CONTEXT RxContext
  256. );
  257. extern NTSTATUS
  258. MRxSmbWrite (
  259. IN OUT PRX_CONTEXT RxContext
  260. );
  261. extern NTSTATUS
  262. MRxSmbLocks(
  263. IN OUT PRX_CONTEXT RxContext
  264. );
  265. extern NTSTATUS
  266. MRxSmbFlush(
  267. IN OUT PRX_CONTEXT RxContext
  268. );
  269. extern NTSTATUS
  270. MRxSmbFsCtl(
  271. IN OUT PRX_CONTEXT RxContext
  272. );
  273. NTSTATUS
  274. MRxSmbIoCtl(
  275. IN OUT PRX_CONTEXT RxContext
  276. );
  277. extern NTSTATUS
  278. MRxSmbNotifyChangeDirectory(
  279. IN OUT PRX_CONTEXT RxContext
  280. );
  281. extern NTSTATUS
  282. MRxSmbComputeNewBufferingState(
  283. IN OUT PMRX_SRV_OPEN pSrvOpen,
  284. IN PVOID pMRxContext,
  285. OUT ULONG *pNewBufferingState);
  286. extern NTSTATUS
  287. MRxSmbFlush (
  288. IN OUT PRX_CONTEXT RxContext
  289. );
  290. extern NTSTATUS
  291. MRxSmbCloseWithDelete (
  292. IN OUT PRX_CONTEXT RxContext
  293. );
  294. extern NTSTATUS
  295. MRxSmbZeroExtend (
  296. IN OUT PRX_CONTEXT RxContext
  297. );
  298. extern NTSTATUS
  299. MRxSmbTruncate (
  300. IN OUT PRX_CONTEXT RxContext
  301. );
  302. extern NTSTATUS
  303. MRxSmbCleanupFobx (
  304. IN OUT PRX_CONTEXT RxContext
  305. );
  306. extern NTSTATUS
  307. MRxSmbCloseSrvOpen (
  308. IN OUT PRX_CONTEXT RxContext
  309. );
  310. extern NTSTATUS
  311. MRxSmbClosedSrvOpenTimeOut (
  312. IN OUT PRX_CONTEXT RxContext
  313. );
  314. extern NTSTATUS
  315. MRxSmbQueryDirectory (
  316. IN OUT PRX_CONTEXT RxContext
  317. );
  318. extern NTSTATUS
  319. MRxSmbIsValidDirectory (
  320. IN OUT PRX_CONTEXT RxContext,
  321. IN PUNICODE_STRING DirectoryName
  322. );
  323. extern NTSTATUS
  324. MRxSmbQueryEaInformation (
  325. IN OUT PRX_CONTEXT RxContext
  326. );
  327. extern NTSTATUS
  328. MRxSmbSetEaInformation (
  329. IN OUT struct _RX_CONTEXT * RxContext
  330. );
  331. extern NTSTATUS
  332. MRxSmbQuerySecurityInformation (
  333. IN OUT PRX_CONTEXT RxContext
  334. );
  335. extern NTSTATUS
  336. MRxSmbSetSecurityInformation (
  337. IN OUT struct _RX_CONTEXT * RxContext
  338. );
  339. extern NTSTATUS
  340. MRxSmbQueryVolumeInformation (
  341. IN OUT PRX_CONTEXT RxContext
  342. );
  343. extern NTSTATUS
  344. MRxSmbSetVolumeInformation (
  345. IN OUT PRX_CONTEXT RxContext
  346. );
  347. extern NTSTATUS
  348. MRxSmbLowIOSubmit (
  349. IN OUT PRX_CONTEXT RxContext
  350. );
  351. extern NTSTATUS
  352. MRxSmbCreateVNetRoot(
  353. IN OUT PMRX_CREATENETROOT_CONTEXT pContext
  354. );
  355. extern NTSTATUS
  356. MRxSmbFinalizeVNetRoot(
  357. IN OUT PMRX_V_NET_ROOT pVirtualNetRoot,
  358. IN PBOOLEAN ForceDisconnect);
  359. extern NTSTATUS
  360. MRxSmbFinalizeNetRoot(
  361. IN OUT PMRX_NET_ROOT pNetRoot,
  362. IN PBOOLEAN ForceDisconnect);
  363. extern NTSTATUS
  364. MRxSmbUpdateNetRootState(
  365. IN PMRX_NET_ROOT pNetRoot);
  366. VOID
  367. MRxSmbExtractNetRootName(
  368. IN PUNICODE_STRING FilePathName,
  369. IN PMRX_SRV_CALL SrvCall,
  370. OUT PUNICODE_STRING NetRootName,
  371. OUT PUNICODE_STRING RestOfName OPTIONAL
  372. );
  373. extern NTSTATUS
  374. MRxSmbCreateSrvCall(
  375. PMRX_SRV_CALL pSrvCall,
  376. PMRX_SRVCALL_CALLBACK_CONTEXT pCallbackContext);
  377. extern NTSTATUS
  378. MRxSmbFinalizeSrvCall(
  379. PMRX_SRV_CALL pSrvCall,
  380. BOOLEAN Force);
  381. extern NTSTATUS
  382. MRxSmbSrvCallWinnerNotify(
  383. IN OUT PMRX_SRV_CALL pSrvCall,
  384. IN BOOLEAN ThisMinirdrIsTheWinner,
  385. IN OUT PVOID pSrvCallContext);
  386. extern NTSTATUS
  387. MRxSmbQueryFileInformation (
  388. IN OUT PRX_CONTEXT RxContext
  389. );
  390. extern NTSTATUS
  391. MRxSmbSetFileInformation (
  392. IN OUT PRX_CONTEXT RxContext
  393. );
  394. NTSTATUS
  395. MRxSmbSetFileInformationAtCleanup(
  396. IN OUT PRX_CONTEXT RxContext
  397. );
  398. NTSTATUS
  399. MRxSmbDeallocateForFcb (
  400. IN OUT PMRX_FCB pFcb
  401. );
  402. NTSTATUS
  403. MRxSmbDeallocateForFobx (
  404. IN OUT PMRX_FOBX pFobx
  405. );
  406. NTSTATUS
  407. MRxSmbIsLockRealizable (
  408. IN OUT PMRX_FCB pFcb,
  409. IN PLARGE_INTEGER ByteOffset,
  410. IN PLARGE_INTEGER Length,
  411. IN ULONG LowIoLockFlags
  412. );
  413. extern NTSTATUS
  414. MRxSmbForcedClose (
  415. IN OUT PMRX_SRV_OPEN SrvOpen
  416. );
  417. extern NTSTATUS
  418. MRxSmbExtendForCache (
  419. IN OUT struct _RX_CONTEXT * RxContext,
  420. IN OUT PLARGE_INTEGER pNewFileSize,
  421. OUT PLARGE_INTEGER pNewAllocationSize
  422. );
  423. extern NTSTATUS
  424. MRxSmbExtendForNonCache (
  425. IN OUT struct _RX_CONTEXT * RxContext,
  426. IN OUT PLARGE_INTEGER pNewFileSize,
  427. OUT PLARGE_INTEGER pNewAllocationSize
  428. );
  429. extern NTSTATUS
  430. MRxSmbCompleteBufferingStateChangeRequest (
  431. IN OUT PRX_CONTEXT RxContext,
  432. IN OUT PMRX_SRV_OPEN SrvOpen,
  433. IN PVOID pContext
  434. );
  435. NTSTATUS
  436. MRxSmbGetFsAttributesFromNetRoot(
  437. IN OUT PRX_CONTEXT RxContext
  438. );
  439. #include "smbutils.h"
  440. #include "smbce.h"
  441. #include "midatlas.h"
  442. #include "smbcedbp.h"
  443. #include "smbcedb.h"
  444. #include "smbxchng.h"
  445. #include "stuffer.h"
  446. #include "smbpse.h"
  447. #include "smbcaps.h"
  448. #include "transprt.h"
  449. #include "transact.h"
  450. #include "recursvc.h" // recurrent service definitions
  451. #include "smbadmin.h"
  452. #include "smbprocs.h" // crossreferenced routines
  453. #include "smbea.h"
  454. #endif // _MRXPROCS_H_
  455.