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.

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