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.

2034 lines
65 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. // Service S-1-5-6 //
  264. // AnonymousLogon S-1-5-7 (aka null logon session) //
  265. // Proxy S-1-5-8 //
  266. // ServerLogon S-1-5-9 (aka domain controller account) //
  267. // Self S-1-5-10 (self RID) //
  268. // Authenticated User S-1-5-11 (Authenticated user somewhere) //
  269. // Restricted Code S-1-5-12 (Running restricted code) //
  270. // Terminal Server S-1-5-13 (Running on Terminal Server) //
  271. // Remote Logon S-1-5-14 (Remote Interactive Logon) //
  272. // //
  273. // (Logon IDs) S-1-5-5-X-Y //
  274. // //
  275. // (NT non-unique IDs) S-1-5-0x15-... //
  276. // //
  277. // (Built-in domain) s-1-5-0x20 //
  278. // //
  279. /////////////////////////////////////////////////////////////////////////////
  280. #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5} // ntifs
  281. #define SECURITY_DIALUP_RID (0x00000001L)
  282. #define SECURITY_NETWORK_RID (0x00000002L)
  283. #define SECURITY_BATCH_RID (0x00000003L)
  284. #define SECURITY_INTERACTIVE_RID (0x00000004L)
  285. #define SECURITY_SERVICE_RID (0x00000006L)
  286. #define SECURITY_ANONYMOUS_LOGON_RID (0x00000007L)
  287. #define SECURITY_PROXY_RID (0x00000008L)
  288. #define SECURITY_ENTERPRISE_CONTROLLERS_RID (0x00000009L)
  289. #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
  290. #define SECURITY_PRINCIPAL_SELF_RID (0x0000000AL)
  291. #define SECURITY_AUTHENTICATED_USER_RID (0x0000000BL)
  292. #define SECURITY_RESTRICTED_CODE_RID (0x0000000CL)
  293. #define SECURITY_TERMINAL_SERVER_RID (0x0000000DL)
  294. #define SECURITY_REMOTE_LOGON_RID (0x0000000EL)
  295. #define SECURITY_LOGON_IDS_RID (0x00000005L)
  296. #define SECURITY_LOGON_IDS_RID_COUNT (3L)
  297. #define SECURITY_LOCAL_SYSTEM_RID (0x00000012L)
  298. #define SECURITY_LOCAL_SERVICE_RID (0x00000013L)
  299. #define SECURITY_NETWORK_SERVICE_RID (0x00000014L)
  300. #define SECURITY_NT_NON_UNIQUE (0x00000015L)
  301. #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT (3L)
  302. #define SECURITY_BUILTIN_DOMAIN_RID (0x00000020L)
  303. /////////////////////////////////////////////////////////////////////////////
  304. // //
  305. // well-known domain relative sub-authority values (RIDs)... //
  306. // //
  307. /////////////////////////////////////////////////////////////////////////////
  308. // Well-known users ...
  309. #define DOMAIN_USER_RID_ADMIN (0x000001F4L)
  310. #define DOMAIN_USER_RID_GUEST (0x000001F5L)
  311. #define DOMAIN_USER_RID_KRBTGT (0x000001F6L)
  312. // well-known groups ...
  313. #define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
  314. #define DOMAIN_GROUP_RID_USERS (0x00000201L)
  315. #define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
  316. #define DOMAIN_GROUP_RID_COMPUTERS (0x00000203L)
  317. #define DOMAIN_GROUP_RID_CONTROLLERS (0x00000204L)
  318. #define DOMAIN_GROUP_RID_CERT_ADMINS (0x00000205L)
  319. #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (0x00000206L)
  320. #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (0x00000207L)
  321. #define DOMAIN_GROUP_RID_POLICY_ADMINS (0x00000208L)
  322. // well-known aliases ...
  323. #define DOMAIN_ALIAS_RID_ADMINS (0x00000220L)
  324. #define DOMAIN_ALIAS_RID_USERS (0x00000221L)
  325. #define DOMAIN_ALIAS_RID_GUESTS (0x00000222L)
  326. #define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L)
  327. #define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
  328. #define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
  329. #define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L)
  330. #define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
  331. #define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L)
  332. #define DOMAIN_ALIAS_RID_RAS_SERVERS (0x00000229L)
  333. #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS (0x0000022AL)
  334. #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS (0x0000022BL)
  335. #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS (0x0000022CL)
  336. // end_winnt end_ntifs
  337. /////////////////////////////////////////////////////////////////////////////
  338. // //
  339. // Foreign Security Authorities //
  340. // //
  341. // SiteServer Authority S-1-6 //
  342. // Internet Site Authority S-1-7 //
  343. // Exchange Authority S-1-8 //
  344. // Resource Manager Authority S-1-9 //
  345. // //
  346. /////////////////////////////////////////////////////////////////////////////
  347. #define SECURITY_SITESERVER_AUTHORITY {0,0,0,0,0,6}
  348. #define SECURITY_INTERNETSITE_AUTHORITY {0,0,0,0,0,7}
  349. #define SECURITY_EXCHANGE_AUTHORITY {0,0,0,0,0,8}
  350. // begin_winnt begin_ntifs
  351. //
  352. // Allocate the System Luid. The first 1000 LUIDs are reserved.
  353. // Use #999 here (0x3E7 = 999)
  354. //
  355. #define SYSTEM_LUID { 0x3E7, 0x0 }
  356. #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
  357. #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
  358. #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
  359. // end_ntifs
  360. ////////////////////////////////////////////////////////////////////////
  361. // //
  362. // User and Group related SID attributes //
  363. // //
  364. ////////////////////////////////////////////////////////////////////////
  365. //
  366. // Group attributes
  367. //
  368. #define SE_GROUP_MANDATORY (0x00000001L)
  369. #define SE_GROUP_ENABLED_BY_DEFAULT (0x00000002L)
  370. #define SE_GROUP_ENABLED (0x00000004L)
  371. #define SE_GROUP_OWNER (0x00000008L)
  372. #define SE_GROUP_USE_FOR_DENY_ONLY (0x00000010L)
  373. #define SE_GROUP_LOGON_ID (0xC0000000L)
  374. #define SE_GROUP_RESOURCE (0x20000000L)
  375. //
  376. // User attributes
  377. //
  378. // (None yet defined.)
  379. ////////////////////////////////////////////////////////////////////////
  380. // //
  381. // ACL and ACE //
  382. // //
  383. ////////////////////////////////////////////////////////////////////////
  384. //
  385. // Define an ACL and the ACE format. The structure of an ACL header
  386. // followed by one or more ACEs. Pictorally the structure of an ACL header
  387. // is as follows:
  388. //
  389. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  390. // 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
  391. // +-------------------------------+---------------+---------------+
  392. // | AclSize | Sbz1 | AclRevision |
  393. // +-------------------------------+---------------+---------------+
  394. // | Sbz2 | AceCount |
  395. // +-------------------------------+-------------------------------+
  396. //
  397. // The current AclRevision is defined to be ACL_REVISION.
  398. //
  399. // AclSize is the size, in bytes, allocated for the ACL. This includes
  400. // the ACL header, ACES, and remaining free space in the buffer.
  401. //
  402. // AceCount is the number of ACES in the ACL.
  403. //
  404. // begin_ntddk begin_wdm begin_ntifs
  405. // This is the *current* ACL revision
  406. #define ACL_REVISION (2)
  407. #define ACL_REVISION_DS (4)
  408. // This is the history of ACL revisions. Add a new one whenever
  409. // ACL_REVISION is updated
  410. #define ACL_REVISION1 (1)
  411. #define MIN_ACL_REVISION ACL_REVISION2
  412. #define ACL_REVISION2 (2)
  413. #define ACL_REVISION3 (3)
  414. #define ACL_REVISION4 (4)
  415. #define MAX_ACL_REVISION ACL_REVISION4
  416. typedef struct _ACL {
  417. UCHAR AclRevision;
  418. UCHAR Sbz1;
  419. USHORT AclSize;
  420. USHORT AceCount;
  421. USHORT Sbz2;
  422. } ACL;
  423. typedef ACL *PACL;
  424. // end_ntddk end_wdm
  425. //
  426. // The structure of an ACE is a common ace header followed by ace type
  427. // specific data. Pictorally the structure of the common ace header is
  428. // as follows:
  429. //
  430. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  431. // 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
  432. // +---------------+-------+-------+---------------+---------------+
  433. // | AceSize | AceFlags | AceType |
  434. // +---------------+-------+-------+---------------+---------------+
  435. //
  436. // AceType denotes the type of the ace, there are some predefined ace
  437. // types
  438. //
  439. // AceSize is the size, in bytes, of ace.
  440. //
  441. // AceFlags are the Ace flags for audit and inheritance, defined shortly.
  442. typedef struct _ACE_HEADER {
  443. UCHAR AceType;
  444. UCHAR AceFlags;
  445. USHORT AceSize;
  446. } ACE_HEADER;
  447. typedef ACE_HEADER *PACE_HEADER;
  448. //
  449. // The following are the predefined ace types that go into the AceType
  450. // field of an Ace header.
  451. //
  452. #define ACCESS_MIN_MS_ACE_TYPE (0x0)
  453. #define ACCESS_ALLOWED_ACE_TYPE (0x0)
  454. #define ACCESS_DENIED_ACE_TYPE (0x1)
  455. #define SYSTEM_AUDIT_ACE_TYPE (0x2)
  456. #define SYSTEM_ALARM_ACE_TYPE (0x3)
  457. #define ACCESS_MAX_MS_V2_ACE_TYPE (0x3)
  458. #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE (0x4)
  459. #define ACCESS_MAX_MS_V3_ACE_TYPE (0x4)
  460. #define ACCESS_MIN_MS_OBJECT_ACE_TYPE (0x5)
  461. #define ACCESS_ALLOWED_OBJECT_ACE_TYPE (0x5)
  462. #define ACCESS_DENIED_OBJECT_ACE_TYPE (0x6)
  463. #define SYSTEM_AUDIT_OBJECT_ACE_TYPE (0x7)
  464. #define SYSTEM_ALARM_OBJECT_ACE_TYPE (0x8)
  465. #define ACCESS_MAX_MS_OBJECT_ACE_TYPE (0x8)
  466. #define ACCESS_MAX_MS_V4_ACE_TYPE (0x8)
  467. #define ACCESS_MAX_MS_ACE_TYPE (0x8)
  468. #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE (0x9)
  469. #define ACCESS_DENIED_CALLBACK_ACE_TYPE (0xA)
  470. #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE (0xB)
  471. #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE (0xC)
  472. #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE (0xD)
  473. #define SYSTEM_ALARM_CALLBACK_ACE_TYPE (0xE)
  474. #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE (0xF)
  475. #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE (0x10)
  476. #define ACCESS_MAX_MS_V5_ACE_TYPE (0x10)
  477. // end_winnt
  478. // begin_winnt
  479. //
  480. // The following are the inherit flags that go into the AceFlags field
  481. // of an Ace header.
  482. //
  483. #define OBJECT_INHERIT_ACE (0x1)
  484. #define CONTAINER_INHERIT_ACE (0x2)
  485. #define NO_PROPAGATE_INHERIT_ACE (0x4)
  486. #define INHERIT_ONLY_ACE (0x8)
  487. #define INHERITED_ACE (0x10)
  488. #define VALID_INHERIT_FLAGS (0x1F)
  489. // The following are the currently defined ACE flags that go into the
  490. // AceFlags field of an ACE header. Each ACE type has its own set of
  491. // AceFlags.
  492. //
  493. // SUCCESSFUL_ACCESS_ACE_FLAG - used only with system audit and alarm ACE
  494. // types to indicate that a message is generated for successful accesses.
  495. //
  496. // FAILED_ACCESS_ACE_FLAG - used only with system audit and alarm ACE types
  497. // to indicate that a message is generated for failed accesses.
  498. //
  499. //
  500. // SYSTEM_AUDIT and SYSTEM_ALARM AceFlags
  501. //
  502. // These control the signaling of audit and alarms for success or failure.
  503. //
  504. #define SUCCESSFUL_ACCESS_ACE_FLAG (0x40)
  505. #define FAILED_ACCESS_ACE_FLAG (0x80)
  506. //
  507. // We'll define the structure of the predefined ACE types. Pictorally
  508. // the structure of the predefined ACE's is as follows:
  509. //
  510. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  511. // 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
  512. // +---------------+-------+-------+---------------+---------------+
  513. // | AceFlags | Resd |Inherit| AceSize | AceType |
  514. // +---------------+-------+-------+---------------+---------------+
  515. // | Mask |
  516. // +---------------------------------------------------------------+
  517. // | |
  518. // + +
  519. // | |
  520. // + Sid +
  521. // | |
  522. // + +
  523. // | |
  524. // +---------------------------------------------------------------+
  525. //
  526. // Mask is the access mask associated with the ACE. This is either the
  527. // access allowed, access denied, audit, or alarm mask.
  528. //
  529. // Sid is the Sid associated with the ACE.
  530. //
  531. // The following are the four predefined ACE types.
  532. // Examine the AceType field in the Header to determine
  533. // which structure is appropriate to use for casting.
  534. typedef struct _ACCESS_ALLOWED_ACE {
  535. ACE_HEADER Header;
  536. ACCESS_MASK Mask;
  537. ULONG SidStart;
  538. } ACCESS_ALLOWED_ACE;
  539. typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE;
  540. typedef struct _ACCESS_DENIED_ACE {
  541. ACE_HEADER Header;
  542. ACCESS_MASK Mask;
  543. ULONG SidStart;
  544. } ACCESS_DENIED_ACE;
  545. typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE;
  546. typedef struct _SYSTEM_AUDIT_ACE {
  547. ACE_HEADER Header;
  548. ACCESS_MASK Mask;
  549. ULONG SidStart;
  550. } SYSTEM_AUDIT_ACE;
  551. typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
  552. typedef struct _SYSTEM_ALARM_ACE {
  553. ACE_HEADER Header;
  554. ACCESS_MASK Mask;
  555. ULONG SidStart;
  556. } SYSTEM_ALARM_ACE;
  557. typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE;
  558. // end_ntifs
  559. // end_winnt
  560. //
  561. // COMPOUND ACE
  562. //
  563. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  564. // 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
  565. // +---------------+-------+-------+---------------+---------------+
  566. // | AceFlags | Resd |Inherit| AceSize | AceType |
  567. // +---------------+-------+-------+---------------+---------------+
  568. // | Mask |
  569. // +-------------------------------+-------------------------------+
  570. // | Compound ACE Type | Reserved (SBZ) |
  571. // +-------------------------------+-------------------------------+
  572. // | |
  573. // + +
  574. // | |
  575. // + Sid +
  576. // | |
  577. // + +
  578. // | |
  579. // +---------------------------------------------------------------+
  580. //
  581. typedef struct _COMPOUND_ACCESS_ALLOWED_ACE {
  582. ACE_HEADER Header;
  583. ACCESS_MASK Mask;
  584. USHORT CompoundAceType;
  585. USHORT Reserved;
  586. ULONG SidStart;
  587. } COMPOUND_ACCESS_ALLOWED_ACE;
  588. typedef COMPOUND_ACCESS_ALLOWED_ACE *PCOMPOUND_ACCESS_ALLOWED_ACE;
  589. //
  590. // Currently defined Compound ACE types
  591. //
  592. #define COMPOUND_ACE_IMPERSONATION 1
  593. // begin_winnt
  594. typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
  595. ACE_HEADER Header;
  596. ACCESS_MASK Mask;
  597. ULONG Flags;
  598. GUID ObjectType;
  599. GUID InheritedObjectType;
  600. ULONG SidStart;
  601. } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
  602. typedef struct _ACCESS_DENIED_OBJECT_ACE {
  603. ACE_HEADER Header;
  604. ACCESS_MASK Mask;
  605. ULONG Flags;
  606. GUID ObjectType;
  607. GUID InheritedObjectType;
  608. ULONG SidStart;
  609. } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
  610. typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
  611. ACE_HEADER Header;
  612. ACCESS_MASK Mask;
  613. ULONG Flags;
  614. GUID ObjectType;
  615. GUID InheritedObjectType;
  616. ULONG SidStart;
  617. } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
  618. typedef struct _SYSTEM_ALARM_OBJECT_ACE {
  619. ACE_HEADER Header;
  620. ACCESS_MASK Mask;
  621. ULONG Flags;
  622. GUID ObjectType;
  623. GUID InheritedObjectType;
  624. ULONG SidStart;
  625. } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_ACE;
  626. //
  627. // Callback ace support in post Win2000.
  628. // Resource managers can put their own data after Sidstart + Length of the sid
  629. //
  630. typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
  631. ACE_HEADER Header;
  632. ACCESS_MASK Mask;
  633. ULONG SidStart;
  634. // Opaque resouce manager specific data
  635. } ACCESS_ALLOWED_CALLBACK_ACE, *PACCESS_ALLOWED_CALLBACK_ACE;
  636. typedef struct _ACCESS_DENIED_CALLBACK_ACE {
  637. ACE_HEADER Header;
  638. ACCESS_MASK Mask;
  639. ULONG SidStart;
  640. // Opaque resouce manager specific data
  641. } ACCESS_DENIED_CALLBACK_ACE, *PACCESS_DENIED_CALLBACK_ACE;
  642. typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
  643. ACE_HEADER Header;
  644. ACCESS_MASK Mask;
  645. ULONG SidStart;
  646. // Opaque resouce manager specific data
  647. } SYSTEM_AUDIT_CALLBACK_ACE, *PSYSTEM_AUDIT_CALLBACK_ACE;
  648. typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
  649. ACE_HEADER Header;
  650. ACCESS_MASK Mask;
  651. ULONG SidStart;
  652. // Opaque resouce manager specific data
  653. } SYSTEM_ALARM_CALLBACK_ACE, *PSYSTEM_ALARM_CALLBACK_ACE;
  654. typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
  655. ACE_HEADER Header;
  656. ACCESS_MASK Mask;
  657. ULONG Flags;
  658. GUID ObjectType;
  659. GUID InheritedObjectType;
  660. ULONG SidStart;
  661. // Opaque resouce manager specific data
  662. } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
  663. typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
  664. ACE_HEADER Header;
  665. ACCESS_MASK Mask;
  666. ULONG Flags;
  667. GUID ObjectType;
  668. GUID InheritedObjectType;
  669. ULONG SidStart;
  670. // Opaque resouce manager specific data
  671. } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
  672. typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
  673. ACE_HEADER Header;
  674. ACCESS_MASK Mask;
  675. ULONG Flags;
  676. GUID ObjectType;
  677. GUID InheritedObjectType;
  678. ULONG SidStart;
  679. // Opaque resouce manager specific data
  680. } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
  681. typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
  682. ACE_HEADER Header;
  683. ACCESS_MASK Mask;
  684. ULONG Flags;
  685. GUID ObjectType;
  686. GUID InheritedObjectType;
  687. ULONG SidStart;
  688. // Opaque resouce manager specific data
  689. } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
  690. //
  691. // Currently define Flags for "OBJECT" ACE types.
  692. //
  693. #define ACE_OBJECT_TYPE_PRESENT 0x1
  694. #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
  695. //
  696. // The following declarations are used for setting and querying information
  697. // about and ACL. First are the various information classes available to
  698. // the user.
  699. //
  700. typedef enum _ACL_INFORMATION_CLASS {
  701. AclRevisionInformation = 1,
  702. AclSizeInformation
  703. } ACL_INFORMATION_CLASS;
  704. //
  705. // This record is returned/sent if the user is requesting/setting the
  706. // AclRevisionInformation
  707. //
  708. typedef struct _ACL_REVISION_INFORMATION {
  709. ULONG AclRevision;
  710. } ACL_REVISION_INFORMATION;
  711. typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
  712. //
  713. // This record is returned if the user is requesting AclSizeInformation
  714. //
  715. typedef struct _ACL_SIZE_INFORMATION {
  716. ULONG AceCount;
  717. ULONG AclBytesInUse;
  718. ULONG AclBytesFree;
  719. } ACL_SIZE_INFORMATION;
  720. typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
  721. // end_winnt
  722. // begin_winnt
  723. ////////////////////////////////////////////////////////////////////////
  724. // //
  725. // SECURITY_DESCRIPTOR //
  726. // //
  727. ////////////////////////////////////////////////////////////////////////
  728. //
  729. // Define the Security Descriptor and related data types.
  730. // This is an opaque data structure.
  731. //
  732. // begin_wdm begin_ntddk begin_ntifs
  733. //
  734. // Current security descriptor revision value
  735. //
  736. #define SECURITY_DESCRIPTOR_REVISION (1)
  737. #define SECURITY_DESCRIPTOR_REVISION1 (1)
  738. // end_wdm end_ntddk
  739. #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
  740. typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
  741. #define SE_OWNER_DEFAULTED (0x0001)
  742. #define SE_GROUP_DEFAULTED (0x0002)
  743. #define SE_DACL_PRESENT (0x0004)
  744. #define SE_DACL_DEFAULTED (0x0008)
  745. #define SE_SACL_PRESENT (0x0010)
  746. #define SE_SACL_DEFAULTED (0x0020)
  747. // end_winnt
  748. #define SE_DACL_UNTRUSTED (0x0040)
  749. #define SE_SERVER_SECURITY (0x0080)
  750. // begin_winnt
  751. #define SE_DACL_AUTO_INHERIT_REQ (0x0100)
  752. #define SE_SACL_AUTO_INHERIT_REQ (0x0200)
  753. #define SE_DACL_AUTO_INHERITED (0x0400)
  754. #define SE_SACL_AUTO_INHERITED (0x0800)
  755. #define SE_DACL_PROTECTED (0x1000)
  756. #define SE_SACL_PROTECTED (0x2000)
  757. #define SE_RM_CONTROL_VALID (0x4000)
  758. #define SE_SELF_RELATIVE (0x8000)
  759. //
  760. // Where:
  761. //
  762. // SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
  763. // SID pointed to by the Owner field was provided by a
  764. // defaulting mechanism rather than explicitly provided by the
  765. // original provider of the security descriptor. This may
  766. // affect the treatment of the SID with respect to inheritence
  767. // of an owner.
  768. //
  769. // SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
  770. // SID in the Group field was provided by a defaulting mechanism
  771. // rather than explicitly provided by the original provider of
  772. // the security descriptor. This may affect the treatment of
  773. // the SID with respect to inheritence of a primary group.
  774. //
  775. // SE_DACL_PRESENT - This boolean flag, when set, indicates that the
  776. // security descriptor contains a discretionary ACL. If this
  777. // flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
  778. // null, then a null ACL is explicitly being specified.
  779. //
  780. // SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
  781. // ACL pointed to by the Dacl field was provided by a defaulting
  782. // mechanism rather than explicitly provided by the original
  783. // provider of the security descriptor. This may affect the
  784. // treatment of the ACL with respect to inheritence of an ACL.
  785. // This flag is ignored if the DaclPresent flag is not set.
  786. //
  787. // SE_SACL_PRESENT - This boolean flag, when set, indicates that the
  788. // security descriptor contains a system ACL pointed to by the
  789. // Sacl field. If this flag is set and the Sacl field of the
  790. // SECURITY_DESCRIPTOR is null, then an empty (but present)
  791. // ACL is being specified.
  792. //
  793. // SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
  794. // ACL pointed to by the Sacl field was provided by a defaulting
  795. // mechanism rather than explicitly provided by the original
  796. // provider of the security descriptor. This may affect the
  797. // treatment of the ACL with respect to inheritence of an ACL.
  798. // This flag is ignored if the SaclPresent flag is not set.
  799. //
  800. // end_winnt
  801. // SE_DACL_TRUSTED - This boolean flag, when set, indicates that the
  802. // ACL pointed to by the Dacl field was provided by a trusted source
  803. // and does not require any editing of compound ACEs. If this flag
  804. // is not set and a compound ACE is encountered, the system will
  805. // substitute known valid SIDs for the server SIDs in the ACEs.
  806. //
  807. // SE_SERVER_SECURITY - This boolean flag, when set, indicates that the
  808. // caller wishes the system to create a Server ACL based on the
  809. // input ACL, regardess of its source (explicit or defaulting.
  810. // This is done by replacing all of the GRANT ACEs with compound
  811. // ACEs granting the current server. This flag is only
  812. // meaningful if the subject is impersonating.
  813. //
  814. // begin_winnt
  815. // SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
  816. // security descriptor is in self-relative form. In this form,
  817. // all fields of the security descriptor are contiguous in memory
  818. // and all pointer fields are expressed as offsets from the
  819. // beginning of the security descriptor. This form is useful
  820. // for treating security descriptors as opaque data structures
  821. // for transmission in communication protocol or for storage on
  822. // secondary media.
  823. //
  824. //
  825. //
  826. // Pictorially the structure of a security descriptor is as follows:
  827. //
  828. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  829. // 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
  830. // +---------------------------------------------------------------+
  831. // | Control |Reserved1 (SBZ)| Revision |
  832. // +---------------------------------------------------------------+
  833. // | Owner |
  834. // +---------------------------------------------------------------+
  835. // | Group |
  836. // +---------------------------------------------------------------+
  837. // | Sacl |
  838. // +---------------------------------------------------------------+
  839. // | Dacl |
  840. // +---------------------------------------------------------------+
  841. //
  842. // In general, this data structure should be treated opaquely to ensure future
  843. // compatibility.
  844. //
  845. //
  846. typedef struct _SECURITY_DESCRIPTOR_RELATIVE {
  847. UCHAR Revision;
  848. UCHAR Sbz1;
  849. SECURITY_DESCRIPTOR_CONTROL Control;
  850. ULONG Owner;
  851. ULONG Group;
  852. ULONG Sacl;
  853. ULONG Dacl;
  854. } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
  855. typedef struct _SECURITY_DESCRIPTOR {
  856. UCHAR Revision;
  857. UCHAR Sbz1;
  858. SECURITY_DESCRIPTOR_CONTROL Control;
  859. PSID Owner;
  860. PSID Group;
  861. PACL Sacl;
  862. PACL Dacl;
  863. } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
  864. // end_ntifs
  865. // Where:
  866. //
  867. // Revision - Contains the revision level of the security
  868. // descriptor. This allows this structure to be passed between
  869. // systems or stored on disk even though it is expected to
  870. // change in the future.
  871. //
  872. // Control - A set of flags which qualify the meaning of the
  873. // security descriptor or individual fields of the security
  874. // descriptor.
  875. //
  876. // Owner - is a pointer to an SID representing an object's owner.
  877. // If this field is null, then no owner SID is present in the
  878. // security descriptor. If the security descriptor is in
  879. // self-relative form, then this field contains an offset to
  880. // the SID, rather than a pointer.
  881. //
  882. // Group - is a pointer to an SID representing an object's primary
  883. // group. If this field is null, then no primary group SID is
  884. // present in the security descriptor. If the security descriptor
  885. // is in self-relative form, then this field contains an offset to
  886. // the SID, rather than a pointer.
  887. //
  888. // Sacl - is a pointer to a system ACL. This field value is only
  889. // valid if the DaclPresent control flag is set. If the
  890. // SaclPresent flag is set and this field is null, then a null
  891. // ACL is specified. If the security descriptor is in
  892. // self-relative form, then this field contains an offset to
  893. // the ACL, rather than a pointer.
  894. //
  895. // Dacl - is a pointer to a discretionary ACL. This field value is
  896. // only valid if the DaclPresent control flag is set. If the
  897. // DaclPresent flag is set and this field is null, then a null
  898. // ACL (unconditionally granting access) is specified. If the
  899. // security descriptor is in self-relative form, then this field
  900. // contains an offset to the ACL, rather than a pointer.
  901. //
  902. // end_winnt
  903. // begin_winnt begin_ntifs
  904. ////////////////////////////////////////////////////////////////////////
  905. // //
  906. // Object Type list for AccessCheckByType //
  907. // //
  908. ////////////////////////////////////////////////////////////////////////
  909. typedef struct _OBJECT_TYPE_LIST {
  910. USHORT Level;
  911. USHORT Sbz;
  912. GUID *ObjectType;
  913. } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
  914. //
  915. // DS values for Level
  916. //
  917. #define ACCESS_OBJECT_GUID 0
  918. #define ACCESS_PROPERTY_SET_GUID 1
  919. #define ACCESS_PROPERTY_GUID 2
  920. #define ACCESS_MAX_LEVEL 4
  921. //
  922. // Parameters to NtAccessCheckByTypeAndAditAlarm
  923. //
  924. typedef enum _AUDIT_EVENT_TYPE {
  925. AuditEventObjectAccess,
  926. AuditEventDirectoryServiceAccess
  927. } AUDIT_EVENT_TYPE, *PAUDIT_EVENT_TYPE;
  928. #define AUDIT_ALLOW_NO_PRIVILEGE 0x1
  929. //
  930. // DS values for Source and ObjectTypeName
  931. //
  932. #define ACCESS_DS_SOURCE_A "DS"
  933. #define ACCESS_DS_SOURCE_W L"DS"
  934. #define ACCESS_DS_OBJECT_TYPE_NAME_A "Directory Service Object"
  935. #define ACCESS_DS_OBJECT_TYPE_NAME_W L"Directory Service Object"
  936. ////////////////////////////////////////////////////////////////////////
  937. // //
  938. // Privilege Related Data Structures //
  939. // //
  940. ////////////////////////////////////////////////////////////////////////
  941. // begin_wdm begin_ntddk begin_nthal
  942. //
  943. // Privilege attributes
  944. //
  945. #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
  946. #define SE_PRIVILEGE_ENABLED (0x00000002L)
  947. #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
  948. //
  949. // Privilege Set Control flags
  950. //
  951. #define PRIVILEGE_SET_ALL_NECESSARY (1)
  952. //
  953. // Privilege Set - This is defined for a privilege set of one.
  954. // If more than one privilege is needed, then this structure
  955. // will need to be allocated with more space.
  956. //
  957. // Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
  958. // structure (defined in se.h)
  959. //
  960. typedef struct _PRIVILEGE_SET {
  961. ULONG PrivilegeCount;
  962. ULONG Control;
  963. LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
  964. } PRIVILEGE_SET, * PPRIVILEGE_SET;
  965. // end_winnt end_wdm end_ntddk end_nthal end_ntifs
  966. // begin_winnt
  967. ////////////////////////////////////////////////////////////////////////
  968. // //
  969. // NT Defined Privileges //
  970. // //
  971. ////////////////////////////////////////////////////////////////////////
  972. // end_winnt
  973. //
  974. // ** ** ** ** ** ** ** ** ** ** NOTE ** ** ** ** ** ** ** ** ** ** ** ** **
  975. //
  976. // Any additions or deletions to the following list
  977. // of privileges must have corresponding changes made
  978. // in the following files:
  979. // - ntos\se\seglobal.c
  980. // - ds\security\base\lsa\msprivs\msprivs.rc
  981. // - ds\security\base\lsa\server\dspolicy\dbpriv.c
  982. //
  983. // ** ** ** ** ** ** ** ** ** ** NOTE ** ** ** ** ** ** ** ** ** ** ** ** **
  984. //
  985. // begin_winnt
  986. #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
  987. #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
  988. #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
  989. #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
  990. #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
  991. #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
  992. #define SE_TCB_NAME TEXT("SeTcbPrivilege")
  993. #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
  994. #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
  995. #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
  996. #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
  997. #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
  998. #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
  999. #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
  1000. #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
  1001. #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
  1002. #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
  1003. #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
  1004. #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
  1005. #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
  1006. #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
  1007. #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
  1008. #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
  1009. #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
  1010. #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
  1011. #define SE_SYNC_AGENT_NAME TEXT("SeSyncAgentPrivilege")
  1012. #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
  1013. #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
  1014. // end_winnt
  1015. // begin_wdm begin_ntddk begin_ntifs
  1016. //
  1017. // These must be converted to LUIDs before use.
  1018. //
  1019. #define SE_MIN_WELL_KNOWN_PRIVILEGE (2L)
  1020. #define SE_CREATE_TOKEN_PRIVILEGE (2L)
  1021. #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE (3L)
  1022. #define SE_LOCK_MEMORY_PRIVILEGE (4L)
  1023. #define SE_INCREASE_QUOTA_PRIVILEGE (5L)
  1024. // end_wdm
  1025. //
  1026. // Unsolicited Input is obsolete and unused.
  1027. //
  1028. #define SE_UNSOLICITED_INPUT_PRIVILEGE (6L)
  1029. // begin_wdm
  1030. #define SE_MACHINE_ACCOUNT_PRIVILEGE (6L)
  1031. #define SE_TCB_PRIVILEGE (7L)
  1032. #define SE_SECURITY_PRIVILEGE (8L)
  1033. #define SE_TAKE_OWNERSHIP_PRIVILEGE (9L)
  1034. #define SE_LOAD_DRIVER_PRIVILEGE (10L)
  1035. #define SE_SYSTEM_PROFILE_PRIVILEGE (11L)
  1036. #define SE_SYSTEMTIME_PRIVILEGE (12L)
  1037. #define SE_PROF_SINGLE_PROCESS_PRIVILEGE (13L)
  1038. #define SE_INC_BASE_PRIORITY_PRIVILEGE (14L)
  1039. #define SE_CREATE_PAGEFILE_PRIVILEGE (15L)
  1040. #define SE_CREATE_PERMANENT_PRIVILEGE (16L)
  1041. #define SE_BACKUP_PRIVILEGE (17L)
  1042. #define SE_RESTORE_PRIVILEGE (18L)
  1043. #define SE_SHUTDOWN_PRIVILEGE (19L)
  1044. #define SE_DEBUG_PRIVILEGE (20L)
  1045. #define SE_AUDIT_PRIVILEGE (21L)
  1046. #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE (22L)
  1047. #define SE_CHANGE_NOTIFY_PRIVILEGE (23L)
  1048. #define SE_REMOTE_SHUTDOWN_PRIVILEGE (24L)
  1049. #define SE_UNDOCK_PRIVILEGE (25L)
  1050. #define SE_SYNC_AGENT_PRIVILEGE (26L)
  1051. #define SE_ENABLE_DELEGATION_PRIVILEGE (27L)
  1052. #define SE_MANAGE_VOLUME_PRIVILEGE (28L)
  1053. #define SE_MAX_WELL_KNOWN_PRIVILEGE (SE_MANAGE_VOLUME_PRIVILEGE)
  1054. // end_wdm end_ntddk end_ntifs
  1055. // begin_winnt
  1056. ////////////////////////////////////////////////////////////////////
  1057. // //
  1058. // Security Quality Of Service //
  1059. // //
  1060. // //
  1061. ////////////////////////////////////////////////////////////////////
  1062. // begin_wdm begin_ntddk begin_nthal begin_ntifs
  1063. //
  1064. // Impersonation Level
  1065. //
  1066. // Impersonation level is represented by a pair of bits in Windows.
  1067. // If a new impersonation level is added or lowest value is changed from
  1068. // 0 to something else, fix the Windows CreateFile call.
  1069. //
  1070. typedef enum _SECURITY_IMPERSONATION_LEVEL {
  1071. SecurityAnonymous,
  1072. SecurityIdentification,
  1073. SecurityImpersonation,
  1074. SecurityDelegation
  1075. } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
  1076. #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
  1077. #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
  1078. #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
  1079. #define VALID_IMPERSONATION_LEVEL(L) (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
  1080. // end_nthal end_wdm end_ntddk end_ntifs end_winnt
  1081. //
  1082. // begin_winnt begin_ntifs
  1083. ////////////////////////////////////////////////////////////////////
  1084. // //
  1085. // Token Object Definitions //
  1086. // //
  1087. // //
  1088. ////////////////////////////////////////////////////////////////////
  1089. //
  1090. // Token Specific Access Rights.
  1091. //
  1092. #define TOKEN_ASSIGN_PRIMARY (0x0001)
  1093. #define TOKEN_DUPLICATE (0x0002)
  1094. #define TOKEN_IMPERSONATE (0x0004)
  1095. #define TOKEN_QUERY (0x0008)
  1096. #define TOKEN_QUERY_SOURCE (0x0010)
  1097. #define TOKEN_ADJUST_PRIVILEGES (0x0020)
  1098. #define TOKEN_ADJUST_GROUPS (0x0040)
  1099. #define TOKEN_ADJUST_DEFAULT (0x0080)
  1100. #define TOKEN_ADJUST_SESSIONID (0x0100)
  1101. #define TOKEN_ALL_ACCESS_P (STANDARD_RIGHTS_REQUIRED |\
  1102. TOKEN_ASSIGN_PRIMARY |\
  1103. TOKEN_DUPLICATE |\
  1104. TOKEN_IMPERSONATE |\
  1105. TOKEN_QUERY |\
  1106. TOKEN_QUERY_SOURCE |\
  1107. TOKEN_ADJUST_PRIVILEGES |\
  1108. TOKEN_ADJUST_GROUPS |\
  1109. TOKEN_ADJUST_DEFAULT )
  1110. #if ((defined(_WIN32_WINNT) && (_WIN32_WINNT > 0x0400)) || (!defined(_WIN32_WINNT)))
  1111. #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P |\
  1112. TOKEN_ADJUST_SESSIONID )
  1113. #else
  1114. #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P)
  1115. #endif
  1116. #define TOKEN_READ (STANDARD_RIGHTS_READ |\
  1117. TOKEN_QUERY)
  1118. #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE |\
  1119. TOKEN_ADJUST_PRIVILEGES |\
  1120. TOKEN_ADJUST_GROUPS |\
  1121. TOKEN_ADJUST_DEFAULT)
  1122. #define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE)
  1123. //
  1124. //
  1125. // Token Types
  1126. //
  1127. typedef enum _TOKEN_TYPE {
  1128. TokenPrimary = 1,
  1129. TokenImpersonation
  1130. } TOKEN_TYPE;
  1131. typedef TOKEN_TYPE *PTOKEN_TYPE;
  1132. //
  1133. // Token Information Classes.
  1134. //
  1135. typedef enum _TOKEN_INFORMATION_CLASS {
  1136. TokenUser = 1,
  1137. TokenGroups,
  1138. TokenPrivileges,
  1139. TokenOwner,
  1140. TokenPrimaryGroup,
  1141. TokenDefaultDacl,
  1142. TokenSource,
  1143. TokenType,
  1144. TokenImpersonationLevel,
  1145. TokenStatistics,
  1146. TokenRestrictedSids,
  1147. TokenSessionId,
  1148. TokenGroupsAndPrivileges,
  1149. TokenSessionReference,
  1150. TokenSandBoxInert
  1151. } TOKEN_INFORMATION_CLASS, *PTOKEN_INFORMATION_CLASS;
  1152. //
  1153. // Token information class structures
  1154. //
  1155. typedef struct _TOKEN_USER {
  1156. SID_AND_ATTRIBUTES User;
  1157. } TOKEN_USER, *PTOKEN_USER;
  1158. typedef struct _TOKEN_GROUPS {
  1159. ULONG GroupCount;
  1160. SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
  1161. } TOKEN_GROUPS, *PTOKEN_GROUPS;
  1162. typedef struct _TOKEN_PRIVILEGES {
  1163. ULONG PrivilegeCount;
  1164. LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
  1165. } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
  1166. typedef struct _TOKEN_OWNER {
  1167. PSID Owner;
  1168. } TOKEN_OWNER, *PTOKEN_OWNER;
  1169. typedef struct _TOKEN_PRIMARY_GROUP {
  1170. PSID PrimaryGroup;
  1171. } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
  1172. typedef struct _TOKEN_DEFAULT_DACL {
  1173. PACL DefaultDacl;
  1174. } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
  1175. typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
  1176. ULONG SidCount;
  1177. ULONG SidLength;
  1178. PSID_AND_ATTRIBUTES Sids;
  1179. ULONG RestrictedSidCount;
  1180. ULONG RestrictedSidLength;
  1181. PSID_AND_ATTRIBUTES RestrictedSids;
  1182. ULONG PrivilegeCount;
  1183. ULONG PrivilegeLength;
  1184. PLUID_AND_ATTRIBUTES Privileges;
  1185. LUID AuthenticationId;
  1186. } TOKEN_GROUPS_AND_PRIVILEGES, *PTOKEN_GROUPS_AND_PRIVILEGES;
  1187. // end_winnt end_ntifs
  1188. typedef enum _PROXY_CLASS {
  1189. ProxyFull,
  1190. ProxyService,
  1191. ProxyTree,
  1192. ProxyDirectory
  1193. } PROXY_CLASS, * PPROXY_CLASS;
  1194. typedef struct _SECURITY_TOKEN_PROXY_DATA {
  1195. ULONG Length;
  1196. PROXY_CLASS ProxyClass;
  1197. UNICODE_STRING PathInfo;
  1198. ACCESS_MASK ContainerMask;
  1199. ACCESS_MASK ObjectMask;
  1200. } SECURITY_TOKEN_PROXY_DATA, *PSECURITY_TOKEN_PROXY_DATA;
  1201. typedef struct _SECURITY_TOKEN_AUDIT_DATA {
  1202. ULONG Length;
  1203. ACCESS_MASK GrantMask;
  1204. ACCESS_MASK DenyMask;
  1205. } SECURITY_TOKEN_AUDIT_DATA, *PSECURITY_TOKEN_AUDIT_DATA;
  1206. // begin_ntifs begin_winnt
  1207. #define TOKEN_SOURCE_LENGTH 8
  1208. typedef struct _TOKEN_SOURCE {
  1209. CHAR SourceName[TOKEN_SOURCE_LENGTH];
  1210. LUID SourceIdentifier;
  1211. } TOKEN_SOURCE, *PTOKEN_SOURCE;
  1212. typedef struct _TOKEN_STATISTICS {
  1213. LUID TokenId;
  1214. LUID AuthenticationId;
  1215. LARGE_INTEGER ExpirationTime;
  1216. TOKEN_TYPE TokenType;
  1217. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  1218. ULONG DynamicCharged;
  1219. ULONG DynamicAvailable;
  1220. ULONG GroupCount;
  1221. ULONG PrivilegeCount;
  1222. LUID ModifiedId;
  1223. } TOKEN_STATISTICS, *PTOKEN_STATISTICS;
  1224. typedef struct _TOKEN_CONTROL {
  1225. LUID TokenId;
  1226. LUID AuthenticationId;
  1227. LUID ModifiedId;
  1228. TOKEN_SOURCE TokenSource;
  1229. } TOKEN_CONTROL, *PTOKEN_CONTROL;
  1230. // end_winnt
  1231. // end_ntifs
  1232. // begin_wdm begin_ntddk begin_ntifs begin_winnt
  1233. //
  1234. // Security Tracking Mode
  1235. //
  1236. #define SECURITY_DYNAMIC_TRACKING (TRUE)
  1237. #define SECURITY_STATIC_TRACKING (FALSE)
  1238. typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
  1239. * PSECURITY_CONTEXT_TRACKING_MODE;
  1240. //
  1241. // Quality Of Service
  1242. //
  1243. typedef struct _SECURITY_QUALITY_OF_SERVICE {
  1244. ULONG Length;
  1245. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  1246. SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
  1247. BOOLEAN EffectiveOnly;
  1248. } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE;
  1249. // end_winnt end_wdm end_ntddk end_ntifs
  1250. //
  1251. // Advanced Quality of Service
  1252. //
  1253. typedef struct _SECURITY_ADVANCED_QUALITY_OF_SERVICE {
  1254. ULONG Length;
  1255. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  1256. SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
  1257. BOOLEAN EffectiveOnly;
  1258. PSECURITY_TOKEN_PROXY_DATA ProxyData;
  1259. PSECURITY_TOKEN_AUDIT_DATA AuditData;
  1260. } SECURITY_ADVANCED_QUALITY_OF_SERVICE, *PSECURITY_ADVANCED_QUALITY_OF_SERVICE;
  1261. // begin_wdm begin_ntddk begin_ntifs begin_winnt
  1262. //
  1263. // Used to represent information related to a thread impersonation
  1264. //
  1265. typedef struct _SE_IMPERSONATION_STATE {
  1266. PACCESS_TOKEN Token;
  1267. BOOLEAN CopyOnOpen;
  1268. BOOLEAN EffectiveOnly;
  1269. SECURITY_IMPERSONATION_LEVEL Level;
  1270. } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
  1271. // end_winnt end_wdm end_ntddk end_ntifs
  1272. ////////////////////////////////////////////////////////////////////////
  1273. // //
  1274. // Flags for NtFilerToken //
  1275. // //
  1276. ////////////////////////////////////////////////////////////////////////
  1277. #define DISABLE_MAX_PRIVILEGE 0x1 // winnt
  1278. #define SANDBOX_INERT 0x2 // winnt
  1279. ////////////////////////////////////////////////////////////////////////
  1280. // //
  1281. // General Security definitions //
  1282. // //
  1283. ////////////////////////////////////////////////////////////////////////
  1284. //
  1285. // Security information associated with objects.
  1286. // Used for query operations.
  1287. //
  1288. // This will be extended in the future to include mandatory access control.
  1289. //
  1290. // begin_winnt begin_wdm begin_ntddk begin_nthal begin_ntifs
  1291. typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
  1292. #define OWNER_SECURITY_INFORMATION (0x00000001L)
  1293. #define GROUP_SECURITY_INFORMATION (0x00000002L)
  1294. #define DACL_SECURITY_INFORMATION (0x00000004L)
  1295. #define SACL_SECURITY_INFORMATION (0x00000008L)
  1296. #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
  1297. #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
  1298. #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
  1299. #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
  1300. // end_winnt end_wdm end_ntddk end_nthal end_ntifs
  1301. //
  1302. // used for password manipulations
  1303. //
  1304. typedef struct _SECURITY_SEED_AND_LENGTH {
  1305. UCHAR Length;
  1306. UCHAR Seed;
  1307. } SECURITY_SEED_AND_LENGTH, *PSECURITY_SEED_AND_LENGTH;
  1308. ////////////////////////////////////////////////////////////////////////
  1309. // //
  1310. // Security System Service Defnitions //
  1311. // //
  1312. ////////////////////////////////////////////////////////////////////////
  1313. //
  1314. // Security check system services
  1315. //
  1316. NTSYSCALLAPI
  1317. NTSTATUS
  1318. NTAPI
  1319. NtAccessCheck (
  1320. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1321. IN HANDLE ClientToken,
  1322. IN ACCESS_MASK DesiredAccess,
  1323. IN PGENERIC_MAPPING GenericMapping,
  1324. OUT PPRIVILEGE_SET PrivilegeSet,
  1325. IN OUT PULONG PrivilegeSetLength,
  1326. OUT PACCESS_MASK GrantedAccess,
  1327. OUT PNTSTATUS AccessStatus
  1328. );
  1329. NTSYSCALLAPI
  1330. NTSTATUS
  1331. NTAPI
  1332. NtAccessCheckByType (
  1333. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1334. IN PSID PrincipalSelfSid,
  1335. IN HANDLE ClientToken,
  1336. IN ACCESS_MASK DesiredAccess,
  1337. IN POBJECT_TYPE_LIST ObjectTypeList,
  1338. IN ULONG ObjectTypeListLength,
  1339. IN PGENERIC_MAPPING GenericMapping,
  1340. OUT PPRIVILEGE_SET PrivilegeSet,
  1341. IN OUT PULONG PrivilegeSetLength,
  1342. OUT PACCESS_MASK GrantedAccess,
  1343. OUT PNTSTATUS AccessStatus
  1344. );
  1345. NTSYSCALLAPI
  1346. NTSTATUS
  1347. NTAPI
  1348. NtAccessCheckByTypeResultList (
  1349. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1350. IN PSID PrincipalSelfSid,
  1351. IN HANDLE ClientToken,
  1352. IN ACCESS_MASK DesiredAccess,
  1353. IN POBJECT_TYPE_LIST ObjectTypeList,
  1354. IN ULONG ObjectTypeListLength,
  1355. IN PGENERIC_MAPPING GenericMapping,
  1356. OUT PPRIVILEGE_SET PrivilegeSet,
  1357. IN OUT PULONG PrivilegeSetLength,
  1358. OUT PACCESS_MASK GrantedAccess,
  1359. OUT PNTSTATUS AccessStatus
  1360. );
  1361. ///////////////////////////////////////////////////////////////////////
  1362. // //
  1363. // Token Object System Services //
  1364. // //
  1365. ///////////////////////////////////////////////////////////////////////
  1366. NTSYSCALLAPI
  1367. NTSTATUS
  1368. NTAPI
  1369. NtCreateToken(
  1370. OUT PHANDLE TokenHandle,
  1371. IN ACCESS_MASK DesiredAccess,
  1372. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  1373. IN TOKEN_TYPE TokenType,
  1374. IN PLUID AuthenticationId,
  1375. IN PLARGE_INTEGER ExpirationTime,
  1376. IN PTOKEN_USER User,
  1377. IN PTOKEN_GROUPS Groups,
  1378. IN PTOKEN_PRIVILEGES Privileges,
  1379. IN PTOKEN_OWNER Owner OPTIONAL,
  1380. IN PTOKEN_PRIMARY_GROUP PrimaryGroup,
  1381. IN PTOKEN_DEFAULT_DACL DefaultDacl OPTIONAL,
  1382. IN PTOKEN_SOURCE TokenSource
  1383. );
  1384. NTSYSCALLAPI
  1385. NTSTATUS
  1386. NTAPI
  1387. NtCompareTokens(
  1388. IN HANDLE FirstTokenHandle,
  1389. IN HANDLE SecondTokenHandle,
  1390. OUT PBOOLEAN Equal
  1391. );
  1392. // begin_ntifs
  1393. NTSYSCALLAPI
  1394. NTSTATUS
  1395. NTAPI
  1396. NtOpenThreadToken(
  1397. IN HANDLE ThreadHandle,
  1398. IN ACCESS_MASK DesiredAccess,
  1399. IN BOOLEAN OpenAsSelf,
  1400. OUT PHANDLE TokenHandle
  1401. );
  1402. NTSYSCALLAPI
  1403. NTSTATUS
  1404. NTAPI
  1405. NtOpenThreadTokenEx(
  1406. IN HANDLE ThreadHandle,
  1407. IN ACCESS_MASK DesiredAccess,
  1408. IN BOOLEAN OpenAsSelf,
  1409. IN ULONG HandleAttributes,
  1410. OUT PHANDLE TokenHandle
  1411. );
  1412. NTSYSCALLAPI
  1413. NTSTATUS
  1414. NTAPI
  1415. NtOpenProcessToken(
  1416. IN HANDLE ProcessHandle,
  1417. IN ACCESS_MASK DesiredAccess,
  1418. OUT PHANDLE TokenHandle
  1419. );
  1420. NTSYSCALLAPI
  1421. NTSTATUS
  1422. NTAPI
  1423. NtOpenProcessTokenEx(
  1424. IN HANDLE ProcessHandle,
  1425. IN ACCESS_MASK DesiredAccess,
  1426. IN ULONG HandleAttributes,
  1427. OUT PHANDLE TokenHandle
  1428. );
  1429. NTSYSAPI
  1430. NTSTATUS
  1431. NTAPI
  1432. NtOpenJobObjectToken(
  1433. IN HANDLE JobHandle,
  1434. IN ACCESS_MASK DesiredAccess,
  1435. OUT PHANDLE TokenHandle
  1436. );
  1437. NTSYSCALLAPI
  1438. NTSTATUS
  1439. NTAPI
  1440. NtDuplicateToken(
  1441. IN HANDLE ExistingTokenHandle,
  1442. IN ACCESS_MASK DesiredAccess,
  1443. IN POBJECT_ATTRIBUTES ObjectAttributes,
  1444. IN BOOLEAN EffectiveOnly,
  1445. IN TOKEN_TYPE TokenType,
  1446. OUT PHANDLE NewTokenHandle
  1447. );
  1448. NTSYSCALLAPI
  1449. NTSTATUS
  1450. NTAPI
  1451. NtFilterToken (
  1452. IN HANDLE ExistingTokenHandle,
  1453. IN ULONG Flags,
  1454. IN PTOKEN_GROUPS SidsToDisable OPTIONAL,
  1455. IN PTOKEN_PRIVILEGES PrivilegesToDelete OPTIONAL,
  1456. IN PTOKEN_GROUPS RestrictedSids OPTIONAL,
  1457. OUT PHANDLE NewTokenHandle
  1458. );
  1459. NTSYSCALLAPI
  1460. NTSTATUS
  1461. NTAPI
  1462. NtImpersonateAnonymousToken(
  1463. IN HANDLE ThreadHandle
  1464. );
  1465. NTSYSCALLAPI
  1466. NTSTATUS
  1467. NTAPI
  1468. NtQueryInformationToken (
  1469. IN HANDLE TokenHandle,
  1470. IN TOKEN_INFORMATION_CLASS TokenInformationClass,
  1471. OUT PVOID TokenInformation,
  1472. IN ULONG TokenInformationLength,
  1473. OUT PULONG ReturnLength
  1474. );
  1475. NTSYSCALLAPI
  1476. NTSTATUS
  1477. NTAPI
  1478. NtSetInformationToken (
  1479. IN HANDLE TokenHandle,
  1480. IN TOKEN_INFORMATION_CLASS TokenInformationClass,
  1481. IN PVOID TokenInformation,
  1482. IN ULONG TokenInformationLength
  1483. );
  1484. NTSYSCALLAPI
  1485. NTSTATUS
  1486. NTAPI
  1487. NtAdjustPrivilegesToken (
  1488. IN HANDLE TokenHandle,
  1489. IN BOOLEAN DisableAllPrivileges,
  1490. IN PTOKEN_PRIVILEGES NewState OPTIONAL,
  1491. IN ULONG BufferLength OPTIONAL,
  1492. OUT PTOKEN_PRIVILEGES PreviousState OPTIONAL,
  1493. OUT PULONG ReturnLength
  1494. );
  1495. NTSYSCALLAPI
  1496. NTSTATUS
  1497. NTAPI
  1498. NtAdjustGroupsToken (
  1499. IN HANDLE TokenHandle,
  1500. IN BOOLEAN ResetToDefault,
  1501. IN PTOKEN_GROUPS NewState OPTIONAL,
  1502. IN ULONG BufferLength OPTIONAL,
  1503. OUT PTOKEN_GROUPS PreviousState OPTIONAL,
  1504. OUT PULONG ReturnLength
  1505. );
  1506. NTSYSCALLAPI
  1507. NTSTATUS
  1508. NTAPI
  1509. NtPrivilegeCheck (
  1510. IN HANDLE ClientToken,
  1511. IN OUT PPRIVILEGE_SET RequiredPrivileges,
  1512. OUT PBOOLEAN Result
  1513. );
  1514. NTSYSCALLAPI
  1515. NTSTATUS
  1516. NTAPI
  1517. NtAccessCheckAndAuditAlarm (
  1518. IN PUNICODE_STRING SubsystemName,
  1519. IN PVOID HandleId,
  1520. IN PUNICODE_STRING ObjectTypeName,
  1521. IN PUNICODE_STRING ObjectName,
  1522. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1523. IN ACCESS_MASK DesiredAccess,
  1524. IN PGENERIC_MAPPING GenericMapping,
  1525. IN BOOLEAN ObjectCreation,
  1526. OUT PACCESS_MASK GrantedAccess,
  1527. OUT PNTSTATUS AccessStatus,
  1528. OUT PBOOLEAN GenerateOnClose
  1529. );
  1530. NTSYSCALLAPI
  1531. NTSTATUS
  1532. NTAPI
  1533. NtAccessCheckByTypeAndAuditAlarm (
  1534. IN PUNICODE_STRING SubsystemName,
  1535. IN PVOID HandleId,
  1536. IN PUNICODE_STRING ObjectTypeName,
  1537. IN PUNICODE_STRING ObjectName,
  1538. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1539. IN PSID PrincipalSelfSid,
  1540. IN ACCESS_MASK DesiredAccess,
  1541. IN AUDIT_EVENT_TYPE AuditType,
  1542. IN ULONG Flags,
  1543. IN POBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  1544. IN ULONG ObjectTypeListLength,
  1545. IN PGENERIC_MAPPING GenericMapping,
  1546. IN BOOLEAN ObjectCreation,
  1547. OUT PACCESS_MASK GrantedAccess,
  1548. OUT PNTSTATUS AccessStatus,
  1549. OUT PBOOLEAN GenerateOnClose
  1550. );
  1551. NTSYSCALLAPI
  1552. NTSTATUS
  1553. NTAPI
  1554. NtAccessCheckByTypeResultListAndAuditAlarm (
  1555. IN PUNICODE_STRING SubsystemName,
  1556. IN PVOID HandleId,
  1557. IN PUNICODE_STRING ObjectTypeName,
  1558. IN PUNICODE_STRING ObjectName,
  1559. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1560. IN PSID PrincipalSelfSid,
  1561. IN ACCESS_MASK DesiredAccess,
  1562. IN AUDIT_EVENT_TYPE AuditType,
  1563. IN ULONG Flags,
  1564. IN POBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  1565. IN ULONG ObjectTypeListLength,
  1566. IN PGENERIC_MAPPING GenericMapping,
  1567. IN BOOLEAN ObjectCreation,
  1568. OUT PACCESS_MASK GrantedAccess,
  1569. OUT PNTSTATUS AccessStatus,
  1570. OUT PBOOLEAN GenerateOnClose
  1571. );
  1572. NTSYSCALLAPI
  1573. NTSTATUS
  1574. NTAPI
  1575. NtAccessCheckByTypeResultListAndAuditAlarmByHandle (
  1576. IN PUNICODE_STRING SubsystemName,
  1577. IN PVOID HandleId,
  1578. IN HANDLE ClientToken,
  1579. IN PUNICODE_STRING ObjectTypeName,
  1580. IN PUNICODE_STRING ObjectName,
  1581. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1582. IN PSID PrincipalSelfSid,
  1583. IN ACCESS_MASK DesiredAccess,
  1584. IN AUDIT_EVENT_TYPE AuditType,
  1585. IN ULONG Flags,
  1586. IN POBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  1587. IN ULONG ObjectTypeListLength,
  1588. IN PGENERIC_MAPPING GenericMapping,
  1589. IN BOOLEAN ObjectCreation,
  1590. OUT PACCESS_MASK GrantedAccess,
  1591. OUT PNTSTATUS AccessStatus,
  1592. OUT PBOOLEAN GenerateOnClose
  1593. );
  1594. NTSYSCALLAPI
  1595. NTSTATUS
  1596. NTAPI
  1597. NtOpenObjectAuditAlarm (
  1598. IN PUNICODE_STRING SubsystemName,
  1599. IN PVOID HandleId OPTIONAL,
  1600. IN PUNICODE_STRING ObjectTypeName,
  1601. IN PUNICODE_STRING ObjectName,
  1602. IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
  1603. IN HANDLE ClientToken,
  1604. IN ACCESS_MASK DesiredAccess,
  1605. IN ACCESS_MASK GrantedAccess,
  1606. IN PPRIVILEGE_SET Privileges OPTIONAL,
  1607. IN BOOLEAN ObjectCreation,
  1608. IN BOOLEAN AccessGranted,
  1609. OUT PBOOLEAN GenerateOnClose
  1610. );
  1611. NTSYSCALLAPI
  1612. NTSTATUS
  1613. NTAPI
  1614. NtPrivilegeObjectAuditAlarm (
  1615. IN PUNICODE_STRING SubsystemName,
  1616. IN PVOID HandleId,
  1617. IN HANDLE ClientToken,
  1618. IN ACCESS_MASK DesiredAccess,
  1619. IN PPRIVILEGE_SET Privileges,
  1620. IN BOOLEAN AccessGranted
  1621. );
  1622. NTSYSCALLAPI
  1623. NTSTATUS
  1624. NTAPI
  1625. NtCloseObjectAuditAlarm (
  1626. IN PUNICODE_STRING SubsystemName,
  1627. IN PVOID HandleId,
  1628. IN BOOLEAN GenerateOnClose
  1629. );
  1630. NTSYSCALLAPI
  1631. NTSTATUS
  1632. NTAPI
  1633. NtDeleteObjectAuditAlarm (
  1634. IN PUNICODE_STRING SubsystemName,
  1635. IN PVOID HandleId,
  1636. IN BOOLEAN GenerateOnClose
  1637. );
  1638. NTSYSCALLAPI
  1639. NTSTATUS
  1640. NTAPI
  1641. NtPrivilegedServiceAuditAlarm (
  1642. IN PUNICODE_STRING SubsystemName,
  1643. IN PUNICODE_STRING ServiceName,
  1644. IN HANDLE ClientToken,
  1645. IN PPRIVILEGE_SET Privileges,
  1646. IN BOOLEAN AccessGranted
  1647. );
  1648. // end_ntifs
  1649. #ifdef __cplusplus
  1650. }
  1651. #endif
  1652. #endif // _NTSEAPI_