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.

1270 lines
26 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. srvsupp.h
  5. Abstract:
  6. This module defines support routines for SMB processors for the LAN
  7. Manager server.
  8. Author:
  9. Chuck Lenzmeier (chuckl) 1-Dec-1989
  10. David Treadwell (davidtr)
  11. Revision History:
  12. --*/
  13. #ifndef _SRVSUPP_
  14. #define _SRVSUPP_
  15. //#include <ntos.h>
  16. //#include <smb.h>
  17. //#include "smbtypes.h"
  18. //#include "srvblock.h"
  19. //
  20. // Use the same directory separator as the object system uses.
  21. //
  22. // Status code used to signal the need for reauthentication
  23. #define SESSION_EXPIRED_STATUS_CODE STATUS_NETWORK_SESSION_EXPIRED
  24. #define DIRECTORY_SEPARATOR_CHAR ((UCHAR)(OBJ_NAME_PATH_SEPARATOR))
  25. #define UNICODE_DIR_SEPARATOR_CHAR ((WCHAR)(OBJ_NAME_PATH_SEPARATOR))
  26. #define RELATIVE_STREAM_INITIAL_CHAR ((UCHAR)':')
  27. #define IS_ANSI_PATH_SEPARATOR(character) \
  28. ( character == DIRECTORY_SEPARATOR_CHAR || character == '\0' )
  29. #define IS_UNICODE_PATH_SEPARATOR(character) \
  30. ( character == UNICODE_DIR_SEPARATOR_CHAR || character == L'\0' )
  31. //
  32. // Access necessary for copying a file. DO NOT use generic bits here;
  33. // these are used in calls to IoCheckDesiredAccess, which cannot accept
  34. // generic bits for the DesiredAccess.
  35. //
  36. #define SRV_COPY_SOURCE_ACCESS READ_CONTROL | \
  37. FILE_READ_DATA | \
  38. FILE_READ_ATTRIBUTES | \
  39. FILE_READ_EA
  40. #define SRV_COPY_TARGET_ACCESS WRITE_DAC | \
  41. WRITE_OWNER | \
  42. FILE_WRITE_DATA | \
  43. FILE_APPEND_DATA | \
  44. FILE_WRITE_ATTRIBUTES | \
  45. FILE_WRITE_EA
  46. //
  47. // This type is used to determine the size of the largest directory query
  48. // information structure.
  49. //
  50. typedef union _SRV_QUERY_DIRECTORY_INFORMATION {
  51. FILE_DIRECTORY_INFORMATION Directory;
  52. FILE_FULL_DIR_INFORMATION FullDir;
  53. FILE_BOTH_DIR_INFORMATION BothDir;
  54. FILE_NAMES_INFORMATION Names;
  55. } SRV_QUERY_DIRECTORY_INFORMATION, *PSRV_QUERY_DIRECTORY_INFORMATION;
  56. //
  57. // Type definition for the structure used by SrvQueryDirectoryFile
  58. // to do its work. Calling routines must set up a buffer in nonpaged
  59. // pool with enough room for this structure plus other things. (See
  60. // MIN_SEARCH_BUFFER_SIZE.)
  61. //
  62. typedef struct _SRV_DIRECTORY_INFORMATION {
  63. HANDLE DirectoryHandle;
  64. PFILE_DIRECTORY_INFORMATION CurrentEntry;
  65. ULONG BufferLength;
  66. struct {
  67. BOOLEAN Wildcards : 1;
  68. BOOLEAN ErrorOnFileOpen : 1;
  69. BOOLEAN OnlySingleEntries : 1;
  70. };
  71. LONG Buffer[1];
  72. } SRV_DIRECTORY_INFORMATION, *PSRV_DIRECTORY_INFORMATION;
  73. //
  74. // Type definition for the structure used by SrvQueryEaFile to do its
  75. // work. Calling routines must set up a buffer in nonpaged pool with
  76. // enough room for this structure and at least a single EA. An EA may
  77. // be as large as sizeof(FILE_FULL_EA_INFORMATION) +
  78. // (2 ^ (sizeof(UCHAR)*8)) + (2 ^ (sizeof(USHORT)*8)) ~= 65k, so
  79. // calling routines should first query the size of the EAs, then allocate
  80. // a buffer big enough for either all the EAs or a single maximum-sized
  81. // EA.
  82. //
  83. typedef struct _SRV_EA_INFORMATION {
  84. PFILE_FULL_EA_INFORMATION CurrentEntry;
  85. ULONG BufferLength;
  86. ULONG GetEaListOffset;
  87. LONG Buffer[1];
  88. } SRV_EA_INFORMATION, *PSRV_EA_INFORMATION;
  89. #define MAX_SIZE_OF_SINGLE_EA ( sizeof(FILE_FULL_EA_INFORMATION) + 257 + 65536 )
  90. //
  91. // The directory cache structure used to maintain information about
  92. // core searches between requests. One of these structures is maintained
  93. // for each file returned.
  94. //
  95. typedef struct _DIRECTORY_CACHE {
  96. ULONG FileIndex;
  97. WCHAR UnicodeResumeName[ 12 ];
  98. USHORT UnicodeResumeNameLength;
  99. } DIRECTORY_CACHE, *PDIRECTORY_CACHE;
  100. //
  101. // Limit the number of files that may be returned on a core search.
  102. //
  103. #define MAX_DIRECTORY_CACHE_SIZE 10
  104. //
  105. // Macros used to determine the search buffer size. The first three are
  106. // possible buffer sizes, the second two are numbers of files to be returned
  107. // that represent cutoff points for using the different search buffer
  108. // sizes.
  109. //
  110. // An approximate formula for determining the size of the search buffer is:
  111. //
  112. // (maxCount+2) * (sizeof(SRV_QUERY_DIRECTORY_INFORMATION)+13) +
  113. // sizeof(SRV_DIRECTORY_INFORMATION)
  114. //
  115. // where maxCount is the maximum number of files to return. The +2 is
  116. // a slop factor to account for the possibility of files that to not
  117. // match the search attributes, and the +13 accounts for the size of
  118. // FAT filenames.
  119. //
  120. // Note that the minimum buffer size must include the following factors in
  121. // order to avoid the possibility of not even being able to hold one entry
  122. // with the longest legal filename:
  123. //
  124. // sizeof(SRV_DIRECTORY_INFORMATION)
  125. // sizeof(SRV_QUERY_DIRECTORY_INFORMATION) + (MAXIMUM_FILENAME_LENGTH * sizeof(WCHAR))
  126. // sizeof(UNICODE_STRING) + (MAXIMUM_FILENAME_LENGTH * sizeof(WCHAR)) + 3
  127. //
  128. // The last factor is needed because SrvIssueQueryDirectoryRequest puts
  129. // the search filename at the end of the buffer. (The +3 is necessary to
  130. // allow for aligning the UNICODE_STRING on a ULONG boundary.)
  131. //
  132. #define MAX_SEARCH_BUFFER_SIZE 4096
  133. #define MED_SEARCH_BUFFER_SIZE 2048
  134. #define MIN_SEARCH_BUFFER_SIZE \
  135. (sizeof(SRV_DIRECTORY_INFORMATION) + \
  136. (sizeof(SRV_QUERY_DIRECTORY_INFORMATION) + (MAXIMUM_FILENAME_LENGTH * sizeof(WCHAR))) + \
  137. (sizeof(UNICODE_STRING) + (MAXIMUM_FILENAME_LENGTH * sizeof(WCHAR)) + 3))
  138. #define MAX_FILES_FOR_MED_SEARCH 20
  139. #define MAX_FILES_FOR_MIN_SEARCH 10
  140. //
  141. // The macros for FIND2 have the same meaning as the SEARCH macros except
  142. // that they are used in the FIND2 protocols.
  143. //
  144. #define MAX_FILES_FOR_MED_FIND2 16
  145. #define MAX_FILES_FOR_MIN_FIND2 8
  146. //
  147. // Macros to check context handles for equality and for NULLness
  148. //
  149. #define CONTEXT_EQUAL(x,y) (((x).dwLower == (y).dwLower) && ((x).dwUpper == (y).dwUpper))
  150. #define CONTEXT_NULL(x) (((x).dwLower == 0) && ((x).dwUpper == 0))
  151. //
  152. // SMB processing support routines.
  153. //
  154. VOID
  155. SrvAllocateAndBuildPathName(
  156. IN PUNICODE_STRING Path1,
  157. IN PUNICODE_STRING Path2,
  158. IN PUNICODE_STRING Path3 OPTIONAL,
  159. OUT PUNICODE_STRING BuiltPath
  160. );
  161. NTSTATUS
  162. SrvCanonicalizePathName(
  163. IN PWORK_CONTEXT WorkContext,
  164. IN PSHARE Share OPTIONAL,
  165. IN PUNICODE_STRING RelatedPath OPTIONAL,
  166. IN OUT PVOID Name,
  167. IN PCHAR LastValidLocation,
  168. IN BOOLEAN RemoveTrailingDots,
  169. IN BOOLEAN SourceIsUnicode,
  170. OUT PUNICODE_STRING String
  171. );
  172. NTSTATUS
  173. SrvCanonicalizePathNameWithReparse(
  174. IN PWORK_CONTEXT WorkContext,
  175. IN PSHARE Share OPTIONAL,
  176. IN PUNICODE_STRING RelatedPath OPTIONAL,
  177. IN OUT PVOID Name,
  178. IN PCHAR LastValidLocation,
  179. IN BOOLEAN RemoveTrailingDots,
  180. IN BOOLEAN SourceIsUnicode,
  181. OUT PUNICODE_STRING String
  182. );
  183. VOID
  184. SrvCloseQueryDirectory(
  185. PSRV_DIRECTORY_INFORMATION DirectoryInformation
  186. );
  187. NTSTATUS
  188. SrvCheckSearchAttributesForHandle(
  189. IN HANDLE FileHandle,
  190. IN USHORT SmbSearchAttributes
  191. );
  192. NTSTATUS SRVFASTCALL
  193. SrvCheckSearchAttributes(
  194. IN USHORT FileAttributes,
  195. IN USHORT SmbSearchAttributes
  196. );
  197. NTSTATUS
  198. SrvCopyFile(
  199. IN HANDLE SourceHandle,
  200. IN HANDLE TargetHandle,
  201. IN USHORT SmbOpenFunction,
  202. IN USHORT SmbFlags,
  203. IN ULONG ActionTaken
  204. );
  205. NTSTATUS
  206. SrvCreateFile(
  207. IN PWORK_CONTEXT WorkContext,
  208. IN USHORT SmbDesiredAccess,
  209. IN USHORT SmbFileAttributes,
  210. IN USHORT SmbOpenFunction,
  211. IN ULONG SmbAllocationSize,
  212. IN PCHAR SmbFileName,
  213. IN PCHAR EndOfSmbFileName,
  214. IN PVOID EaBuffer OPTIONAL,
  215. IN ULONG EaLength,
  216. IN PULONG EaErrorOffset OPTIONAL,
  217. IN OPLOCK_TYPE RequestedOplockType,
  218. IN PRESTART_ROUTINE RestartRoutine
  219. );
  220. NTSTATUS
  221. SrvNtCreateFile(
  222. IN OUT PWORK_CONTEXT WorkContext,
  223. IN ULONG RootDirectoryFid,
  224. IN ACCESS_MASK DesiredAccess,
  225. IN LARGE_INTEGER AllocationSize,
  226. IN ULONG FileAttributes,
  227. IN ULONG ShareAccess,
  228. IN ULONG CreateDisposition,
  229. IN ULONG CreateOptions,
  230. IN PVOID SecurityDescriptorBuffer OPTIONAL,
  231. IN PUNICODE_STRING FileName,
  232. IN PVOID EaBuffer OPTIONAL,
  233. IN ULONG EaLength,
  234. OUT PULONG EaErrorOffset OPTIONAL,
  235. ULONG OptionFlags,
  236. PSECURITY_QUALITY_OF_SERVICE QualityOfService,
  237. IN OPLOCK_TYPE RequestedOplockType,
  238. IN PRESTART_ROUTINE RestartRoutine
  239. );
  240. VOID
  241. SrvDosTimeToTime(
  242. OUT PLARGE_INTEGER Time,
  243. IN SMB_DATE DosDate,
  244. IN SMB_TIME DosTime
  245. );
  246. PSHARE
  247. SrvFindShare(
  248. IN PUNICODE_STRING ShareName
  249. );
  250. VOID
  251. SrvGetBaseFileName (
  252. IN PUNICODE_STRING InputName,
  253. OUT PUNICODE_STRING OutputName
  254. );
  255. CLONG
  256. SrvGetNumberOfEasInList (
  257. IN PVOID List
  258. );
  259. USHORT
  260. SrvGetSubdirectoryLength (
  261. IN PUNICODE_STRING InputName
  262. );
  263. NTSTATUS
  264. SrvMakeUnicodeString (
  265. IN BOOLEAN SourceIsUnicode,
  266. OUT PUNICODE_STRING Destination,
  267. IN PVOID Source,
  268. IN PUSHORT SourceLength OPTIONAL
  269. );
  270. USHORT
  271. SrvGetString (
  272. OUT PUNICODE_STRING Destination,
  273. IN PVOID Source,
  274. IN PVOID EndOfSourceBuffer,
  275. IN BOOLEAN SourceIsUnicode
  276. );
  277. USHORT
  278. SrvGetStringLength (
  279. IN PVOID Source,
  280. IN PVOID EndOfSourceBuffer,
  281. IN BOOLEAN SourceIsUnicode,
  282. IN BOOLEAN IncludeNullTerminator
  283. );
  284. NTSTATUS
  285. SrvMoveFile(
  286. IN PWORK_CONTEXT WorkContext,
  287. IN PSHARE TargetShare,
  288. IN USHORT SmbOpenFunction,
  289. IN PUSHORT SmbFlags,
  290. IN USHORT SmbSearchAttributes,
  291. IN BOOLEAN FailIfTargetIsDirectory,
  292. IN USHORT InformationLevel,
  293. IN ULONG ClusterCount,
  294. IN PUNICODE_STRING Source,
  295. IN OUT PUNICODE_STRING Target
  296. );
  297. VOID
  298. SrvNtAttributesToSmb(
  299. IN ULONG NtAttributes,
  300. IN BOOLEAN Directory OPTIONAL,
  301. OUT PUSHORT SmbAttributes
  302. );
  303. NTSTATUS
  304. SrvQueryDirectoryFile (
  305. IN PWORK_CONTEXT WorkContext,
  306. IN BOOLEAN IsFirstCall,
  307. IN BOOLEAN FilterLongNames,
  308. IN BOOLEAN FindWithBackupIntent,
  309. IN FILE_INFORMATION_CLASS FileInformationClass,
  310. IN ULONG SearchStorageType,
  311. IN PUNICODE_STRING FilePathName,
  312. IN PULONG ResumeFileIndex OPTIONAL,
  313. IN USHORT SmbSearchAttributes,
  314. IN PSRV_DIRECTORY_INFORMATION DirectoryInformation,
  315. IN CLONG BufferLength
  316. );
  317. NTSTATUS
  318. SrvQueryEaFile (
  319. IN BOOLEAN IsFirstCall,
  320. IN HANDLE FileHandle,
  321. IN PFILE_GET_EA_INFORMATION EaList OPTIONAL,
  322. IN ULONG EaListLength,
  323. IN PSRV_EA_INFORMATION EaInformation,
  324. IN CLONG BufferLength,
  325. OUT PULONG EaErrorOffset
  326. );
  327. NTSTATUS
  328. SrvQueryInformationFile (
  329. IN HANDLE FileHandle,
  330. PFILE_OBJECT FileObject,
  331. OUT PSRV_FILE_INFORMATION SrvFileInformation,
  332. IN SHARE_TYPE ShareType,
  333. IN BOOLEAN QueryEaSize
  334. );
  335. NTSTATUS
  336. SrvQueryInformationFileAbbreviated (
  337. IN HANDLE FileHandle,
  338. PFILE_OBJECT FileObject,
  339. OUT PSRV_FILE_INFORMATION_ABBREVIATED SrvFileInformation,
  340. IN BOOLEAN AdditionalInformation,
  341. IN SHARE_TYPE ShareType
  342. );
  343. NTSTATUS
  344. SrvQueryNtInformationFile (
  345. IN HANDLE FileHandle,
  346. PFILE_OBJECT FileObject,
  347. IN SHARE_TYPE ShareType,
  348. IN BOOLEAN AdditionalInformation,
  349. OUT PSRV_NT_FILE_INFORMATION SrvFileInformation
  350. );
  351. NTSTATUS
  352. SrvQueryBasicAndStandardInformation(
  353. HANDLE FileHandle,
  354. PFILE_OBJECT FileObject,
  355. PFILE_BASIC_INFORMATION FileBasicInfo,
  356. PFILE_STANDARD_INFORMATION FileStandardInfo OPTIONAL
  357. );
  358. NTSTATUS
  359. SrvQueryNetworkOpenInformation(
  360. IN HANDLE FileHandle,
  361. IN PFILE_OBJECT FileObject OPTIONAL,
  362. IN OUT PSRV_NETWORK_OPEN_INFORMATION SrvNetworkOpenInformation,
  363. IN BOOLEAN QueryEaSize
  364. );
  365. VOID
  366. SrvReleaseContext (
  367. IN PWORK_CONTEXT WorkContext
  368. );
  369. BOOLEAN
  370. SrvSetFileWritethroughMode (
  371. IN PLFCB Lfcb,
  372. IN BOOLEAN Writethrough
  373. );
  374. #define SrvSetSmbError( _wc, _status ) { \
  375. _SrvSetSmbError2( (_wc), (_status), FALSE, __LINE__, __FILE__ ); \
  376. }
  377. #define SrvSetSmbError2( _wc, _status, HeaderOnly ) { \
  378. _SrvSetSmbError2( (_wc), (_status), HeaderOnly, __LINE__, __FILE__ ); \
  379. }
  380. VOID
  381. _SrvSetSmbError2 (
  382. IN PWORK_CONTEXT WorkContext,
  383. IN NTSTATUS Status,
  384. IN BOOLEAN HeaderOnly,
  385. IN ULONG LineNumber,
  386. IN PCHAR FileName
  387. );
  388. VOID
  389. SrvSetBufferOverflowError (
  390. IN PWORK_CONTEXT WorkContext
  391. );
  392. VOID
  393. SrvSmbAttributesToNt (
  394. IN USHORT SmbAttributes,
  395. OUT PBOOLEAN Directory,
  396. OUT PULONG NtAttributes
  397. );
  398. VOID
  399. SrvTimeToDosTime (
  400. IN PLARGE_INTEGER Time,
  401. OUT PSMB_DATE DosDate,
  402. OUT PSMB_TIME DosTime
  403. );
  404. USHORT
  405. SrvGetOs2TimeZone(
  406. IN PLARGE_INTEGER SystemTime
  407. );
  408. #define SrvVerifyFid(_wc,_fid,_fail,_ser,_status) \
  409. ((_wc)->Rfcb != NULL ? \
  410. (_wc)->Rfcb : SrvVerifyFid2(_wc,_fid,_fail,_ser,_status))
  411. PRFCB
  412. SrvVerifyFid2 (
  413. IN PWORK_CONTEXT WorkContext,
  414. IN USHORT Fid,
  415. IN BOOLEAN FailOnSavedError,
  416. IN PRESTART_ROUTINE SerializeWithRawRestartRoutine OPTIONAL,
  417. OUT PNTSTATUS NtStatus
  418. );
  419. #define SRV_INVALID_RFCB_POINTER ((PRFCB)-1)
  420. PRFCB
  421. SrvVerifyFidForRawWrite (
  422. IN PWORK_CONTEXT WorkContext,
  423. IN USHORT Fid,
  424. OUT PNTSTATUS NtStatus
  425. );
  426. PSEARCH
  427. SrvVerifySid (
  428. IN PWORK_CONTEXT WorkContext,
  429. IN USHORT Index,
  430. IN USHORT Sequence,
  431. IN PSRV_DIRECTORY_INFORMATION DirectoryInformation,
  432. IN CLONG BufferSize
  433. );
  434. PTREE_CONNECT
  435. SrvVerifyTid (
  436. IN PWORK_CONTEXT WorkContext,
  437. IN USHORT Tid
  438. );
  439. PSESSION
  440. SrvVerifyUid (
  441. IN PWORK_CONTEXT WorkContext,
  442. IN USHORT Uid
  443. );
  444. NTSTATUS
  445. SrvVerifyUidAndTid (
  446. IN PWORK_CONTEXT WorkContext,
  447. OUT PSESSION *Session,
  448. OUT PTREE_CONNECT *TreeConnect,
  449. IN SHARE_TYPE ShareType
  450. );
  451. NTSTATUS
  452. SrvWildcardRename(
  453. IN PUNICODE_STRING FileSpec,
  454. IN PUNICODE_STRING SourceString,
  455. OUT PUNICODE_STRING TargetString
  456. );
  457. //
  458. // Security routines.
  459. //
  460. NTSTATUS
  461. SrvValidateUser (
  462. OUT CtxtHandle *Token,
  463. IN PSESSION Session OPTIONAL,
  464. IN PCONNECTION Connection OPTIONAL,
  465. IN PUNICODE_STRING UserName OPTIONAL,
  466. IN PCHAR CaseInsensitivePassword,
  467. IN CLONG CaseInsensitivePasswordLength,
  468. IN PCHAR CaseSensitivePassword OPTIONAL,
  469. IN CLONG CaseSensitivePasswordLength,
  470. IN BOOLEAN SmbSecuritySignatureRequired,
  471. OUT PUSHORT Action OPTIONAL
  472. );
  473. NTSTATUS
  474. SrvValidateSecurityBuffer(
  475. IN PCONNECTION Connection,
  476. IN OUT PCtxtHandle Handle,
  477. IN PSESSION Session,
  478. IN PCHAR Buffer,
  479. IN ULONG BufferLength,
  480. IN BOOLEAN SecuritySignaturesRequired,
  481. OUT PCHAR ReturnBuffer,
  482. OUT PULONG ReturnBufferLength,
  483. OUT PLARGE_INTEGER Expiry,
  484. OUT PCHAR NtUserSessionKey,
  485. OUT PLUID LogonId,
  486. OUT PBOOLEAN IsGuest
  487. );
  488. NTSTATUS
  489. SrvGetExtensibleSecurityNegotiateBuffer(
  490. OUT PCtxtHandle Token,
  491. OUT PCHAR Buffer,
  492. OUT USHORT *BufferLength
  493. );
  494. NTSTATUS
  495. SrvFreeSecurityContexts (
  496. IN PSESSION Session
  497. );
  498. NTSTATUS
  499. AcquireLMCredentials (
  500. VOID
  501. );
  502. NTSTATUS
  503. SrvGetUserAndDomainName (
  504. IN PSESSION Session,
  505. OUT PUNICODE_STRING UserName OPTIONAL,
  506. OUT PUNICODE_STRING DomainName OPTIONAL
  507. );
  508. VOID
  509. SrvReleaseUserAndDomainName (
  510. IN PSESSION Session,
  511. IN OUT PUNICODE_STRING UserName OPTIONAL,
  512. IN OUT PUNICODE_STRING DomainName OPTIONAL
  513. );
  514. VOID
  515. SrvAddSecurityCredentials(
  516. IN PANSI_STRING ComputerName,
  517. IN PUNICODE_STRING DomainName,
  518. IN DWORD PasswordLength,
  519. IN PBYTE Password
  520. );
  521. BOOLEAN
  522. SrvIsAdmin(
  523. CtxtHandle Handle
  524. );
  525. BOOLEAN
  526. SrvIsNullSession(
  527. CtxtHandle Handle
  528. );
  529. NTSTATUS
  530. SrvIsAllowedOnAdminShare(
  531. IN PWORK_CONTEXT WorkContext,
  532. IN PSHARE Share
  533. );
  534. NTSTATUS
  535. SrvCheckShareFileAccess(
  536. IN PWORK_CONTEXT WorkContext,
  537. IN ACCESS_MASK FileDesiredAccess
  538. );
  539. NTSTATUS
  540. SrvRetrieveMaximalAccessRightsForUser(
  541. CtxtHandle *pUserHandle,
  542. PSECURITY_DESCRIPTOR pSecurityDescriptor,
  543. PGENERIC_MAPPING pMapping,
  544. PACCESS_MASK pMaximalAccessRights);
  545. NTSTATUS
  546. SrvRetrieveMaximalAccessRights(
  547. IN OUT PWORK_CONTEXT WorkContext,
  548. OUT PACCESS_MASK pMaximalAccessRights,
  549. OUT PACCESS_MASK pGuestMaximalAccessRights);
  550. NTSTATUS
  551. SrvRetrieveMaximalShareAccessRights(
  552. IN PWORK_CONTEXT WorkContext,
  553. OUT PACCESS_MASK pMaximalAccessRights,
  554. OUT PACCESS_MASK pGuestMaximalAccessRights);
  555. NTSTATUS
  556. SrvUpdateMaximalAccessRightsInResponse(
  557. IN OUT PWORK_CONTEXT WorkContext,
  558. OUT PSMB_ULONG pMaximalAccessRightsInResponse,
  559. OUT PSMB_ULONG pGuestMaximalAccessRightsInResponse
  560. );
  561. NTSTATUS
  562. SrvUpdateMaximalShareAccessRightsInResponse(
  563. IN OUT PWORK_CONTEXT WorkContext,
  564. OUT PSMB_ULONG pMaximalAccessRightsInResponse,
  565. OUT PSMB_ULONG pGuestMaximalAccessRightsInResponse
  566. );
  567. //
  568. // Share handling routines.
  569. //
  570. PSHARE
  571. SrvVerifyShare (
  572. IN PWORK_CONTEXT WorkContext,
  573. IN PSZ ShareName,
  574. IN PSZ ShareTypeString,
  575. IN BOOLEAN ShareNameIsUnicode,
  576. IN BOOLEAN IsNullSession,
  577. OUT PNTSTATUS Status,
  578. OUT PUNICODE_STRING ServerName
  579. );
  580. VOID
  581. SrvRemoveShare(
  582. PSHARE Share
  583. );
  584. VOID
  585. SrvAddShare(
  586. PSHARE Share
  587. );
  588. NTSTATUS
  589. SrvShareEnumApiHandler (
  590. IN PSERVER_REQUEST_PACKET Srp,
  591. IN PVOID OutputBuffer,
  592. IN ULONG BufferLength,
  593. IN PENUM_FILTER_ROUTINE FilterRoutine,
  594. IN PENUM_SIZE_ROUTINE SizeRoutine,
  595. IN PENUM_FILL_ROUTINE FillRoutine
  596. );
  597. SMB_PROCESSOR_RETURN_TYPE
  598. SrvConsumeSmbData(
  599. IN OUT PWORK_CONTEXT WorkContext
  600. );
  601. BOOLEAN
  602. SrvIsDottedQuadAddress(
  603. IN PUNICODE_STRING ServerName
  604. );
  605. //
  606. // Fat name routines.
  607. //
  608. VOID
  609. Srv8dot3ToUnicodeString (
  610. IN PSZ Input8dot3,
  611. OUT PUNICODE_STRING OutputString
  612. );
  613. BOOLEAN SRVFASTCALL
  614. SrvIsLegalFatName (
  615. IN PWSTR InputName,
  616. IN CLONG InputNameLength
  617. );
  618. VOID
  619. SrvOemStringTo8dot3 (
  620. IN POEM_STRING InputString,
  621. OUT PSZ Output8dot3
  622. );
  623. VOID
  624. SrvUnicodeStringTo8dot3 (
  625. IN PUNICODE_STRING InputString,
  626. OUT PSZ Output8dot3,
  627. IN BOOLEAN Upcase
  628. );
  629. //
  630. // EA conversion support routines.
  631. //
  632. BOOLEAN
  633. SrvAreEasNeeded (
  634. IN PFILE_FULL_EA_INFORMATION NtFullEa
  635. );
  636. USHORT
  637. SrvGetOs2FeaOffsetOfError (
  638. IN ULONG NtErrorOffset,
  639. IN PFILE_FULL_EA_INFORMATION NtFullEa,
  640. IN PFEALIST FeaList
  641. );
  642. USHORT
  643. SrvGetOs2GeaOffsetOfError (
  644. IN ULONG NtErrorOffset,
  645. IN PFILE_GET_EA_INFORMATION NtGetEa,
  646. IN PGEALIST GeaList
  647. );
  648. NTSTATUS
  649. SrvOs2FeaListToNt (
  650. IN PFEALIST FeaList,
  651. OUT PFILE_FULL_EA_INFORMATION *NtFullEa,
  652. OUT PULONG BufferLength,
  653. OUT PUSHORT EaErrorOffset
  654. );
  655. ULONG
  656. SrvOs2FeaListSizeToNt (
  657. IN PFEALIST FeaList
  658. );
  659. PVOID
  660. SrvOs2FeaToNt (
  661. OUT PFILE_FULL_EA_INFORMATION NtFullEa,
  662. IN PFEA Fea
  663. );
  664. NTSTATUS
  665. SrvOs2GeaListToNt (
  666. IN PGEALIST GeaList,
  667. OUT PFILE_GET_EA_INFORMATION *NtGetEa,
  668. OUT PULONG BufferLength,
  669. OUT PUSHORT EaErrorOffset
  670. );
  671. ULONG
  672. SrvOs2GeaListSizeToNt (
  673. IN PGEALIST GeaList
  674. );
  675. PVOID
  676. SrvOs2GeaToNt (
  677. OUT PFILE_GET_EA_INFORMATION NtGetEa,
  678. IN PGEA Gea
  679. );
  680. PVOID
  681. SrvNtFullEaToOs2 (
  682. OUT PFEA Fea,
  683. IN PFILE_FULL_EA_INFORMATION NtFullEa
  684. );
  685. PVOID
  686. SrvNtGetEaToOs2 (
  687. OUT PGEA Gea,
  688. IN PFILE_GET_EA_INFORMATION NtGetEa
  689. );
  690. CLONG
  691. SrvNumberOfEasInList (
  692. IN PVOID List
  693. );
  694. NTSTATUS
  695. SrvQueryOs2FeaList (
  696. IN HANDLE FileHandle,
  697. IN PGEALIST GeaList OPTIONAL,
  698. IN PFILE_GET_EA_INFORMATION NtGetEaList OPTIONAL,
  699. IN ULONG GeaListLength OPTIONAL,
  700. IN PFEALIST FeaList,
  701. IN ULONG BufferLength,
  702. OUT PUSHORT EaErrorOffset
  703. );
  704. NTSTATUS
  705. SrvSetOs2FeaList (
  706. IN HANDLE FileHandle,
  707. IN PFEALIST FeaList,
  708. IN ULONG BufferLength,
  709. OUT PUSHORT EaErrorOffset
  710. );
  711. NTSTATUS
  712. SrvConstructNullOs2FeaList (
  713. IN PFILE_GET_EA_INFORMATION NtGeaList,
  714. OUT PFEALIST FeaList,
  715. IN ULONG BufferLength
  716. );
  717. //
  718. // Named pipe worker functions.
  719. //
  720. SMB_TRANS_STATUS
  721. SrvCallNamedPipe (
  722. IN OUT PWORK_CONTEXT WorkContext
  723. );
  724. SMB_TRANS_STATUS
  725. SrvWaitNamedPipe (
  726. IN OUT PWORK_CONTEXT WorkContext
  727. );
  728. SMB_TRANS_STATUS
  729. SrvQueryStateNamedPipe (
  730. IN OUT PWORK_CONTEXT WorkContext
  731. );
  732. SMB_TRANS_STATUS
  733. SrvQueryInformationNamedPipe (
  734. IN OUT PWORK_CONTEXT WorkContext
  735. );
  736. SMB_TRANS_STATUS
  737. SrvSetStateNamedPipe (
  738. IN OUT PWORK_CONTEXT WorkContext
  739. );
  740. SMB_TRANS_STATUS
  741. SrvPeekNamedPipe (
  742. IN OUT PWORK_CONTEXT WorkContext
  743. );
  744. SMB_TRANS_STATUS
  745. SrvTransactNamedPipe (
  746. IN OUT PWORK_CONTEXT WorkContext
  747. );
  748. BOOLEAN
  749. SrvFastTransactNamedPipe (
  750. IN OUT PWORK_CONTEXT WorkContext,
  751. OUT SMB_STATUS *SmbStatus
  752. );
  753. SMB_TRANS_STATUS
  754. SrvRawWriteNamedPipe (
  755. IN OUT PWORK_CONTEXT WorkContext
  756. );
  757. SMB_TRANS_STATUS
  758. SrvWriteNamedPipe (
  759. IN OUT PWORK_CONTEXT WorkContext
  760. );
  761. SMB_TRANS_STATUS
  762. SrvReadNamedPipe (
  763. IN OUT PWORK_CONTEXT WorkContext
  764. );
  765. //
  766. // Transaction worker functions.
  767. //
  768. VOID
  769. SrvCompleteExecuteTransaction (
  770. IN OUT PWORK_CONTEXT WorkContext,
  771. IN SMB_TRANS_STATUS ResultStatus
  772. );
  773. VOID SRVFASTCALL
  774. SrvRestartExecuteTransaction (
  775. IN OUT PWORK_CONTEXT WorkContext
  776. );
  777. //
  778. // XACTSRV support routines.
  779. //
  780. PVOID
  781. SrvXsAllocateHeap(
  782. IN ULONG SizeOfAllocation OPTIONAL,
  783. OUT PNTSTATUS Status
  784. );
  785. NTSTATUS
  786. SrvXsConnect (
  787. IN PUNICODE_STRING PortName
  788. );
  789. VOID
  790. SrvXsFreeHeap(
  791. IN PVOID MemoryToFree OPTIONAL
  792. );
  793. SMB_TRANS_STATUS
  794. SrvXsRequest (
  795. IN OUT PWORK_CONTEXT WorkContext
  796. );
  797. NTSTATUS
  798. SrvXsLSOperation (
  799. IN PSESSION Session,
  800. IN ULONG Type
  801. );
  802. VOID
  803. SrvXsPnpOperation(
  804. IN PUNICODE_STRING DeviceName,
  805. IN BOOLEAN Bind
  806. );
  807. VOID
  808. SrvXsDisconnect();
  809. //
  810. // Oplock support routines.
  811. //
  812. VOID SRVFASTCALL
  813. SrvOplockBreakNotification (
  814. IN PWORK_CONTEXT WorkContext // actually, a PRFCB
  815. );
  816. VOID
  817. SrvFillOplockBreakRequest (
  818. IN PWORK_CONTEXT WorkContext,
  819. IN PRFCB Rfcb
  820. );
  821. VOID SRVFASTCALL
  822. SrvRestartOplockBreakSend(
  823. IN PWORK_CONTEXT WorkContext
  824. );
  825. VOID
  826. SrvAcknowledgeOplockBreak (
  827. IN PRFCB Rfcb,
  828. IN UCHAR NewOplockLevel
  829. );
  830. BOOLEAN
  831. SrvRequestOplock (
  832. IN PWORK_CONTEXT WorkContext,
  833. IN POPLOCK_TYPE OplockType,
  834. IN BOOLEAN RequestIIOnFailure
  835. );
  836. LARGE_INTEGER
  837. SrvGetOplockBreakTimeout (
  838. IN PWORK_CONTEXT WorkContext
  839. );
  840. VOID
  841. SrvSendOplockRequest(
  842. IN PCONNECTION Connection,
  843. IN PRFCB Rfcb,
  844. IN KIRQL OldIrql
  845. );
  846. VOID SRVFASTCALL
  847. SrvCheckDeferredOpenOplockBreak(
  848. IN PWORK_CONTEXT WorkContext
  849. );
  850. //
  851. // Buffer management support
  852. //
  853. BOOLEAN
  854. SrvReceiveBufferShortage(
  855. VOID
  856. );
  857. NTSTATUS
  858. SrvIoCreateFile (
  859. IN PWORK_CONTEXT WorkContext,
  860. OUT PHANDLE FileHandle,
  861. IN ACCESS_MASK DesiredAccess,
  862. IN POBJECT_ATTRIBUTES ObjectAttributes,
  863. OUT PIO_STATUS_BLOCK IoStatusBlock,
  864. IN PLARGE_INTEGER AllocationSize OPTIONAL,
  865. IN ULONG FileAttributes,
  866. IN ULONG ShareAccess,
  867. IN ULONG Disposition,
  868. IN ULONG CreateOptions,
  869. IN PVOID EaBuffer OPTIONAL,
  870. IN ULONG EaLength,
  871. IN CREATE_FILE_TYPE CreateFileType,
  872. IN PVOID ExtraCreateParameters OPTIONAL,
  873. IN ULONG Options,
  874. IN PSHARE Share OPTIONAL
  875. );
  876. NTSTATUS
  877. SrvNtClose (
  878. IN HANDLE Handle,
  879. IN BOOLEAN QuotaCharged
  880. );
  881. NTSTATUS
  882. SrvVerifyDeviceStackSize(
  883. IN HANDLE FileHandle,
  884. IN BOOLEAN ReferenceFileObject,
  885. OUT PFILE_OBJECT *FileObject,
  886. OUT PDEVICE_OBJECT *DeviceObject,
  887. OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL
  888. );
  889. VOID
  890. SrvCheckForBadSlm (
  891. IN PRFCB Rfcb,
  892. IN ULONG StartOffset,
  893. IN PCONNECTION Connection,
  894. IN PVOID Buffer,
  895. IN ULONG BufferLength
  896. );
  897. //
  898. // Routines used to go to XACTSRV through LPC to issue user-mode APIs.
  899. //
  900. NTSTATUS
  901. SrvOpenPrinter (
  902. IN PWCH PrinterName,
  903. OUT PHANDLE phPrinter,
  904. OUT PULONG Error
  905. );
  906. NTSTATUS
  907. SrvAddPrintJob (
  908. IN PWORK_CONTEXT WorkContext,
  909. IN HANDLE Handle,
  910. OUT PUNICODE_STRING FileName,
  911. OUT PULONG JobId,
  912. OUT PULONG Error
  913. );
  914. NTSTATUS
  915. SrvSchedulePrintJob (
  916. IN HANDLE PrinterHandle,
  917. IN ULONG JobId
  918. );
  919. NTSTATUS
  920. SrvClosePrinter (
  921. OUT HANDLE Handle
  922. );
  923. //
  924. // Routines for handling impersonation of remote clients.
  925. //
  926. NTSTATUS
  927. SrvImpersonate (
  928. IN PWORK_CONTEXT WorkContext
  929. );
  930. VOID
  931. SrvRevert (
  932. VOID
  933. );
  934. //
  935. // Routine for setting the last write time on a file given the last
  936. // write time in seconds since 1970.
  937. //
  938. #ifdef INCLUDE_SMB_IFMODIFIED
  939. NTSTATUS
  940. SrvSetLastWriteTime (
  941. IN PRFCB Rfcb,
  942. IN ULONG LastWriteTimeInSeconds,
  943. IN ACCESS_MASK GrantedAccess,
  944. IN BOOLEAN ForceChanges
  945. );
  946. #else
  947. NTSTATUS
  948. SrvSetLastWriteTime (
  949. IN PRFCB Rfcb,
  950. IN ULONG LastWriteTimeInSeconds,
  951. IN ACCESS_MASK GrantedAccess
  952. );
  953. #endif
  954. ULONG
  955. SrvLengthOfStringInApiBuffer (
  956. IN PUNICODE_STRING UnicodeString
  957. );
  958. //
  959. // Routine for updating quality of service information for a vc
  960. //
  961. VOID
  962. SrvUpdateVcQualityOfService(
  963. IN PCONNECTION Connection,
  964. IN PLARGE_INTEGER CurrentTime OPTIONAL
  965. );
  966. //
  967. // Routines for obtaining and releasing share root directory handles
  968. // for removable devices
  969. //
  970. VOID
  971. SrvFillInFileSystemName(
  972. IN PSHARE Share,
  973. IN PWSTR FileSystemName,
  974. IN ULONG FileSystemNameLength
  975. );
  976. NTSTATUS
  977. SrvGetShareRootHandle(
  978. IN PSHARE Share
  979. );
  980. BOOLEAN
  981. SrvRefreshShareRootHandle (
  982. IN PSHARE Share,
  983. OUT PNTSTATUS Status
  984. );
  985. VOID
  986. SrvReleaseShareRootHandle(
  987. IN PSHARE Share
  988. );
  989. //
  990. // SMB validation routine.
  991. //
  992. BOOLEAN SRVFASTCALL
  993. SrvValidateSmb (
  994. IN PWORK_CONTEXT WorkContext
  995. );
  996. //
  997. // Check on saved error.
  998. //
  999. NTSTATUS
  1000. SrvCheckForSavedError(
  1001. IN PWORK_CONTEXT WorkContext,
  1002. IN PRFCB Rfcb
  1003. );
  1004. //
  1005. // Read registry parameters.
  1006. //
  1007. VOID
  1008. SrvGetMultiSZList(
  1009. PWSTR **ListPointer,
  1010. PWSTR BaseKeyName,
  1011. PWSTR ParameterKeyName,
  1012. PWSTR *DefaultPointerValue
  1013. );
  1014. //
  1015. // Read server display name from the registry.
  1016. //
  1017. VOID
  1018. SrvGetAlertServiceName(
  1019. VOID
  1020. );
  1021. //
  1022. // Read OS version string from registry.
  1023. //
  1024. VOID
  1025. SrvGetOsVersionString(
  1026. VOID
  1027. );
  1028. //
  1029. // Queues up blocks for later cleanup
  1030. //
  1031. VOID
  1032. DispatchToOrphanage(
  1033. IN PQUEUEABLE_BLOCK_HEADER Block
  1034. );
  1035. #ifdef INCLUDE_SMB_IFMODIFIED
  1036. NTSTATUS
  1037. SrvGetUsnInfoForFile(
  1038. IN PWORK_CONTEXT WorkContext,
  1039. IN PRFCB Rfcb,
  1040. IN BOOLEAN SubmitClose,
  1041. OUT PLARGE_INTEGER Usn,
  1042. OUT PLARGE_INTEGER FileRefNumber
  1043. );
  1044. #define QuadAlign(P) ( \
  1045. ((((P)) + 7) & (-8)) \
  1046. )
  1047. #endif
  1048. #ifdef INCLUDE_SMB_PERSISTENT
  1049. NTSTATUS
  1050. SrvSetupPersistentShare (
  1051. IN OUT PSHARE Share,
  1052. IN BOOLEAN Restore
  1053. );
  1054. NTSTATUS
  1055. SrvClosePersistentShare (
  1056. IN OUT PSHARE Share,
  1057. IN BOOLEAN ClearState
  1058. );
  1059. SMB_STATUS
  1060. SrvPostPersistentOpen (
  1061. IN OUT PWORK_CONTEXT WorkContext,
  1062. IN SMB_STATUS SmbStatus
  1063. );
  1064. #endif
  1065. #endif // def _SRVSUPP_