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.

730 lines
24 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. srvfsctl.h
  5. Abstract:
  6. This module defines I/O control codes and structures for the File
  7. System Driver of the LAN Manager server.
  8. Author:
  9. David Treadwell (davidtr) 22-May-1990
  10. Revision History:
  11. --*/
  12. #ifndef _SRVFSCTL_
  13. #define _SRVFSCTL_
  14. //
  15. // The name of the server device.
  16. //
  17. #define SERVER_DEVICE_NAME TEXT("\\Device\\LanmanServer")
  18. //
  19. // IRP control codes used to send requests to the server. These are
  20. // used as parameters to NtFsControlFile, and may be found in
  21. // Irp->Parameters.FsControl.FsControlCode in the server dispatch
  22. // routine.
  23. //
  24. // Note that the low two bits of this code indicate the "method" in
  25. // which the IO system uses the buffers passed by the user to
  26. // NtFsControlFile. We use method 0--normal, buffered output (not
  27. // DMA)--for non-API requests, and method 3--"neither" IO--for API
  28. // requests that get processed in the server FSD. For the APIs
  29. // that are processed in the server FSP, use method 0.
  30. //
  31. // !!! Add more as necessary.
  32. #define FSCTL_SRV_BASE FILE_DEVICE_NETWORK_FILE_SYSTEM
  33. #define SRV_API_METHOD 0x800
  34. #define SRV_API_INDEX(code) ((code>>2)&0x7FF)
  35. #define _SRV_CONTROL_CODE(request,method) \
  36. CTL_CODE( FSCTL_SRV_BASE, request, method, FILE_READ_ACCESS )
  37. #define _SRV_CONTROL_CODE_ACCESS(request,method,access) \
  38. CTL_CODE( FSCTL_SRV_BASE, request, method, access )
  39. #define _SRV_API_CONTROL_CODE(request) \
  40. CTL_CODE( FSCTL_SRV_BASE, request | SRV_API_METHOD, METHOD_NEITHER, FILE_READ_ACCESS)
  41. //
  42. // Standard FSCTLs.
  43. //
  44. #define FSCTL_SRV_STARTUP _SRV_CONTROL_CODE( 0, METHOD_NEITHER )
  45. #define FSCTL_SRV_SHUTDOWN _SRV_CONTROL_CODE( 1, METHOD_NEITHER )
  46. #define FSCTL_SRV_CLEAR_STATISTICS _SRV_CONTROL_CODE_ACCESS( 2, METHOD_BUFFERED, FILE_ANY_ACCESS )
  47. #define FSCTL_SRV_GET_STATISTICS _SRV_CONTROL_CODE_ACCESS( 3, METHOD_BUFFERED, FILE_ANY_ACCESS )
  48. #define FSCTL_SRV_SET_DEBUG _SRV_CONTROL_CODE( 4, METHOD_BUFFERED )
  49. #define FSCTL_SRV_XACTSRV_CONNECT _SRV_CONTROL_CODE( 5, METHOD_BUFFERED )
  50. #define FSCTL_SRV_SEND_DATAGRAM _SRV_CONTROL_CODE( 6, METHOD_NEITHER )
  51. #define FSCTL_SRV_SET_PASSWORD_SERVER _SRV_CONTROL_CODE( 7, METHOD_BUFFERED )
  52. #define FSCTL_SRV_START_SMBTRACE _SRV_CONTROL_CODE( 8, METHOD_BUFFERED )
  53. #define FSCTL_SRV_SMBTRACE_FREE_SMB _SRV_CONTROL_CODE( 9, METHOD_BUFFERED )
  54. #define FSCTL_SRV_END_SMBTRACE _SRV_CONTROL_CODE( 10, METHOD_BUFFERED )
  55. #define FSCTL_SRV_QUERY_CONNECTIONS _SRV_CONTROL_CODE( 11, METHOD_BUFFERED )
  56. #define FSCTL_SRV_PAUSE _SRV_CONTROL_CODE( 12, METHOD_NEITHER )
  57. #define FSCTL_SRV_CONTINUE _SRV_CONTROL_CODE( 13, METHOD_NEITHER )
  58. #define FSCTL_SRV_GET_CHALLENGE _SRV_CONTROL_CODE( 14, METHOD_BUFFERED )
  59. #define FSCTL_SRV_GET_DEBUG_STATISTICS _SRV_CONTROL_CODE_ACCESS( 15, METHOD_BUFFERED, FILE_ANY_ACCESS )
  60. #define FSCTL_SRV_XACTSRV_DISCONNECT _SRV_CONTROL_CODE( 16, METHOD_BUFFERED )
  61. #define FSCTL_SRV_REGISTRY_CHANGE _SRV_CONTROL_CODE( 17, METHOD_NEITHER )
  62. #define FSCTL_SRV_GET_QUEUE_STATISTICS _SRV_CONTROL_CODE_ACCESS( 18, METHOD_BUFFERED, FILE_ANY_ACCESS )
  63. #define FSCTL_SRV_SHARE_STATE_CHANGE _SRV_CONTROL_CODE( 19, METHOD_BUFFERED )
  64. #define FSCTL_SRV_BEGIN_PNP_NOTIFICATIONS _SRV_CONTROL_CODE(20, METHOD_BUFFERED )
  65. #define FSCTL_SRV_CHANGE_DOMAIN_NAME _SRV_CONTROL_CODE( 22, METHOD_BUFFERED )
  66. #define FSCTL_SRV_INTERNAL_TEST_REAUTH _SRV_CONTROL_CODE( 23, METHOD_BUFFERED )
  67. #define FSCTL_SRV_CHANGE_DNS_DOMAIN_NAME _SRV_CONTROL_CODE( 24, METHOD_BUFFERED )
  68. #define FSCTL_SRV_ENUMERATE_SNAPSHOTS _SRV_CONTROL_CODE( 25, METHOD_BUFFERED )
  69. // lwio ioctl's
  70. #define FSCTL_SRV_REQUEST_RESUME_KEY _SRV_CONTROL_CODE_ACCESS( 30, METHOD_BUFFERED, FILE_ANY_ACCESS )
  71. #define FSCTL_SRV_REQUEST_HANDLE_DUP _SRV_CONTROL_CODE_ACCESS( 31, METHOD_BUFFERED, FILE_WRITE_ACCESS )
  72. #define FSCTL_SRV_SET_LWIO_CONTEXT _SRV_CONTROL_CODE_ACCESS( 32, METHOD_BUFFERED, FILE_WRITE_ACCESS )
  73. #define FSCTL_SRV_QUERY_LWIO_CONTEXT _SRV_CONTROL_CODE_ACCESS( 33, METHOD_BUFFERED, FILE_WRITE_ACCESS )
  74. // DFS ioctl's
  75. #define FSCTL_DFS_UPDATE_SHARE_TABLE _SRV_CONTROL_CODE_ACCESS( 34, METHOD_BUFFERED, FILE_WRITE_ACCESS )
  76. #define FSCTL_DFS_RELEASE_SHARE_TABLE _SRV_CONTROL_CODE_ACCESS( 35, METHOD_BUFFERED, FILE_WRITE_ACCESS )
  77. //
  78. // The following FSCTL can be issued by a kernel driver to hook into the server
  79. // for accelerated direct host IPX performance. A pointer to an SRV_IPX_SMART_CARD
  80. // structure is given for the START fsctl as the InputBuffer.
  81. #define FSCTL_SRV_IPX_SMART_CARD_START _SRV_CONTROL_CODE( 21, METHOD_NEITHER )
  82. //
  83. // API FSCTLs.
  84. //
  85. // *** The order of these must match the order of API processors in
  86. // the SrvApiDispatchTable jump table defined in ntos\srv\srvdata.c!
  87. #define FSCTL_SRV_NET_CONNECTION_ENUM _SRV_API_CONTROL_CODE( 0 )
  88. #define FSCTL_SRV_NET_FILE_CLOSE _SRV_API_CONTROL_CODE( 1 )
  89. #define FSCTL_SRV_NET_FILE_ENUM _SRV_API_CONTROL_CODE( 2 )
  90. #define FSCTL_SRV_NET_SERVER_DISK_ENUM _SRV_API_CONTROL_CODE( 3 )
  91. #define FSCTL_SRV_NET_SERVER_SET_INFO _SRV_API_CONTROL_CODE( 4 )
  92. #define FSCTL_SRV_NET_SERVER_XPORT_ADD _SRV_API_CONTROL_CODE( 5 )
  93. #define FSCTL_SRV_NET_SERVER_XPORT_DEL _SRV_API_CONTROL_CODE( 6 )
  94. #define FSCTL_SRV_NET_SERVER_XPORT_ENUM _SRV_API_CONTROL_CODE( 7 )
  95. #define FSCTL_SRV_NET_SESSION_DEL _SRV_API_CONTROL_CODE( 8 )
  96. #define FSCTL_SRV_NET_SESSION_ENUM _SRV_API_CONTROL_CODE( 9 )
  97. #define FSCTL_SRV_NET_SHARE_ADD _SRV_API_CONTROL_CODE( 10 )
  98. #define FSCTL_SRV_NET_SHARE_DEL _SRV_API_CONTROL_CODE( 11 )
  99. #define FSCTL_SRV_NET_SHARE_ENUM _SRV_API_CONTROL_CODE( 12 )
  100. #define FSCTL_SRV_NET_SHARE_SET_INFO _SRV_API_CONTROL_CODE( 13 )
  101. #define FSCTL_SRV_NET_STATISTICS_GET _SRV_API_CONTROL_CODE( 14 )
  102. #define FSCTL_SRV_MAX_API_CODE FSCTL_SRV_NET_STATISTICS_GET
  103. //
  104. // Startup information level
  105. //
  106. #define SS_STARTUP_LEVEL -1L
  107. #ifdef INCLUDE_SRV_IPX_SMART_CARD_INTERFACE
  108. //
  109. // Structure passed to the srv via the FSCTL_SRV_IPX_SMART_CARD_START call by an
  110. // intelligent direct host IPX card. The Smart card fills in its own
  111. // Open, Close, Read, and DeRegister entry points - which the server
  112. // calls at the appropriate times. The server fills in its own
  113. // ReadComplete entry point which the smart card calls when it is done
  114. // transferring the data to the client.
  115. //
  116. typedef struct {
  117. //
  118. // This routine is called by the server when it is opening a file on
  119. // behalf of a direct host IPX client. It gives the smart card a chance
  120. // to decide it it wants to help with file access. If the smart card is
  121. // interested, it should return TRUE and set SmartCardContext to a
  122. // non-zero value of its choice.
  123. //
  124. BOOLEAN (* Open)(
  125. IN PVOID SmbHeader, // Points to request PNT_SMB_HEADER
  126. IN PFILE_OBJECT FileObject, // FileObject opened by the client
  127. IN PUNICODE_STRING FileName, // Name of the file opened by the client
  128. IN PTDI_ADDRESS_IPX IpxAddress, // Address of the client
  129. IN ULONG Flags, // FO_CACHE_SUPPORTED (for now)
  130. OUT PVOID *SmartCardContext // Context value returned by this routine
  131. );
  132. //
  133. // This is called by the server when the file is being closed. The context
  134. // value received at Open time is passed to this routine.
  135. //
  136. VOID ( * Close )(
  137. IN PVOID SmartCardContext // Same context returned by Open() above
  138. );
  139. //
  140. // This is called by the server to see if the smart card wishes to handle the
  141. // client's read request. If the card is handling the read, it should return
  142. // TRUE and the server will discontinue processing the read. When the card is
  143. // finished handling the read, it must call ReadComplete (below) to inform the
  144. // server. If Read returns FALSE, the server handles the read as usual.
  145. //
  146. BOOLEAN ( * Read )(
  147. IN PVOID SmbHeader, // Points to request PNT_SMB_HEADER
  148. IN PVOID SmartCardContext, // Same context returned by Open() above
  149. IN ULONG Key, // Key value needed to read through locks
  150. IN PVOID SrvContext // Opaque value provided by the server
  151. );
  152. //
  153. // This is the server's entry point which the smart card must call when it is
  154. // finished handling the Read request (above).
  155. //
  156. VOID ( * ReadComplete )(
  157. IN PVOID SrvContext, // Same as SrvContext in Read() above
  158. IN PFILE_OBJECT FileObject, // Client FileObject to which this applies
  159. IN PMDL Mdl OPTIONAL, // Mdl smart card is now finished with
  160. IN ULONG Length // Length of data indicated by the MDL
  161. );
  162. //
  163. // This is called by the server when the server wishes to disconnect from the
  164. // card. Once this returns, the card should not call back into the server.
  165. //
  166. VOID ( *DeRegister )(
  167. VOID
  168. );
  169. } SRV_IPX_SMART_CARD, *PSRV_IPX_SMART_CARD;
  170. #endif
  171. //
  172. // SMB_STATISTICS holds the count of SMBs and total turn around for a
  173. // class of SMBs. For example, a single SMB_STATISTIC structure could
  174. // hold information about all read SMBs: Read, ReadAndX, ReadRaw,
  175. // and ReadMultiplexed.
  176. //
  177. typedef struct _SMB_STATISTICS {
  178. LARGE_INTEGER TotalTurnaroundTime;
  179. ULONG SmbCount;
  180. } SMB_STATISTICS, *PSMB_STATISTICS;
  181. //
  182. // Used to record the number of times something happened and some
  183. // pertinent time measure.
  184. //
  185. typedef struct _SRV_TIMED_COUNTER {
  186. LARGE_INTEGER Time;
  187. ULONG Count;
  188. } SRV_TIMED_COUNTER, *PSRV_TIMED_COUNTER;
  189. //
  190. // SRV_POOL_STATISTICS is used for tracking server pool usage, paged and
  191. // nonpaged. It is only enabled with SRVDBG2 and is controlled in the
  192. // server module heapmgr.c.
  193. //
  194. typedef struct _SRV_POOL_STATISTICS {
  195. ULONG TotalBlocksAllocated;
  196. ULONG TotalBytesAllocated;
  197. ULONG TotalBlocksFreed;
  198. ULONG TotalBytesFreed;
  199. ULONG BlocksInUse;
  200. ULONG BytesInUse;
  201. ULONG MaxBlocksInUse;
  202. ULONG MaxBytesInUse;
  203. } SRV_POOL_STATISTICS, *PSRV_POOL_STATISTICS;
  204. //
  205. // BLOCK_COUNTS is used to maintain statistics on server block types
  206. //
  207. typedef struct _BLOCK_COUNTS {
  208. ULONG Allocations;
  209. ULONG Closes;
  210. ULONG Frees;
  211. } BLOCK_COUNTS, *PBLOCK_COUNTS;
  212. #define MAX_NON_TRANS_SMB 0x84
  213. #ifndef TRANS2_MAX_FUNCTION
  214. #define TRANS2_MAX_FUNCTION 0x11
  215. #endif
  216. #define MAX_STATISTICS_SMB MAX_NON_TRANS_SMB + TRANS2_MAX_FUNCTION + 1
  217. //
  218. // SRV_STATISTICS is the structure returned to the FSCTL_GET_STATISTICS
  219. // fsctl.
  220. //
  221. typedef struct _SRV_STATISTICS {
  222. //
  223. // The time at which statistics gathering began (or stats were last
  224. // cleared).
  225. //
  226. TIME StatisticsStartTime;
  227. //
  228. // Large integer counts of bytes received and sent
  229. //
  230. LARGE_INTEGER TotalBytesReceived;
  231. LARGE_INTEGER TotalBytesSent;
  232. //
  233. // Causes of session termination
  234. //
  235. ULONG SessionLogonAttempts;
  236. ULONG SessionsTimedOut;
  237. ULONG SessionsErroredOut;
  238. ULONG SessionsLoggedOff;
  239. ULONG SessionsForcedLogOff;
  240. //
  241. // Misc. Errors
  242. //
  243. ULONG LogonErrors;
  244. ULONG AccessPermissionErrors;
  245. ULONG GrantedAccessErrors;
  246. ULONG SystemErrors;
  247. ULONG BlockingSmbsRejected;
  248. ULONG WorkItemShortages;
  249. //
  250. // Cumulative counts of various statistics. Note that when stats are
  251. // cleared, those "Total" fields which have a "Current" equivalent
  252. // are set to the "Current" value to avoid situations where the
  253. // current count is greater than the total.
  254. //
  255. ULONG TotalFilesOpened;
  256. ULONG CurrentNumberOfOpenFiles;
  257. ULONG CurrentNumberOfSessions;
  258. ULONG CurrentNumberOfOpenSearches;
  259. //
  260. // Memory usage stats we want to xport
  261. //
  262. ULONG CurrentNonPagedPoolUsage;
  263. ULONG NonPagedPoolFailures;
  264. ULONG PeakNonPagedPoolUsage;
  265. ULONG CurrentPagedPoolUsage;
  266. ULONG PagedPoolFailures;
  267. ULONG PeakPagedPoolUsage;
  268. //
  269. // Used to record the number of times work context blocks were placed
  270. // on the server's FSP queue and the total amount of time they spent
  271. // there.
  272. //
  273. SRV_TIMED_COUNTER TotalWorkContextBlocksQueued;
  274. ULONG CompressedReads;
  275. ULONG CompressedReadsRejected;
  276. ULONG CompressedReadsFailed;
  277. ULONG CompressedWrites;
  278. ULONG CompressedWritesRejected;
  279. ULONG CompressedWritesFailed;
  280. ULONG CompressedWritesExpanded;
  281. } SRV_STATISTICS, *PSRV_STATISTICS;
  282. //
  283. // Per work-queue statistics for the server. There is a workqueue for each
  284. // processor in the system for nonblocking work, and a single workqueue for
  285. // blocking work.
  286. //
  287. // These statistics are retrieved via FSCTL_SRV_GET_QUEUE_STATISTICS to the
  288. // server driver. For an N-processor system, the first N structs are per-processor,
  289. // the N+1'th struct is for the blocking work queue.
  290. //
  291. typedef struct _SRV_QUEUE_STATISTICS {
  292. ULONG QueueLength; // current length of the workitem queue
  293. ULONG ActiveThreads; // # of threads currently servicing requests
  294. ULONG AvailableThreads; // # of threads waiting for work
  295. ULONG FreeWorkItems; // # of free work items
  296. ULONG StolenWorkItems; // # of work items taken from this free list
  297. // by another queue
  298. ULONG NeedWorkItem; // # of work items we are currently short for this queue
  299. ULONG CurrentClients; // # of clients being serviced by this queue
  300. LARGE_INTEGER BytesReceived; // # of bytes in from the network to clients on this queue
  301. LARGE_INTEGER BytesSent; // # of bytes sent to the network from clients on this queue
  302. LARGE_INTEGER ReadOperations; // # file read operations by clients on this queue
  303. LARGE_INTEGER BytesRead; // # of data bytes read from files by clients on this queue
  304. LARGE_INTEGER WriteOperations; // # of file write ops by clients on this queue
  305. LARGE_INTEGER BytesWritten; // # of data bytes written to files by clients on this queue
  306. SRV_TIMED_COUNTER TotalWorkContextBlocksQueued; // as above, but per-queue
  307. } SRV_QUEUE_STATISTICS, *PSRV_QUEUE_STATISTICS;
  308. //
  309. // SRV_STATISTICS_DEBUG is the structure used for the
  310. // FSCTL_SRV_GET_DEBUG_STATISTICS fsctl. This structure is valid
  311. // only when SRVDBG3 is set.
  312. //
  313. typedef struct _SRV_STATISTICS_DEBUG {
  314. //
  315. // Large integer counts of bytes read and written.
  316. //
  317. LARGE_INTEGER TotalBytesRead;
  318. LARGE_INTEGER TotalBytesWritten;
  319. //
  320. // Raw reads and writes statistics
  321. //
  322. ULONG RawWritesAttempted;
  323. ULONG RawWritesRejected;
  324. ULONG RawReadsAttempted;
  325. ULONG RawReadsRejected;
  326. //
  327. // Cumulative count of time spent opening files and closing handles.
  328. //
  329. LARGE_INTEGER TotalIoCreateFileTime;
  330. LARGE_INTEGER TotalNtCloseTime;
  331. ULONG TotalHandlesClosed;
  332. ULONG TotalOpenAttempts;
  333. ULONG TotalOpensForPathOperations;
  334. ULONG TotalOplocksGranted;
  335. ULONG TotalOplocksDenied;
  336. ULONG TotalOplocksBroken;
  337. ULONG OpensSatisfiedWithCachedRfcb;
  338. ULONG FastLocksAttempted;
  339. ULONG FastLocksFailed;
  340. ULONG FastReadsAttempted;
  341. ULONG FastReadsFailed;
  342. ULONG FastUnlocksAttempted;
  343. ULONG FastUnlocksFailed;
  344. ULONG FastWritesAttempted;
  345. ULONG FastWritesFailed;
  346. ULONG DirectSendsAttempted;
  347. ULONG LockViolations;
  348. ULONG LockDelays;
  349. ULONG CoreSearches;
  350. ULONG CompleteCoreSearches;
  351. //
  352. // information about block types
  353. //
  354. BLOCK_COUNTS ConnectionInfo;
  355. BLOCK_COUNTS EndpointInfo;
  356. BLOCK_COUNTS LfcbInfo;
  357. BLOCK_COUNTS MfcbInfo;
  358. BLOCK_COUNTS RfcbInfo;
  359. BLOCK_COUNTS SearchInfo;
  360. BLOCK_COUNTS SessionInfo;
  361. BLOCK_COUNTS ShareInfo;
  362. BLOCK_COUNTS TransactionInfo;
  363. BLOCK_COUNTS TreeConnectInfo;
  364. BLOCK_COUNTS WorkContextInfo;
  365. BLOCK_COUNTS WaitForOplockBreakInfo;
  366. //
  367. // Statistics for different read and write sizes. Each element of
  368. // the array corresponds to a range of IO sizes; see srv\smbsupp.c
  369. // for exact correspondences.
  370. //
  371. SMB_STATISTICS ReadSize[17];
  372. SMB_STATISTICS WriteSize[17];
  373. //
  374. // Statistics for each SMB type by command code.
  375. //
  376. SMB_STATISTICS Smb[MAX_STATISTICS_SMB+2+TRANS2_MAX_FUNCTION+1];
  377. struct {
  378. ULONG Depth;
  379. ULONG Threads;
  380. ULONG ItemsQueued;
  381. ULONG MaximumDepth;
  382. } QueueStatistics[3];
  383. } SRV_STATISTICS_DEBUG, *PSRV_STATISTICS_DEBUG;
  384. //
  385. // SET DEBUG input and output structure. Contains off/on masks for SrvDebug
  386. // and SmbDebug. The off mask is applied first, then the on mask is
  387. // applied. To set the entire mask to a specific value, set the off
  388. // mask to all ones, and set the on mask to the desired value. To leave
  389. // a mask unchanged, set both masks to 0. SET DEBUG is also used
  390. // to modify other server heuristics. HeuristicsChangeMask is used to
  391. // indicate which heuristics are being changed.
  392. //
  393. // On output, the structure is presented in such a way as to allow the
  394. // original values to be restored easily. The output data is simply
  395. // passed back as input data.
  396. //
  397. typedef struct _FSCTL_SRV_SET_DEBUG_IN_OUT {
  398. ULONG SrvDebugOff;
  399. ULONG SrvDebugOn;
  400. ULONG SmbDebugOff;
  401. ULONG SmbDebugOn;
  402. ULONG CcDebugOff;
  403. ULONG CcDebugOn;
  404. ULONG PbDebugOff;
  405. ULONG PbDebugOn;
  406. ULONG FatDebugOff;
  407. ULONG FatDebugOn;
  408. ULONG HeuristicsChangeMask;
  409. ULONG MaxCopyReadLength;
  410. ULONG MaxCopyWriteLength;
  411. ULONG DumpVerbosity;
  412. ULONG DumpRawLength;
  413. BOOLEAN EnableOplocks;
  414. BOOLEAN EnableFcbOpens;
  415. BOOLEAN EnableSoftCompatibility;
  416. BOOLEAN EnableRawMode;
  417. BOOLEAN EnableDpcLevelProcessing;
  418. BOOLEAN EnableMdlIo;
  419. BOOLEAN EnableFastIo;
  420. BOOLEAN DumpRequests;
  421. BOOLEAN DumpResponses;
  422. } FSCTL_SRV_SET_DEBUG_IN_OUT, *PFSCTL_SRV_SET_DEBUG_IN_OUT;
  423. //
  424. // Bit assignments for server heuristics change mask. The first group
  425. // contains those that are values, while the second group contains those
  426. // that are booleans.
  427. //
  428. #define SRV_HEUR_MAX_COPY_READ 0x00000001
  429. #define SRV_HEUR_MAX_COPY_WRITE 0x00000002
  430. #define SRV_HEUR_DUMP_VERBOSITY 0x00000004
  431. #define SRV_HEUR_DUMP_RAW_LENGTH 0x00000008
  432. #define SRV_HEUR_OPLOCKS 0x00010000
  433. #define SRV_HEUR_FCB_OPENS 0x00020000
  434. #define SRV_HEUR_SOFT_COMPATIBILITY 0x00040000
  435. #define SRV_HEUR_RAW_MODE 0x00080000
  436. #define SRV_HEUR_DPC_LEVEL_PROCESSING 0x00100000
  437. #define SRV_HEUR_MDL_IO 0x00200000
  438. #define SRV_HEUR_FAST_IO 0x00400000
  439. #define SRV_HEUR_DUMP_REQUESTS 0x00800000
  440. #define SRV_HEUR_DUMP_RESPONSES 0x01000000
  441. //
  442. // Structure returned in response to FSCTL_SRV_QUERY_CONNECTIONS.
  443. //
  444. typedef struct _BLOCK_INFORMATION {
  445. PVOID Block;
  446. ULONG BlockType;
  447. ULONG BlockState;
  448. ULONG ReferenceCount;
  449. } BLOCK_INFORMATION, *PBLOCK_INFORMATION;
  450. //
  451. // Structure for communication between the file server and the server
  452. // service.
  453. //
  454. typedef struct _SERVER_REQUEST_PACKET {
  455. UNICODE_STRING Name1;
  456. UNICODE_STRING Name2;
  457. ULONG Level;
  458. ULONG ErrorCode;
  459. ULONG Flags;
  460. union {
  461. struct {
  462. ULONG EntriesRead;
  463. ULONG TotalEntries;
  464. ULONG TotalBytesNeeded;
  465. ULONG ResumeHandle;
  466. } Get;
  467. struct {
  468. ULONG ErrorParameter;
  469. union {
  470. struct {
  471. ULONG MaxUses;
  472. } ShareInfo;
  473. } Api;
  474. } Set;
  475. } Parameters;
  476. } SERVER_REQUEST_PACKET, *PSERVER_REQUEST_PACKET;
  477. //
  478. // Flags for the Flags field of the server request packet.
  479. //
  480. #define SRP_RETURN_SINGLE_ENTRY 0x01
  481. #define SRP_CLEAR_STATISTICS 0x02
  482. #define SRP_SET_SHARE_IN_DFS 0x04
  483. #define SRP_CLEAR_SHARE_IN_DFS 0x08
  484. //
  485. // Flags used in the XPORT_ADD function
  486. //
  487. #define SRP_XADD_PRIMARY_MACHINE 0x1 // this is the primary machine name
  488. #define SRP_XADD_REMAP_PIPE_NAMES 0x2 // remap pipe names to separate dir
  489. //
  490. // The valid set of flags for the XPORT_ADD function
  491. //
  492. #define SRP_XADD_FLAGS (SRP_XADD_PRIMARY_MACHINE | SRP_XADD_REMAP_PIPE_NAMES)
  493. //
  494. // #defines for the share GENERIC_MAPPING structure, which must be available
  495. // to both the server and the server service.
  496. //
  497. #define SRVSVC_SHARE_CONNECT 0x0001
  498. #define SRVSVC_PAUSED_SHARE_CONNECT 0x0002
  499. #define SRVSVC_SHARE_CONNECT_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | \
  500. SRVSVC_SHARE_CONNECT | \
  501. SRVSVC_PAUSED_SHARE_CONNECT )
  502. #define GENERIC_SHARE_CONNECT_MAPPING { \
  503. STANDARD_RIGHTS_READ | \
  504. SRVSVC_SHARE_CONNECT, \
  505. STANDARD_RIGHTS_WRITE | \
  506. SRVSVC_PAUSED_SHARE_CONNECT, \
  507. STANDARD_RIGHTS_EXECUTE, \
  508. SRVSVC_SHARE_CONNECT_ALL_ACCESS }
  509. //
  510. // #defines for the file GENERIC_MAPPING structure, which must be available
  511. // to both the server and the server service. This structure is identical
  512. // to the io file generic mapping "IopFileMapping" defined in io\ioinit.c
  513. //
  514. #define GENERIC_SHARE_FILE_ACCESS_MAPPING { \
  515. FILE_GENERIC_READ, \
  516. FILE_GENERIC_WRITE, \
  517. FILE_GENERIC_EXECUTE, \
  518. FILE_ALL_ACCESS }
  519. //
  520. // Special cases of STYPE_DISKTREE
  521. //
  522. #define STYPE_CDROM 104
  523. #define STYPE_REMOVABLE 105
  524. #ifdef INCLUDE_SMB_PERSISTENT
  525. #define STYPE_PERSISTENT 0x40000000
  526. #endif
  527. #define SRV_LWIO_CONTEXT_SIZE 512
  528. #ifdef _NTIFS_
  529. typedef NTSTATUS (*PSRV_RESUME_CONTEXT_CALLBACK)(PCHAR ClientMachineName,
  530. CtxtHandle SessionKey,
  531. struct _SRV_REQUEST_RESUME_KEY* Request, ULONG MaxBufferLength,
  532. PCHAR InData, ULONG InLength);
  533. #else
  534. typedef PVOID PSRV_RESUME_CONTEXT_CALLBACK;
  535. #endif
  536. //
  537. // SRV_RESUME_KEY
  538. //
  539. // This structure is used to uniquely identify a file for a given server
  540. // It is currently used for handle duplication
  541. typedef struct _SRV_RESUME_KEY {
  542. UINT64 ResumeKey;
  543. UINT64 Timestamp;
  544. UINT64 Pid;
  545. } SRV_RESUME_KEY, *PSRV_RESUME_KEY;
  546. //
  547. // FSCTL_SRV_REQUEST_RESUME_KEY
  548. //
  549. // Command is received over the network on the FID we're requesting a Resume Key for.
  550. // Output buffer is of the format SRV_REQUEST_RESUME_KEY
  551. // Data containt
  552. typedef struct _SRV_REQUEST_RESUME_KEY {
  553. SRV_RESUME_KEY Key;
  554. ULONG ContextLength;
  555. BYTE Context[1];
  556. } SRV_REQUEST_RESUME_KEY, *PSRV_REQUEST_RESUME_KEY;
  557. //
  558. // FSCTL_SRV_QUERY_RESUME_CONTEXT
  559. //
  560. // Caller can user-mode to query resume context.
  561. typedef struct _SRV_QUERY_RESUME_CONTEXT {
  562. ULONG ContextLength;
  563. BYTE Context[1];
  564. } SRV_QUERY_RESUME_CONTEXT, *PSRV_QUERY_RESUME_CONTEXT;
  565. //
  566. // FSCTL_SRV_SET_RESUME_CONTEXT
  567. //
  568. // Caller must be calling from System Process to set this
  569. // value with a non-NULL Callback. If Callback is NULL, caller
  570. // can be user-mode.
  571. typedef struct _SRV_SET_RESUME_CONTEXT {
  572. PSRV_RESUME_CONTEXT_CALLBACK Callback;
  573. ULONG ContextLength;
  574. BYTE Context[1];
  575. } SRV_SET_RESUME_CONTEXT, *PSRV_SET_RESUME_CONTEXT;
  576. //
  577. // FSCTL_SRV_REQUEST_HANDLE_DUP
  578. //
  579. // This is the response to a HandleDup request. The input buffer should
  580. // be a SRV_REQUEST_HANDLE_DUP structure. Caller must be privileged.
  581. typedef struct _SRV_REQUEST_HANDLE_DUP {
  582. SRV_RESUME_KEY Key;
  583. ULONG Options;
  584. } SRV_REQUEST_HANDLE_DUP, *PSRV_REQUEST_HANDLE_DUP;
  585. typedef struct _SRV_RESPONSE_HANDLE_DUP {
  586. HANDLE hFile;
  587. ULONG LockKey;
  588. } SRV_RESPONSE_HANDLE_DUP, *PSRV_RESPONSE_HANDLE_DUP;
  589. #endif // ndef _SRVFSCTL_