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.

569 lines
12 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. SrvSvcP.h
  5. Abstract:
  6. This is the header file for the NT server service.
  7. Author:
  8. David Treadwell (davidtr) 10-Jan-1991
  9. Revision History:
  10. --*/
  11. #ifndef _SRVSVCP_
  12. #define _SRVSVCP_
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <rpc.h>
  18. #include <lmcons.h>
  19. #include <secobj.h>
  20. #include <ntlsapi.h>
  21. #include <srvfsctl.h>
  22. #include <srvsvc.h>
  23. #include <svcs.h>
  24. #include <winreg.h>
  25. #include "ssdebug.h"
  26. #include "sssec.h"
  27. //
  28. // String constants.
  29. //
  30. #define IPC_SHARE_NAME TEXT("IPC$")
  31. #define ADMIN_SHARE_NAME TEXT("ADMIN$")
  32. #define SRVSVC_MAX_NUMBER_OF_DISKS 26
  33. //
  34. // Internationalizable strings
  35. //
  36. extern LPWSTR SsAdminShareRemark ;
  37. extern LPWSTR SsIPCShareRemark ;
  38. extern LPWSTR SsDiskAdminShareRemark ;
  39. //
  40. // Bits of server type (in announcement messages) that can only be set
  41. // by the server itself -- not by services via the internal API
  42. // I_NetServerSetServiceBits.
  43. //
  44. // SV_TYPE_TIME_SOURCE is a pseudo internal bit. It can be set internally or
  45. // it can be set by the w32time service.
  46. //
  47. #define SERVER_TYPE_INTERNAL_BITS (SV_TYPE_SERVER | \
  48. SV_TYPE_PRINTQ_SERVER | \
  49. SV_TYPE_NT | \
  50. SV_TYPE_DFS)
  51. //
  52. // INITIAL_BUFFER_SIZE is the buffer size that GetInfo and Enum requests
  53. // first try to fill. If this buffer isn't large enough, they allocate
  54. // a buffer large enough to hold all the information plus a fudge factor,
  55. // EXTRA_ALLOCATION.
  56. //
  57. #define INITIAL_BUFFER_SIZE (ULONG)8192
  58. #define EXTRA_ALLOCATION 1024
  59. //
  60. // ServerProductName in SERVER_SERVICE_DATA is the name passed to the
  61. // Licensing DLL as the name of this service. MAXPRODNAME is the max
  62. // number of characters in the service name.
  63. #define SERVER_PRODUCT_NAME L"SMBServer"
  64. // szVersionNumber in SERVER_SERVICE_DATA is the version string passed
  65. // to the Licensing DLL as the vesion of this service. MAXVERSIONSZ
  66. // is the max number of characters for the version string
  67. #define MAXVERSIONSZ 10
  68. //
  69. // Structures used to hold transport specific server type bits
  70. //
  71. typedef struct _TRANSPORT_LIST_ENTRY {
  72. struct _TRANSPORT_LIST_ENTRY *Next;
  73. LPWSTR TransportName; // device name for xport
  74. DWORD ServiceBits; // SV... announce bits
  75. } TRANSPORT_LIST_ENTRY, *PTRANSPORT_LIST_ENTRY;
  76. typedef struct _NAME_LIST_ENTRY {
  77. struct _NAME_LIST_ENTRY *Next;
  78. CHAR TransportAddress[ MAX_PATH ]; // address of this server
  79. ULONG TransportAddressLength;
  80. LPWSTR DomainName; // name of the domain
  81. DWORD ServiceBits; // SV... announce bits
  82. struct {
  83. ULONG PrimaryName: 1; // Is this the server's primary name?
  84. };
  85. PTRANSPORT_LIST_ENTRY Transports;
  86. } NAME_LIST_ENTRY, *PNAME_LIST_ENTRY;
  87. //
  88. // Structure for server service global data.
  89. //
  90. typedef struct _SERVER_SERVICE_DATA {
  91. SERVER_INFO_102 ServerInfo102;
  92. SERVER_INFO_599 ServerInfo599;
  93. SERVER_INFO_598 ServerInfo598;
  94. //
  95. // Handle for accessing the server.
  96. //
  97. HANDLE SsServerDeviceHandle;
  98. //
  99. // Pointer to global data made available by SVCS main image.
  100. //
  101. PSVCHOST_GLOBAL_DATA SsLmsvcsGlobalData;
  102. //
  103. // Resource for synchronizing access to server info.
  104. //
  105. RTL_RESOURCE SsServerInfoResource;
  106. BOOL SsServerInfoResourceInitialized;
  107. //
  108. // Boolean indicating whether the server service is initialized.
  109. //
  110. BOOL SsInitialized;
  111. //
  112. // Boolean indicating whether the kernel-mode server FSP has been
  113. // started.
  114. //
  115. BOOL SsServerFspStarted;
  116. //
  117. // Event used for synchronizing server service termination.
  118. //
  119. HANDLE SsTerminationEvent;
  120. //
  121. // Event used for forcing the server to announce itself on the network from
  122. // remote clients.
  123. //
  124. HANDLE SsAnnouncementEvent;
  125. //
  126. // Event used for forcing the server to announce itself on the network from
  127. // inside the server service.
  128. //
  129. HANDLE SsStatusChangedEvent;
  130. //
  131. // Event used to detect domain name changes
  132. //
  133. HANDLE SsDomainNameChangeEvent;
  134. //
  135. // Name of this computer in OEM format.
  136. //
  137. CHAR SsServerTransportAddress[ MAX_PATH ];
  138. ULONG SsServerTransportAddressLength;
  139. //
  140. // List containing transport specific service names and bits
  141. //
  142. PNAME_LIST_ENTRY SsServerNameList;
  143. //
  144. // If we are asked to set some service bits before we've bound to
  145. // any transports, we need to save those bits here and use them later
  146. // when we finally do bind to transports.
  147. //
  148. DWORD ServiceBits;
  149. BOOLEAN IsDfsRoot; // TRUE if we are the root of a DFS tree
  150. UNICODE_STRING ServerAnnounceName;
  151. LONG NumberOfPrintShares;
  152. WCHAR ServerNameBuffer[MAX_PATH];
  153. WCHAR AnnounceNameBuffer[MAX_PATH];
  154. WCHAR ServerCommentBuffer[MAXCOMMENTSZ+1];
  155. WCHAR UserPathBuffer[MAX_PATH+1];
  156. WCHAR DomainNameBuffer[MAX_PATH];
  157. WCHAR ServerProductName[ sizeof( SERVER_PRODUCT_NAME ) ];
  158. WCHAR szVersionNumber[ MAXVERSIONSZ+1 ];
  159. //
  160. // Number of XACTSRV worker threads.
  161. //
  162. LONG XsThreads;
  163. //
  164. // This is the number of Xs threads blocked waiting for an LPC request.
  165. // When it drops to zero, all threads are active and another thread is
  166. // created.
  167. //
  168. LONG XsWaitingApiThreads;
  169. //
  170. // Event signalled when the last XACTSRV worker thread terminates.
  171. //
  172. HANDLE XsAllThreadsTerminatedEvent;
  173. //
  174. // Boolean indicating whether XACTSRV is active or terminating.
  175. //
  176. BOOL XsTerminating;
  177. //
  178. // Handle for the LPC port used for communication between the file server
  179. // and XACTSRV.
  180. //
  181. HANDLE XsConnectionPortHandle;
  182. HANDLE XsCommunicationPortHandle;
  183. //
  184. // Handle to the NTLSAPI.DLL library
  185. //
  186. HMODULE XsLicenseLibrary;
  187. //
  188. // Entry point for obtaining a client license
  189. //
  190. PNT_LICENSE_REQUEST_W SsLicenseRequest;
  191. //
  192. // Entry point for freeing a client license
  193. //
  194. PNT_LS_FREE_HANDLE SsFreeLicense;
  195. //
  196. // Handle to the XACT library
  197. //
  198. HMODULE XsXactsrvLibrary;
  199. BOOL ApiThreadsStarted;
  200. //
  201. // This resource is used to ensure that more than one thread aren't trying
  202. // to load the xactsrv library at the same time.
  203. //
  204. BOOL LibraryResourceInitialized;
  205. RTL_RESOURCE LibraryResource;
  206. } SERVER_SERVICE_DATA, *PSERVER_SERVICE_DATA;
  207. extern SERVER_SERVICE_DATA SsData;
  208. //
  209. // Structure type used for generalized switch matching.
  210. //
  211. typedef struct _FIELD_DESCRIPTOR {
  212. LPWCH FieldName;
  213. ULONG FieldType;
  214. ULONG FieldOffset;
  215. ULONG Level;
  216. DWORD ParameterNumber;
  217. ULONG Settable;
  218. DWORD_PTR DefaultValue;
  219. DWORD MinimumValue;
  220. DWORD MaximumValue;
  221. } FIELD_DESCRIPTOR, *PFIELD_DESCRIPTOR;
  222. //
  223. // Used by NetrShareEnumSticky to get share information from the registry.
  224. //
  225. typedef struct _SRVSVC_SHARE_ENUM_INFO {
  226. ULONG Level;
  227. ULONG ResumeHandle;
  228. ULONG EntriesRead;
  229. ULONG TotalEntries;
  230. ULONG TotalBytesNeeded;
  231. PVOID OutputBuffer;
  232. ULONG OutputBufferLength;
  233. //
  234. // Scratch fields used by SsEnumerateStickyShares
  235. //
  236. ULONG ShareEnumIndex;
  237. PCHAR StartOfFixedData;
  238. PCHAR EndOfVariableData;
  239. } SRVSVC_SHARE_ENUM_INFO, *PSRVSVC_SHARE_ENUM_INFO;
  240. //
  241. // Internal structure used for two-step delete of share's
  242. //
  243. typedef struct _SHARE_DEL_CONTEXT {
  244. struct _SHARE_DEL_CONTEXT* Next;
  245. SERVER_REQUEST_PACKET Srp;
  246. BOOL IsPrintShare;
  247. BOOL IsSpecial;
  248. //WCHAR NetName[];
  249. } SHARE_DEL_CONTEXT, *PSHARE_DEL_CONTEXT;
  250. //
  251. // Manifests that determine field type.
  252. //
  253. #define BOOLEAN_FIELD 0
  254. #define DWORD_FIELD 1
  255. #define LPSTR_FIELD 2
  256. //
  257. // Manifests that determine when a field may be set.
  258. //
  259. #define NOT_SETTABLE 0
  260. #define SET_ON_STARTUP 1
  261. #define ALWAYS_SETTABLE 2
  262. //
  263. // Data for all server info fields.
  264. //
  265. extern FIELD_DESCRIPTOR SsServerInfoFields[];
  266. extern VOID SsInitializeServerInfoFields( VOID );
  267. //
  268. // Macros.
  269. //
  270. #define POINTER_TO_OFFSET(val,start) \
  271. (val) = (val) == NULL ? NULL : (PVOID)( (PCHAR)(val) - (ULONG_PTR)(start) )
  272. #define OFFSET_TO_POINTER(val,start) \
  273. (val) = (val) == NULL ? NULL : (PVOID)( (PCHAR)(val) + (ULONG_PTR)(start) )
  274. #define FIXED_SIZE_OF_SHARE(level) \
  275. ( (level) == 0 ? sizeof(SHARE_INFO_0) : \
  276. (level) == 1 ? sizeof(SHARE_INFO_1) : \
  277. (level) == 2 ? sizeof(SHARE_INFO_2) : \
  278. sizeof(SHARE_INFO_502) )
  279. #define SIZE_WSTR( Str ) \
  280. ( ( Str ) == NULL ? 0 : ((wcslen( Str ) + 1) * sizeof(WCHAR)) )
  281. //
  282. // Internal routine prototypes.
  283. //
  284. PSERVER_REQUEST_PACKET
  285. SsAllocateSrp (
  286. VOID
  287. );
  288. NET_API_STATUS
  289. SsCheckAccess (
  290. IN PSRVSVC_SECURITY_OBJECT SecurityObject,
  291. IN ACCESS_MASK DesiredAccess
  292. );
  293. VOID
  294. SsCloseServer (
  295. VOID
  296. );
  297. VOID
  298. SsControlCHandler (
  299. IN ULONG CtrlType
  300. );
  301. NET_API_STATUS
  302. SsCreateSecurityObjects (
  303. VOID
  304. );
  305. VOID
  306. SsDeleteSecurityObjects (
  307. VOID
  308. );
  309. VOID
  310. SsFreeSrp (
  311. IN PSERVER_REQUEST_PACKET Srp
  312. );
  313. NET_API_STATUS
  314. SsInitialize (
  315. IN DWORD argc,
  316. IN LPTSTR argv[]
  317. );
  318. VOID
  319. SsLogEvent(
  320. IN DWORD MessageId,
  321. IN DWORD NumberOfSubStrings,
  322. IN LPWSTR *SubStrings,
  323. IN DWORD ErrorCode
  324. );
  325. NET_API_STATUS
  326. SsOpenServer ( void );
  327. NET_API_STATUS
  328. SsParseCommandLine (
  329. IN DWORD argc,
  330. IN LPTSTR argv[],
  331. IN BOOLEAN Starting
  332. );
  333. DWORD
  334. SsScavengerThread (
  335. IN LPVOID lpThreadParameter
  336. );
  337. NET_API_STATUS
  338. SsServerFsControlGetInfo (
  339. IN ULONG ServerControlCode,
  340. IN PSERVER_REQUEST_PACKET Srp,
  341. IN OUT PVOID *OutputBuffer,
  342. IN OUT ULONG OutputBufferLength
  343. );
  344. NET_API_STATUS
  345. SsServerFsControl (
  346. IN ULONG ServerControlCode,
  347. IN PSERVER_REQUEST_PACKET Srp,
  348. IN PVOID Buffer OPTIONAL,
  349. IN ULONG BufferLength
  350. );
  351. DWORD
  352. SsGetServerType (
  353. VOID
  354. );
  355. VOID
  356. SsSetExportedServerType (
  357. IN PNAME_LIST_ENTRY Service OPTIONAL,
  358. IN BOOL ExternalBitsAlreadyChanged,
  359. IN BOOL UpdateImmediately
  360. );
  361. NET_API_STATUS
  362. SsSetField (
  363. IN PFIELD_DESCRIPTOR Field,
  364. IN PVOID Value,
  365. IN BOOLEAN WriteToRegistry,
  366. OUT BOOLEAN *AnnouncementInformationChanged OPTIONAL
  367. );
  368. UINT
  369. SsGetDriveType (
  370. IN LPWSTR path
  371. );
  372. NET_API_STATUS
  373. SsTerminate (
  374. VOID
  375. );
  376. DWORD
  377. SsAtol (
  378. IN LPTSTR Input
  379. );
  380. VOID
  381. SsNotifyRdrOfGuid(
  382. LPGUID Guid
  383. );
  384. VOID
  385. AnnounceServiceStatus (
  386. DWORD increment
  387. );
  388. VOID
  389. BindToTransport (
  390. IN PVOID TransportName
  391. );
  392. VOID
  393. BindOptionalNames (
  394. IN PWSTR TransportName
  395. );
  396. NET_API_STATUS NET_API_FUNCTION
  397. I_NetrServerTransportAddEx (
  398. IN DWORD Level,
  399. IN LPTRANSPORT_INFO Buffer
  400. );
  401. VOID
  402. I_NetServerTransportDel(
  403. IN PUNICODE_STRING TransportName
  404. );
  405. NET_API_STATUS
  406. StartPnpNotifications (
  407. VOID
  408. );
  409. NET_API_STATUS NET_API_FUNCTION
  410. I_NetrShareDelStart (
  411. IN LPWSTR ServerName,
  412. IN LPWSTR NetName,
  413. IN DWORD Reserved,
  414. IN PSHARE_DEL_HANDLE ContextHandle,
  415. IN BOOLEAN CheckAccess
  416. );
  417. NET_API_STATUS NET_API_FUNCTION
  418. I_NetrShareAdd (
  419. IN LPWSTR ServerName,
  420. IN DWORD Level,
  421. IN LPSHARE_INFO Buffer,
  422. OUT LPDWORD ErrorParameter,
  423. IN BOOLEAN BypassSecurity
  424. );
  425. //
  426. // XACTSRV functions.
  427. //
  428. DWORD
  429. XsStartXactsrv (
  430. VOID
  431. );
  432. VOID
  433. XsStopXactsrv (
  434. VOID
  435. );
  436. NET_API_STATUS
  437. ShareEnumCommon (
  438. IN DWORD Level,
  439. OUT LPBYTE *Buffer,
  440. IN DWORD PreferredMaximumLength,
  441. OUT LPDWORD EntriesRead,
  442. OUT LPDWORD TotalEntries,
  443. IN OUT LPDWORD ResumeHandle OPTIONAL,
  444. IN LPWSTR NetName OPTIONAL
  445. );
  446. NET_API_STATUS
  447. ConvertStringToTransportAddress (
  448. IN PUNICODE_STRING InputName,
  449. OUT CHAR TransportAddress[MAX_PATH],
  450. OUT PULONG TransportAddressLength
  451. );
  452. VOID
  453. SsSetDfsRoot();
  454. VOID
  455. SsSetDomainName (
  456. VOID
  457. );
  458. #endif // ndef _SRVSVCP_