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.

221 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. DATA.C
  5. Abstract:
  6. This file contains all the global data elements of the eventlog service.
  7. Author:
  8. Rajen Shah (rajens) 10-Jul-1991
  9. [Environment:]
  10. User Mode - Win32, except for NTSTATUS returned by some functions.
  11. Revision History:
  12. 10-Jul-1991 RajenS
  13. created
  14. --*/
  15. //
  16. // INCLUDES
  17. //
  18. #include <eventp.h>
  19. #include <elfcfg.h>
  20. #if DBG
  21. //
  22. // Always write errors to the debugger on checked builds
  23. //
  24. DWORD ElfDebugLevel = DEBUG_ERROR;
  25. #endif // DBG
  26. //
  27. // Handles used for the LPC port.
  28. //
  29. HANDLE ElfConnectionPortHandle;
  30. HANDLE ElfCommunicationPortHandle;
  31. // The heads of various linked lists
  32. //
  33. LIST_ENTRY LogFilesHead; // Log files
  34. RTL_CRITICAL_SECTION LogFileCritSec; // Accessing log files
  35. LIST_ENTRY LogModuleHead; // Modules registered for logging
  36. RTL_CRITICAL_SECTION LogModuleCritSec; // Accessing log files
  37. LIST_ENTRY LogHandleListHead; // Context-handles for log handles
  38. RTL_CRITICAL_SECTION LogHandleCritSec; // Accessing log handles
  39. LIST_ENTRY QueuedEventListHead; // Deferred events to write
  40. RTL_CRITICAL_SECTION QueuedEventCritSec; // Accessing the deferred events
  41. LIST_ENTRY QueuedMessageListHead; // Deferred messagebox
  42. RTL_CRITICAL_SECTION QueuedMessageCritSec; // Accessing the deferred mb's
  43. //
  44. // Service-related global data
  45. //
  46. SERVICE_STATUS_HANDLE ElfServiceStatusHandle;
  47. //
  48. // The following resource is used to serialize access to the resources
  49. // of the Eventlog service at the highest level. It is used to make sure
  50. // that the threads that write/read/clear the log file(s) do not step over
  51. // the threads that monitor the registry and deal with service control
  52. // operations.
  53. //
  54. // The threads that operate on the log file(s) have Shared access to the
  55. // resource, since they are further serialized on the file that they are
  56. // working on.
  57. //
  58. // The threads that will modify the internal data structures, or the state
  59. // of the service, need Exclusive access to the resource so that we can
  60. // control access to the data structures and log files.
  61. //
  62. RTL_RESOURCE GlobalElfResource;
  63. //
  64. // This is used by the Backup API to signify which 4K block of the log it's
  65. // currently reading. This is used to prevent a writer from overwriting this
  66. // block while it is reading it. The event is used to let a writer block if
  67. // it was going to overwrite the current backup block, and get pulsed when
  68. // the backup thread moves to the next block.
  69. PVOID ElfBackupPointer;
  70. HANDLE ElfBackupEvent;
  71. //
  72. // Handle for the LPC thread
  73. //
  74. HANDLE LPCThreadHandle;
  75. //
  76. // Handle for the MessageBox thread
  77. //
  78. HANDLE MBThreadHandle;
  79. //
  80. // Handle and ID for the registry monitor thread
  81. //
  82. HANDLE RegistryThreadHandle;
  83. DWORD RegistryThreadId;
  84. //
  85. // Bitmask of things that have been allocated and/or started by the
  86. // service. When the service terminates, this is what needs to be
  87. // cleaned.
  88. //
  89. ULONG EventFlags; // Keep track of what is allocated
  90. //
  91. // Record used to indicate the end of the event records in the file.
  92. //
  93. ELF_EOF_RECORD EOFRecord = { ELFEOFRECORDSIZE,
  94. 0x11111111,
  95. 0x22222222,
  96. 0x33333333,
  97. 0x44444444,
  98. FILEHEADERBUFSIZE,
  99. FILEHEADERBUFSIZE,
  100. 1,
  101. 1,
  102. ELFEOFRECORDSIZE
  103. };
  104. //
  105. // Default module to use if no match is found, APPLICATION
  106. //
  107. PLOGMODULE ElfDefaultLogModule;
  108. //
  109. // Module for the eventlog service itself
  110. //
  111. PLOGMODULE ElfModule;
  112. //
  113. // Module for security
  114. //
  115. PLOGMODULE ElfSecModule;
  116. //
  117. // Handle (key) to the event log node in the registry.
  118. // This is set up by the service main function.
  119. //
  120. HANDLE hEventLogNode;
  121. //
  122. // Handle (key) to the ComputerName node in the registry.
  123. // This is set up by the service main function.
  124. //
  125. HANDLE hComputerNameNode;
  126. //
  127. // Used to create a unigue module name for backup logs
  128. //
  129. DWORD BackupModuleNumber;
  130. //
  131. // NT well-known SIDs
  132. //
  133. PSVCS_GLOBAL_DATA ElfGlobalData;
  134. //
  135. // Global anonymous logon sid - used in log ACL's. The only SID allocated
  136. // specifically by the eventlog service, all others are passed in from
  137. // the service controller in ElfGlobalData.
  138. //
  139. PSID AnonymousLogonSid;
  140. //
  141. // Shutdown Flag
  142. //
  143. BOOL EventlogShutdown;
  144. HANDLE ElfGlobalSvcRefHandle;
  145. //
  146. // This is the string used as the title of the log full message box.
  147. // GlobalMessageBoxTitle will either point to the default string or
  148. // to the string allocated in the format Message function.
  149. //
  150. LPWSTR GlobalMessageBoxTitle;
  151. //SS:start of changes for clustering
  152. BOOL gbClustering=FALSE; //the cluster service has registered for replication of events
  153. PPACKEDEVENTINFO gpClPackedEventInfo=NULL; //pointer to preallocated memory for event propagation
  154. RTL_CRITICAL_SECTION gClPropCritSec; // for using the global glClPackedEventInfo structure
  155. HMODULE ghClusDll=NULL;
  156. PROPAGATEEVENTSPROC gpfnPropagateEvents=NULL;
  157. BINDTOCLUSTERPROC gpfnBindToCluster=NULL;
  158. UNBINDFROMCLUSTERPROC gpfnUnbindFromCluster=NULL;
  159. HANDLE ghCluster=NULL;
  160. //SS: end of changes for clustering