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.

647 lines
14 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. smbprocs.h
  5. Abstract:
  6. This module defines functions for processing SMBs.
  7. Author:
  8. Chuck Lenzmeier (chuckl) 5-Oct-1989
  9. Revision History:
  10. --*/
  11. #ifndef _SMBPROCS_
  12. #define _SMBPROCS_
  13. //#include <ntos.h>
  14. //#include "srvblock.h"
  15. //
  16. // SMB processing routine definiton. SMB_PROCESSOR_PARAMETERS is used
  17. // to declare SMB processing routines. It reduces the changes that
  18. // have to be made if the definition changes. SMB_PROCESSOR_ARGUMENTS
  19. // is used by one SMB processor to call another.
  20. //
  21. //
  22. #define SMB_PROCESSOR_PARAMETERS \
  23. IN OUT PWORK_CONTEXT WorkContext
  24. #define SMB_PROCESSOR_ARGUMENTS \
  25. WorkContext
  26. #define SMB_PROCESSOR_RETURN_TYPE SMB_STATUS SRVFASTCALL
  27. #define SMB_PROCESSOR_RETURN_LOCAL SMB_STATUS
  28. //
  29. // SMB processor return status.
  30. //
  31. typedef enum _SMB_STATUS {
  32. SmbStatusMoreCommands,
  33. SmbStatusSendResponse,
  34. SmbStatusNoResponse,
  35. SmbStatusInProgress
  36. } SMB_STATUS, *PSMB_STATUS;
  37. //
  38. // SMB transaction processor return status.
  39. //
  40. typedef enum _SMB_TRANS_STATUS {
  41. SmbTransStatusSuccess,
  42. SmbTransStatusErrorWithData,
  43. SmbTransStatusErrorWithoutData,
  44. SmbTransStatusInProgress
  45. } SMB_TRANS_STATUS, *PSMB_TRANS_STATUS;
  46. typedef
  47. SMB_STATUS
  48. (SRVFASTCALL *PSMB_PROCESSOR) (
  49. SMB_PROCESSOR_PARAMETERS
  50. );
  51. /*++
  52. Routine Description:
  53. The SMB_PROCESSOR is a routine that is called to process a specific
  54. SMB command.
  55. Arguments:
  56. WorkContext - Supplies the address of a Work Context Block
  57. describing the current request. In particular, the following
  58. fields are valid:
  59. RequestHeader - Address of the request SMB header.
  60. RequestParameters - Address of the current command's request
  61. parameters. The SMB processor should update this field to
  62. point to the next command in the SMB, if any.
  63. ResponseHeader - Address of the response SMB header. Initially,
  64. this is a copy of the request header. As return data, such
  65. as UID, TID, and FID, becomes available, it should be
  66. written into both the request header (for AndX command
  67. processors) and the response header (for the client). Note
  68. that the response header address *may* be the same as the
  69. request header address.
  70. ResponseParameters - Address of the current command's response
  71. parameters. The SMB processor should write the response
  72. data to this address, then update the pointer to point to
  73. the address of the next command's response area, if any.
  74. If there are no more commands in the SMB, this field should
  75. be set to point to the first byte after the response so that
  76. the length of the response can be computed.
  77. Endpoint, Connection - Addresses of the endpoint and the
  78. connection that received the SMB. These fields should not
  79. be changed by the SMB processor. Other block pointers in
  80. WorkContext (Share, Session, TreeConnect, and Rfcb) may be
  81. set by the SMB processor if such blocks are referenced
  82. during processing. Any non-NULL pointers in these fields
  83. are dereferenced when SMB processing is complete, before the
  84. response (if any) is sent. The Connection and Endpoint
  85. pointers are not cleared until the WorkContext is requeued
  86. to the receive queue.
  87. Parameters - This union is used by the various SMB processors to
  88. retain state during asynchronous operations.
  89. Return Value:
  90. SMB_STATUS - Indicates the action to be taken by the calling routine.
  91. Possible values are the following:
  92. SmbStatusMoreCommands - There is at least one more AndX
  93. follow-on command in the request SMB. The SMB processor has
  94. updated RequestParameters and ResponseParameters in
  95. WorkContext to point to the next command's request and
  96. response areas. It has also copied the command code of
  97. the next command into RequestHeader->Command, so that
  98. SrvProcessSmb can dispatch the next request.
  99. SmbStatusSendResponse - Processing of the request is complete,
  100. and a response is to be sent. ResponseParameters has been
  101. updated to point to the first location *after* the end of
  102. the response. This is used to compute the length of the
  103. response.
  104. SmbStatusNoResponse - Processing of the request is complete, but
  105. either no response is needed or the SMB processor has
  106. already taken care of sending the response(s).
  107. SmbStatusInProgress - The SMB processor has started an
  108. asynchronous operation and will continue processing the SMB
  109. at an appropriate restart routine when the operation
  110. completes. The restart routine, after updating WorkContext,
  111. calls SrvSmbProcessSmb to continue (or end) processing the
  112. SMB.
  113. --*/
  114. typedef
  115. SMB_TRANS_STATUS
  116. (*PSMB_TRANSACTION_PROCESSOR) (
  117. IN OUT PWORK_CONTEXT WorkContext
  118. );
  119. /*++
  120. Routine Description:
  121. The SMB_TRANSACTION_PROCESSOR is a routine that is called to process
  122. a specific Transaction or Transaction2 SMB subfunction.
  123. Arguments:
  124. WorkContext - Supplies the address of a Work Context Block
  125. describing the current request. In particular, the following
  126. fields are valid and intended for use by the transaction
  127. processor:
  128. ResponseHeader - Address of the response SMB header. Initially,
  129. this is a copy of the request header. The transaction
  130. processor may update the error class and code fields if it
  131. encounters an error.
  132. Parameters.Transacton - Points to the transaction block
  133. describing the transaction. All block pointer fields
  134. (Connection, Session, TreeConnect) in the block are valid.
  135. Pointers to the setup words and parameter and data bytes,
  136. and the lengths of these items, are valid. The transaction
  137. block is on the connection's pending transaction list.
  138. The transaction processor must update the transaction block
  139. to indicate how much data to return.
  140. Return Value:
  141. BOOLEAN - Indicates whether an error occurred. FALSE indicates that
  142. the operation was successful, and that the data counts were
  143. updated to indicate how much data to return. TRUE indicates
  144. that an error occurred, and that SrvSetSmbError was called to
  145. update the response header and place a null parameters field at
  146. the end of the response.
  147. --*/
  148. //
  149. // SMB Processing routines.
  150. //
  151. SMB_PROCESSOR_RETURN_TYPE
  152. SrvSmbNotImplemented (
  153. SMB_PROCESSOR_PARAMETERS
  154. );
  155. SMB_PROCESSOR_RETURN_TYPE
  156. SrvSmbCreateDirectory (
  157. SMB_PROCESSOR_PARAMETERS
  158. );
  159. SMB_PROCESSOR_RETURN_TYPE
  160. SrvSmbDeleteDirectory (
  161. SMB_PROCESSOR_PARAMETERS
  162. );
  163. SMB_PROCESSOR_RETURN_TYPE
  164. SrvSmbOpen (
  165. SMB_PROCESSOR_PARAMETERS
  166. );
  167. SMB_PROCESSOR_RETURN_TYPE
  168. SrvSmbCreate (
  169. SMB_PROCESSOR_PARAMETERS
  170. );
  171. SMB_PROCESSOR_RETURN_TYPE
  172. SrvSmbClose (
  173. SMB_PROCESSOR_PARAMETERS
  174. );
  175. SMB_PROCESSOR_RETURN_TYPE
  176. SrvSmbFlush (
  177. SMB_PROCESSOR_PARAMETERS
  178. );
  179. SMB_PROCESSOR_RETURN_TYPE
  180. SrvSmbDelete (
  181. SMB_PROCESSOR_PARAMETERS
  182. );
  183. SMB_PROCESSOR_RETURN_TYPE
  184. SrvSmbRename (
  185. SMB_PROCESSOR_PARAMETERS
  186. );
  187. SMB_PROCESSOR_RETURN_TYPE
  188. SrvSmbQueryInformation (
  189. SMB_PROCESSOR_PARAMETERS
  190. );
  191. SMB_PROCESSOR_RETURN_TYPE
  192. SrvSmbSetInformation (
  193. SMB_PROCESSOR_PARAMETERS
  194. );
  195. SMB_PROCESSOR_RETURN_TYPE
  196. SrvSmbRead (
  197. SMB_PROCESSOR_PARAMETERS
  198. );
  199. SMB_PROCESSOR_RETURN_TYPE
  200. SrvSmbWrite (
  201. SMB_PROCESSOR_PARAMETERS
  202. );
  203. SMB_PROCESSOR_RETURN_TYPE
  204. SrvSmbLockByteRange (
  205. SMB_PROCESSOR_PARAMETERS
  206. );
  207. SMB_PROCESSOR_RETURN_TYPE
  208. SrvSmbUnlockByteRange (
  209. SMB_PROCESSOR_PARAMETERS
  210. );
  211. SMB_PROCESSOR_RETURN_TYPE
  212. SrvSmbCreateTemporary (
  213. SMB_PROCESSOR_PARAMETERS
  214. );
  215. SMB_PROCESSOR_RETURN_TYPE
  216. SrvSmbCreateNew (
  217. SMB_PROCESSOR_PARAMETERS
  218. );
  219. SMB_PROCESSOR_RETURN_TYPE
  220. SrvSmbCheckDirectory (
  221. SMB_PROCESSOR_PARAMETERS
  222. );
  223. SMB_PROCESSOR_RETURN_TYPE
  224. SrvSmbProcessExit (
  225. SMB_PROCESSOR_PARAMETERS
  226. );
  227. SMB_PROCESSOR_RETURN_TYPE
  228. SrvSmbSeek (
  229. SMB_PROCESSOR_PARAMETERS
  230. );
  231. SMB_PROCESSOR_RETURN_TYPE
  232. SrvSmbLockAndRead (
  233. SMB_PROCESSOR_PARAMETERS
  234. );
  235. SMB_PROCESSOR_RETURN_TYPE
  236. SrvSmbReadRaw (
  237. SMB_PROCESSOR_PARAMETERS
  238. );
  239. SMB_PROCESSOR_RETURN_TYPE
  240. SrvSmbReadMpx (
  241. SMB_PROCESSOR_PARAMETERS
  242. );
  243. SMB_PROCESSOR_RETURN_TYPE
  244. SrvSmbWriteRaw (
  245. SMB_PROCESSOR_PARAMETERS
  246. );
  247. SMB_PROCESSOR_RETURN_TYPE
  248. SrvSmbWriteMpx (
  249. SMB_PROCESSOR_PARAMETERS
  250. );
  251. SMB_PROCESSOR_RETURN_TYPE
  252. SrvSmbWriteMpxSecondary (
  253. SMB_PROCESSOR_PARAMETERS
  254. );
  255. SMB_PROCESSOR_RETURN_TYPE
  256. SrvSmbSetInformation2 (
  257. SMB_PROCESSOR_PARAMETERS
  258. );
  259. SMB_PROCESSOR_RETURN_TYPE
  260. SrvSmbQueryInformation2 (
  261. SMB_PROCESSOR_PARAMETERS
  262. );
  263. SMB_PROCESSOR_RETURN_TYPE
  264. SrvSmbLockingAndX (
  265. SMB_PROCESSOR_PARAMETERS
  266. );
  267. SMB_PROCESSOR_RETURN_TYPE
  268. SrvSmbTransaction (
  269. SMB_PROCESSOR_PARAMETERS
  270. );
  271. SMB_PROCESSOR_RETURN_TYPE
  272. SrvSmbTransactionSecondary (
  273. SMB_PROCESSOR_PARAMETERS
  274. );
  275. SMB_PROCESSOR_RETURN_TYPE
  276. SrvSmbNtTransaction (
  277. SMB_PROCESSOR_PARAMETERS
  278. );
  279. SMB_PROCESSOR_RETURN_TYPE
  280. SrvSmbNtTransactionSecondary (
  281. SMB_PROCESSOR_PARAMETERS
  282. );
  283. SMB_PROCESSOR_RETURN_TYPE
  284. SrvSmbNtCreateAndX (
  285. SMB_PROCESSOR_PARAMETERS
  286. );
  287. SMB_PROCESSOR_RETURN_TYPE
  288. SrvSmbIoctl (
  289. SMB_PROCESSOR_PARAMETERS
  290. );
  291. SMB_PROCESSOR_RETURN_TYPE
  292. SrvSmbIoctlSecondary (
  293. SMB_PROCESSOR_PARAMETERS
  294. );
  295. SMB_PROCESSOR_RETURN_TYPE
  296. SrvSmbMove (
  297. SMB_PROCESSOR_PARAMETERS
  298. );
  299. SMB_PROCESSOR_RETURN_TYPE
  300. SrvSmbEcho (
  301. SMB_PROCESSOR_PARAMETERS
  302. );
  303. SMB_PROCESSOR_RETURN_TYPE
  304. SrvSmbWriteAndClose (
  305. SMB_PROCESSOR_PARAMETERS
  306. );
  307. SMB_PROCESSOR_RETURN_TYPE
  308. SrvSmbOpenAndX (
  309. SMB_PROCESSOR_PARAMETERS
  310. );
  311. SMB_PROCESSOR_RETURN_TYPE
  312. SrvSmbReadAndX (
  313. SMB_PROCESSOR_PARAMETERS
  314. );
  315. SMB_PROCESSOR_RETURN_TYPE
  316. SrvSmbWriteAndX (
  317. SMB_PROCESSOR_PARAMETERS
  318. );
  319. SMB_PROCESSOR_RETURN_TYPE
  320. SrvSmbCloseAndTreeDisc (
  321. SMB_PROCESSOR_PARAMETERS
  322. );
  323. SMB_PROCESSOR_RETURN_TYPE
  324. SrvSmbFindClose2 (
  325. SMB_PROCESSOR_PARAMETERS
  326. );
  327. SMB_PROCESSOR_RETURN_TYPE
  328. SrvSmbFindNotifyClose (
  329. SMB_PROCESSOR_PARAMETERS
  330. );
  331. SMB_PROCESSOR_RETURN_TYPE
  332. SrvSmbTreeConnect (
  333. SMB_PROCESSOR_PARAMETERS
  334. );
  335. SMB_PROCESSOR_RETURN_TYPE
  336. SrvSmbTreeDisconnect (
  337. SMB_PROCESSOR_PARAMETERS
  338. );
  339. SMB_PROCESSOR_RETURN_TYPE
  340. SrvSmbNegotiate (
  341. SMB_PROCESSOR_PARAMETERS
  342. );
  343. SMB_PROCESSOR_RETURN_TYPE
  344. SrvSmbSessionSetupAndX (
  345. SMB_PROCESSOR_PARAMETERS
  346. );
  347. SMB_PROCESSOR_RETURN_TYPE
  348. SrvSmbLogoffAndX (
  349. SMB_PROCESSOR_PARAMETERS
  350. );
  351. SMB_PROCESSOR_RETURN_TYPE
  352. SrvSmbTreeConnectAndX (
  353. SMB_PROCESSOR_PARAMETERS
  354. );
  355. SMB_PROCESSOR_RETURN_TYPE
  356. SrvSmbQueryInformationDisk (
  357. SMB_PROCESSOR_PARAMETERS
  358. );
  359. SMB_PROCESSOR_RETURN_TYPE
  360. SrvSmbSearch (
  361. SMB_PROCESSOR_PARAMETERS
  362. );
  363. SMB_PROCESSOR_RETURN_TYPE
  364. SrvSmbOpenPrintFile (
  365. SMB_PROCESSOR_PARAMETERS
  366. );
  367. SMB_PROCESSOR_RETURN_TYPE
  368. SrvSmbClosePrintFile (
  369. SMB_PROCESSOR_PARAMETERS
  370. );
  371. SMB_PROCESSOR_RETURN_TYPE
  372. SrvSmbGetPrintQueue (
  373. SMB_PROCESSOR_PARAMETERS
  374. );
  375. SMB_PROCESSOR_RETURN_TYPE
  376. SrvSmbNtCancel (
  377. SMB_PROCESSOR_PARAMETERS
  378. );
  379. //
  380. // Transaction SMB processors
  381. //
  382. SMB_TRANS_STATUS
  383. SrvSmbOpen2 (
  384. IN OUT PWORK_CONTEXT WorkContext
  385. );
  386. SMB_TRANS_STATUS
  387. SrvSmbFindFirst2 (
  388. IN OUT PWORK_CONTEXT WorkContext
  389. );
  390. SMB_TRANS_STATUS
  391. SrvSmbFindNext2 (
  392. IN OUT PWORK_CONTEXT WorkContext
  393. );
  394. SMB_TRANS_STATUS
  395. SrvSmbQueryFsInformation (
  396. IN OUT PWORK_CONTEXT WorkContext
  397. );
  398. SMB_TRANS_STATUS
  399. SrvSmbSetFsInformation (
  400. IN OUT PWORK_CONTEXT WorkContext
  401. );
  402. SMB_TRANS_STATUS
  403. SrvSmbQueryPathInformation (
  404. IN OUT PWORK_CONTEXT WorkContext
  405. );
  406. SMB_TRANS_STATUS
  407. SrvSmbSetPathInformation (
  408. IN OUT PWORK_CONTEXT WorkContext
  409. );
  410. SMB_TRANS_STATUS
  411. SrvSmbQueryFileInformation (
  412. IN OUT PWORK_CONTEXT WorkContext
  413. );
  414. SMB_TRANS_STATUS
  415. SrvSmbSetFileInformation (
  416. IN OUT PWORK_CONTEXT WorkContext
  417. );
  418. SMB_TRANS_STATUS
  419. SrvSmbFsctl (
  420. IN OUT PWORK_CONTEXT WorkContext
  421. );
  422. SMB_TRANS_STATUS
  423. SrvSmbIoctl2 (
  424. IN OUT PWORK_CONTEXT WorkContext
  425. );
  426. SMB_TRANS_STATUS
  427. SrvSmbFindNotify (
  428. IN OUT PWORK_CONTEXT WorkContext
  429. );
  430. SMB_TRANS_STATUS
  431. SrvSmbCreateDirectory2 (
  432. IN OUT PWORK_CONTEXT WorkContext
  433. );
  434. SMB_TRANS_STATUS
  435. SrvSmbCreateWithSdOrEa (
  436. IN OUT PWORK_CONTEXT WorkContext
  437. );
  438. SMB_TRANS_STATUS
  439. SrvSmbNtIoctl (
  440. IN OUT PWORK_CONTEXT WorkContext
  441. );
  442. SMB_TRANS_STATUS
  443. SrvSmbNtNotifyChange (
  444. IN OUT PWORK_CONTEXT WorkContext
  445. );
  446. SMB_TRANS_STATUS
  447. SrvSmbNtRename (
  448. IN OUT PWORK_CONTEXT WorkContext
  449. );
  450. SMB_TRANS_STATUS
  451. SrvSmbQuerySecurityDescriptor (
  452. IN OUT PWORK_CONTEXT WorkContext
  453. );
  454. SMB_TRANS_STATUS
  455. SrvSmbSetSecurityDescriptor (
  456. IN OUT PWORK_CONTEXT WorkContext
  457. );
  458. SMB_TRANS_STATUS
  459. SrvSmbQueryQuota (
  460. IN OUT PWORK_CONTEXT WorkContext
  461. );
  462. SMB_TRANS_STATUS
  463. SrvSmbSetQuota (
  464. IN OUT PWORK_CONTEXT WorkContext
  465. );
  466. SMB_TRANS_STATUS
  467. SrvTransactionNotImplemented (
  468. IN OUT PWORK_CONTEXT WorkContext
  469. );
  470. //
  471. // Dfs transactions and support routines
  472. //
  473. VOID
  474. SrvInitializeDfs();
  475. VOID
  476. SrvTerminateDfs();
  477. SMB_TRANS_STATUS
  478. SrvSmbGetDfsReferral (
  479. IN OUT PWORK_CONTEXT WorkContext
  480. );
  481. SMB_TRANS_STATUS
  482. SrvSmbReportDfsInconsistency (
  483. IN OUT PWORK_CONTEXT WorkContext
  484. );
  485. NTSTATUS SRVFASTCALL
  486. DfsNormalizeName(
  487. IN PSHARE Share,
  488. IN PUNICODE_STRING RelatedPath OPTIONAL,
  489. IN BOOLEAN StripLastComponent,
  490. IN OUT PUNICODE_STRING String
  491. );
  492. NTSTATUS SRVFASTCALL
  493. DfsFindShareName(
  494. IN PUNICODE_STRING ShareName
  495. );
  496. VOID SRVFASTCALL
  497. SrvIsShareInDfs(
  498. IN PSHARE Share,
  499. OUT BOOLEAN *IsDfs,
  500. OUT BOOLEAN *IsDfsRoot
  501. );
  502. #endif // def _SMBPROCS_