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.

2188 lines
74 KiB

  1. /*++ BUILD Version: 0003 // Increment this if a change has global effects
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. ntseapi.h
  5. Abstract:
  6. This module contains the Security APIs and any public data
  7. structures needed to call these APIs.
  8. This module should be included by including "nt.h".
  9. Author:
  10. Gary Kimura (GaryKi) 06-Mar-1989
  11. Revision History:
  12. --*/
  13. #ifndef _NTSEAPI_
  14. #define _NTSEAPI_
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. ////////////////////////////////////////////////////////////////////////
  22. // //
  23. // Pointers to Opaque data types //
  24. // //
  25. ////////////////////////////////////////////////////////////////////////
  26. //
  27. // Some of these data types may have related data types defined elsewhere
  28. // in this file.
  29. //
  30. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  31. //
  32. // Define an access token from a programmer's viewpoint. The structure is
  33. // completely opaque and the programer is only allowed to have pointers
  34. // to tokens.
  35. //
  36. typedef PVOID PACCESS_TOKEN; // winnt
  37. //
  38. // Pointer to a SECURITY_DESCRIPTOR opaque data type.
  39. //
  40. typedef PVOID PSECURITY_DESCRIPTOR; // winnt
  41. //
  42. // Define a pointer to the Security ID data type (an opaque data type)
  43. //
  44. typedef PVOID PSID; // winnt
  45. // end_ntddk end_wdm end_nthal end_ntifs
  46. // begin_winnt
  47. ////////////////////////////////////////////////////////////////////////
  48. // //
  49. // ACCESS MASK //
  50. // //
  51. ////////////////////////////////////////////////////////////////////////
  52. //
  53. // Define the access mask as a longword sized structure divided up as
  54. // follows:
  55. //
  56. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  57. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  58. // +---------------+---------------+-------------------------------+
  59. // |G|G|G|G|Res'd|A| StandardRights| SpecificRights |
  60. // |R|W|E|A| |S| | |
  61. // +-+-------------+---------------+-------------------------------+
  62. //
  63. // typedef struct _ACCESS_MASK {
  64. // USHORT SpecificRights;
  65. // UCHAR StandardRights;
  66. // UCHAR AccessSystemAcl : 1;
  67. // UCHAR Reserved : 3;
  68. // UCHAR GenericAll : 1;
  69. // UCHAR GenericExecute : 1;
  70. // UCHAR GenericWrite : 1;
  71. // UCHAR GenericRead : 1;
  72. // } ACCESS_MASK;
  73. // typedef ACCESS_MASK *PACCESS_MASK;
  74. //
  75. // but to make life simple for programmer's we'll allow them to specify
  76. // a desired access mask by simply OR'ing together mulitple single rights
  77. // and treat an access mask as a ULONG. For example
  78. //
  79. // DesiredAccess = DELETE | READ_CONTROL
  80. //
  81. // So we'll declare ACCESS_MASK as ULONG
  82. //
  83. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  84. typedef ULONG ACCESS_MASK;
  85. typedef ACCESS_MASK *PACCESS_MASK;
  86. // end_winnt
  87. // end_ntddk end_wdm end_nthal end_ntifs
  88. // begin_winnt
  89. ////////////////////////////////////////////////////////////////////////
  90. // //
  91. // ACCESS TYPES //
  92. // //
  93. ////////////////////////////////////////////////////////////////////////
  94. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  95. //
  96. // The following are masks for the predefined standard access types
  97. //
  98. #define DELETE (0x00010000L)
  99. #define READ_CONTROL (0x00020000L)
  100. #define WRITE_DAC (0x00040000L)
  101. #define WRITE_OWNER (0x00080000L)
  102. #define SYNCHRONIZE (0x00100000L)
  103. #define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
  104. #define STANDARD_RIGHTS_READ (READ_CONTROL)
  105. #define STANDARD_RIGHTS_WRITE (READ_CONTROL)
  106. #define STANDARD_RIGHTS_EXECUTE (READ_CONTROL)
  107. #define STANDARD_RIGHTS_ALL (0x001F0000L)
  108. #define SPECIFIC_RIGHTS_ALL (0x0000FFFFL)
  109. //
  110. // AccessSystemAcl access type
  111. //
  112. #define ACCESS_SYSTEM_SECURITY (0x01000000L)
  113. //
  114. // MaximumAllowed access type
  115. //
  116. #define MAXIMUM_ALLOWED (0x02000000L)
  117. //
  118. // These are the generic rights.
  119. //
  120. #define GENERIC_READ (0x80000000L)
  121. #define GENERIC_WRITE (0x40000000L)
  122. #define GENERIC_EXECUTE (0x20000000L)
  123. #define GENERIC_ALL (0x10000000L)
  124. //
  125. // Define the generic mapping array. This is used to denote the
  126. // mapping of each generic access right to a specific access mask.
  127. //
  128. typedef struct _GENERIC_MAPPING {
  129. ACCESS_MASK GenericRead;
  130. ACCESS_MASK GenericWrite;
  131. ACCESS_MASK GenericExecute;
  132. ACCESS_MASK GenericAll;
  133. } GENERIC_MAPPING;
  134. typedef GENERIC_MAPPING *PGENERIC_MAPPING;
  135. // end_winnt end_ntddk end_wdm end_nthal end_ntifs
  136. // begin_ntddk begin_wdm begin_winnt begin_nthal begin_ntifs
  137. ////////////////////////////////////////////////////////////////////////
  138. // //
  139. // LUID_AND_ATTRIBUTES //
  140. // //
  141. ////////////////////////////////////////////////////////////////////////
  142. //
  143. //
  144. #include <pshpack4.h>
  145. typedef struct _LUID_AND_ATTRIBUTES {
  146. LUID Luid;
  147. ULONG Attributes;
  148. } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
  149. typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
  150. typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
  151. #include <poppack.h>
  152. // end_winnt end_wdm end_ntddk end_nthal end_ntifs
  153. // begin_winnt
  154. ////////////////////////////////////////////////////////////////////////
  155. // //
  156. // Security Id (SID) //
  157. // //
  158. ////////////////////////////////////////////////////////////////////////
  159. //
  160. //
  161. // Pictorially the structure of an SID is as follows:
  162. //
  163. // 1 1 1 1 1 1
  164. // 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  165. // +---------------------------------------------------------------+
  166. // | SubAuthorityCount |Reserved1 (SBZ)| Revision |
  167. // +---------------------------------------------------------------+
  168. // | IdentifierAuthority[0] |
  169. // +---------------------------------------------------------------+
  170. // | IdentifierAuthority[1] |
  171. // +---------------------------------------------------------------+
  172. // | IdentifierAuthority[2] |
  173. // +---------------------------------------------------------------+
  174. // | |
  175. // +- - - - - - - - SubAuthority[] - - - - - - - - -+
  176. // | |
  177. // +---------------------------------------------------------------+
  178. //
  179. //
  180. // begin_ntifs
  181. #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
  182. #define SID_IDENTIFIER_AUTHORITY_DEFINED
  183. typedef struct _SID_IDENTIFIER_AUTHORITY {
  184. UCHAR Value[6];
  185. } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
  186. #endif
  187. #ifndef SID_DEFINED
  188. #define SID_DEFINED
  189. typedef struct _SID {
  190. UCHAR Revision;
  191. UCHAR SubAuthorityCount;
  192. SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
  193. #ifdef MIDL_PASS
  194. [size_is(SubAuthorityCount)] ULONG SubAuthority[*];
  195. #else // MIDL_PASS
  196. ULONG SubAuthority[ANYSIZE_ARRAY];
  197. #endif // MIDL_PASS
  198. } SID, *PISID;
  199. #endif
  200. #define SID_REVISION (1) // Current revision level
  201. #define SID_MAX_SUB_AUTHORITIES (15)
  202. #define SID_RECOMMENDED_SUB_AUTHORITIES (1) // Will change to around 6
  203. // in a future release.
  204. #ifndef MIDL_PASS
  205. #define SECURITY_MAX_SID_SIZE \
  206. (sizeof(SID) - sizeof(ULONG) + (SID_MAX_SUB_AUTHORITIES * sizeof(ULONG)))
  207. #endif // MIDL_PASS
  208. typedef enum _SID_NAME_USE {
  209. SidTypeUser = 1,
  210. SidTypeGroup,
  211. SidTypeDomain,
  212. SidTypeAlias,
  213. SidTypeWellKnownGroup,
  214. SidTypeDeletedAccount,
  215. SidTypeInvalid,
  216. SidTypeUnknown,
  217. SidTypeComputer
  218. } SID_NAME_USE, *PSID_NAME_USE;
  219. typedef struct _SID_AND_ATTRIBUTES {
  220. PSID Sid;
  221. ULONG Attributes;
  222. } SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES;
  223. typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
  224. typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
  225. /////////////////////////////////////////////////////////////////////////////
  226. // //
  227. // Universal well-known SIDs //
  228. // //
  229. // Null SID S-1-0-0 //
  230. // World S-1-1-0 //
  231. // Local S-1-2-0 //
  232. // Creator Owner ID S-1-3-0 //
  233. // Creator Group ID S-1-3-1 //
  234. // Creator Owner Server ID S-1-3-2 //
  235. // Creator Group Server ID S-1-3-3 //
  236. // //
  237. // (Non-unique IDs) S-1-4 //
  238. // //
  239. /////////////////////////////////////////////////////////////////////////////
  240. #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
  241. #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
  242. #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
  243. #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
  244. #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
  245. #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
  246. #define SECURITY_NULL_RID (0x00000000L)
  247. #define SECURITY_WORLD_RID (0x00000000L)
  248. #define SECURITY_LOCAL_RID (0x00000000L)
  249. #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
  250. #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
  251. #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
  252. #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
  253. ///////////////////////////////////////////////////////////////////////////////
  254. // //
  255. // NT well-known SIDs //
  256. // //
  257. // NT Authority S-1-5 //
  258. // Dialup S-1-5-1 //
  259. // //
  260. // Network S-1-5-2 //
  261. // Batch S-1-5-3 //
  262. // Interactive S-1-5-4 //
  263. // (Logon IDs) S-1-5-5-X-Y //
  264. // Service S-1-5-6 //
  265. // AnonymousLogon S-1-5-7 (aka null logon session) //
  266. // Proxy S-1-5-8 //
  267. // Enterprise DC (EDC) S-1-5-9 (aka domain controller account) //
  268. // Self S-1-5-10 (self RID) //
  269. // Authenticated User S-1-5-11 (Authenticated user somewhere) //
  270. // Restricted Code S-1-5-12 (Running restricted code) //
  271. // Terminal Server S-1-5-13 (Running on Terminal Server) //
  272. // Remote Logon S-1-5-14 (Remote Interactive Logon) //
  273. // This Organization S-1-5-15 //
  274. // //
  275. // Local System S-1-5-18 //
  276. // Local Service S-1-5-19 //
  277. // Network Service S-1-5-20 //
  278. // //
  279. // (NT non-unique IDs) S-1-5-0x15-... (NT Domain Sids) //
  280. // //
  281. // (Built-in domain) S-1-5-0x20 //
  282. // //
  283. // (Security Package IDs) S-1-5-0x40 //
  284. // NTLM Authentication S-1-5-0x40-10 //
  285. // SChannel Authentication S-1-5-0x40-14 //
  286. // Digest Authentication S-1-5-0x40-21 //
  287. // //
  288. // Other Organization S-1-5-1000 (>=1000 can not be filtered) //
  289. // //
  290. // //
  291. // NOTE: the relative identifier values (RIDs) determine which security //
  292. // boundaries the SID is allowed to cross. Before adding new RIDs, //
  293. // a determination needs to be made regarding which range they should //
  294. // be added to in order to ensure proper "SID filtering" //
  295. // //
  296. ///////////////////////////////////////////////////////////////////////////////
  297. #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5} // ntifs
  298. #define SECURITY_DIALUP_RID (0x00000001L)
  299. #define SECURITY_NETWORK_RID (0x00000002L)
  300. #define SECURITY_BATCH_RID (0x00000003L)
  301. #define SECURITY_INTERACTIVE_RID (0x00000004L)
  302. #define SECURITY_LOGON_IDS_RID (0x00000005L)
  303. #define SECURITY_LOGON_IDS_RID_COUNT (3L)
  304. #define SECURITY_SERVICE_RID (0x00000006L)
  305. #define SECURITY_ANONYMOUS_LOGON_RID (0x00000007L)
  306. #define SECURITY_PROXY_RID (0x00000008L)
  307. #define SECURITY_ENTERPRISE_CONTROLLERS_RID (0x00000009L)
  308. #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
  309. #define SECURITY_PRINCIPAL_SELF_RID (0x0000000AL)
  310. #define SECURITY_AUTHENTICATED_USER_RID (0x0000000BL)
  311. #define SECURITY_RESTRICTED_CODE_RID (0x0000000CL)
  312. #define SECURITY_TERMINAL_SERVER_RID (0x0000000DL)
  313. #define SECURITY_REMOTE_LOGON_RID (0x0000000EL)
  314. #define SECURITY_THIS_ORGANIZATION_RID (0x0000000FL)
  315. #define SECURITY_LOCAL_SYSTEM_RID (0x00000012L)
  316. #define SECURITY_LOCAL_SERVICE_RID (0x00000013L)
  317. #define SECURITY_NETWORK_SERVICE_RID (0x00000014L)
  318. #define SECURITY_NT_NON_UNIQUE (0x00000015L)
  319. #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT (3L)
  320. #define SECURITY_BUILTIN_DOMAIN_RID (0x00000020L)
  321. #define SECURITY_PACKAGE_BASE_RID (0x00000040L)
  322. #define SECURITY_PACKAGE_RID_COUNT (2L)
  323. #define SECURITY_PACKAGE_NTLM_RID (0x0000000AL)
  324. #define SECURITY_PACKAGE_SCHANNEL_RID (0x0000000EL)
  325. #define SECURITY_PACKAGE_DIGEST_RID (0x00000015L)
  326. #define SECURITY_MAX_ALWAYS_FILTERED (0x000003E7L)
  327. #define SECURITY_MIN_NEVER_FILTERED (0x000003E8L)
  328. #define SECURITY_OTHER_ORGANIZATION_RID (0x000003E8L)
  329. /////////////////////////////////////////////////////////////////////////////
  330. // //
  331. // well-known domain relative sub-authority values (RIDs)... //
  332. // //
  333. /////////////////////////////////////////////////////////////////////////////
  334. // Well-known users ...
  335. #define FOREST_USER_RID_MAX (0x000001F3L)
  336. #define DOMAIN_USER_RID_ADMIN (0x000001F4L)
  337. #define DOMAIN_USER_RID_GUEST (0x000001F5L)
  338. #define DOMAIN_USER_RID_KRBTGT (0x000001F6L)
  339. #define DOMAIN_USER_RID_MAX (0x000003E7L)
  340. // well-known groups ...
  341. #define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
  342. #define DOMAIN_GROUP_RID_USERS (0x00000201L)
  343. #define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
  344. #define DOMAIN_GROUP_RID_COMPUTERS (0x00000203L)
  345. #define DOMAIN_GROUP_RID_CONTROLLERS (0x00000204L)
  346. #define DOMAIN_GROUP_RID_CERT_ADMINS (0x00000205L)
  347. #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (0x00000206L)
  348. #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (0x00000207L)
  349. #define DOMAIN_GROUP_RID_POLICY_ADMINS (0x00000208L)
  350. // well-known aliases ...
  351. #define DOMAIN_ALIAS_RID_ADMINS (0x00000220L)
  352. #define DOMAIN_ALIAS_RID_USERS (0x00000221L)
  353. #define DOMAIN_ALIAS_RID_GUESTS (0x00000222L)
  354. #define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L)
  355. #define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
  356. #define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
  357. #define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L)
  358. #define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
  359. #define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L)
  360. #define DOMAIN_ALIAS_RID_RAS_SERVERS (0x00000229L)
  361. #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS (0x0000022AL)
  362. #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS (0x0000022BL)
  363. #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS (0x0000022CL)
  364. #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS (0x0000022DL)
  365. #define DOMAIN_ALIAS_RID_MONITORING_USERS (0x0000022EL)
  366. #define DOMAIN_ALIAS_RID_LOGGING_USERS (0x0000022FL)
  367. #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS (0x00000230L)
  368. #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS (0x00000231L)
  369. // end_winnt end_ntifs
  370. /////////////////////////////////////////////////////////////////////////////
  371. // //
  372. // Foreign Security Authorities //
  373. // //
  374. // SiteServer Authority S-1-6 //
  375. // Internet Site Authority S-1-7 //
  376. // Exchange Authority S-1-8 //
  377. // Resource Manager Authority S-1-9 //
  378. // Passport Authority S-1-10 //
  379. // //
  380. /////////////////////////////////////////////////////////////////////////////
  381. #define SECURITY_SITESERVER_AUTHORITY {0,0,0,0,0,6}
  382. #define SECURITY_INTERNETSITE_AUTHORITY {0,0,0,0,0,7}
  383. #define SECURITY_EXCHANGE_AUTHORITY {0,0,0,0,0,8}
  384. #define SECURITY_PASSPORT_AUTHORITY {0,0,0,0,0,10}
  385. //
  386. // Well known SID definitions for lookup.
  387. //
  388. // begin_winnt begin_ntddk begin_ntifs
  389. typedef enum {
  390. WinNullSid = 0,
  391. WinWorldSid = 1,
  392. WinLocalSid = 2,
  393. WinCreatorOwnerSid = 3,
  394. WinCreatorGroupSid = 4,
  395. WinCreatorOwnerServerSid = 5,
  396. WinCreatorGroupServerSid = 6,
  397. WinNtAuthoritySid = 7,
  398. WinDialupSid = 8,
  399. WinNetworkSid = 9,
  400. WinBatchSid = 10,
  401. WinInteractiveSid = 11,
  402. WinServiceSid = 12,
  403. WinAnonymousSid = 13,
  404. WinProxySid = 14,
  405. WinEnterpriseControllersSid = 15,
  406. WinSelfSid = 16,
  407. WinAuthenticatedUserSid = 17,
  408. WinRestrictedCodeSid = 18,
  409. WinTerminalServerSid = 19,
  410. WinRemoteLogonIdSid = 20,
  411. WinLogonIdsSid = 21,
  412. WinLocalSystemSid = 22,
  413. WinLocalServiceSid = 23,
  414. WinNetworkServiceSid = 24,
  415. WinBuiltinDomainSid = 25,
  416. WinBuiltinAdministratorsSid = 26,
  417. WinBuiltinUsersSid = 27,
  418. WinBuiltinGuestsSid = 28,
  419. WinBuiltinPowerUsersSid = 29,
  420. WinBuiltinAccountOperatorsSid = 30,
  421. WinBuiltinSystemOperatorsSid = 31,
  422. WinBuiltinPrintOperatorsSid = 32,
  423. WinBuiltinBackupOperatorsSid = 33,
  424. WinBuiltinReplicatorSid = 34,
  425. WinBuiltinPreWindows2000CompatibleAccessSid = 35,
  426. WinBuiltinRemoteDesktopUsersSid = 36,
  427. WinBuiltinNetworkConfigurationOperatorsSid = 37,
  428. WinAccountAdministratorSid = 38,
  429. WinAccountGuestSid = 39,
  430. WinAccountKrbtgtSid = 40,
  431. WinAccountDomainAdminsSid = 41,
  432. WinAccountDomainUsersSid = 42,
  433. WinAccountDomainGuestsSid = 43,
  434. WinAccountComputersSid = 44,
  435. WinAccountControllersSid = 45,
  436. WinAccountCertAdminsSid = 46,
  437. WinAccountSchemaAdminsSid = 47,
  438. WinAccountEnterpriseAdminsSid = 48,
  439. WinAccountPolicyAdminsSid = 49,
  440. WinAccountRasAndIasServersSid = 50,
  441. WinNTLMAuthenticationSid = 51,
  442. WinDigestAuthenticationSid = 52,
  443. WinSChannelAuthenticationSid = 53,
  444. WinThisOrganizationSid = 54,
  445. WinOtherOrganizationSid = 55,
  446. WinBuiltinIncomingForestTrustBuildersSid = 56,
  447. WinBuiltinPerfMonitoringUsersSid = 57,
  448. WinBuiltinPerfLoggingUsersSid = 58,
  449. WinBuiltinAuthorizationAccessSid = 59,
  450. WinBuiltinTerminalServerLicenseServersSid = 60,
  451. } WELL_KNOWN_SID_TYPE;
  452. // end_winnt end_ntddk end_ntifs
  453. // begin_winnt begin_ntifs
  454. //
  455. // Allocate the System Luid. The first 1000 LUIDs are reserved.
  456. // Use #999 here (0x3E7 = 999)
  457. //
  458. #define SYSTEM_LUID { 0x3E7, 0x0 }
  459. #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
  460. #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
  461. #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
  462. // end_ntifs
  463. ////////////////////////////////////////////////////////////////////////
  464. // //
  465. // User and Group related SID attributes //
  466. // //
  467. ////////////////////////////////////////////////////////////////////////
  468. //
  469. // Group attributes
  470. //
  471. #define SE_GROUP_MANDATORY (0x00000001L)
  472. #define SE_GROUP_ENABLED_BY_DEFAULT (0x00000002L)
  473. #define SE_GROUP_ENABLED (0x00000004L)
  474. #define SE_GROUP_OWNER (0x00000008L)
  475. #define SE_GROUP_USE_FOR_DENY_ONLY (0x00000010L)
  476. #define SE_GROUP_LOGON_ID (0xC0000000L)
  477. #define SE_GROUP_RESOURCE (0x20000000L)
  478. //
  479. // User attributes
  480. //
  481. // (None yet defined.)
  482. ////////////////////////////////////////////////////////////////////////
  483. // //
  484. // ACL and ACE //
  485. // //
  486. ////////////////////////////////////////////////////////////////////////
  487. //
  488. // Define an ACL and the ACE format. The structure of an ACL header
  489. // followed by one or more ACEs. Pictorally the structure of an ACL header
  490. // is as follows:
  491. //
  492. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  493. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  494. // +-------------------------------+---------------+---------------+
  495. // | AclSize | Sbz1 | AclRevision |
  496. // +-------------------------------+---------------+---------------+
  497. // | Sbz2 | AceCount |
  498. // +-------------------------------+-------------------------------+
  499. //
  500. // The current AclRevision is defined to be ACL_REVISION.
  501. //
  502. // AclSize is the size, in bytes, allocated for the ACL. This includes
  503. // the ACL header, ACES, and remaining free space in the buffer.
  504. //
  505. // AceCount is the number of ACES in the ACL.
  506. //
  507. // begin_ntddk begin_wdm begin_ntifs
  508. // This is the *current* ACL revision
  509. #define ACL_REVISION (2)
  510. #define ACL_REVISION_DS (4)
  511. // This is the history of ACL revisions. Add a new one whenever
  512. // ACL_REVISION is updated
  513. #define ACL_REVISION1 (1)
  514. #define MIN_ACL_REVISION ACL_REVISION2
  515. #define ACL_REVISION2 (2)
  516. #define ACL_REVISION3 (3)
  517. #define ACL_REVISION4 (4)
  518. #define MAX_ACL_REVISION ACL_REVISION4
  519. typedef struct _ACL {
  520. UCHAR AclRevision;
  521. UCHAR Sbz1;
  522. USHORT AclSize;
  523. USHORT AceCount;
  524. USHORT Sbz2;
  525. } ACL;
  526. typedef ACL *PACL;
  527. // end_ntddk end_wdm
  528. //
  529. // The structure of an ACE is a common ace header followed by ace type
  530. // specific data. Pictorally the structure of the common ace header is
  531. // as follows:
  532. //
  533. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  534. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  535. // +---------------+-------+-------+---------------+---------------+
  536. // | AceSize | AceFlags | AceType |
  537. // +---------------+-------+-------+---------------+---------------+
  538. //
  539. // AceType denotes the type of the ace, there are some predefined ace
  540. // types
  541. //
  542. // AceSize is the size, in bytes, of ace.
  543. //
  544. // AceFlags are the Ace flags for audit and inheritance, defined shortly.
  545. typedef struct _ACE_HEADER {
  546. UCHAR AceType;
  547. UCHAR AceFlags;
  548. USHORT AceSize;
  549. } ACE_HEADER;
  550. typedef ACE_HEADER *PACE_HEADER;
  551. //
  552. // The following are the predefined ace types that go into the AceType
  553. // field of an Ace header.
  554. //
  555. #define ACCESS_MIN_MS_ACE_TYPE (0x0)
  556. #define ACCESS_ALLOWED_ACE_TYPE (0x0)
  557. #define ACCESS_DENIED_ACE_TYPE (0x1)
  558. #define SYSTEM_AUDIT_ACE_TYPE (0x2)
  559. #define SYSTEM_ALARM_ACE_TYPE (0x3)
  560. #define ACCESS_MAX_MS_V2_ACE_TYPE (0x3)
  561. #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE (0x4)
  562. #define ACCESS_MAX_MS_V3_ACE_TYPE (0x4)
  563. #define ACCESS_MIN_MS_OBJECT_ACE_TYPE (0x5)
  564. #define ACCESS_ALLOWED_OBJECT_ACE_TYPE (0x5)
  565. #define ACCESS_DENIED_OBJECT_ACE_TYPE (0x6)
  566. #define SYSTEM_AUDIT_OBJECT_ACE_TYPE (0x7)
  567. #define SYSTEM_ALARM_OBJECT_ACE_TYPE (0x8)
  568. #define ACCESS_MAX_MS_OBJECT_ACE_TYPE (0x8)
  569. #define ACCESS_MAX_MS_V4_ACE_TYPE (0x8)
  570. #define ACCESS_MAX_MS_ACE_TYPE (0x8)
  571. #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE (0x9)
  572. #define ACCESS_DENIED_CALLBACK_ACE_TYPE (0xA)
  573. #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE (0xB)
  574. #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE (0xC)
  575. #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE (0xD)
  576. #define SYSTEM_ALARM_CALLBACK_ACE_TYPE (0xE)
  577. #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE (0xF)
  578. #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE (0x10)
  579. #define ACCESS_MAX_MS_V5_ACE_TYPE (0x10)
  580. // end_winnt
  581. // begin_winnt
  582. //
  583. // The following are the inherit flags that go into the AceFlags field
  584. // of an Ace header.
  585. //
  586. #define OBJECT_INHERIT_ACE (0x1)
  587. #define CONTAINER_INHERIT_ACE (0x2)
  588. #define NO_PROPAGATE_INHERIT_ACE (0x4)
  589. #define INHERIT_ONLY_ACE (0x8)
  590. #define INHERITED_ACE (0x10)
  591. #define VALID_INHERIT_FLAGS (0x1F)
  592. // The following are the currently defined ACE flags that go into the
  593. // AceFlags field of an ACE header. Each ACE type has its own set of
  594. // AceFlags.
  595. //
  596. // SUCCESSFUL_ACCESS_ACE_FLAG - used only with system audit and alarm ACE
  597. // types to indicate that a message is generated for successful accesses.
  598. //
  599. // FAILED_ACCESS_ACE_FLAG - used only with system audit and alarm ACE types
  600. // to indicate that a message is generated for failed accesses.
  601. //
  602. //
  603. // SYSTEM_AUDIT and SYSTEM_ALARM AceFlags
  604. //
  605. // These control the signaling of audit and alarms for success or failure.
  606. //
  607. #define SUCCESSFUL_ACCESS_ACE_FLAG (0x40)
  608. #define FAILED_ACCESS_ACE_FLAG (0x80)
  609. //
  610. // We'll define the structure of the predefined ACE types. Pictorally
  611. // the structure of the predefined ACE's is as follows:
  612. //
  613. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  614. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  615. // +---------------+-------+-------+---------------+---------------+
  616. // | AceFlags | Resd |Inherit| AceSize | AceType |
  617. // +---------------+-------+-------+---------------+---------------+
  618. // | Mask |
  619. // +---------------------------------------------------------------+
  620. // | |
  621. // + +
  622. // | |
  623. // + Sid +
  624. // | |
  625. // + +
  626. // | |
  627. // +---------------------------------------------------------------+
  628. //
  629. // Mask is the access mask associated with the ACE. This is either the
  630. // access allowed, access denied, audit, or alarm mask.
  631. //
  632. // Sid is the Sid associated with the ACE.
  633. //
  634. // The following are the four predefined ACE types.
  635. // Examine the AceType field in the Header to determine
  636. // which structure is appropriate to use for casting.
  637. typedef struct _ACCESS_ALLOWED_ACE {
  638. ACE_HEADER Header;
  639. ACCESS_MASK Mask;
  640. ULONG SidStart;
  641. } ACCESS_ALLOWED_ACE;
  642. typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE;
  643. typedef struct _ACCESS_DENIED_ACE {
  644. ACE_HEADER Header;
  645. ACCESS_MASK Mask;
  646. ULONG SidStart;
  647. } ACCESS_DENIED_ACE;
  648. typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE;
  649. typedef struct _SYSTEM_AUDIT_ACE {
  650. ACE_HEADER Header;
  651. ACCESS_MASK Mask;
  652. ULONG SidStart;
  653. } SYSTEM_AUDIT_ACE;
  654. typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
  655. typedef struct _SYSTEM_ALARM_ACE {
  656. ACE_HEADER Header;
  657. ACCESS_MASK Mask;
  658. ULONG SidStart;
  659. } SYSTEM_ALARM_ACE;
  660. typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE;
  661. // end_ntifs
  662. // end_winnt
  663. //
  664. // COMPOUND ACE
  665. //
  666. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  667. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  668. // +---------------+-------+-------+---------------+---------------+
  669. // | AceFlags | Resd |Inherit| AceSize | AceType |
  670. // +---------------+-------+-------+---------------+---------------+
  671. // | Mask |
  672. // +-------------------------------+-------------------------------+
  673. // | Compound ACE Type | Reserved (SBZ) |
  674. // +-------------------------------+-------------------------------+
  675. // | |
  676. // + +
  677. // | |
  678. // + Sid +
  679. // | |
  680. // + +
  681. // | |
  682. // +---------------------------------------------------------------+
  683. //
  684. typedef struct _COMPOUND_ACCESS_ALLOWED_ACE {
  685. ACE_HEADER Header;
  686. ACCESS_MASK Mask;
  687. USHORT CompoundAceType;
  688. USHORT Reserved;
  689. ULONG SidStart;
  690. } COMPOUND_ACCESS_ALLOWED_ACE;
  691. typedef COMPOUND_ACCESS_ALLOWED_ACE *PCOMPOUND_ACCESS_ALLOWED_ACE;
  692. //
  693. // Currently defined Compound ACE types
  694. //
  695. #define COMPOUND_ACE_IMPERSONATION 1
  696. // begin_winnt
  697. typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
  698. ACE_HEADER Header;
  699. ACCESS_MASK Mask;
  700. ULONG Flags;
  701. GUID ObjectType;
  702. GUID InheritedObjectType;
  703. ULONG SidStart;
  704. } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
  705. typedef struct _ACCESS_DENIED_OBJECT_ACE {
  706. ACE_HEADER Header;
  707. ACCESS_MASK Mask;
  708. ULONG Flags;
  709. GUID ObjectType;
  710. GUID InheritedObjectType;
  711. ULONG SidStart;
  712. } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
  713. typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
  714. ACE_HEADER Header;
  715. ACCESS_MASK Mask;
  716. ULONG Flags;
  717. GUID ObjectType;
  718. GUID InheritedObjectType;
  719. ULONG SidStart;
  720. } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
  721. typedef struct _SYSTEM_ALARM_OBJECT_ACE {
  722. ACE_HEADER Header;
  723. ACCESS_MASK Mask;
  724. ULONG Flags;
  725. GUID ObjectType;
  726. GUID InheritedObjectType;
  727. ULONG SidStart;
  728. } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_ACE;
  729. //
  730. // Callback ace support in post Win2000.
  731. // Resource managers can put their own data after Sidstart + Length of the sid
  732. //
  733. typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
  734. ACE_HEADER Header;
  735. ACCESS_MASK Mask;
  736. ULONG SidStart;
  737. // Opaque resouce manager specific data
  738. } ACCESS_ALLOWED_CALLBACK_ACE, *PACCESS_ALLOWED_CALLBACK_ACE;
  739. typedef struct _ACCESS_DENIED_CALLBACK_ACE {
  740. ACE_HEADER Header;
  741. ACCESS_MASK Mask;
  742. ULONG SidStart;
  743. // Opaque resouce manager specific data
  744. } ACCESS_DENIED_CALLBACK_ACE, *PACCESS_DENIED_CALLBACK_ACE;
  745. typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
  746. ACE_HEADER Header;
  747. ACCESS_MASK Mask;
  748. ULONG SidStart;
  749. // Opaque resouce manager specific data
  750. } SYSTEM_AUDIT_CALLBACK_ACE, *PSYSTEM_AUDIT_CALLBACK_ACE;
  751. typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
  752. ACE_HEADER Header;
  753. ACCESS_MASK Mask;
  754. ULONG SidStart;
  755. // Opaque resouce manager specific data
  756. } SYSTEM_ALARM_CALLBACK_ACE, *PSYSTEM_ALARM_CALLBACK_ACE;
  757. typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
  758. ACE_HEADER Header;
  759. ACCESS_MASK Mask;
  760. ULONG Flags;
  761. GUID ObjectType;
  762. GUID InheritedObjectType;
  763. ULONG SidStart;
  764. // Opaque resouce manager specific data
  765. } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
  766. typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
  767. ACE_HEADER Header;
  768. ACCESS_MASK Mask;
  769. ULONG Flags;
  770. GUID ObjectType;
  771. GUID InheritedObjectType;
  772. ULONG SidStart;
  773. // Opaque resouce manager specific data
  774. } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
  775. typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
  776. ACE_HEADER Header;
  777. ACCESS_MASK Mask;
  778. ULONG Flags;
  779. GUID ObjectType;
  780. GUID InheritedObjectType;
  781. ULONG SidStart;
  782. // Opaque resouce manager specific data
  783. } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
  784. typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
  785. ACE_HEADER Header;
  786. ACCESS_MASK Mask;
  787. ULONG Flags;
  788. GUID ObjectType;
  789. GUID InheritedObjectType;
  790. ULONG SidStart;
  791. // Opaque resouce manager specific data
  792. } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
  793. //
  794. // Currently define Flags for "OBJECT" ACE types.
  795. //
  796. #define ACE_OBJECT_TYPE_PRESENT 0x1
  797. #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
  798. //
  799. // The following declarations are used for setting and querying information
  800. // about and ACL. First are the various information classes available to
  801. // the user.
  802. //
  803. typedef enum _ACL_INFORMATION_CLASS {
  804. AclRevisionInformation = 1,
  805. AclSizeInformation
  806. } ACL_INFORMATION_CLASS;
  807. //
  808. // This record is returned/sent if the user is requesting/setting the
  809. // AclRevisionInformation
  810. //
  811. typedef struct _ACL_REVISION_INFORMATION {
  812. ULONG AclRevision;
  813. } ACL_REVISION_INFORMATION;
  814. typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
  815. //
  816. // This record is returned if the user is requesting AclSizeInformation
  817. //
  818. typedef struct _ACL_SIZE_INFORMATION {
  819. ULONG AceCount;
  820. ULONG AclBytesInUse;
  821. ULONG AclBytesFree;
  822. } ACL_SIZE_INFORMATION;
  823. typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
  824. // end_winnt
  825. // begin_winnt
  826. ////////////////////////////////////////////////////////////////////////
  827. // //
  828. // SECURITY_DESCRIPTOR //
  829. // //
  830. ////////////////////////////////////////////////////////////////////////
  831. //
  832. // Define the Security Descriptor and related data types.
  833. // This is an opaque data structure.
  834. //
  835. // begin_wdm begin_ntddk begin_ntifs
  836. //
  837. // Current security descriptor revision value
  838. //
  839. #define SECURITY_DESCRIPTOR_REVISION (1)
  840. #define SECURITY_DESCRIPTOR_REVISION1 (1)
  841. // end_wdm end_ntddk
  842. #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
  843. typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
  844. #define SE_OWNER_DEFAULTED (0x0001)
  845. #define SE_GROUP_DEFAULTED (0x0002)
  846. #define SE_DACL_PRESENT (0x0004)
  847. #define SE_DACL_DEFAULTED (0x0008)
  848. #define SE_SACL_PRESENT (0x0010)
  849. #define SE_SACL_DEFAULTED (0x0020)
  850. // end_winnt
  851. #define SE_DACL_UNTRUSTED (0x0040)
  852. #define SE_SERVER_SECURITY (0x0080)
  853. // begin_winnt
  854. #define SE_DACL_AUTO_INHERIT_REQ (0x0100)
  855. #define SE_SACL_AUTO_INHERIT_REQ (0x0200)
  856. #define SE_DACL_AUTO_INHERITED (0x0400)
  857. #define SE_SACL_AUTO_INHERITED (0x0800)
  858. #define SE_DACL_PROTECTED (0x1000)
  859. #define SE_SACL_PROTECTED (0x2000)
  860. #define SE_RM_CONTROL_VALID (0x4000)
  861. #define SE_SELF_RELATIVE (0x8000)
  862. //
  863. // Where:
  864. //
  865. // SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
  866. // SID pointed to by the Owner field was provided by a
  867. // defaulting mechanism rather than explicitly provided by the
  868. // original provider of the security descriptor. This may
  869. // affect the treatment of the SID with respect to inheritence
  870. // of an owner.
  871. //
  872. // SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
  873. // SID in the Group field was provided by a defaulting mechanism
  874. // rather than explicitly provided by the original provider of
  875. // the security descriptor. This may affect the treatment of
  876. // the SID with respect to inheritence of a primary group.
  877. //
  878. // SE_DACL_PRESENT - This boolean flag, when set, indicates that the
  879. // security descriptor contains a discretionary ACL. If this
  880. // flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
  881. // null, then a null ACL is explicitly being specified.
  882. //
  883. // SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
  884. // ACL pointed to by the Dacl field was provided by a defaulting
  885. // mechanism rather than explicitly provided by the original
  886. // provider of the security descriptor. This may affect the
  887. // treatment of the ACL with respect to inheritence of an ACL.
  888. // This flag is ignored if the DaclPresent flag is not set.
  889. //
  890. // SE_SACL_PRESENT - This boolean flag, when set, indicates that the
  891. // security descriptor contains a system ACL pointed to by the
  892. // Sacl field. If this flag is set and the Sacl field of the
  893. // SECURITY_DESCRIPTOR is null, then an empty (but present)
  894. // ACL is being specified.
  895. //
  896. // SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
  897. // ACL pointed to by the Sacl field was provided by a defaulting
  898. // mechanism rather than explicitly provided by the original
  899. // provider of the security descriptor. This may affect the
  900. // treatment of the ACL with respect to inheritence of an ACL.
  901. // This flag is ignored if the SaclPresent flag is not set.
  902. //
  903. // end_winnt
  904. // SE_DACL_TRUSTED - This boolean flag, when set, indicates that the
  905. // ACL pointed to by the Dacl field was provided by a trusted source
  906. // and does not require any editing of compound ACEs. If this flag
  907. // is not set and a compound ACE is encountered, the system will
  908. // substitute known valid SIDs for the server SIDs in the ACEs.
  909. //
  910. // SE_SERVER_SECURITY - This boolean flag, when set, indicates that the
  911. // caller wishes the system to create a Server ACL based on the
  912. // input ACL, regardess of its source (explicit or defaulting.
  913. // This is done by replacing all of the GRANT ACEs with compound
  914. // ACEs granting the current server. This flag is only
  915. // meaningful if the subject is impersonating.
  916. //
  917. // begin_winnt
  918. // SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
  919. // security descriptor is in self-relative form. In this form,
  920. // all fields of the security descriptor are contiguous in memory
  921. // and all pointer fields are expressed as offsets from the
  922. // beginning of the security descriptor. This form is useful
  923. // for treating security descriptors as opaque data structures
  924. // for transmission in communication protocol or for storage on
  925. // secondary media.
  926. //
  927. //
  928. //
  929. // Pictorially the structure of a security descriptor is as follows:
  930. //
  931. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  932. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  933. // +---------------------------------------------------------------+
  934. // | Control |Reserved1 (SBZ)| Revision |
  935. // +---------------------------------------------------------------+
  936. // | Owner |
  937. // +---------------------------------------------------------------+
  938. // | Group |
  939. // +---------------------------------------------------------------+
  940. // | Sacl |
  941. // +---------------------------------------------------------------+
  942. // | Dacl |
  943. // +---------------------------------------------------------------+
  944. //
  945. // In general, this data structure should be treated opaquely to ensure future
  946. // compatibility.
  947. //
  948. //
  949. typedef struct _SECURITY_DESCRIPTOR_RELATIVE {
  950. UCHAR Revision;
  951. UCHAR Sbz1;
  952. SECURITY_DESCRIPTOR_CONTROL Control;
  953. ULONG Owner;
  954. ULONG Group;
  955. ULONG Sacl;
  956. ULONG Dacl;
  957. } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
  958. typedef struct _SECURITY_DESCRIPTOR {
  959. UCHAR Revision;
  960. UCHAR Sbz1;
  961. SECURITY_DESCRIPTOR_CONTROL Control;
  962. PSID Owner;
  963. PSID Group;
  964. PACL Sacl;
  965. PACL Dacl;
  966. } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
  967. // end_ntifs
  968. // Where:
  969. //
  970. // Revision - Contains the revision level of the security
  971. // descriptor. This allows this structure to be passed between
  972. // systems or stored on disk even though it is expected to
  973. // change in the future.
  974. //
  975. // Control - A set of flags which qualify the meaning of the
  976. // security descriptor or individual fields of the security
  977. // descriptor.
  978. //
  979. // Owner - is a pointer to an SID representing an object's owner.
  980. // If this field is null, then no owner SID is present in the
  981. // security descriptor. If the security descriptor is in
  982. // self-relative form, then this field contains an offset to
  983. // the SID, rather than a pointer.
  984. //
  985. // Group - is a pointer to an SID representing an object's primary
  986. // group. If this field is null, then no primary group SID is
  987. // present in the security descriptor. If the security descriptor
  988. // is in self-relative form, then this field contains an offset to
  989. // the SID, rather than a pointer.
  990. //
  991. // Sacl - is a pointer to a system ACL. This field value is only
  992. // valid if the DaclPresent control flag is set. If the
  993. // SaclPresent flag is set and this field is null, then a null
  994. // ACL is specified. If the security descriptor is in
  995. // self-relative form, then this field contains an offset to
  996. // the ACL, rather than a pointer.
  997. //
  998. // Dacl - is a pointer to a discretionary ACL. This field value is
  999. // only valid if the DaclPresent control flag is set. If the
  1000. // DaclPresent flag is set and this field is null, then a null
  1001. // ACL (unconditionally granting access) is specified. If the
  1002. // security descriptor is in self-relative form, then this field
  1003. // contains an offset to the ACL, rather than a pointer.
  1004. //
  1005. // end_winnt
  1006. // begin_winnt begin_ntifs
  1007. ////////////////////////////////////////////////////////////////////////
  1008. // //
  1009. // Object Type list for AccessCheckByType //
  1010. // //
  1011. ////////////////////////////////////////////////////////////////////////
  1012. typedef struct _OBJECT_TYPE_LIST {
  1013. USHORT Level;
  1014. USHORT Sbz;
  1015. GUID *ObjectType;
  1016. } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
  1017. //
  1018. // DS values for Level
  1019. //
  1020. #define ACCESS_OBJECT_GUID 0
  1021. #define ACCESS_PROPERTY_SET_GUID 1
  1022. #define ACCESS_PROPERTY_GUID 2
  1023. #define ACCESS_MAX_LEVEL 4
  1024. //
  1025. // Parameters to NtAccessCheckByTypeAndAditAlarm
  1026. //
  1027. typedef enum _AUDIT_EVENT_TYPE {
  1028. AuditEventObjectAccess,
  1029. AuditEventDirectoryServiceAccess
  1030. } AUDIT_EVENT_TYPE, *PAUDIT_EVENT_TYPE;
  1031. #define AUDIT_ALLOW_NO_PRIVILEGE 0x1
  1032. //
  1033. // DS values for Source and ObjectTypeName
  1034. //
  1035. #define ACCESS_DS_SOURCE_A "DS"
  1036. #define ACCESS_DS_SOURCE_W L"DS"
  1037. #define ACCESS_DS_OBJECT_TYPE_NAME_A "Directory Service Object"
  1038. #define ACCESS_DS_OBJECT_TYPE_NAME_W L"Directory Service Object"
  1039. ////////////////////////////////////////////////////////////////////////
  1040. // //
  1041. // Privilege Related Data Structures //
  1042. // //
  1043. ////////////////////////////////////////////////////////////////////////
  1044. // begin_wdm begin_ntddk begin_nthal
  1045. //
  1046. // Privilege attributes
  1047. //
  1048. #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
  1049. #define SE_PRIVILEGE_ENABLED (0x00000002L)
  1050. #define SE_PRIVILEGE_REMOVED (0X00000004L)
  1051. #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
  1052. //
  1053. // Privilege Set Control flags
  1054. //
  1055. #define PRIVILEGE_SET_ALL_NECESSARY (1)
  1056. //
  1057. // Privilege Set - This is defined for a privilege set of one.
  1058. // If more than one privilege is needed, then this structure
  1059. // will need to be allocated with more space.
  1060. //
  1061. // Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
  1062. // structure (defined in se.h)
  1063. //
  1064. typedef struct _PRIVILEGE_SET {
  1065. ULONG PrivilegeCount;
  1066. ULONG Control;
  1067. LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
  1068. } PRIVILEGE_SET, * PPRIVILEGE_SET;
  1069. // end_winnt end_wdm end_ntddk end_nthal end_ntifs
  1070. // begin_winnt
  1071. ////////////////////////////////////////////////////////////////////////
  1072. // //
  1073. // NT Defined Privileges //
  1074. // //
  1075. ////////////////////////////////////////////////////////////////////////
  1076. // end_winnt
  1077. //
  1078. // ** ** ** ** ** ** ** ** ** ** NOTE ** ** ** ** ** ** ** ** ** ** ** ** **
  1079. //
  1080. // Any additions or deletions to the following list
  1081. // of privileges must have corresponding changes made
  1082. // in the following files:
  1083. // - ntos\se\seglobal.c
  1084. // - ds\security\base\lsa\msprivs\msprivs.rc
  1085. // - ds\security\base\lsa\server\dspolicy\dbpriv.c
  1086. //
  1087. // ** ** ** ** ** ** ** ** ** ** NOTE ** ** ** ** ** ** ** ** ** ** ** ** **
  1088. //
  1089. // begin_winnt
  1090. #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
  1091. #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
  1092. #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
  1093. #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
  1094. #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
  1095. #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
  1096. #define SE_TCB_NAME TEXT("SeTcbPrivilege")
  1097. #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
  1098. #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
  1099. #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
  1100. #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
  1101. #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
  1102. #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
  1103. #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
  1104. #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
  1105. #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
  1106. #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
  1107. #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
  1108. #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
  1109. #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
  1110. #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
  1111. #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
  1112. #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
  1113. #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
  1114. #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
  1115. #define SE_SYNC_AGENT_NAME TEXT("SeSyncAgentPrivilege")
  1116. #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
  1117. #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
  1118. #define SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege")
  1119. #define SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege")
  1120. // end_winnt
  1121. // begin_wdm begin_ntddk begin_ntifs
  1122. //
  1123. // These must be converted to LUIDs before use.
  1124. //
  1125. #define SE_MIN_WELL_KNOWN_PRIVILEGE (2L)
  1126. #define SE_CREATE_TOKEN_PRIVILEGE (2L)
  1127. #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE (3L)
  1128. #define SE_LOCK_MEMORY_PRIVILEGE (4L)
  1129. #define SE_INCREASE_QUOTA_PRIVILEGE (5L)
  1130. // end_wdm
  1131. //
  1132. // Unsolicited Input is obsolete and unused.
  1133. //
  1134. #define SE_UNSOLICITED_INPUT_PRIVILEGE (6L)
  1135. // begin_wdm
  1136. #define SE_MACHINE_ACCOUNT_PRIVILEGE (6L)
  1137. #define SE_TCB_PRIVILEGE (7L)
  1138. #define SE_SECURITY_PRIVILEGE (8L)
  1139. #define SE_TAKE_OWNERSHIP_PRIVILEGE (9L)
  1140. #define SE_LOAD_DRIVER_PRIVILEGE (10L)
  1141. #define SE_SYSTEM_PROFILE_PRIVILEGE (11L)
  1142. #define SE_SYSTEMTIME_PRIVILEGE (12L)
  1143. #define SE_PROF_SINGLE_PROCESS_PRIVILEGE (13L)
  1144. #define SE_INC_BASE_PRIORITY_PRIVILEGE (14L)
  1145. #define SE_CREATE_PAGEFILE_PRIVILEGE (15L)
  1146. #define SE_CREATE_PERMANENT_PRIVILEGE (16L)
  1147. #define SE_BACKUP_PRIVILEGE (17L)
  1148. #define SE_RESTORE_PRIVILEGE (18L)
  1149. #define SE_SHUTDOWN_PRIVILEGE (19L)
  1150. #define SE_DEBUG_PRIVILEGE (20L)
  1151. #define SE_AUDIT_PRIVILEGE (21L)
  1152. #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE (22L)
  1153. #define SE_CHANGE_NOTIFY_PRIVILEGE (23L)
  1154. #define SE_REMOTE_SHUTDOWN_PRIVILEGE (24L)
  1155. #define SE_UNDOCK_PRIVILEGE (25L)
  1156. #define SE_SYNC_AGENT_PRIVILEGE (26L)
  1157. #define SE_ENABLE_DELEGATION_PRIVILEGE (27L)
  1158. #define SE_MANAGE_VOLUME_PRIVILEGE (28L)
  1159. #define SE_IMPERSONATE_PRIVILEGE (29L)
  1160. #define SE_CREATE_GLOBAL_PRIVILEGE (30L)
  1161. #define SE_MAX_WELL_KNOWN_PRIVILEGE (SE_CREATE_GLOBAL_PRIVILEGE)
  1162. // end_wdm end_ntddk end_ntifs
  1163. // begin_winnt
  1164. ////////////////////////////////////////////////////////////////////
  1165. // //
  1166. // Security Quality Of Service //
  1167. // //
  1168. // //
  1169. ////////////////////////////////////////////////////////////////////
  1170. // begin_wdm begin_ntddk begin_nthal begin_ntifs
  1171. //
  1172. // Impersonation Level
  1173. //
  1174. // Impersonation level is represented by a pair of bits in Windows.
  1175. // If a new impersonation level is added or lowest value is changed from
  1176. // 0 to something else, fix the Windows CreateFile call.
  1177. //
  1178. typedef enum _SECURITY_IMPERSONATION_LEVEL {
  1179. SecurityAnonymous,
  1180. SecurityIdentification,
  1181. SecurityImpersonation,
  1182. SecurityDelegation
  1183. } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
  1184. #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
  1185. #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
  1186. #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
  1187. #define VALID_IMPERSONATION_LEVEL(L) (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
  1188. // end_nthal end_wdm end_ntddk end_ntifs end_winnt
  1189. //
  1190. // begin_winnt begin_ntifs
  1191. ////////////////////////////////////////////////////////////////////
  1192. // //
  1193. // Token Object Definitions //
  1194. // //
  1195. // //
  1196. ////////////////////////////////////////////////////////////////////
  1197. //
  1198. // Token Specific Access Rights.
  1199. //
  1200. #define TOKEN_ASSIGN_PRIMARY (0x0001)
  1201. #define TOKEN_DUPLICATE (0x0002)
  1202. #define TOKEN_IMPERSONATE (0x0004)
  1203. #define TOKEN_QUERY (0x0008)
  1204. #define TOKEN_QUERY_SOURCE (0x0010)
  1205. #define TOKEN_ADJUST_PRIVILEGES (0x0020)
  1206. #define TOKEN_ADJUST_GROUPS (0x0040)
  1207. #define TOKEN_ADJUST_DEFAULT (0x0080)
  1208. #define TOKEN_ADJUST_SESSIONID (0x0100)
  1209. #define TOKEN_ALL_ACCESS_P (STANDARD_RIGHTS_REQUIRED |\
  1210. TOKEN_ASSIGN_PRIMARY |\
  1211. TOKEN_DUPLICATE |\
  1212. TOKEN_IMPERSONATE |\
  1213. TOKEN_QUERY |\
  1214. TOKEN_QUERY_SOURCE |\
  1215. TOKEN_ADJUST_PRIVILEGES |\
  1216. TOKEN_ADJUST_GROUPS |\
  1217. TOKEN_ADJUST_DEFAULT )
  1218. #if ((defined(_WIN32_WINNT) && (_WIN32_WINNT > 0x0400)) || (!defined(_WIN32_WINNT)))
  1219. #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P |\
  1220. TOKEN_ADJUST_SESSIONID )
  1221. #else
  1222. #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P)
  1223. #endif
  1224. #define TOKEN_READ (STANDARD_RIGHTS_READ |\
  1225. TOKEN_QUERY)
  1226. #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE |\
  1227. TOKEN_ADJUST_PRIVILEGES |\
  1228. TOKEN_ADJUST_GROUPS |\
  1229. TOKEN_ADJUST_DEFAULT)
  1230. #define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE)
  1231. //
  1232. //
  1233. // Token Types
  1234. //
  1235. typedef enum _TOKEN_TYPE {
  1236. TokenPrimary = 1,
  1237. TokenImpersonation
  1238. } TOKEN_TYPE;
  1239. typedef TOKEN_TYPE *PTOKEN_TYPE;
  1240. //
  1241. // Token Information Classes.
  1242. //
  1243. typedef enum _TOKEN_INFORMATION_CLASS {
  1244. TokenUser = 1,
  1245. TokenGroups,
  1246. TokenPrivileges,
  1247. TokenOwner,
  1248. TokenPrimaryGroup,
  1249. TokenDefaultDacl,
  1250. TokenSource,
  1251. TokenType,
  1252. TokenImpersonationLevel,
  1253. TokenStatistics,
  1254. TokenRestrictedSids,
  1255. TokenSessionId,
  1256. TokenGroupsAndPrivileges,
  1257. TokenSessionReference,
  1258. TokenSandBoxInert,
  1259. TokenAuditPolicy,
  1260. TokenOrigin,
  1261. MaxTokenInfoClass // MaxTokenInfoClass should always be the last enum
  1262. } TOKEN_INFORMATION_CLASS, *PTOKEN_INFORMATION_CLASS;
  1263. //
  1264. // Token information class structures
  1265. //
  1266. typedef struct _TOKEN_USER {
  1267. SID_AND_ATTRIBUTES User;
  1268. } TOKEN_USER, *PTOKEN_USER;
  1269. typedef struct _TOKEN_GROUPS {
  1270. ULONG GroupCount;
  1271. SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
  1272. } TOKEN_GROUPS, *PTOKEN_GROUPS;
  1273. typedef struct _TOKEN_PRIVILEGES {
  1274. ULONG PrivilegeCount;
  1275. LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
  1276. } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
  1277. typedef struct _TOKEN_OWNER {
  1278. PSID Owner;
  1279. } TOKEN_OWNER, *PTOKEN_OWNER;
  1280. typedef struct _TOKEN_PRIMARY_GROUP {
  1281. PSID PrimaryGroup;
  1282. } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
  1283. typedef struct _TOKEN_DEFAULT_DACL {
  1284. PACL DefaultDacl;
  1285. } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
  1286. typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
  1287. ULONG SidCount;
  1288. ULONG SidLength;
  1289. PSID_AND_ATTRIBUTES Sids;
  1290. ULONG RestrictedSidCount;
  1291. ULONG RestrictedSidLength;
  1292. PSID_AND_ATTRIBUTES RestrictedSids;
  1293. ULONG PrivilegeCount;
  1294. ULONG PrivilegeLength;
  1295. PLUID_AND_ATTRIBUTES Privileges;
  1296. LUID AuthenticationId;
  1297. } TOKEN_GROUPS_AND_PRIVILEGES, *PTOKEN_GROUPS_AND_PRIVILEGES;
  1298. //
  1299. // Valid bits for each TOKEN_AUDIT_POLICY policy mask field.
  1300. //
  1301. #define TOKEN_AUDIT_SUCCESS_INCLUDE 0x1
  1302. #define TOKEN_AUDIT_SUCCESS_EXCLUDE 0x2
  1303. #define TOKEN_AUDIT_FAILURE_INCLUDE 0x4
  1304. #define TOKEN_AUDIT_FAILURE_EXCLUDE 0x8
  1305. #define VALID_AUDIT_POLICY_BITS (TOKEN_AUDIT_SUCCESS_INCLUDE | \
  1306. TOKEN_AUDIT_SUCCESS_EXCLUDE | \
  1307. TOKEN_AUDIT_FAILURE_INCLUDE | \
  1308. TOKEN_AUDIT_FAILURE_EXCLUDE)
  1309. #define VALID_TOKEN_AUDIT_POLICY_ELEMENT(P) ((((P).PolicyMask & ~VALID_AUDIT_POLICY_BITS) == 0) && \
  1310. ((P).Category <= AuditEventMaxType))
  1311. typedef struct _TOKEN_AUDIT_POLICY_ELEMENT {
  1312. ULONG Category;
  1313. ULONG PolicyMask;
  1314. } TOKEN_AUDIT_POLICY_ELEMENT, *PTOKEN_AUDIT_POLICY_ELEMENT;
  1315. typedef struct _TOKEN_AUDIT_POLICY {
  1316. ULONG PolicyCount;
  1317. TOKEN_AUDIT_POLICY_ELEMENT Policy[ANYSIZE_ARRAY];
  1318. } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
  1319. #define PER_USER_AUDITING_POLICY_SIZE(p) \
  1320. ( sizeof(TOKEN_AUDIT_POLICY) + (((p)->PolicyCount > ANYSIZE_ARRAY) ? (sizeof(TOKEN_AUDIT_POLICY_ELEMENT) * ((p)->PolicyCount - ANYSIZE_ARRAY)) : 0) )
  1321. #define PER_USER_AUDITING_POLICY_SIZE_BY_COUNT(C) \
  1322. ( sizeof(TOKEN_AUDIT_POLICY) + (((C) > ANYSIZE_ARRAY) ? (sizeof(TOKEN_AUDIT_POLICY_ELEMENT) * ((C) - ANYSIZE_ARRAY)) : 0) )
  1323. // end_winnt end_ntifs
  1324. typedef enum _PROXY_CLASS {
  1325. ProxyFull,
  1326. ProxyService,
  1327. ProxyTree,
  1328. ProxyDirectory
  1329. } PROXY_CLASS, * PPROXY_CLASS;
  1330. typedef struct _SECURITY_TOKEN_PROXY_DATA {
  1331. ULONG Length;
  1332. PROXY_CLASS ProxyClass;
  1333. UNICODE_STRING PathInfo;
  1334. ACCESS_MASK ContainerMask;
  1335. ACCESS_MASK ObjectMask;
  1336. } SECURITY_TOKEN_PROXY_DATA, *PSECURITY_TOKEN_PROXY_DATA;
  1337. typedef struct _SECURITY_TOKEN_AUDIT_DATA {
  1338. ULONG Length;
  1339. ACCESS_MASK GrantMask;
  1340. ACCESS_MASK DenyMask;
  1341. } SECURITY_TOKEN_AUDIT_DATA, *PSECURITY_TOKEN_AUDIT_DATA;
  1342. // begin_ntifs begin_winnt
  1343. #define TOKEN_SOURCE_LENGTH 8
  1344. typedef struct _TOKEN_SOURCE {
  1345. CHAR SourceName[TOKEN_SOURCE_LENGTH];
  1346. LUID SourceIdentifier;
  1347. } TOKEN_SOURCE, *PTOKEN_SOURCE;
  1348. typedef struct _TOKEN_STATISTICS {
  1349. LUID TokenId;
  1350. LUID AuthenticationId;
  1351. LARGE_INTEGER ExpirationTime;
  1352. TOKEN_TYPE TokenType;
  1353. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  1354. ULONG DynamicCharged;
  1355. ULONG DynamicAvailable;
  1356. ULONG GroupCount;
  1357. ULONG PrivilegeCount;
  1358. LUID ModifiedId;
  1359. } TOKEN_STATISTICS, *PTOKEN_STATISTICS;
  1360. typedef struct _TOKEN_CONTROL {
  1361. LUID TokenId;
  1362. LUID AuthenticationId;
  1363. LUID ModifiedId;
  1364. TOKEN_SOURCE TokenSource;
  1365. } TOKEN_CONTROL, *PTOKEN_CONTROL;
  1366. typedef struct _TOKEN_ORIGIN {
  1367. LUID OriginatingLogonSession ;
  1368. } TOKEN_ORIGIN, * PTOKEN_ORIGIN ;
  1369. // end_winnt
  1370. // end_ntifs
  1371. // begin_wdm begin_ntddk begin_ntifs begin_winnt
  1372. //
  1373. // Security Tracking Mode
  1374. //
  1375. #define SECURITY_DYNAMIC_TRACKING (TRUE)
  1376. #define SECURITY_STATIC_TRACKING (FALSE)
  1377. typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
  1378. * PSECURITY_CONTEXT_TRACKING_MODE;
  1379. //
  1380. // Quality Of Service
  1381. //
  1382. typedef struct _SECURITY_QUALITY_OF_SERVICE {
  1383. ULONG Length;
  1384. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  1385. SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
  1386. BOOLEAN EffectiveOnly;
  1387. } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE;
  1388. // end_winnt end_wdm end_ntddk end_ntifs
  1389. //
  1390. // Advanced Quality of Service
  1391. //
  1392. typedef struct _SECURITY_ADVANCED_QUALITY_OF_SERVICE {
  1393. ULONG Length;
  1394. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  1395. SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
  1396. BOOLEAN EffectiveOnly;
  1397. PSECURITY_TOKEN_PROXY_DATA ProxyData;
  1398. PSECURITY_TOKEN_AUDIT_DATA AuditData;
  1399. } SECURITY_ADVANCED_QUALITY_OF_SERVICE, *PSECURITY_ADVANCED_QUALITY_OF_SERVICE;
  1400. // begin_wdm begin_ntddk begin_ntifs begin_winnt
  1401. //
  1402. // Used to represent information related to a thread impersonation
  1403. //
  1404. typedef struct _SE_IMPERSONATION_STATE {
  1405. PACCESS_TOKEN Token;
  1406. BOOLEAN CopyOnOpen;
  1407. BOOLEAN EffectiveOnly;
  1408. SECURITY_IMPERSONATION_LEVEL Level;
  1409. } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
  1410. // end_winnt end_wdm end_ntddk end_ntifs
  1411. ////////////////////////////////////////////////////////////////////////
  1412. // //
  1413. // Flags for NtFilerToken //
  1414. // //
  1415. ////////////////////////////////////////////////////////////////////////
  1416. #define DISABLE_MAX_PRIVILEGE 0x1 // winnt
  1417. #define SANDBOX_INERT 0x2 // winnt
  1418. ////////////////////////////////////////////////////////////////////////
  1419. // //
  1420. // General Security definitions //
  1421. // //
  1422. ////////////////////////////////////////////////////////////////////////
  1423. //
  1424. // Security information associated with objects.
  1425. // Used for query operations.
  1426. //
  1427. // This will be extended in the future to include mandatory access control.
  1428. //
  1429. // begin_winnt begin_wdm begin_ntddk begin_nthal begin_ntifs
  1430. typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
  1431. #define OWNER_SECURITY_INFORMATION (0x00000001L)
  1432. #define GROUP_SECURITY_INFORMATION (0x00000002L)
  1433. #define DACL_SECURITY_INFORMATION (0x00000004L)
  1434. #define SACL_SECURITY_INFORMATION (0x00000008L)
  1435. #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
  1436. #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
  1437. #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
  1438. #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
  1439. // end_winnt end_wdm end_ntddk end_nthal end_ntifs
  1440. //
  1441. // used for password manipulations
  1442. //
  1443. typedef struct _SECURITY_SEED_AND_LENGTH {
  1444. UCHAR Length;
  1445. UCHAR Seed;
  1446. } SECURITY_SEED_AND_LENGTH, *PSECURITY_SEED_AND_LENGTH;
  1447. ////////////////////////////////////////////////////////////////////////
  1448. // //
  1449. // Security System Service Defnitions //
  1450. // //
  1451. ////////////////////////////////////////////////////////////////////////
  1452. //
  1453. // Security check system services
  1454. //
  1455. NTSYSCALLAPI
  1456. NTSTATUS
  1457. NTAPI
  1458. NtAccessCheck (
  1459. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1460. IN HANDLE ClientToken,
  1461. IN ACCESS_MASK DesiredAccess,
  1462. IN PGENERIC_MAPPING GenericMapping,
  1463. OUT PPRIVILEGE_SET PrivilegeSet,
  1464. IN OUT PULONG PrivilegeSetLength,
  1465. OUT PACCESS_MASK GrantedAccess,
  1466. OUT PNTSTATUS AccessStatus
  1467. );
  1468. NTSYSCALLAPI
  1469. NTSTATUS
  1470. NTAPI
  1471. NtAccessCheckByType (
  1472. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1473. IN PSID PrincipalSelfSid,
  1474. IN HANDLE ClientToken,
  1475. IN ACCESS_MASK DesiredAccess,
  1476. IN POBJECT_TYPE_LIST ObjectTypeList,
  1477. IN ULONG ObjectTypeListLength,
  1478. IN PGENERIC_MAPPING GenericMapping,
  1479. OUT PPRIVILEGE_SET PrivilegeSet,
  1480. IN OUT PULONG PrivilegeSetLength,
  1481. OUT PACCESS_MASK GrantedAccess,
  1482. OUT PNTSTATUS AccessStatus
  1483. );
  1484. NTSYSCALLAPI
  1485. NTSTATUS
  1486. NTAPI
  1487. NtAccessCheckByTypeResultList (
  1488. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1489. IN PSID PrincipalSelfSid,
  1490. IN HANDLE ClientToken,
  1491. IN ACCESS_MASK DesiredAccess,
  1492. IN POBJECT_TYPE_LIST ObjectTypeList,
  1493. IN ULONG ObjectTypeListLength,
  1494. IN PGENERIC_MAPPING GenericMapping,
  1495. OUT PPRIVILEGE_SET PrivilegeSet,
  1496. IN OUT PULONG PrivilegeSetLength,
  1497. OUT PACCESS_MASK GrantedAccess,
  1498. OUT PNTSTATUS AccessStatus
  1499. );
  1500. ///////////////////////////////////////////////////////////////////////
  1501. // //
  1502. // Token Object System Services //
  1503. // //
  1504. ///////////////////////////////////////////////////////////////////////
  1505. NTSYSCALLAPI
  1506. NTSTATUS
  1507. NTAPI
  1508. NtCreateToken(
  1509. OUT PHANDLE TokenHandle,
  1510. IN ACCESS_MASK DesiredAccess,
  1511. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  1512. IN TOKEN_TYPE TokenType,
  1513. IN PLUID AuthenticationId,
  1514. IN PLARGE_INTEGER ExpirationTime,
  1515. IN PTOKEN_USER User,
  1516. IN PTOKEN_GROUPS Groups,
  1517. IN PTOKEN_PRIVILEGES Privileges,
  1518. IN PTOKEN_OWNER Owner OPTIONAL,
  1519. IN PTOKEN_PRIMARY_GROUP PrimaryGroup,
  1520. IN PTOKEN_DEFAULT_DACL DefaultDacl OPTIONAL,
  1521. IN PTOKEN_SOURCE TokenSource
  1522. );
  1523. NTSYSCALLAPI
  1524. NTSTATUS
  1525. NTAPI
  1526. NtCompareTokens(
  1527. IN HANDLE FirstTokenHandle,
  1528. IN HANDLE SecondTokenHandle,
  1529. OUT PBOOLEAN Equal
  1530. );
  1531. // begin_ntifs
  1532. NTSYSCALLAPI
  1533. NTSTATUS
  1534. NTAPI
  1535. NtOpenThreadToken(
  1536. IN HANDLE ThreadHandle,
  1537. IN ACCESS_MASK DesiredAccess,
  1538. IN BOOLEAN OpenAsSelf,
  1539. OUT PHANDLE TokenHandle
  1540. );
  1541. NTSYSCALLAPI
  1542. NTSTATUS
  1543. NTAPI
  1544. NtOpenThreadTokenEx(
  1545. IN HANDLE ThreadHandle,
  1546. IN ACCESS_MASK DesiredAccess,
  1547. IN BOOLEAN OpenAsSelf,
  1548. IN ULONG HandleAttributes,
  1549. OUT PHANDLE TokenHandle
  1550. );
  1551. NTSYSCALLAPI
  1552. NTSTATUS
  1553. NTAPI
  1554. NtOpenProcessToken(
  1555. IN HANDLE ProcessHandle,
  1556. IN ACCESS_MASK DesiredAccess,
  1557. OUT PHANDLE TokenHandle
  1558. );
  1559. NTSYSCALLAPI
  1560. NTSTATUS
  1561. NTAPI
  1562. NtOpenProcessTokenEx(
  1563. IN HANDLE ProcessHandle,
  1564. IN ACCESS_MASK DesiredAccess,
  1565. IN ULONG HandleAttributes,
  1566. OUT PHANDLE TokenHandle
  1567. );
  1568. NTSYSAPI
  1569. NTSTATUS
  1570. NTAPI
  1571. NtOpenJobObjectToken(
  1572. IN HANDLE JobHandle,
  1573. IN ACCESS_MASK DesiredAccess,
  1574. OUT PHANDLE TokenHandle
  1575. );
  1576. NTSYSCALLAPI
  1577. NTSTATUS
  1578. NTAPI
  1579. NtDuplicateToken(
  1580. IN HANDLE ExistingTokenHandle,
  1581. IN ACCESS_MASK DesiredAccess,
  1582. IN POBJECT_ATTRIBUTES ObjectAttributes,
  1583. IN BOOLEAN EffectiveOnly,
  1584. IN TOKEN_TYPE TokenType,
  1585. OUT PHANDLE NewTokenHandle
  1586. );
  1587. NTSYSCALLAPI
  1588. NTSTATUS
  1589. NTAPI
  1590. NtFilterToken (
  1591. IN HANDLE ExistingTokenHandle,
  1592. IN ULONG Flags,
  1593. IN PTOKEN_GROUPS SidsToDisable OPTIONAL,
  1594. IN PTOKEN_PRIVILEGES PrivilegesToDelete OPTIONAL,
  1595. IN PTOKEN_GROUPS RestrictedSids OPTIONAL,
  1596. OUT PHANDLE NewTokenHandle
  1597. );
  1598. NTSYSCALLAPI
  1599. NTSTATUS
  1600. NTAPI
  1601. NtImpersonateAnonymousToken(
  1602. IN HANDLE ThreadHandle
  1603. );
  1604. NTSYSCALLAPI
  1605. NTSTATUS
  1606. NTAPI
  1607. NtQueryInformationToken (
  1608. IN HANDLE TokenHandle,
  1609. IN TOKEN_INFORMATION_CLASS TokenInformationClass,
  1610. OUT PVOID TokenInformation,
  1611. IN ULONG TokenInformationLength,
  1612. OUT PULONG ReturnLength
  1613. );
  1614. NTSYSCALLAPI
  1615. NTSTATUS
  1616. NTAPI
  1617. NtSetInformationToken (
  1618. IN HANDLE TokenHandle,
  1619. IN TOKEN_INFORMATION_CLASS TokenInformationClass,
  1620. IN PVOID TokenInformation,
  1621. IN ULONG TokenInformationLength
  1622. );
  1623. NTSYSCALLAPI
  1624. NTSTATUS
  1625. NTAPI
  1626. NtAdjustPrivilegesToken (
  1627. IN HANDLE TokenHandle,
  1628. IN BOOLEAN DisableAllPrivileges,
  1629. IN PTOKEN_PRIVILEGES NewState OPTIONAL,
  1630. IN ULONG BufferLength OPTIONAL,
  1631. OUT PTOKEN_PRIVILEGES PreviousState OPTIONAL,
  1632. OUT PULONG ReturnLength
  1633. );
  1634. NTSYSCALLAPI
  1635. NTSTATUS
  1636. NTAPI
  1637. NtAdjustGroupsToken (
  1638. IN HANDLE TokenHandle,
  1639. IN BOOLEAN ResetToDefault,
  1640. IN PTOKEN_GROUPS NewState OPTIONAL,
  1641. IN ULONG BufferLength OPTIONAL,
  1642. OUT PTOKEN_GROUPS PreviousState OPTIONAL,
  1643. OUT PULONG ReturnLength
  1644. );
  1645. NTSYSCALLAPI
  1646. NTSTATUS
  1647. NTAPI
  1648. NtPrivilegeCheck (
  1649. IN HANDLE ClientToken,
  1650. IN OUT PPRIVILEGE_SET RequiredPrivileges,
  1651. OUT PBOOLEAN Result
  1652. );
  1653. NTSYSCALLAPI
  1654. NTSTATUS
  1655. NTAPI
  1656. NtAccessCheckAndAuditAlarm (
  1657. IN PUNICODE_STRING SubsystemName,
  1658. IN PVOID HandleId,
  1659. IN PUNICODE_STRING ObjectTypeName,
  1660. IN PUNICODE_STRING ObjectName,
  1661. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1662. IN ACCESS_MASK DesiredAccess,
  1663. IN PGENERIC_MAPPING GenericMapping,
  1664. IN BOOLEAN ObjectCreation,
  1665. OUT PACCESS_MASK GrantedAccess,
  1666. OUT PNTSTATUS AccessStatus,
  1667. OUT PBOOLEAN GenerateOnClose
  1668. );
  1669. NTSYSCALLAPI
  1670. NTSTATUS
  1671. NTAPI
  1672. NtAccessCheckByTypeAndAuditAlarm (
  1673. IN PUNICODE_STRING SubsystemName,
  1674. IN PVOID HandleId,
  1675. IN PUNICODE_STRING ObjectTypeName,
  1676. IN PUNICODE_STRING ObjectName,
  1677. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1678. IN PSID PrincipalSelfSid,
  1679. IN ACCESS_MASK DesiredAccess,
  1680. IN AUDIT_EVENT_TYPE AuditType,
  1681. IN ULONG Flags,
  1682. IN POBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  1683. IN ULONG ObjectTypeListLength,
  1684. IN PGENERIC_MAPPING GenericMapping,
  1685. IN BOOLEAN ObjectCreation,
  1686. OUT PACCESS_MASK GrantedAccess,
  1687. OUT PNTSTATUS AccessStatus,
  1688. OUT PBOOLEAN GenerateOnClose
  1689. );
  1690. NTSYSCALLAPI
  1691. NTSTATUS
  1692. NTAPI
  1693. NtAccessCheckByTypeResultListAndAuditAlarm (
  1694. IN PUNICODE_STRING SubsystemName,
  1695. IN PVOID HandleId,
  1696. IN PUNICODE_STRING ObjectTypeName,
  1697. IN PUNICODE_STRING ObjectName,
  1698. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1699. IN PSID PrincipalSelfSid,
  1700. IN ACCESS_MASK DesiredAccess,
  1701. IN AUDIT_EVENT_TYPE AuditType,
  1702. IN ULONG Flags,
  1703. IN POBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  1704. IN ULONG ObjectTypeListLength,
  1705. IN PGENERIC_MAPPING GenericMapping,
  1706. IN BOOLEAN ObjectCreation,
  1707. OUT PACCESS_MASK GrantedAccess,
  1708. OUT PNTSTATUS AccessStatus,
  1709. OUT PBOOLEAN GenerateOnClose
  1710. );
  1711. NTSYSCALLAPI
  1712. NTSTATUS
  1713. NTAPI
  1714. NtAccessCheckByTypeResultListAndAuditAlarmByHandle (
  1715. IN PUNICODE_STRING SubsystemName,
  1716. IN PVOID HandleId,
  1717. IN HANDLE ClientToken,
  1718. IN PUNICODE_STRING ObjectTypeName,
  1719. IN PUNICODE_STRING ObjectName,
  1720. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1721. IN PSID PrincipalSelfSid,
  1722. IN ACCESS_MASK DesiredAccess,
  1723. IN AUDIT_EVENT_TYPE AuditType,
  1724. IN ULONG Flags,
  1725. IN POBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  1726. IN ULONG ObjectTypeListLength,
  1727. IN PGENERIC_MAPPING GenericMapping,
  1728. IN BOOLEAN ObjectCreation,
  1729. OUT PACCESS_MASK GrantedAccess,
  1730. OUT PNTSTATUS AccessStatus,
  1731. OUT PBOOLEAN GenerateOnClose
  1732. );
  1733. NTSYSCALLAPI
  1734. NTSTATUS
  1735. NTAPI
  1736. NtOpenObjectAuditAlarm (
  1737. IN PUNICODE_STRING SubsystemName,
  1738. IN PVOID HandleId OPTIONAL,
  1739. IN PUNICODE_STRING ObjectTypeName,
  1740. IN PUNICODE_STRING ObjectName,
  1741. IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
  1742. IN HANDLE ClientToken,
  1743. IN ACCESS_MASK DesiredAccess,
  1744. IN ACCESS_MASK GrantedAccess,
  1745. IN PPRIVILEGE_SET Privileges OPTIONAL,
  1746. IN BOOLEAN ObjectCreation,
  1747. IN BOOLEAN AccessGranted,
  1748. OUT PBOOLEAN GenerateOnClose
  1749. );
  1750. NTSYSCALLAPI
  1751. NTSTATUS
  1752. NTAPI
  1753. NtPrivilegeObjectAuditAlarm (
  1754. IN PUNICODE_STRING SubsystemName,
  1755. IN PVOID HandleId,
  1756. IN HANDLE ClientToken,
  1757. IN ACCESS_MASK DesiredAccess,
  1758. IN PPRIVILEGE_SET Privileges,
  1759. IN BOOLEAN AccessGranted
  1760. );
  1761. NTSYSCALLAPI
  1762. NTSTATUS
  1763. NTAPI
  1764. NtCloseObjectAuditAlarm (
  1765. IN PUNICODE_STRING SubsystemName,
  1766. IN PVOID HandleId,
  1767. IN BOOLEAN GenerateOnClose
  1768. );
  1769. NTSYSCALLAPI
  1770. NTSTATUS
  1771. NTAPI
  1772. NtDeleteObjectAuditAlarm (
  1773. IN PUNICODE_STRING SubsystemName,
  1774. IN PVOID HandleId,
  1775. IN BOOLEAN GenerateOnClose
  1776. );
  1777. NTSYSCALLAPI
  1778. NTSTATUS
  1779. NTAPI
  1780. NtPrivilegedServiceAuditAlarm (
  1781. IN PUNICODE_STRING SubsystemName,
  1782. IN PUNICODE_STRING ServiceName,
  1783. IN HANDLE ClientToken,
  1784. IN PPRIVILEGE_SET Privileges,
  1785. IN BOOLEAN AccessGranted
  1786. );
  1787. // end_ntifs
  1788. #ifdef __cplusplus
  1789. }
  1790. #endif
  1791. #endif // _NTSEAPI_