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.

239 lines
6.6 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. // //
  30. // Reference Monitor Private Macros //
  31. // //
  32. ///////////////////////////////////////////////////////////////////////////////
  33. //
  34. // acquire exclusive access to a token
  35. //
  36. #define SepRmAcquireDbReadLock() KeEnterCriticalRegion(); \
  37. ExAcquireResourceSharedLite(&SepRmDbLock, TRUE)
  38. #define SepRmAcquireDbWriteLock() KeEnterCriticalRegion(); \
  39. ExAcquireResourceExclusiveLite(&SepRmDbLock, TRUE)
  40. #define SepRmReleaseDbReadLock() ExReleaseResourceLite(&SepRmDbLock); \
  41. KeLeaveCriticalRegion()
  42. #define SepRmReleaseDbWriteLock() ExReleaseResourceLite(&SepRmDbLock); \
  43. KeLeaveCriticalRegion()
  44. ///////////////////////////////////////////////////////////////////////////////
  45. // //
  46. // Reference Monitor Private Data Types //
  47. // //
  48. ///////////////////////////////////////////////////////////////////////////////
  49. #define SEP_RM_LSA_SHARED_MEMORY_SIZE ((ULONG) PAGE_SIZE)
  50. //
  51. // Reference Monitor Private Global State Data Structure
  52. //
  53. typedef struct _SEP_RM_STATE {
  54. HANDLE LsaInitEventHandle;
  55. HANDLE LsaCommandPortHandle;
  56. HANDLE SepRmThreadHandle;
  57. HANDLE RmCommandPortHandle;
  58. HANDLE RmCommandServerPortHandle;
  59. ULONG AuditingEnabled;
  60. LSA_OPERATIONAL_MODE OperationalMode;
  61. HANDLE LsaCommandPortSectionHandle;
  62. LARGE_INTEGER LsaCommandPortSectionSize;
  63. PVOID LsaViewPortMemory;
  64. PVOID RmViewPortMemory;
  65. LONG LsaCommandPortMemoryDelta;
  66. // BOOLEAN LsaCommandPortResourceInitialized;
  67. BOOLEAN LsaCommandPortActive;
  68. // ERESOURCE LsaCommandPortResource;
  69. } SEP_RM_STATE, *PSEP_RM_STATE;
  70. //
  71. // Reference Monitor Command Port Connection Info
  72. //
  73. typedef struct _SEP_RM_CONNECT_INFO {
  74. ULONG ConnectInfo;
  75. } SEP_RM_CONNECT_INFO;
  76. typedef struct SEP_RM_CONNECT_INFO *PSEP_RM_CONNECT_INFO;
  77. //
  78. // Reference Monitor Command Table Entry Format
  79. //
  80. #define SEP_RM_COMMAND_MAX 4
  81. typedef VOID (*SEP_RM_COMMAND_WORKER)( PRM_COMMAND_MESSAGE, PRM_REPLY_MESSAGE );
  82. typedef struct _SEP_LOGON_SESSION_TOKEN {
  83. LIST_ENTRY ListEntry;
  84. PTOKEN Token;
  85. } SEP_LOGON_SESSION_TOKEN, *PSEP_LOGON_SESSION_TOKEN;
  86. //
  87. // Each logon session active in the system has a corresponding record of
  88. // the following type...
  89. //
  90. typedef struct _SEP_LOGON_SESSION_REFERENCES {
  91. struct _SEP_LOGON_SESSION_REFERENCES *Next;
  92. LUID LogonId;
  93. ULONG ReferenceCount;
  94. ULONG Flags;
  95. PDEVICE_MAP pDeviceMap;
  96. #if DBG || TOKEN_LEAK_MONITOR
  97. LIST_ENTRY TokenList;
  98. #endif
  99. } SEP_LOGON_SESSION_REFERENCES, *PSEP_LOGON_SESSION_REFERENCES;
  100. #define SEP_TERMINATION_NOTIFY 0x1
  101. //
  102. // File systems interested in being notified when a logon session is being
  103. // terminated register a callback routine. The following data structure
  104. // describes the callback routines.
  105. //
  106. // The global list of callback routines is pointed to by SeFileSystemNotifyRoutines.
  107. // This list is protected by the RM database lock.
  108. //
  109. typedef struct _SEP_LOGON_SESSION_TERMINATED_NOTIFICATION {
  110. struct _SEP_LOGON_SESSION_TERMINATED_NOTIFICATION *Next;
  111. PSE_LOGON_SESSION_TERMINATED_ROUTINE CallbackRoutine;
  112. } SEP_LOGON_SESSION_TERMINATED_NOTIFICATION, *PSEP_LOGON_SESSION_TERMINATED_NOTIFICATION;
  113. extern SEP_LOGON_SESSION_TERMINATED_NOTIFICATION
  114. SeFileSystemNotifyRoutinesHead;
  115. ///////////////////////////////////////////////////////////////////////////////
  116. // //
  117. // Reference Monitor Private Function Prototypes //
  118. // //
  119. ///////////////////////////////////////////////////////////////////////////////
  120. BOOLEAN
  121. SepRmDbInitialization(
  122. VOID
  123. );
  124. VOID
  125. SepRmCommandServerThread(
  126. IN PVOID StartContext
  127. );
  128. BOOLEAN SepRmCommandServerThreadInit(
  129. );
  130. VOID
  131. SepRmComponentTestCommandWrkr(
  132. IN PRM_COMMAND_MESSAGE CommandMessage,
  133. OUT PRM_REPLY_MESSAGE ReplyMessage
  134. );
  135. VOID
  136. SepRmSetAuditEventWrkr(
  137. IN PRM_COMMAND_MESSAGE CommandMessage,
  138. OUT PRM_REPLY_MESSAGE ReplyMessage
  139. );
  140. VOID
  141. SepRmSendCommandToLsaWrkr(
  142. IN PRM_COMMAND_MESSAGE CommandMessage,
  143. OUT PRM_REPLY_MESSAGE ReplyMessage
  144. );
  145. VOID
  146. SepRmCreateLogonSessionWrkr(
  147. IN PRM_COMMAND_MESSAGE CommandMessage,
  148. OUT PRM_REPLY_MESSAGE ReplyMessage
  149. );
  150. VOID
  151. SepRmDeleteLogonSessionWrkr(
  152. IN PRM_COMMAND_MESSAGE CommandMessage,
  153. OUT PRM_REPLY_MESSAGE ReplyMessage
  154. ) ;
  155. NTSTATUS
  156. SepCreateLogonSessionTrack(
  157. IN PLUID LogonId
  158. );
  159. NTSTATUS
  160. SepDeleteLogonSessionTrack(
  161. IN PLUID LogonId
  162. );
  163. ///////////////////////////////////////////////////////////////////////////////
  164. // //
  165. // Reference Monitor Private Variables Declarations //
  166. // These variables are defined in rmvars.c //
  167. // //
  168. ///////////////////////////////////////////////////////////////////////////////
  169. extern PEPROCESS SepRmLsaCallProcess;
  170. extern SEP_RM_STATE SepRmState;
  171. extern ERESOURCE SepRmDbLock;
  172. extern PSEP_LOGON_SESSION_REFERENCES *SepLogonSessions;
  173. #endif // _RMP_H_