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.

1876 lines
48 KiB

  1. /*++ BUILD Version: 0011 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. se.h
  5. Abstract:
  6. This module contains the Security routines that are only callable
  7. from kernel mode.
  8. This file is included by including "ntos.h".
  9. Author:
  10. Gary Kimura (GaryKi) 09-Mar-1989
  11. Revision History:
  12. --*/
  13. #ifndef _SE_
  14. #define _SE_
  15. //////////////////////////////////////////////////////////////////////////////
  16. // //
  17. // Kernel mode only data structures //
  18. // Opaque security data structures are defined in seopaque.h //
  19. // //
  20. //////////////////////////////////////////////////////////////////////////////
  21. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  22. //
  23. // Security operation codes
  24. //
  25. typedef enum _SECURITY_OPERATION_CODE {
  26. SetSecurityDescriptor,
  27. QuerySecurityDescriptor,
  28. DeleteSecurityDescriptor,
  29. AssignSecurityDescriptor
  30. } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
  31. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  32. //
  33. // Default security quota
  34. //
  35. // This is the minimum amount of quota (in bytes) that will be
  36. // charged for security information for an object that has
  37. // security.
  38. //
  39. #define SE_DEFAULT_SECURITY_QUOTA 2048
  40. // begin_ntifs
  41. //
  42. // Token Flags
  43. //
  44. // Flags that may be defined in the TokenFlags field of the token object,
  45. // or in an ACCESS_STATE structure
  46. //
  47. #define TOKEN_HAS_TRAVERSE_PRIVILEGE 0x01
  48. #define TOKEN_HAS_BACKUP_PRIVILEGE 0x02
  49. #define TOKEN_HAS_RESTORE_PRIVILEGE 0x04
  50. #define TOKEN_HAS_ADMIN_GROUP 0x08
  51. #define TOKEN_IS_RESTRICTED 0x10
  52. #define TOKEN_SESSION_NOT_REFERENCED 0x20
  53. #define TOKEN_SANDBOX_INERT 0x40
  54. #define TOKEN_HAS_IMPERSONATE_PRIVILEGE 0x80
  55. // end_ntifs
  56. //
  57. // General flag
  58. //
  59. #define SE_BACKUP_PRIVILEGES_CHECKED 0x00000010
  60. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  61. //
  62. // Data structure used to capture subject security context
  63. // for access validations and auditing.
  64. //
  65. // THE FIELDS OF THIS DATA STRUCTURE SHOULD BE CONSIDERED OPAQUE
  66. // BY ALL EXCEPT THE SECURITY ROUTINES.
  67. //
  68. typedef struct _SECURITY_SUBJECT_CONTEXT {
  69. PACCESS_TOKEN ClientToken;
  70. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  71. PACCESS_TOKEN PrimaryToken;
  72. PVOID ProcessAuditId;
  73. } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
  74. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  75. //
  76. // where
  77. //
  78. // ClientToken - optionally points to a token object being used by the
  79. // subject's thread to impersonate a client. If the subject's
  80. // thread is not impersonating a client, this field is set to null.
  81. // The token's reference count is incremented to count this field
  82. // as an outstanding reference.
  83. //
  84. // ImpersonationLevel - Contains the impersonation level of the subject's
  85. // thread. This field is only meaningful if the ClientToken field
  86. // is not null. This field over-rides any higher impersonation
  87. // level value that might be in the client's token.
  88. //
  89. // PrimaryToken - points the the subject's primary token. The token's
  90. // reference count is incremented to count this field value as an
  91. // outstanding reference.
  92. //
  93. // ProcessAuditId - Is an ID assigned to represent the subject's process.
  94. // As an implementation detail, this is the process object's address.
  95. // However, this field should not be treated as a pointer, and the
  96. // reference count of the process object is not incremented to
  97. // count it as an outstanding reference.
  98. //
  99. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  100. ///////////////////////////////////////////////////////////////////////////////
  101. // //
  102. // ACCESS_STATE and related structures //
  103. // //
  104. ///////////////////////////////////////////////////////////////////////////////
  105. //
  106. // Initial Privilege Set - Room for three privileges, which should
  107. // be enough for most applications. This structure exists so that
  108. // it can be imbedded in an ACCESS_STATE structure. Use PRIVILEGE_SET
  109. // for all other references to Privilege sets.
  110. //
  111. #define INITIAL_PRIVILEGE_COUNT 3
  112. typedef struct _INITIAL_PRIVILEGE_SET {
  113. ULONG PrivilegeCount;
  114. ULONG Control;
  115. LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
  116. } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
  117. //
  118. // Combine the information that describes the state
  119. // of an access-in-progress into a single structure
  120. //
  121. typedef struct _ACCESS_STATE {
  122. LUID OperationID;
  123. BOOLEAN SecurityEvaluated;
  124. BOOLEAN GenerateAudit;
  125. BOOLEAN GenerateOnClose;
  126. BOOLEAN PrivilegesAllocated;
  127. ULONG Flags;
  128. ACCESS_MASK RemainingDesiredAccess;
  129. ACCESS_MASK PreviouslyGrantedAccess;
  130. ACCESS_MASK OriginalDesiredAccess;
  131. SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
  132. PSECURITY_DESCRIPTOR SecurityDescriptor;
  133. PVOID AuxData;
  134. union {
  135. INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
  136. PRIVILEGE_SET PrivilegeSet;
  137. } Privileges;
  138. BOOLEAN AuditPrivileges;
  139. UNICODE_STRING ObjectName;
  140. UNICODE_STRING ObjectTypeName;
  141. } ACCESS_STATE, *PACCESS_STATE;
  142. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  143. /*
  144. where:
  145. OperationID - an LUID to identify the operation being performed. This
  146. ID will be put in the audit log to allow non-contiguous operations
  147. on the same object to be associated with one another.
  148. SecurityEvaluated - a marker to be set by Parse Methods to indicate
  149. that security access checking and audit logging has been performed.
  150. Flags - Holds misc flags for reference during the access attempt.
  151. AuditHandleCreation - a flag set by SeOpenObjectAuditAlarm to indicate
  152. that auditing is to take place when the handle for the object
  153. is allocated.
  154. RemainingDesiredAccess - Access mask containing the access types that
  155. have not yet been granted.
  156. PreviouslyGrantedAccess - Access mask containing the access types that
  157. have been granted, one way or another (for example, a given access
  158. may be granted as a result of owning a privilege rather than being
  159. in an ACL. A routine can check the privilege and mark the access
  160. as granted without doing a formal access check).
  161. SubjectSecurityContext - The subject's captured security context
  162. PrivilegesAllocated - Flag to indicate whether we have allocated
  163. space for the privilege set from pool memory, so it can be
  164. freed.
  165. SecurityDescriptor - Temporarily contains the security descriptor
  166. for the object being created between the time the user's
  167. security descriptor is captured and the time the security
  168. descriptor is passed to SeAssignSecurity. NO ONE BUT
  169. SEASSIGNSECURITY SHOULD EVER LOOK IN THIS FIELD FOR AN
  170. OBJECT'S SECURITY DESCRIPTOR.
  171. AuxData - points to an auxillary data structure to be used for future
  172. expansion of the access state in an upwardly compatible way. This
  173. field replaces the PrivilegesUsed pointer, which was for internal
  174. use only.
  175. Privileges - A set of privileges, some of which may have the
  176. UsedForAccess bit set. If the pre-allocated number of privileges
  177. is not enough, we will allocate space from pool memory to allow
  178. for growth.
  179. */
  180. //*******************************************************************************
  181. // *
  182. // Since the AccessState structure is publically exposed to driver *
  183. // writers, this structure contains additional data added after NT 3.51. *
  184. // *
  185. // Its contents must be accessed only through Se level interfaces, *
  186. // never directly by name. *
  187. // *
  188. // This structure is pointed to by the AuxData field of the AccessState. *
  189. // It is allocated by SeCreateAccessState and freed by SeDeleteAccessState. *
  190. // *
  191. // DO NOT EXPOSE THIS STRUCTURE TO THE PUBLIC. *
  192. // *
  193. //*******************************************************************************
  194. // begin_ntosp
  195. typedef struct _AUX_ACCESS_DATA {
  196. PPRIVILEGE_SET PrivilegesUsed;
  197. GENERIC_MAPPING GenericMapping;
  198. ACCESS_MASK AccessesToAudit;
  199. ACCESS_MASK MaximumAuditMask;
  200. } AUX_ACCESS_DATA, *PAUX_ACCESS_DATA;
  201. // end_ntosp
  202. /*
  203. where:
  204. PrivilegesUsed - Points to the set of privileges used during the access
  205. validation.
  206. GenericMapping - Points to the generic mapping for the object being accessed.
  207. Normally this would be filled in with the generic mapping passed to
  208. SeCreateAccessState, but in the case of the IO system (which does not
  209. know the type of object being accessed until it parses the name),
  210. it must be filled in later. See the discussion of the GenericMapping
  211. parameter in SeCreateAccessState for more details.
  212. AccessToAudit - Used as a temporary holding area for the access mask
  213. to put into the audit record. This field is necessary because the
  214. access being put into the newly created handle may not be the ones
  215. we want to audit. This occurs when a file is opened for read-only
  216. transacted mode, where a read only file is opened for write access.
  217. We don't want to audit the fact that we granted write access, since
  218. we really didn't, and customers would be confused to see the extra
  219. bit in the audit record.
  220. MaximumAuditMask - Stores the audit mask that will be stored into the
  221. new handle structure to support operation based audits.
  222. */
  223. //
  224. // Structure describing whether or not a particular type of event
  225. // is being audited
  226. //
  227. typedef struct _SE_AUDITING_STATE {
  228. BOOLEAN AuditOnSuccess;
  229. BOOLEAN AuditOnFailure;
  230. } SE_AUDITING_STATE, *PSE_AUDITING_STATE;
  231. typedef struct _SE_PROCESS_AUDIT_INFO {
  232. PEPROCESS Process;
  233. PEPROCESS Parent;
  234. } SE_PROCESS_AUDIT_INFO, *PSE_PROCESS_AUDIT_INFO;
  235. /************************************************************
  236. WARNING WARNING WARNING
  237. Only add new fields to the end of this structure.
  238. *************************************************************/
  239. // begin_ntifs begin_ntosp
  240. typedef struct _SE_EXPORTS {
  241. //
  242. // Privilege values
  243. //
  244. LUID SeCreateTokenPrivilege;
  245. LUID SeAssignPrimaryTokenPrivilege;
  246. LUID SeLockMemoryPrivilege;
  247. LUID SeIncreaseQuotaPrivilege;
  248. LUID SeUnsolicitedInputPrivilege;
  249. LUID SeTcbPrivilege;
  250. LUID SeSecurityPrivilege;
  251. LUID SeTakeOwnershipPrivilege;
  252. LUID SeLoadDriverPrivilege;
  253. LUID SeCreatePagefilePrivilege;
  254. LUID SeIncreaseBasePriorityPrivilege;
  255. LUID SeSystemProfilePrivilege;
  256. LUID SeSystemtimePrivilege;
  257. LUID SeProfileSingleProcessPrivilege;
  258. LUID SeCreatePermanentPrivilege;
  259. LUID SeBackupPrivilege;
  260. LUID SeRestorePrivilege;
  261. LUID SeShutdownPrivilege;
  262. LUID SeDebugPrivilege;
  263. LUID SeAuditPrivilege;
  264. LUID SeSystemEnvironmentPrivilege;
  265. LUID SeChangeNotifyPrivilege;
  266. LUID SeRemoteShutdownPrivilege;
  267. //
  268. // Universally defined Sids
  269. //
  270. PSID SeNullSid;
  271. PSID SeWorldSid;
  272. PSID SeLocalSid;
  273. PSID SeCreatorOwnerSid;
  274. PSID SeCreatorGroupSid;
  275. //
  276. // Nt defined Sids
  277. //
  278. PSID SeNtAuthoritySid;
  279. PSID SeDialupSid;
  280. PSID SeNetworkSid;
  281. PSID SeBatchSid;
  282. PSID SeInteractiveSid;
  283. PSID SeLocalSystemSid;
  284. PSID SeAliasAdminsSid;
  285. PSID SeAliasUsersSid;
  286. PSID SeAliasGuestsSid;
  287. PSID SeAliasPowerUsersSid;
  288. PSID SeAliasAccountOpsSid;
  289. PSID SeAliasSystemOpsSid;
  290. PSID SeAliasPrintOpsSid;
  291. PSID SeAliasBackupOpsSid;
  292. //
  293. // New Sids defined for NT5
  294. //
  295. PSID SeAuthenticatedUsersSid;
  296. PSID SeRestrictedSid;
  297. PSID SeAnonymousLogonSid;
  298. //
  299. // New Privileges defined for NT5
  300. //
  301. LUID SeUndockPrivilege;
  302. LUID SeSyncAgentPrivilege;
  303. LUID SeEnableDelegationPrivilege;
  304. //
  305. // New Sids defined for post-Windows 2000
  306. PSID SeLocalServiceSid;
  307. PSID SeNetworkServiceSid;
  308. //
  309. // New Privileges defined for post-Windows 2000
  310. //
  311. LUID SeManageVolumePrivilege;
  312. LUID SeImpersonatePrivilege;
  313. LUID SeCreateGlobalPrivilege;
  314. } SE_EXPORTS, *PSE_EXPORTS;
  315. // end_ntifs end_ntosp
  316. /************************************************************
  317. WARNING WARNING WARNING
  318. Only add new fields to the end of this structure.
  319. *************************************************************/
  320. // begin_ntifs
  321. ///////////////////////////////////////////////////////////////////////////////
  322. // //
  323. // Logon session notification callback routines //
  324. // //
  325. ///////////////////////////////////////////////////////////////////////////////
  326. //
  327. // These callback routines are used to notify file systems that have
  328. // registered of logon sessions being terminated, so they can cleanup state
  329. // associated with this logon session
  330. //
  331. typedef NTSTATUS
  332. (*PSE_LOGON_SESSION_TERMINATED_ROUTINE)(
  333. IN PLUID LogonId);
  334. // end_ntifs
  335. ///////////////////////////////////////////////////////////////////////////////
  336. // //
  337. // Exported Security Macro Definitions //
  338. // //
  339. ///////////////////////////////////////////////////////////////////////////////
  340. //++
  341. //
  342. // ACCESS_MASK
  343. // SeComputeDeniedAccesses(
  344. // IN ACCESS_MASK GrantedAccess,
  345. // IN ACCESS_MASK DesiredAccess
  346. // );
  347. //
  348. // Routine Description:
  349. //
  350. // This routine generates an access mask containing those accesses
  351. // requested by DesiredAccess that aren't granted by GrantedAccess.
  352. // The result of this routine may be compared to 0 to determine
  353. // if a DesiredAccess mask contains any accesses that have not
  354. // been granted.
  355. //
  356. // If the result IS ZERO, then all desired accesses have been granted.
  357. //
  358. // Arguments:
  359. //
  360. // GrantedAccess - Specifies the granted access mask.
  361. //
  362. // DesiredAccess - Specifies the desired access mask.
  363. //
  364. // Return Value:
  365. //
  366. // An ACCESS_MASK containing the desired accesses that have
  367. // not been granted.
  368. //
  369. //--
  370. #define SeComputeDeniedAccesses( GrantedAccess, DesiredAccess ) \
  371. ((~(GrantedAccess)) & (DesiredAccess) )
  372. //++
  373. //
  374. // BOOLEAN
  375. // SeComputeGrantedAccesses(
  376. // IN ACCESS_MASK GrantedAccess,
  377. // IN ACCESS_MASK DesiredAccess
  378. // );
  379. //
  380. // Routine Description:
  381. //
  382. // This routine generates an access mask containing acccesses
  383. // requested by DesiredAccess that are granted by GrantedAccess.
  384. // The result of this routine may be compared to 0 to determine
  385. // if any desired accesses have been granted.
  386. //
  387. // If the result IS NON-ZERO, then at least one desired accesses
  388. // has been granted.
  389. //
  390. // Arguments:
  391. //
  392. // GrantedAccess - Specifies the granted access mask.
  393. //
  394. // DesiredAccess - Specifies the desired access mask.
  395. //
  396. // Return Value:
  397. //
  398. // This routine returns TRUE if the DesiredAccess mask does specifies
  399. // any bits that are set in the GrantedAccess mask.
  400. //
  401. //--
  402. #define SeComputeGrantedAccesses( GrantedAccess, DesiredAccess ) \
  403. ((GrantedAccess) & (DesiredAccess) )
  404. // begin_ntifs
  405. //++
  406. //
  407. // ULONG
  408. // SeLengthSid(
  409. // IN PSID Sid
  410. // );
  411. //
  412. // Routine Description:
  413. //
  414. // This routine computes the length of a SID.
  415. //
  416. // Arguments:
  417. //
  418. // Sid - Points to the SID whose length is to be returned.
  419. //
  420. // Return Value:
  421. //
  422. // The length, in bytes of the SID.
  423. //
  424. //--
  425. #define SeLengthSid( Sid ) \
  426. (8 + (4 * ((SID *)Sid)->SubAuthorityCount))
  427. // end_ntifs
  428. //++
  429. // BOOLEAN
  430. // SeSameToken (
  431. // IN PTOKEN_CONTROL TokenControl1,
  432. // IN PTOKEN_CONTROL TokenControl2
  433. // )
  434. //
  435. //
  436. // Routine Description:
  437. //
  438. // This routine returns a boolean value indicating whether the two
  439. // token control values represent the same token. The token may
  440. // have changed over time, but must have the same authentication ID
  441. // and token ID. A value of TRUE indicates they
  442. // are equal. A value of FALSE indicates they are not equal.
  443. //
  444. //
  445. //
  446. // Arguments:
  447. //
  448. // TokenControl1 - Points to a token control to compare.
  449. //
  450. // TokenControl2 - Points to the other token control to compare.
  451. //
  452. // Return Value:
  453. //
  454. // TRUE => The token control values represent the same token.
  455. //
  456. // FALSE => The token control values do not represent the same token.
  457. //
  458. //
  459. //--
  460. #define SeSameToken(TC1,TC2) ( \
  461. ((TC1)->TokenId.HighPart == (TC2)->TokenId.HighPart) && \
  462. ((TC1)->TokenId.LowPart == (TC2)->TokenId.LowPart) && \
  463. (RtlEqualLuid(&(TC1)->AuthenticationId,&(TC2)->AuthenticationId)) \
  464. )
  465. // begin_ntifs
  466. //
  467. //VOID
  468. //SeDeleteClientSecurity(
  469. // IN PSECURITY_CLIENT_CONTEXT ClientContext
  470. // )
  471. //
  472. ///*++
  473. //
  474. //Routine Description:
  475. //
  476. // This service deletes a client security context block,
  477. // performing whatever cleanup might be necessary to do so. In
  478. // particular, reference to any client token is removed.
  479. //
  480. //Arguments:
  481. //
  482. // ClientContext - Points to the client security context block to be
  483. // deleted.
  484. //
  485. //
  486. //Return Value:
  487. //
  488. //
  489. //
  490. //--*/
  491. //--
  492. // begin_ntosp
  493. #define SeDeleteClientSecurity(C) { \
  494. if (SeTokenType((C)->ClientToken) == TokenPrimary) { \
  495. PsDereferencePrimaryToken( (C)->ClientToken ); \
  496. } else { \
  497. PsDereferenceImpersonationToken( (C)->ClientToken ); \
  498. } \
  499. }
  500. //++
  501. //VOID
  502. //SeStopImpersonatingClient()
  503. //
  504. ///*++
  505. //
  506. //Routine Description:
  507. //
  508. // This service is used to stop impersonating a client using an
  509. // impersonation token. This service must be called in the context
  510. // of the server thread which wishes to stop impersonating its
  511. // client.
  512. //
  513. //
  514. //Arguments:
  515. //
  516. // None.
  517. //
  518. //Return Value:
  519. //
  520. // None.
  521. //
  522. //--*/
  523. //--
  524. #define SeStopImpersonatingClient() PsRevertToSelf()
  525. // end_ntosp end_ntifs
  526. #define SeAssertMappedCanonicalAccess( AccessMask ) \
  527. ASSERT(!( ( AccessMask ) & \
  528. ( GENERIC_READ | \
  529. GENERIC_WRITE | \
  530. GENERIC_EXECUTE | \
  531. GENERIC_ALL )) \
  532. )
  533. /*++
  534. Routine Description:
  535. This routine asserts that the given AccessMask does not contain
  536. any generic access types.
  537. Arguments:
  538. AccessMask - The access mask to be checked.
  539. Return Value:
  540. None, or doesn't return.
  541. --*/
  542. #define SeComputeSecurityQuota( Size ) \
  543. ( \
  544. ((( Size ) * 2 ) > SE_DEFAULT_SECURITY_QUOTA) ? \
  545. (( Size ) * 2 ) : SE_DEFAULT_SECURITY_QUOTA \
  546. )
  547. /*++
  548. Routine Description:
  549. This macro computes the amount of quota to charge for
  550. security information.
  551. The current algorithm is to use the larger of twice the size
  552. of the Group + Dacl information being applied and the default as
  553. specified by SE_DEFAULT_SECURITY_QUOTA.
  554. Arguments:
  555. Size - The size in bytes of the Group + Dacl information being applied
  556. to the object.
  557. Return Value:
  558. The size in bytes to charge for security information on this object.
  559. --*/
  560. // begin_ntifs begin_ntosp
  561. //++
  562. //
  563. // PACCESS_TOKEN
  564. // SeQuerySubjectContextToken(
  565. // IN PSECURITY_SUBJECT_CONTEXT SubjectContext
  566. // );
  567. //
  568. // Routine Description:
  569. //
  570. // This routine returns the effective token from the subject context,
  571. // either the client token, if present, or the process token.
  572. //
  573. // Arguments:
  574. //
  575. // SubjectContext - Context to query
  576. //
  577. // Return Value:
  578. //
  579. // This routine returns the PACCESS_TOKEN for the effective token.
  580. // The pointer may be passed to SeQueryInformationToken. This routine
  581. // does not affect the lock status of the token, i.e. the token is not
  582. // locked. If the SubjectContext has been locked, the token remains locked,
  583. // if not, the token remains unlocked.
  584. //
  585. //--
  586. #define SeQuerySubjectContextToken( SubjectContext ) \
  587. ( ARGUMENT_PRESENT( ((PSECURITY_SUBJECT_CONTEXT) SubjectContext)->ClientToken) ? \
  588. ((PSECURITY_SUBJECT_CONTEXT) SubjectContext)->ClientToken : \
  589. ((PSECURITY_SUBJECT_CONTEXT) SubjectContext)->PrimaryToken )
  590. // end_ntifs end_ntosp
  591. ///////////////////////////////////////////////////////////////////////////////
  592. // //
  593. // Define the exported procedures that are callable only from kernel mode //
  594. // //
  595. ///////////////////////////////////////////////////////////////////////////////
  596. BOOLEAN
  597. SeInitSystem( VOID );
  598. VOID
  599. SeSetSecurityAccessMask(
  600. IN SECURITY_INFORMATION SecurityInformation,
  601. OUT PACCESS_MASK DesiredAccess
  602. );
  603. VOID
  604. SeQuerySecurityAccessMask(
  605. IN SECURITY_INFORMATION SecurityInformation,
  606. OUT PACCESS_MASK DesiredAccess
  607. );
  608. NTSTATUS
  609. SeDefaultObjectMethod (
  610. IN PVOID Object,
  611. IN SECURITY_OPERATION_CODE OperationCode,
  612. IN PSECURITY_INFORMATION SecurityInformation,
  613. IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
  614. IN OUT PULONG Length,
  615. IN OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  616. IN POOL_TYPE PoolType,
  617. IN PGENERIC_MAPPING GenericMapping
  618. );
  619. // begin_ntosp
  620. NTKERNELAPI
  621. NTSTATUS
  622. SeCaptureSecurityDescriptor (
  623. IN PSECURITY_DESCRIPTOR InputSecurityDescriptor,
  624. IN KPROCESSOR_MODE RequestorMode,
  625. IN POOL_TYPE PoolType,
  626. IN BOOLEAN ForceCapture,
  627. OUT PSECURITY_DESCRIPTOR *OutputSecurityDescriptor
  628. );
  629. NTKERNELAPI
  630. VOID
  631. SeReleaseSecurityDescriptor (
  632. IN PSECURITY_DESCRIPTOR CapturedSecurityDescriptor,
  633. IN KPROCESSOR_MODE RequestorMode,
  634. IN BOOLEAN ForceCapture
  635. );
  636. // begin_ntifs
  637. NTKERNELAPI
  638. VOID
  639. SeCaptureSubjectContext (
  640. OUT PSECURITY_SUBJECT_CONTEXT SubjectContext
  641. );
  642. NTKERNELAPI
  643. VOID
  644. SeLockSubjectContext(
  645. IN PSECURITY_SUBJECT_CONTEXT SubjectContext
  646. );
  647. NTKERNELAPI
  648. VOID
  649. SeUnlockSubjectContext(
  650. IN PSECURITY_SUBJECT_CONTEXT SubjectContext
  651. );
  652. NTKERNELAPI
  653. VOID
  654. SeReleaseSubjectContext (
  655. IN PSECURITY_SUBJECT_CONTEXT SubjectContext
  656. );
  657. NTSTATUS
  658. SeCaptureAuditPolicy(
  659. IN PTOKEN_AUDIT_POLICY Policy,
  660. IN KPROCESSOR_MODE RequestorMode,
  661. IN PVOID CaptureBuffer OPTIONAL,
  662. IN ULONG CaptureBufferLength,
  663. IN POOL_TYPE PoolType,
  664. IN BOOLEAN ForceCapture,
  665. OUT PTOKEN_AUDIT_POLICY *CapturedPolicy
  666. );
  667. VOID
  668. SeReleaseAuditPolicy (
  669. IN PTOKEN_AUDIT_POLICY CapturedPolicy,
  670. IN KPROCESSOR_MODE RequestorMode,
  671. IN BOOLEAN ForceCapture
  672. );
  673. // end_ntifs end_ntosp
  674. VOID
  675. SeCaptureSubjectContextEx (
  676. IN PETHREAD Thread,
  677. IN PEPROCESS Process,
  678. OUT PSECURITY_SUBJECT_CONTEXT SubjectContext
  679. );
  680. NTSTATUS
  681. SeCaptureSecurityQos (
  682. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  683. IN KPROCESSOR_MODE RequestorMode,
  684. IN PBOOLEAN SecurityQosPresent,
  685. IN PSECURITY_ADVANCED_QUALITY_OF_SERVICE CapturedSecurityQos
  686. );
  687. VOID
  688. SeFreeCapturedSecurityQos(
  689. IN PVOID SecurityQos
  690. );
  691. NTSTATUS
  692. SeCaptureSid (
  693. IN PSID InputSid,
  694. IN KPROCESSOR_MODE RequestorMode,
  695. IN PVOID CaptureBuffer OPTIONAL,
  696. IN ULONG CaptureBufferLength,
  697. IN POOL_TYPE PoolType,
  698. IN BOOLEAN ForceCapture,
  699. OUT PSID *CapturedSid
  700. );
  701. VOID
  702. SeReleaseSid (
  703. IN PSID CapturedSid,
  704. IN KPROCESSOR_MODE RequestorMode,
  705. IN BOOLEAN ForceCapture
  706. );
  707. NTSTATUS
  708. SeCaptureAcl (
  709. IN PACL InputAcl,
  710. IN KPROCESSOR_MODE RequestorMode,
  711. IN PVOID CaptureBuffer OPTIONAL,
  712. IN ULONG CaptureBufferLength,
  713. IN POOL_TYPE PoolType,
  714. IN BOOLEAN ForceCapture,
  715. OUT PACL *CapturedAcl,
  716. OUT PULONG AlignedAclSize
  717. );
  718. VOID
  719. SeReleaseAcl (
  720. IN PACL CapturedAcl,
  721. IN KPROCESSOR_MODE RequestorMode,
  722. IN BOOLEAN ForceCapture
  723. );
  724. NTSTATUS
  725. SeCaptureLuidAndAttributesArray (
  726. IN PLUID_AND_ATTRIBUTES InputArray,
  727. IN ULONG ArrayCount,
  728. IN KPROCESSOR_MODE RequestorMode,
  729. IN PVOID CaptureBuffer OPTIONAL,
  730. IN ULONG CaptureBufferLength,
  731. IN POOL_TYPE PoolType,
  732. IN BOOLEAN ForceCapture,
  733. OUT PLUID_AND_ATTRIBUTES *CapturedArray,
  734. OUT PULONG AlignedArraySize
  735. );
  736. VOID
  737. SeReleaseLuidAndAttributesArray (
  738. IN PLUID_AND_ATTRIBUTES CapturedArray,
  739. IN KPROCESSOR_MODE RequestorMode,
  740. IN BOOLEAN ForceCapture
  741. );
  742. NTSTATUS
  743. SeCaptureSidAndAttributesArray (
  744. IN PSID_AND_ATTRIBUTES InputArray,
  745. IN ULONG ArrayCount,
  746. IN KPROCESSOR_MODE RequestorMode,
  747. IN PVOID CaptureBuffer OPTIONAL,
  748. IN ULONG CaptureBufferLength,
  749. IN POOL_TYPE PoolType,
  750. IN BOOLEAN ForceCapture,
  751. OUT PSID_AND_ATTRIBUTES *CapturedArray,
  752. OUT PULONG AlignedArraySize
  753. );
  754. VOID
  755. SeReleaseSidAndAttributesArray (
  756. IN PSID_AND_ATTRIBUTES CapturedArray,
  757. IN KPROCESSOR_MODE RequestorMode,
  758. IN BOOLEAN ForceCapture
  759. );
  760. // begin_ntddk begin_wdm begin_ntifs begin_ntosp
  761. NTKERNELAPI
  762. NTSTATUS
  763. SeAssignSecurity (
  764. IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
  765. IN PSECURITY_DESCRIPTOR ExplicitDescriptor,
  766. OUT PSECURITY_DESCRIPTOR *NewDescriptor,
  767. IN BOOLEAN IsDirectoryObject,
  768. IN PSECURITY_SUBJECT_CONTEXT SubjectContext,
  769. IN PGENERIC_MAPPING GenericMapping,
  770. IN POOL_TYPE PoolType
  771. );
  772. NTKERNELAPI
  773. NTSTATUS
  774. SeAssignSecurityEx (
  775. IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
  776. IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL,
  777. OUT PSECURITY_DESCRIPTOR *NewDescriptor,
  778. IN GUID *ObjectType OPTIONAL,
  779. IN BOOLEAN IsDirectoryObject,
  780. IN ULONG AutoInheritFlags,
  781. IN PSECURITY_SUBJECT_CONTEXT SubjectContext,
  782. IN PGENERIC_MAPPING GenericMapping,
  783. IN POOL_TYPE PoolType
  784. );
  785. NTKERNELAPI
  786. NTSTATUS
  787. SeDeassignSecurity (
  788. IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor
  789. );
  790. NTKERNELAPI
  791. BOOLEAN
  792. SeAccessCheck (
  793. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  794. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  795. IN BOOLEAN SubjectContextLocked,
  796. IN ACCESS_MASK DesiredAccess,
  797. IN ACCESS_MASK PreviouslyGrantedAccess,
  798. OUT PPRIVILEGE_SET *Privileges OPTIONAL,
  799. IN PGENERIC_MAPPING GenericMapping,
  800. IN KPROCESSOR_MODE AccessMode,
  801. OUT PACCESS_MASK GrantedAccess,
  802. OUT PNTSTATUS AccessStatus
  803. );
  804. #ifdef SE_NTFS_WORLD_CACHE
  805. VOID
  806. SeGetWorldRights (
  807. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  808. IN PGENERIC_MAPPING GenericMapping,
  809. OUT PACCESS_MASK GrantedAccess
  810. );
  811. #endif
  812. // end_ntddk end_wdm end_ntifs end_ntosp
  813. BOOLEAN
  814. SeProxyAccessCheck (
  815. IN PUNICODE_STRING Volume,
  816. IN PUNICODE_STRING RelativePath,
  817. IN BOOLEAN ContainerObject,
  818. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  819. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  820. IN BOOLEAN SubjectContextLocked,
  821. IN ACCESS_MASK DesiredAccess,
  822. IN ACCESS_MASK PreviouslyGrantedAccess,
  823. OUT PPRIVILEGE_SET *Privileges OPTIONAL,
  824. IN PGENERIC_MAPPING GenericMapping,
  825. IN KPROCESSOR_MODE AccessMode,
  826. OUT PACCESS_MASK GrantedAccess,
  827. OUT PNTSTATUS AccessStatus
  828. );
  829. // begin_ntifs begin_ntosp
  830. NTKERNELAPI
  831. BOOLEAN
  832. SePrivilegeCheck(
  833. IN OUT PPRIVILEGE_SET RequiredPrivileges,
  834. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  835. IN KPROCESSOR_MODE AccessMode
  836. );
  837. NTKERNELAPI
  838. VOID
  839. SeFreePrivileges(
  840. IN PPRIVILEGE_SET Privileges
  841. );
  842. // end_ntifs end_ntosp
  843. NTSTATUS
  844. SePrivilegePolicyCheck(
  845. IN OUT PACCESS_MASK RemainingDesiredAccess,
  846. IN OUT PACCESS_MASK PreviouslyGrantedAccess,
  847. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext OPTIONAL,
  848. IN PACCESS_TOKEN Token OPTIONAL,
  849. OUT PPRIVILEGE_SET *PrivilegeSet,
  850. IN KPROCESSOR_MODE PreviousMode
  851. );
  852. VOID
  853. SeGenerateMessage (
  854. IN PSTRING ObjectName,
  855. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  856. IN PACCESS_TOKEN Token,
  857. IN ACCESS_MASK DesiredAccess,
  858. IN BOOLEAN AccessGranted,
  859. IN HANDLE AuditPort,
  860. IN HANDLE AlarmPort,
  861. IN KPROCESSOR_MODE AccessMode
  862. );
  863. // begin_ntifs
  864. NTKERNELAPI
  865. VOID
  866. SeOpenObjectAuditAlarm (
  867. IN PUNICODE_STRING ObjectTypeName,
  868. IN PVOID Object OPTIONAL,
  869. IN PUNICODE_STRING AbsoluteObjectName OPTIONAL,
  870. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  871. IN PACCESS_STATE AccessState,
  872. IN BOOLEAN ObjectCreated,
  873. IN BOOLEAN AccessGranted,
  874. IN KPROCESSOR_MODE AccessMode,
  875. OUT PBOOLEAN GenerateOnClose
  876. );
  877. NTKERNELAPI
  878. VOID
  879. SeOpenObjectForDeleteAuditAlarm (
  880. IN PUNICODE_STRING ObjectTypeName,
  881. IN PVOID Object OPTIONAL,
  882. IN PUNICODE_STRING AbsoluteObjectName OPTIONAL,
  883. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  884. IN PACCESS_STATE AccessState,
  885. IN BOOLEAN ObjectCreated,
  886. IN BOOLEAN AccessGranted,
  887. IN KPROCESSOR_MODE AccessMode,
  888. OUT PBOOLEAN GenerateOnClose
  889. );
  890. VOID
  891. SeDeleteObjectAuditAlarm(
  892. IN PVOID Object,
  893. IN HANDLE Handle
  894. );
  895. // end_ntifs
  896. VOID
  897. SeCloseObjectAuditAlarm(
  898. IN PVOID Object,
  899. IN HANDLE Handle,
  900. IN BOOLEAN GenerateOnClose
  901. );
  902. VOID
  903. SeCreateInstanceAuditAlarm(
  904. IN PLUID OperationID OPTIONAL,
  905. IN PVOID Object,
  906. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  907. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  908. IN ACCESS_MASK DesiredAccess,
  909. IN PPRIVILEGE_SET Privileges OPTIONAL,
  910. IN BOOLEAN AccessGranted,
  911. IN KPROCESSOR_MODE AccessMode
  912. );
  913. VOID
  914. SeCreateObjectAuditAlarm(
  915. IN PLUID OperationID OPTIONAL,
  916. IN PVOID Object,
  917. IN PUNICODE_STRING ComponentName,
  918. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  919. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  920. IN ACCESS_MASK DesiredAccess,
  921. IN PPRIVILEGE_SET Privileges OPTIONAL,
  922. IN BOOLEAN AccessGranted,
  923. OUT PBOOLEAN AuditPerformed,
  924. IN KPROCESSOR_MODE AccessMode
  925. );
  926. VOID
  927. SeObjectReferenceAuditAlarm(
  928. IN PLUID OperationID OPTIONAL,
  929. IN PVOID Object,
  930. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  931. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  932. IN ACCESS_MASK DesiredAccess,
  933. IN PPRIVILEGE_SET Privileges OPTIONAL,
  934. IN BOOLEAN AccessGranted,
  935. IN KPROCESSOR_MODE AccessMode
  936. );
  937. // begin_ntosp
  938. NTKERNELAPI
  939. VOID
  940. SePrivilegeObjectAuditAlarm(
  941. IN HANDLE Handle,
  942. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  943. IN ACCESS_MASK DesiredAccess,
  944. IN PPRIVILEGE_SET Privileges,
  945. IN BOOLEAN AccessGranted,
  946. IN KPROCESSOR_MODE AccessMode
  947. );
  948. // end_ntosp
  949. BOOLEAN
  950. SeCheckPrivilegedObject(
  951. LUID PrivilegeValue,
  952. HANDLE ObjectHandle,
  953. ACCESS_MASK DesiredAccess,
  954. KPROCESSOR_MODE PreviousMode
  955. );
  956. // begin_ntddk begin_wdm begin_ntifs
  957. NTKERNELAPI
  958. BOOLEAN
  959. SeValidSecurityDescriptor(
  960. IN ULONG Length,
  961. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  962. );
  963. // end_ntddk end_wdm end_ntifs
  964. //VOID
  965. //SeImplicitObjectAuditAlarm(
  966. // IN PLUID OperationID OPTIONAL,
  967. // IN PVOID Object,
  968. // IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  969. // IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  970. // IN ACCESS_MASK DesiredAccess,
  971. // IN PPRIVILEGE_SET Privileges OPTIONAL,
  972. // IN BOOLEAN AccessGranted,
  973. // IN KPROCESSOR_MODE AccessMode
  974. // );
  975. //
  976. VOID
  977. SeAuditHandleCreation(
  978. IN PACCESS_STATE AccessState,
  979. IN HANDLE Handle
  980. );
  981. PACCESS_TOKEN
  982. SeMakeSystemToken (
  983. VOID
  984. );
  985. PACCESS_TOKEN
  986. SeMakeAnonymousLogonToken (
  987. VOID
  988. );
  989. PACCESS_TOKEN
  990. SeMakeAnonymousLogonTokenNoEveryone (
  991. VOID
  992. );
  993. VOID
  994. SeGetTokenControlInformation (
  995. IN PACCESS_TOKEN Token,
  996. OUT PTOKEN_CONTROL TokenControl
  997. );
  998. // begin_ntosp
  999. extern struct _OBJECT_TYPE *SeTokenObjectType;
  1000. NTKERNELAPI // ntifs
  1001. TOKEN_TYPE // ntifs
  1002. SeTokenType( // ntifs
  1003. IN PACCESS_TOKEN Token // ntifs
  1004. ); // ntifs
  1005. SECURITY_IMPERSONATION_LEVEL
  1006. SeTokenImpersonationLevel(
  1007. IN PACCESS_TOKEN Token
  1008. );
  1009. NTKERNELAPI // ntifs
  1010. BOOLEAN // ntifs
  1011. SeTokenIsAdmin( // ntifs
  1012. IN PACCESS_TOKEN Token // ntifs
  1013. ); // ntifs
  1014. NTKERNELAPI // ntifs
  1015. BOOLEAN // ntifs
  1016. SeTokenIsRestricted( // ntifs
  1017. IN PACCESS_TOKEN Token // ntifs
  1018. ); // ntifs
  1019. NTKERNELAPI
  1020. NTSTATUS
  1021. SeTokenCanImpersonate(
  1022. IN PACCESS_TOKEN ProcessToken,
  1023. IN PACCESS_TOKEN Token,
  1024. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
  1025. );
  1026. // end_ntosp
  1027. NTSTATUS
  1028. SeSubProcessToken (
  1029. IN PACCESS_TOKEN ParentToken,
  1030. OUT PACCESS_TOKEN *ChildToken,
  1031. IN BOOLEAN MarkAsActive,
  1032. IN ULONG SessionId
  1033. );
  1034. VOID
  1035. SeAssignPrimaryToken(
  1036. IN PEPROCESS Process,
  1037. IN PACCESS_TOKEN Token
  1038. );
  1039. VOID
  1040. SeDeassignPrimaryToken(
  1041. IN PEPROCESS Process
  1042. );
  1043. NTSTATUS
  1044. SeExchangePrimaryToken(
  1045. IN PEPROCESS Process,
  1046. IN PACCESS_TOKEN NewAccessToken,
  1047. OUT PACCESS_TOKEN *OldAccessToken
  1048. );
  1049. NTSTATUS
  1050. SeCopyClientToken(
  1051. IN PACCESS_TOKEN ClientToken,
  1052. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  1053. IN KPROCESSOR_MODE RequestorMode,
  1054. OUT PACCESS_TOKEN *DuplicateToken
  1055. );
  1056. // begin_ntifs
  1057. NTSTATUS
  1058. SeFilterToken (
  1059. IN PACCESS_TOKEN ExistingToken,
  1060. IN ULONG Flags,
  1061. IN PTOKEN_GROUPS SidsToDisable OPTIONAL,
  1062. IN PTOKEN_PRIVILEGES PrivilegesToDelete OPTIONAL,
  1063. IN PTOKEN_GROUPS RestrictedSids OPTIONAL,
  1064. OUT PACCESS_TOKEN * FilteredToken
  1065. );
  1066. // begin_ntosp
  1067. NTKERNELAPI
  1068. NTSTATUS
  1069. SeQueryAuthenticationIdToken(
  1070. IN PACCESS_TOKEN Token,
  1071. OUT PLUID AuthenticationId
  1072. );
  1073. // end_ntosp
  1074. NTKERNELAPI
  1075. NTSTATUS
  1076. SeQuerySessionIdToken(
  1077. IN PACCESS_TOKEN,
  1078. IN PULONG pSessionId
  1079. );
  1080. NTKERNELAPI
  1081. NTSTATUS
  1082. SeSetSessionIdToken(
  1083. IN PACCESS_TOKEN,
  1084. IN ULONG SessionId
  1085. );
  1086. // begin_ntosp
  1087. NTKERNELAPI
  1088. NTSTATUS
  1089. SeCreateClientSecurity (
  1090. IN PETHREAD ClientThread,
  1091. IN PSECURITY_QUALITY_OF_SERVICE ClientSecurityQos,
  1092. IN BOOLEAN RemoteSession,
  1093. OUT PSECURITY_CLIENT_CONTEXT ClientContext
  1094. );
  1095. // end_ntosp
  1096. NTKERNELAPI
  1097. VOID
  1098. SeImpersonateClient(
  1099. IN PSECURITY_CLIENT_CONTEXT ClientContext,
  1100. IN PETHREAD ServerThread OPTIONAL
  1101. );
  1102. // begin_ntosp
  1103. NTKERNELAPI
  1104. NTSTATUS
  1105. SeImpersonateClientEx(
  1106. IN PSECURITY_CLIENT_CONTEXT ClientContext,
  1107. IN PETHREAD ServerThread OPTIONAL
  1108. );
  1109. // end_ntosp
  1110. NTKERNELAPI
  1111. NTSTATUS
  1112. SeCreateClientSecurityFromSubjectContext (
  1113. IN PSECURITY_SUBJECT_CONTEXT SubjectContext,
  1114. IN PSECURITY_QUALITY_OF_SERVICE ClientSecurityQos,
  1115. IN BOOLEAN ServerIsRemote,
  1116. OUT PSECURITY_CLIENT_CONTEXT ClientContext
  1117. );
  1118. // end_ntifs
  1119. //
  1120. // Do not export the following routines to drivers.
  1121. // If you need to do so, create a new routine that
  1122. // does not take the AuxData parameter and export
  1123. // that.
  1124. //
  1125. // begin_ntosp
  1126. NTKERNELAPI
  1127. NTSTATUS
  1128. SeCreateAccessState(
  1129. IN PACCESS_STATE AccessState,
  1130. IN PAUX_ACCESS_DATA AuxData,
  1131. IN ACCESS_MASK DesiredAccess,
  1132. IN PGENERIC_MAPPING GenericMapping
  1133. );
  1134. NTKERNELAPI
  1135. VOID
  1136. SeDeleteAccessState(
  1137. IN PACCESS_STATE AccessState
  1138. );
  1139. // end_ntosp
  1140. NTSTATUS
  1141. SeCreateAccessStateEx(
  1142. IN PETHREAD Thread OPTIONAL,
  1143. IN PEPROCESS PRocess,
  1144. IN PACCESS_STATE AccessState,
  1145. IN PAUX_ACCESS_DATA AuxData,
  1146. IN ACCESS_MASK DesiredAccess,
  1147. IN PGENERIC_MAPPING GenericMapping OPTIONAL
  1148. );
  1149. NTSTATUS
  1150. SeUpdateClientSecurity(
  1151. IN PETHREAD ClientThread,
  1152. IN OUT PSECURITY_CLIENT_CONTEXT ClientContext,
  1153. OUT PBOOLEAN ChangesMade,
  1154. OUT PBOOLEAN NewToken
  1155. );
  1156. BOOLEAN
  1157. SeRmInitPhase1(
  1158. VOID
  1159. );
  1160. NTSTATUS
  1161. SeInitializeProcessAuditName (
  1162. IN PVOID FileObject,
  1163. IN BOOLEAN bIgnoreAuditPolicy,
  1164. OUT POBJECT_NAME_INFORMATION *pAuditName
  1165. );
  1166. NTSTATUS
  1167. SeLocateProcessImageName(
  1168. IN PEPROCESS Process,
  1169. IN PUNICODE_STRING *pImageFileName
  1170. );
  1171. VOID
  1172. SeAuditSystemTimeChange(
  1173. IN LARGE_INTEGER OldTime,
  1174. IN LARGE_INTEGER NewTime
  1175. );
  1176. // begin_ntifs begin_ntosp
  1177. NTKERNELAPI
  1178. NTSTATUS
  1179. SeQuerySecurityDescriptorInfo (
  1180. IN PSECURITY_INFORMATION SecurityInformation,
  1181. OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
  1182. IN OUT PULONG Length,
  1183. IN PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor
  1184. );
  1185. NTKERNELAPI
  1186. NTSTATUS
  1187. SeSetSecurityDescriptorInfo (
  1188. IN PVOID Object OPTIONAL,
  1189. IN PSECURITY_INFORMATION SecurityInformation,
  1190. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1191. IN OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  1192. IN POOL_TYPE PoolType,
  1193. IN PGENERIC_MAPPING GenericMapping
  1194. );
  1195. NTKERNELAPI
  1196. NTSTATUS
  1197. SeSetSecurityDescriptorInfoEx (
  1198. IN PVOID Object OPTIONAL,
  1199. IN PSECURITY_INFORMATION SecurityInformation,
  1200. IN PSECURITY_DESCRIPTOR ModificationDescriptor,
  1201. IN OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  1202. IN ULONG AutoInheritFlags,
  1203. IN POOL_TYPE PoolType,
  1204. IN PGENERIC_MAPPING GenericMapping
  1205. );
  1206. NTKERNELAPI
  1207. NTSTATUS
  1208. SeAppendPrivileges(
  1209. PACCESS_STATE AccessState,
  1210. PPRIVILEGE_SET Privileges
  1211. );
  1212. // end_ntifs end_ntosp
  1213. NTSTATUS
  1214. SeComputeQuotaInformationSize(
  1215. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1216. OUT PULONG Size
  1217. );
  1218. VOID
  1219. SePrivilegedServiceAuditAlarm (
  1220. IN PUNICODE_STRING ServiceName,
  1221. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  1222. IN PPRIVILEGE_SET Privileges,
  1223. IN BOOLEAN AccessGranted
  1224. );
  1225. NTKERNELAPI // ntddk ntifs ntosp
  1226. BOOLEAN // ntddk ntifs ntosp
  1227. SeSinglePrivilegeCheck( // ntddk ntifs ntosp
  1228. LUID PrivilegeValue, // ntddk ntifs ntosp
  1229. KPROCESSOR_MODE PreviousMode // ntddk ntifs ntosp
  1230. ); // ntddk ntifs ntosp
  1231. BOOLEAN
  1232. SeCheckAuditPrivilege (
  1233. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  1234. IN KPROCESSOR_MODE PreviousMode
  1235. );
  1236. NTSTATUS
  1237. SeAssignWorldSecurityDescriptor(
  1238. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1239. IN OUT PULONG Length,
  1240. IN PSECURITY_INFORMATION SecurityInformation
  1241. );
  1242. BOOLEAN
  1243. SeFastTraverseCheck(
  1244. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1245. IN PACCESS_STATE AccessState OPTIONAL,
  1246. IN ACCESS_MASK TraverseAccess,
  1247. IN KPROCESSOR_MODE AccessMode
  1248. );
  1249. // begin_ntifs
  1250. NTKERNELAPI
  1251. BOOLEAN
  1252. SeAuditingFileEvents(
  1253. IN BOOLEAN AccessGranted,
  1254. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  1255. );
  1256. NTKERNELAPI
  1257. BOOLEAN
  1258. SeAuditingFileEventsWithContext(
  1259. IN BOOLEAN AccessGranted,
  1260. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1261. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext OPTIONAL
  1262. );
  1263. NTKERNELAPI
  1264. BOOLEAN
  1265. SeAuditingHardLinkEvents(
  1266. IN BOOLEAN AccessGranted,
  1267. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  1268. );
  1269. NTKERNELAPI
  1270. BOOLEAN
  1271. SeAuditingHardLinkEventsWithContext(
  1272. IN BOOLEAN AccessGranted,
  1273. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1274. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext OPTIONAL
  1275. );
  1276. NTKERNELAPI
  1277. BOOLEAN
  1278. SeAuditingFileOrGlobalEvents(
  1279. IN BOOLEAN AccessGranted,
  1280. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  1281. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext
  1282. );
  1283. NTKERNELAPI
  1284. BOOLEAN
  1285. FASTCALL
  1286. SeDetailedAuditingWithToken(
  1287. IN PACCESS_TOKEN AccessToken OPTIONAL
  1288. );
  1289. // end_ntifs
  1290. VOID
  1291. SeAuditProcessCreation(
  1292. PEPROCESS Process
  1293. );
  1294. VOID
  1295. SeAuditProcessExit(
  1296. PEPROCESS Process
  1297. );
  1298. VOID // ntifs
  1299. SeAuditHardLinkCreation( // ntifs
  1300. IN PUNICODE_STRING FileName, // ntifs
  1301. IN PUNICODE_STRING LinkName, // ntifs
  1302. IN BOOLEAN bSuccess // ntifs
  1303. ); // ntifs
  1304. VOID
  1305. SeAuditLPCInvalidUse(
  1306. IN PUNICODE_STRING LpcCallName,
  1307. IN PUNICODE_STRING LpcServerPort
  1308. );
  1309. VOID
  1310. SeAuditHandleDuplication(
  1311. PVOID SourceHandle,
  1312. PVOID NewHandle,
  1313. PEPROCESS SourceProcess,
  1314. PEPROCESS TargetProcess
  1315. );
  1316. VOID
  1317. SeMaximumAuditMask(
  1318. IN PACL Sacl,
  1319. IN ACCESS_MASK GrantedAccess,
  1320. IN PACCESS_TOKEN Token,
  1321. OUT PACCESS_MASK pAuditMask
  1322. );
  1323. VOID
  1324. SeOperationAuditAlarm (
  1325. IN PUNICODE_STRING CapturedSubsystemName OPTIONAL,
  1326. IN PVOID HandleId,
  1327. IN PUNICODE_STRING ObjectTypeName,
  1328. IN ACCESS_MASK AuditMask,
  1329. IN PSID UserSid OPTIONAL
  1330. );
  1331. VOID
  1332. SeAddSaclToProcess(
  1333. IN PEPROCESS Process,
  1334. IN PACCESS_TOKEN Token,
  1335. IN PVOID Reserved
  1336. );
  1337. // begin_ntifs
  1338. VOID
  1339. SeSetAccessStateGenericMapping (
  1340. PACCESS_STATE AccessState,
  1341. PGENERIC_MAPPING GenericMapping
  1342. );
  1343. // end_ntifs
  1344. // begin_ntifs
  1345. NTKERNELAPI
  1346. NTSTATUS
  1347. SeRegisterLogonSessionTerminatedRoutine(
  1348. IN PSE_LOGON_SESSION_TERMINATED_ROUTINE CallbackRoutine
  1349. );
  1350. NTKERNELAPI
  1351. NTSTATUS
  1352. SeUnregisterLogonSessionTerminatedRoutine(
  1353. IN PSE_LOGON_SESSION_TERMINATED_ROUTINE CallbackRoutine
  1354. );
  1355. NTKERNELAPI
  1356. NTSTATUS
  1357. SeMarkLogonSessionForTerminationNotification(
  1358. IN PLUID LogonId
  1359. );
  1360. // begin_ntosp
  1361. NTKERNELAPI
  1362. NTSTATUS
  1363. SeQueryInformationToken (
  1364. IN PACCESS_TOKEN Token,
  1365. IN TOKEN_INFORMATION_CLASS TokenInformationClass,
  1366. OUT PVOID *TokenInformation
  1367. );
  1368. // end_ntifs end_ntosp
  1369. NTSTATUS
  1370. SeIsChildToken(
  1371. IN HANDLE Token,
  1372. OUT PBOOLEAN IsChild
  1373. );
  1374. NTSTATUS
  1375. SeIsChildTokenByPointer(
  1376. IN PACCESS_TOKEN Token,
  1377. OUT PBOOLEAN IsChild
  1378. );
  1379. NTSTATUS
  1380. SeFastFilterToken(
  1381. IN PACCESS_TOKEN ExistingToken,
  1382. IN KPROCESSOR_MODE RequestorMode,
  1383. IN ULONG Flags,
  1384. IN ULONG GroupCount,
  1385. IN PSID_AND_ATTRIBUTES GroupsToDisable OPTIONAL,
  1386. IN ULONG PrivilegeCount,
  1387. IN PLUID_AND_ATTRIBUTES PrivilegesToDelete OPTIONAL,
  1388. IN ULONG SidCount,
  1389. IN PSID_AND_ATTRIBUTES RestrictedSids OPTIONAL,
  1390. IN ULONG SidLength,
  1391. OUT PACCESS_TOKEN * FilteredToken
  1392. );
  1393. ////////////////////////////////////////////////////////////////////////
  1394. // //
  1395. // Global, READ ONLY, Security variables //
  1396. // //
  1397. ////////////////////////////////////////////////////////////////////////
  1398. // **************************************************************
  1399. //
  1400. // C A V E A T P R O G R A M M E R
  1401. //
  1402. //
  1403. // If you wish to include this file in an NT driver and use SeExports structure
  1404. // defined above, you need to call:
  1405. //
  1406. //
  1407. // SeEnableAccessToExports()
  1408. //
  1409. // exactly once during initialization.
  1410. //
  1411. // C A V E A T P R O G R A M M E R
  1412. //
  1413. // **************************************************************
  1414. #if 0
  1415. #define SeEnableAccessToExports() SeExports = *(PSE_EXPORTS *)SeExports;
  1416. extern PSE_EXPORTS SeExports;
  1417. #else
  1418. // begin_ntifs begin_ntosp
  1419. //
  1420. // Grants access to SeExports structure
  1421. //
  1422. extern NTKERNELAPI PSE_EXPORTS SeExports;
  1423. // end_ntifs end_ntosp
  1424. #endif
  1425. //
  1426. // Value used to represent the authentication ID of system processes
  1427. //
  1428. extern const LUID SeSystemAuthenticationId;
  1429. extern const LUID SeAnonymousAuthenticationId;
  1430. extern const TOKEN_SOURCE SeSystemTokenSource;
  1431. //
  1432. // Universal well known SIDs
  1433. //
  1434. extern PSID SeNullSid;
  1435. extern PSID SeWorldSid;
  1436. extern PSID SeLocalSid;
  1437. extern PSID SeCreatorOwnerSid;
  1438. extern PSID SeCreatorGroupSid;
  1439. extern PSID SeCreatorOwnerServerSid;
  1440. extern PSID SeCreatorGroupServerSid;
  1441. extern PSID SePrincipalSelfSid;
  1442. //
  1443. // Sids defined by NT
  1444. //
  1445. extern PSID SeNtAuthoritySid;
  1446. extern PSID SeDialupSid;
  1447. extern PSID SeNetworkSid;
  1448. extern PSID SeBatchSid;
  1449. extern PSID SeInteractiveSid;
  1450. extern PSID SeLocalSystemSid;
  1451. extern PSID SeAuthenticatedUsersSid;
  1452. extern PSID SeAliasAdminsSid;
  1453. extern PSID SeRestrictedSid;
  1454. extern PSID SeAnonymousLogonSid;
  1455. extern PSID SeAliasUsersSid;
  1456. extern PSID SeAliasGuestsSid;
  1457. extern PSID SeAliasPowerUsersSid;
  1458. extern PSID SeAliasAccountOpsSid;
  1459. extern PSID SeAliasSystemOpsSid;
  1460. extern PSID SeAliasPrintOpsSid;
  1461. extern PSID SeAliasBackupOpsSid;
  1462. //
  1463. // Well known tokens
  1464. //
  1465. extern PACCESS_TOKEN SeAnonymousLogonToken;
  1466. extern PACCESS_TOKEN SeAnonymousLogonTokenNoEveryone;
  1467. //
  1468. // System default DACLs & Security Descriptors
  1469. //
  1470. extern PSECURITY_DESCRIPTOR SePublicDefaultSd;
  1471. extern PSECURITY_DESCRIPTOR SePublicDefaultUnrestrictedSd;
  1472. extern PSECURITY_DESCRIPTOR SePublicOpenSd;
  1473. extern PSECURITY_DESCRIPTOR SePublicOpenUnrestrictedSd;
  1474. extern PSECURITY_DESCRIPTOR SeSystemDefaultSd;
  1475. extern PSECURITY_DESCRIPTOR SeLocalServicePublicSd;
  1476. extern PACL SePublicDefaultDacl;
  1477. extern PACL SePublicDefaultUnrestrictedDacl;
  1478. extern PACL SePublicOpenDacl;
  1479. extern PACL SePublicOpenUnrestrictedDacl;
  1480. extern PACL SeSystemDefaultDacl;
  1481. extern PACL SeUnrestrictedDacl;
  1482. extern PACL SeLocalServicePublicDacl;
  1483. //
  1484. // Well known privilege values
  1485. //
  1486. extern LUID SeCreateTokenPrivilege;
  1487. extern LUID SeAssignPrimaryTokenPrivilege;
  1488. extern LUID SeLockMemoryPrivilege;
  1489. extern LUID SeIncreaseQuotaPrivilege;
  1490. extern LUID SeUnsolicitedInputPrivilege;
  1491. extern LUID SeTcbPrivilege;
  1492. extern LUID SeSecurityPrivilege;
  1493. extern LUID SeTakeOwnershipPrivilege;
  1494. extern LUID SeLoadDriverPrivilege;
  1495. extern LUID SeCreatePagefilePrivilege;
  1496. extern LUID SeIncreaseBasePriorityPrivilege;
  1497. extern LUID SeSystemProfilePrivilege;
  1498. extern LUID SeSystemtimePrivilege;
  1499. extern LUID SeProfileSingleProcessPrivilege;
  1500. extern LUID SeCreatePermanentPrivilege;
  1501. extern LUID SeBackupPrivilege;
  1502. extern LUID SeRestorePrivilege;
  1503. extern LUID SeShutdownPrivilege;
  1504. extern LUID SeDebugPrivilege;
  1505. extern LUID SeAuditPrivilege;
  1506. extern LUID SeSystemEnvironmentPrivilege;
  1507. extern LUID SeChangeNotifyPrivilege;
  1508. extern LUID SeRemoteShutdownPrivilege;
  1509. extern LUID SeUndockPrivilege;
  1510. extern LUID SeSyncAgentPrivilege;
  1511. extern LUID SeEnableDelegationPrivilege;
  1512. extern LUID SeManageVolumePrivilege;
  1513. extern LUID SeImpersonatePrivilege;
  1514. extern LUID SeCreateGlobalPrivilege;
  1515. //
  1516. // Auditing information array
  1517. //
  1518. extern SE_AUDITING_STATE SeAuditingState[];
  1519. extern const UNICODE_STRING SeSubsystemName;
  1520. #endif // _SE_