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.

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