Source code of Windows XP (NT5)
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.

418 lines
8.6 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. srvfsd.h
  5. Abstract:
  6. This module defines routines in the File System Driver for the LAN
  7. Manager server.
  8. Author:
  9. Chuck Lenzmeier (chuckl) 1-Dec-1989
  10. Revision History:
  11. --*/
  12. #ifndef _SRVFSD_
  13. #define _SRVFSD_
  14. //#include "srvblock.h"
  15. #include "wmilib.h"
  16. typedef struct _DEVICE_EXTENSION {
  17. PDEVICE_OBJECT pDeviceObject;
  18. ULONG TestCounter;
  19. WMILIB_CONTEXT WmiLibContext;
  20. } DEVICE_EXTENSION, * PDEVICE_EXTENSION;
  21. typedef enum _tagSrvWmiEvents {
  22. EVENT_TYPE_SMB_CREATE_DIRECTORY,
  23. EVENT_TYPE_SMB_DELETE_DIRECTORY,
  24. EVENT_TYPE_SMB_OPEN,
  25. EVENT_TYPE_SMB_CREATE,
  26. EVENT_TYPE_SMB_CLOSE,
  27. EVENT_TYPE_SMB_FLUSH,
  28. EVENT_TYPE_SMB_DELETE,
  29. EVENT_TYPE_SMB_RENAME,
  30. EVENT_TYPE_SMB_QUERY_INFORMATION,
  31. EVENT_TYPE_SMB_SET_INFORMATION,
  32. EVENT_TYPE_SMB_READ,
  33. EVENT_TYPE_SMB_WRITE,
  34. EVENT_TYPE_SMB_LOCK_BYTE_RANGE,
  35. EVENT_TYPE_SMB_UNLOCK_BYTE_RANGE,
  36. EVENT_TYPE_SMB_CREATE_TEMPORARY,
  37. EVENT_TYPE_SMB_CHECK_DIRECTORY,
  38. EVENT_TYPE_SMB_PROCESS_EXIT,
  39. EVENT_TYPE_SMB_SEEK,
  40. EVENT_TYPE_SMB_LOCK_AND_READ,
  41. EVENT_TYPE_SMB_SET_INFORMATION2,
  42. EVENT_TYPE_SMB_QUERY_INFORMATION2,
  43. EVENT_TYPE_SMB_LOCKING_AND_X,
  44. EVENT_TYPE_SMB_TRANSACTION,
  45. EVENT_TYPE_SMB_TRANSACTION_SECONDARY,
  46. EVENT_TYPE_SMB_IOCTL,
  47. EVENT_TYPE_SMB_IOCTL_SECONDARY,
  48. EVENT_TYPE_SMB_MOVE,
  49. EVENT_TYPE_SMB_ECHO,
  50. EVENT_TYPE_SMB_OPEN_AND_X,
  51. EVENT_TYPE_SMB_READ_AND_X,
  52. EVENT_TYPE_SMB_WRITE_AND_X,
  53. EVENT_TYPE_SMB_FIND_CLOSE2,
  54. EVENT_TYPE_SMB_FIND_NOTIFY_CLOSE,
  55. EVENT_TYPE_SMB_TREE_CONNECT,
  56. EVENT_TYPE_SMB_TREE_DISCONNECT,
  57. EVENT_TYPE_SMB_NEGOTIATE,
  58. EVENT_TYPE_SMB_SESSION_SETUP_AND_X,
  59. EVENT_TYPE_SMB_LOGOFF_AND_X,
  60. EVENT_TYPE_SMB_TREE_CONNECT_AND_X,
  61. EVENT_TYPE_SMB_QUERY_INFORMATION_DISK,
  62. EVENT_TYPE_SMB_SEARCH,
  63. EVENT_TYPE_SMB_NT_TRANSACTION,
  64. EVENT_TYPE_SMB_NT_TRANSACTION_SECONDARY,
  65. EVENT_TYPE_SMB_NT_CREATE_AND_X,
  66. EVENT_TYPE_SMB_NT_CANCEL,
  67. EVENT_TYPE_SMB_OPEN_PRINT_FILE,
  68. EVENT_TYPE_SMB_CLOSE_PRINT_FILE,
  69. EVENT_TYPE_SMB_GET_PRINT_QUEUE,
  70. EVENT_TYPE_SMB_READ_RAW,
  71. EVENT_TYPE_SMB_WRITE_RAW,
  72. EVENT_TYPE_SMB_READ_MPX,
  73. EVENT_TYPE_SMB_WRITE_MPX,
  74. EVENT_TYPE_SMB_WRITE_MPX_SECONDARY,
  75. EVENT_TYPE_SMB_OPEN2,
  76. EVENT_TYPE_SMB_FIND_FIRST2,
  77. EVENT_TYPE_SMB_FIND_NEXT2,
  78. EVENT_TYPE_SMB_QUERY_FS_INFORMATION,
  79. EVENT_TYPE_SMB_SET_FS_INFORMATION,
  80. EVENT_TYPE_SMB_QUERY_PATH_INFORMATION,
  81. EVENT_TYPE_SMB_SET_PATH_INFORMATION,
  82. EVENT_TYPE_SMB_QUERY_FILE_INFORMATION,
  83. EVENT_TYPE_SMB_SET_FILE_INFORMATION,
  84. EVENT_TYPE_SMB_FSCTL,
  85. EVENT_TYPE_SMB_IOCTL2,
  86. EVENT_TYPE_SMB_FIND_NOTIFY,
  87. EVENT_TYPE_SMB_CREATE_DIRECTORY2,
  88. EVENT_TYPE_SMB_GET_DFS_REFERRALS,
  89. EVENT_TYPE_SMB_REPORT_DFS_INCONSISTENCY,
  90. EVENT_TYPE_SMB_CREATE_WITH_SD_OR_EA,
  91. EVENT_TYPE_SMB_NT_IOCTL,
  92. EVENT_TYPE_SMB_SET_SECURITY_DESCRIPTOR,
  93. EVENT_TYPE_SMB_NT_NOTIFY_CHANGE,
  94. EVENT_TYPE_SMB_NT_RENAME,
  95. EVENT_TYPE_SMB_QUERY_SECURITY_DESCRIPTOR,
  96. EVENT_TYPE_SMB_QUERY_QUOTA,
  97. EVENT_TYPE_SMB_SET_QUOTA,
  98. EVENT_TYPE_SMB_LAST_EVENT
  99. } SrvWmiEvents;
  100. // WMI Dispatch routine
  101. //
  102. void
  103. SrvWmiInitContext(
  104. PWORK_CONTEXT WorkContext
  105. );
  106. void
  107. SrvWmiStartContext(
  108. PWORK_CONTEXT WorkContext
  109. );
  110. void
  111. SrvWmiEndContext(
  112. PWORK_CONTEXT WorkContext
  113. );
  114. void
  115. SrvWmiTraceEvent(
  116. PWORK_CONTEXT WorkContext
  117. );
  118. NTSTATUS
  119. SrvWmiDispatch(
  120. IN PDEVICE_OBJECT DeviceObject,
  121. IN PIRP Irp
  122. );
  123. //
  124. // FSD dispatch routine.
  125. //
  126. NTSTATUS
  127. SrvFsdDispatch (
  128. IN PDEVICE_OBJECT DeviceObject,
  129. IN PIRP Irp
  130. );
  131. //
  132. // FSD I/O completion routine
  133. //
  134. NTSTATUS
  135. SrvFsdIoCompletionRoutine (
  136. IN PDEVICE_OBJECT DeviceObject,
  137. IN PIRP Irp,
  138. IN PVOID Context
  139. );
  140. //
  141. // FSD TDI send completion routine
  142. //
  143. NTSTATUS
  144. SrvFsdSendCompletionRoutine (
  145. IN PDEVICE_OBJECT DeviceObject,
  146. IN PIRP Irp,
  147. IN PVOID Context
  148. );
  149. //
  150. // FSD Oplock request completion routine
  151. //
  152. NTSTATUS
  153. SrvFsdOplockCompletionRoutine (
  154. IN PDEVICE_OBJECT DeviceObject,
  155. IN PIRP Irp,
  156. IN PVOID Context
  157. );
  158. //
  159. // FSD transport Connect indication handler
  160. //
  161. NTSTATUS
  162. SrvFsdTdiConnectHandler (
  163. IN PVOID TdiEventContext,
  164. IN int RemoteAddressLength,
  165. IN PVOID RemoteAddress,
  166. IN int UserDataLength,
  167. IN PVOID UserData,
  168. IN int OptionsLength,
  169. IN PVOID Options,
  170. OUT CONNECTION_CONTEXT *ConnectionContext,
  171. OUT PIRP *AcceptIrp
  172. );
  173. //
  174. // FSD transport Disconnect indication handler
  175. //
  176. NTSTATUS
  177. SrvFsdTdiDisconnectHandler (
  178. IN PVOID TdiEventContext,
  179. IN CONNECTION_CONTEXT ConnectionContext,
  180. IN int DisconnectDataLength,
  181. IN PVOID DisconnectData,
  182. IN int DisconnectInformationLength,
  183. IN PVOID DisconnectInformation,
  184. IN ULONG DisconnectFlags
  185. );
  186. //
  187. // FSD transport Receive indication handler
  188. //
  189. NTSTATUS
  190. SrvFsdTdiReceiveHandler (
  191. IN PVOID TdiEventContext,
  192. IN CONNECTION_CONTEXT ConnectionContext,
  193. IN ULONG ReceiveFlags,
  194. IN ULONG BytesIndicated,
  195. IN ULONG BytesAvailable,
  196. OUT ULONG *BytesTaken,
  197. IN PVOID Tsdu,
  198. OUT PIRP *IoRequestPacket
  199. );
  200. VOID
  201. SrvPnpBindingHandler (
  202. IN TDI_PNP_OPCODE PnpOpcode,
  203. IN PUNICODE_STRING DeviceName,
  204. IN PWSTR MultiSZBindList
  205. );
  206. NTSTATUS
  207. SrvPnpPowerHandler (
  208. IN PUNICODE_STRING DeviceName,
  209. IN PNET_PNP_EVENT PnPEvent,
  210. IN PTDI_PNP_CONTEXT Context1,
  211. IN PTDI_PNP_CONTEXT Context2
  212. );
  213. //
  214. // Routine to get a work item from the free list. Wakes the resource
  215. // thread if the list is getting empty.
  216. //
  217. PWORK_CONTEXT SRVFASTCALL
  218. SrvFsdGetReceiveWorkItem (
  219. PWORK_QUEUE queue
  220. );
  221. //
  222. // If a workitem could not be allocated, SrvServiceWorkItemShortage() is called
  223. // when the next workitem is freed
  224. //
  225. VOID SRVFASTCALL
  226. SrvServiceWorkItemShortage (
  227. IN PWORK_CONTEXT WorkContext
  228. );
  229. //
  230. // If we have detected a DoS attack, the workitem will trigger a teardown
  231. //
  232. VOID SRVFASTCALL
  233. SrvServiceDoSTearDown (
  234. IN PWORK_CONTEXT WorkContext
  235. );
  236. //
  237. // Routine to queue an EX work item to an EX worker thread.
  238. //
  239. #define SrvFsdQueueExWorkItem(_item,_running,_type) { \
  240. if ( !*(_running) ) { \
  241. *(_running) = TRUE; \
  242. ObReferenceObject( SrvDeviceObject ); \
  243. ExQueueWorkItem( (_item), (_type) ); \
  244. } \
  245. }
  246. //
  247. // SMB processing support routines.
  248. //
  249. VOID SRVFASTCALL
  250. SrvFsdRequeueReceiveWorkItem (
  251. IN OUT PWORK_CONTEXT WorkContext
  252. );
  253. VOID SRVFASTCALL
  254. SrvFsdRestartSmbComplete (
  255. IN OUT PWORK_CONTEXT WorkContext
  256. );
  257. VOID
  258. SrvFsdServiceNeedResourceQueue (
  259. IN PWORK_CONTEXT *WorkContext,
  260. IN PKIRQL OldIrql
  261. );
  262. //
  263. // SMB processing restart routines referenced by the FSP.
  264. //
  265. VOID SRVFASTCALL
  266. SrvFsdRestartRead (
  267. IN OUT PWORK_CONTEXT WorkContext
  268. );
  269. VOID SRVFASTCALL
  270. SrvFsdRestartReadAndX (
  271. IN OUT PWORK_CONTEXT WorkContext
  272. );
  273. VOID SRVFASTCALL
  274. SrvFsdRestartReadAndXCompressed (
  275. IN OUT PWORK_CONTEXT WorkContext
  276. );
  277. VOID SRVFASTCALL
  278. SrvFsdRestartWrite (
  279. IN OUT PWORK_CONTEXT WorkContext
  280. );
  281. VOID SRVFASTCALL
  282. SrvFsdRestartWriteAndX (
  283. IN OUT PWORK_CONTEXT WorkContext
  284. );
  285. VOID SRVFASTCALL
  286. IpxRestartStartSendOnCorrectProcessor (
  287. IN OUT PWORK_CONTEXT WorkContext
  288. );
  289. VOID SRVFASTCALL
  290. SrvFsdRestartLargeReadAndX (
  291. IN OUT PWORK_CONTEXT WorkContext
  292. );
  293. //
  294. // Resource shortage routines.
  295. //
  296. BOOLEAN
  297. SrvAddToNeedResourceQueue (
  298. IN PCONNECTION Connection,
  299. IN RESOURCE_TYPE ResourceType,
  300. IN PRFCB Rfcb OPTIONAL
  301. );
  302. VOID
  303. SrvCheckForAndQueueDoS(
  304. PWORK_QUEUE queue
  305. );
  306. //
  307. // Send Completion Routines
  308. //
  309. NTSTATUS
  310. SrvFsdRestartSmbAtSendCompletion (
  311. IN PDEVICE_OBJECT DeviceObject,
  312. IN PIRP Irp,
  313. IN PWORK_CONTEXT WorkContext
  314. );
  315. NTSTATUS
  316. SrvQueueWorkToFspAtSendCompletion (
  317. IN PDEVICE_OBJECT DeviceObject,
  318. IN PIRP Irp,
  319. IN PWORK_CONTEXT WorkContext
  320. );
  321. NTSTATUS
  322. SrvFsdRestartSendOplockIItoNone(
  323. IN PDEVICE_OBJECT DeviceObject,
  324. IN PIRP Irp,
  325. IN OUT PWORK_CONTEXT WorkContext
  326. );
  327. NTSTATUS
  328. RequeueIpxWorkItemAtSendCompletion (
  329. IN PDEVICE_OBJECT DeviceObject,
  330. IN PIRP Irp,
  331. IN OUT PWORK_CONTEXT WorkContext
  332. );
  333. NTSTATUS
  334. RestartCopyReadMpxComplete (
  335. IN PDEVICE_OBJECT DeviceObject,
  336. IN PIRP Irp,
  337. IN OUT PWORK_CONTEXT WorkContext
  338. );
  339. NTSTATUS
  340. RestartCopyReadRawResponse (
  341. IN PDEVICE_OBJECT DeviceObject,
  342. IN PIRP Irp,
  343. IN OUT PWORK_CONTEXT WorkContext
  344. );
  345. VOID
  346. SrvpNotifyChangesToNetBt(
  347. IN TDI_PNP_OPCODE PnPOpcode,
  348. IN PUNICODE_STRING DeviceName,
  349. IN PWSTR MultiSZBindList);
  350. #endif // ndef _SRVFSD_