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.

131 lines
2.6 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. MFC_CATCH_DWSTATUS
  63. if ( ERROR_SUCCESS == dwStatus ) {
  64. dwStatus = m_pProviders->Open( rstrMachineName );
  65. }
  66. if ( ERROR_SUCCESS == dwStatus ) {
  67. dwStatus = CSmLogService::Open ( rstrMachineName );
  68. }
  69. return dwStatus;
  70. }
  71. //
  72. // Close Function
  73. // closes registry handles and frees allocated memory
  74. //
  75. DWORD
  76. CSmTraceLogService::Close ()
  77. {
  78. // Close and delete the list of trace providers
  79. if ( NULL != m_pProviders ) {
  80. m_pProviders->Close();
  81. delete m_pProviders;
  82. m_pProviders = NULL;
  83. }
  84. return ( CSmLogService::Close() );
  85. }
  86. //
  87. // SyncWithRegistry()
  88. // reads the current values for all queries from the registry
  89. // and reloads the internal values to match.
  90. //
  91. // Updates the trace provider list.
  92. //
  93. DWORD
  94. CSmTraceLogService::SyncWithRegistry()
  95. {
  96. DWORD dwStatus = ERROR_SUCCESS;
  97. dwStatus = CSmLogService::SyncWithRegistry();
  98. return dwStatus;
  99. }
  100. CSmTraceProviders*
  101. CSmTraceLogService::GetProviders()
  102. {
  103. return m_pProviders;
  104. }