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.

139 lines
3.0 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. smtracsv.cpp
  5. Abstract:
  6. This object is used to represent the trace log query components of the
  7. sysmon log service
  8. --*/
  9. #include "Stdafx.h"
  10. #include "smtprov.h"
  11. #include "smtraceq.h"
  12. #include "smtracsv.h"
  13. USE_HANDLE_MACROS("SMLOGCFG(smalrtq.cpp)");
  14. //
  15. // Constructor
  16. CSmTraceLogService::CSmTraceLogService()
  17. : m_pProviders ( NULL )
  18. {
  19. CString strTemp;
  20. ResourceStateManager rsm;
  21. // String allocation errors are thrown, to be
  22. // captured by rootnode alloc exception handler
  23. strTemp.LoadString ( IDS_SERVICE_NAME_TRACE );
  24. SetBaseName ( strTemp );
  25. strTemp.LoadString ( IDS_TRACE_NODE_DESCRIPTION );
  26. SetDescription( strTemp );
  27. }
  28. //
  29. // Destructor
  30. CSmTraceLogService::~CSmTraceLogService()
  31. {
  32. // make sure Close method was called first!
  33. ASSERT ( NULL == m_pProviders );
  34. return;
  35. }
  36. PSLQUERY
  37. CSmTraceLogService::CreateQuery ( const CString& rstrName )
  38. {
  39. return ( CSmLogService::CreateTypedQuery( rstrName, SLQ_TRACE_LOG ) );
  40. }
  41. DWORD
  42. CSmTraceLogService::DeleteQuery ( PSLQUERY pQuery )
  43. {
  44. ASSERT ( SLQ_TRACE_LOG == pQuery->GetLogType ( ) );
  45. return ( CSmLogService::DeleteQuery ( pQuery ) );
  46. }
  47. DWORD
  48. CSmTraceLogService::LoadQueries ( void )
  49. {
  50. return ( CSmLogService::LoadQueries( SLQ_TRACE_LOG ) );
  51. }
  52. //
  53. // Open function. Opens all existing log query entries.
  54. //
  55. DWORD
  56. CSmTraceLogService::Open ( const CString& rstrMachineName )
  57. {
  58. DWORD dwStatus = ERROR_SUCCESS;
  59. // Initialize trace provider list.
  60. MFC_TRY
  61. m_pProviders = new CSmTraceProviders ( this );
  62. dwStatus = m_pProviders->Open( rstrMachineName );
  63. if ( ERROR_SUCCESS == dwStatus ) {
  64. dwStatus = CSmLogService::Open ( rstrMachineName );
  65. if ( ERROR_SUCCESS != dwStatus ) {
  66. m_pProviders->Close();
  67. }
  68. }
  69. MFC_CATCH_DWSTATUS
  70. if ( ERROR_SUCCESS != dwStatus ) {
  71. if ( NULL != m_pProviders ) {
  72. delete m_pProviders;
  73. m_pProviders = NULL;
  74. }
  75. }
  76. return dwStatus;
  77. }
  78. //
  79. // Close Function
  80. // closes registry handles and frees allocated memory
  81. //
  82. DWORD
  83. CSmTraceLogService::Close ()
  84. {
  85. // Close and delete the list of trace providers
  86. if ( NULL != m_pProviders ) {
  87. m_pProviders->Close();
  88. delete m_pProviders;
  89. m_pProviders = NULL;
  90. }
  91. return ( CSmLogService::Close() );
  92. }
  93. //
  94. // SyncWithRegistry()
  95. // reads the current values for all queries from the registry
  96. // and reloads the internal values to match.
  97. //
  98. // Updates the trace provider list.
  99. //
  100. DWORD
  101. CSmTraceLogService::SyncWithRegistry( PSLQUERY* ppActiveQuery )
  102. {
  103. DWORD dwStatus = ERROR_SUCCESS;
  104. dwStatus = CSmLogService::SyncWithRegistry ( ppActiveQuery );
  105. return dwStatus;
  106. }
  107. CSmTraceProviders*
  108. CSmTraceLogService::GetProviders()
  109. {
  110. return m_pProviders;
  111. }