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.

234 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. rmp.h
  5. Abstract:
  6. Security Reference Monitor Private Data Types, Functions and Defines
  7. Author:
  8. Scott Birrell (ScottBi) March 12, 1991
  9. Environment:
  10. Revision History:
  11. --*/
  12. #ifndef _RMP_H_
  13. #define _RMP_H_
  14. #include <nt.h>
  15. #include <ntlsa.h>
  16. #include "sep.h"
  17. ///////////////////////////////////////////////////////////////////////////////
  18. // //
  19. // Reference Monitor Private defines //
  20. // //
  21. ///////////////////////////////////////////////////////////////////////////////
  22. //
  23. // Used to define the bounds of the array used to track logon session
  24. // reference counts.
  25. //
  26. #define SEP_LOGON_TRACK_INDEX_MASK (0x0000000FL)
  27. #define SEP_LOGON_TRACK_ARRAY_SIZE (0x00000010L)
  28. //
  29. // Used to define the bounds of the locks array used to reference the logon
  30. // sessions. We use a hardcoded index of ZERO for when LogonId is not
  31. // available.
  32. // The number of locks was chosen to be 4 based on performance tests on
  33. // uniproc and 8-proc machines.
  34. //
  35. #define SEP_LOGON_TRACK_LOCK_INDEX_MASK (0x00000003L)
  36. #define SEP_LOGON_TRACK_LOCK_ARRAY_SIZE (0x00000004L)
  37. #define SEP_HARDCODED_LOCK_INDEX (0)
  38. ///////////////////////////////////////////////////////////////////////////////
  39. // //
  40. // Reference Monitor Private Macros //
  41. // //
  42. ///////////////////////////////////////////////////////////////////////////////
  43. //
  44. // acquire exclusive access to a token
  45. //
  46. #define SepRmAcquireDbReadLock(i) KeEnterCriticalRegion(); \
  47. ExAcquireResourceSharedLite(&(SepRmDbLock[(i) & SEP_LOGON_TRACK_LOCK_INDEX_MASK]), TRUE)
  48. #define SepRmAcquireDbWriteLock(i) KeEnterCriticalRegion(); \
  49. ExAcquireResourceExclusiveLite(&(SepRmDbLock[(i) & SEP_LOGON_TRACK_LOCK_INDEX_MASK]), TRUE)
  50. #define SepRmReleaseDbReadLock(i) ExReleaseResourceLite(&(SepRmDbLock[(i) & SEP_LOGON_TRACK_LOCK_INDEX_MASK])); \
  51. KeLeaveCriticalRegion()
  52. #define SepRmReleaseDbWriteLock(i) ExReleaseResourceLite(&(SepRmDbLock[(i) & SEP_LOGON_TRACK_LOCK_INDEX_MASK])); \
  53. KeLeaveCriticalRegion()
  54. ///////////////////////////////////////////////////////////////////////////////
  55. // //
  56. // Reference Monitor Private Data Types //
  57. // //
  58. ///////////////////////////////////////////////////////////////////////////////
  59. #define SEP_RM_LSA_SHARED_MEMORY_SIZE ((ULONG) PAGE_SIZE)
  60. //
  61. // Reference Monitor Private Global State Data Structure
  62. //
  63. typedef struct _SEP_RM_STATE {
  64. HANDLE LsaInitEventHandle;
  65. HANDLE LsaCommandPortHandle;
  66. HANDLE SepRmThreadHandle;
  67. HANDLE RmCommandPortHandle;
  68. HANDLE RmCommandServerPortHandle;
  69. ULONG AuditingEnabled;
  70. LSA_OPERATIONAL_MODE OperationalMode;
  71. HANDLE LsaCommandPortSectionHandle;
  72. LARGE_INTEGER LsaCommandPortSectionSize;
  73. PVOID LsaViewPortMemory;
  74. PVOID RmViewPortMemory;
  75. LONG LsaCommandPortMemoryDelta;
  76. // BOOLEAN LsaCommandPortResourceInitialized;
  77. BOOLEAN LsaCommandPortActive;
  78. // ERESOURCE LsaCommandPortResource;
  79. } SEP_RM_STATE, *PSEP_RM_STATE;
  80. //
  81. // Reference Monitor Command Port Connection Info
  82. //
  83. typedef struct _SEP_RM_CONNECT_INFO {
  84. ULONG ConnectInfo;
  85. } SEP_RM_CONNECT_INFO;
  86. typedef struct SEP_RM_CONNECT_INFO *PSEP_RM_CONNECT_INFO;
  87. //
  88. // Reference Monitor Command Table Entry Format
  89. //
  90. #define SEP_RM_COMMAND_MAX 4
  91. typedef VOID (*SEP_RM_COMMAND_WORKER)( PRM_COMMAND_MESSAGE, PRM_REPLY_MESSAGE );
  92. typedef struct _SEP_LOGON_SESSION_TOKEN {
  93. LIST_ENTRY ListEntry;
  94. PTOKEN Token;
  95. } SEP_LOGON_SESSION_TOKEN, *PSEP_LOGON_SESSION_TOKEN;
  96. #define SEP_TERMINATION_NOTIFY 0x1
  97. //
  98. // File systems interested in being notified when a logon session is being
  99. // terminated register a callback routine. The following data structure
  100. // describes the callback routines.
  101. //
  102. // The global list of callback routines is pointed to by SeFileSystemNotifyRoutines.
  103. // This list is protected by the RM database lock.
  104. //
  105. typedef struct _SEP_LOGON_SESSION_TERMINATED_NOTIFICATION {
  106. struct _SEP_LOGON_SESSION_TERMINATED_NOTIFICATION *Next;
  107. PSE_LOGON_SESSION_TERMINATED_ROUTINE CallbackRoutine;
  108. } SEP_LOGON_SESSION_TERMINATED_NOTIFICATION, *PSEP_LOGON_SESSION_TERMINATED_NOTIFICATION;
  109. extern SEP_LOGON_SESSION_TERMINATED_NOTIFICATION
  110. SeFileSystemNotifyRoutinesHead;
  111. ///////////////////////////////////////////////////////////////////////////////
  112. // //
  113. // Reference Monitor Private Function Prototypes //
  114. // //
  115. ///////////////////////////////////////////////////////////////////////////////
  116. BOOLEAN
  117. SepRmDbInitialization(
  118. VOID
  119. );
  120. VOID
  121. SepRmCommandServerThread(
  122. IN PVOID StartContext
  123. );
  124. BOOLEAN SepRmCommandServerThreadInit(
  125. );
  126. VOID
  127. SepRmComponentTestCommandWrkr(
  128. IN PRM_COMMAND_MESSAGE CommandMessage,
  129. OUT PRM_REPLY_MESSAGE ReplyMessage
  130. );
  131. VOID
  132. SepRmSetAuditEventWrkr(
  133. IN PRM_COMMAND_MESSAGE CommandMessage,
  134. OUT PRM_REPLY_MESSAGE ReplyMessage
  135. );
  136. VOID
  137. SepRmSendCommandToLsaWrkr(
  138. IN PRM_COMMAND_MESSAGE CommandMessage,
  139. OUT PRM_REPLY_MESSAGE ReplyMessage
  140. );
  141. VOID
  142. SepRmCreateLogonSessionWrkr(
  143. IN PRM_COMMAND_MESSAGE CommandMessage,
  144. OUT PRM_REPLY_MESSAGE ReplyMessage
  145. );
  146. VOID
  147. SepRmDeleteLogonSessionWrkr(
  148. IN PRM_COMMAND_MESSAGE CommandMessage,
  149. OUT PRM_REPLY_MESSAGE ReplyMessage
  150. ) ;
  151. NTSTATUS
  152. SepCreateLogonSessionTrack(
  153. IN PLUID LogonId
  154. );
  155. NTSTATUS
  156. SepDeleteLogonSessionTrack(
  157. IN PLUID LogonId
  158. );
  159. ///////////////////////////////////////////////////////////////////////////////
  160. // //
  161. // Reference Monitor Private Variables Declarations //
  162. // These variables are defined in rmvars.c //
  163. // //
  164. ///////////////////////////////////////////////////////////////////////////////
  165. extern PEPROCESS SepRmLsaCallProcess;
  166. extern SEP_RM_STATE SepRmState;
  167. extern ERESOURCE SepRmDbLock[];
  168. extern PSEP_LOGON_SESSION_REFERENCES *SepLogonSessions;
  169. #endif // _RMP_H_