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.

163 lines
5.5 KiB

  1. /*****************************************************************************
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. ETCommon.h
  5. Abstract:
  6. This module contains all necessary defines & MACROs required by
  7. this project.
  8. Author:
  9. Akhil Gokhale 03-Oct.-2000
  10. Revision History:
  11. ******************************************************************************/
  12. #ifndef _ETCOMMON_H
  13. #define _ETCOMMON_H
  14. //
  15. // general purpose macros
  16. //
  17. // Following macro will help for debuggig the application.
  18. // To enable debugging define DEBUG.
  19. //#define DEBUG_EVT
  20. //#define DEBUG
  21. #ifdef DEBUG_EVT
  22. #define DEBUG_INFO wprintf(L"File Name: %S, Line No: %d\n",__FILE__,__LINE__)
  23. #else
  24. #define DEBUG_INFO 1
  25. #endif
  26. #define SCHEDULER_NOT_RUNNING_ERROR_CODE 0x80041315
  27. #define RPC_SERVER_NOT_AVAILABLE 0x800706B5
  28. #define ERROR_INVALID_RU 0x80041310
  29. #define ERROR_RUN_AS_USER 0x8004130F
  30. #define ERROR_UNABLE_SET_RU 0x80070005
  31. // Customized Error codes comming from Provider.
  32. #define SUCCESS_OPERATION 0
  33. #define ERROR_TRIGNAME_ALREADY_EXIST MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 1 )
  34. #define ERROR_TRIGGER_NOT_DELETED MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 2 )
  35. #define ERROR_TRIGGER_NOT_FOUND MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 3 )
  36. #define ERROR_INVALID_USER MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 4 )
  37. #define WARNING_INVALID_USER MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 5 )
  38. #define ERROR_TRIGGER_ID_EXCEED MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 6 )
  39. #define ERROR_TRIGGER_CORRUPTED MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 7 )
  40. #define TRIGGER_CORRUPTED GetResString(IDS_TRIGGER_CORRUPTED)
  41. #define E_REMOTE_INCOMPATIBLE GetResString(IDS_E_REMOTE_INCOMPATIBLE)
  42. #define MAX_TASK_NAME 263
  43. #define MAX_TRIGGER_NAME 196
  44. const WCHAR szHelpOption[] = L"?";
  45. const WCHAR szCreateOption[] = L"CREATE";
  46. const WCHAR szDeleteOption[] = L"DELETE";
  47. const WCHAR szQueryOption[] = L"QUERY";
  48. const WCHAR szServerNameOption[] = L"s";
  49. const WCHAR szUserNameOption[] = L"u";
  50. const WCHAR szPasswordOption[] = L"p";
  51. const WCHAR szTriggerNameOption[] = L"tr";
  52. const WCHAR szLogNameOption[] = L"l";
  53. const WCHAR szEIDOption[] = L"eid";
  54. const WCHAR szTypeOption[] = L"t";
  55. const WCHAR szSource[] = L"so";
  56. const WCHAR szDescriptionOption[] = L"d";
  57. const WCHAR szFormatOption[] = L"fo";
  58. const WCHAR szNoHeaderOption[] = L"nh";
  59. const WCHAR szVerboseOption[] = L"v";
  60. const WCHAR szTaskNameOption[] = L"tk";
  61. const WCHAR szTIDOption[] = L"tid";
  62. const WCHAR szRunAsUserNameOption[] = L"ru";
  63. const WCHAR szRunAsPasswordOption[] = L"rp";
  64. const WCHAR szTriggerIDOption[] = L"id";
  65. HRESULT PropertyGet1( IWbemClassObject* pWmiObject,
  66. LPCTSTR szProperty,
  67. LPVOID pValue, DWORD dwSize );
  68. extern DWORD g_dwOptionFlag;
  69. // CLS stands for class
  70. #define CLS_TRIGGER_EVENT_CONSUMER L"CmdTriggerConsumer"
  71. #define CLS_FILTER_TO_CONSUMERBINDING L"__FilterToConsumerBinding"
  72. #define CLS_WIN32_NT_EVENT_LOGFILE L"Win32_NTEventLogFile"
  73. #define CLS_EVENT_FILTER L"__EventFilter"
  74. // FN stands for Function name
  75. #define FN_CREATE_ETRIGGER L"CreateETriggerEx"
  76. #define FN_DELETE_ETRIGGER L"DeleteETriggerEx"
  77. #define FN_QUERY_ETRIGGER L"QueryETriggerEx"
  78. // FN stands for Function name
  79. // Used only for XP machines.
  80. #define FN_CREATE_ETRIGGER_XP L"CreateETrigger"
  81. #define FN_DELETE_ETRIGGER_XP L"DeleteETrigger"
  82. #define FN_QUERY_ETRIGGER_XP L"QueryETrigger"
  83. // FPR stands for function-parameter
  84. #define FPR_TRIGGER_NAME L"TriggerName"
  85. #define FPR_TRIGGER_DESC L"TriggerDesc"
  86. #define FPR_TRIGGER_QUERY L"TriggerQuery"
  87. #define FPR_TRIGGER_ACTION L"TriggerAction"
  88. #define FPR_TRIGGER_ID L"TriggerID"
  89. #define FPR_RETURN_VALUE L"ReturnValue"
  90. #define FPR_RUN_AS_USER L"RunAsUser"
  91. #define FPR_RUN_AS_USER_PASSWORD L"RunAsPwd"
  92. #define FPR_TASK_SCHEDULER L"ScheduledTaskName"
  93. #define QUERY_STRING L"select * from __instancecreationevent where targetinstance isa \"win32_ntlogevent\""
  94. #define QUERY_LANGUAGE L"WQL"
  95. #define QUERY_RANGE L"select * from CmdTriggerConsumer where TriggerId >= %d and TriggerId <= %d"
  96. #define BINDING_CLASS_QUERY L"select * from __filtertoconsumerbinding where Consumer = \"CmdTriggerConsumer.TriggerId=%d\""
  97. #define RELEASE_MEMORY_EX( block ) \
  98. if ( (block) != NULL ) \
  99. { \
  100. delete [] (block); \
  101. (block) = NULL; \
  102. } \
  103. 1
  104. #define DESTROY_ARRAY( array ) \
  105. if ( (array) != NULL ) \
  106. { \
  107. DestroyDynamicArray( &(array) ); \
  108. (array) = NULL; \
  109. } \
  110. 1
  111. #define SAFE_RELEASE_BSTR(bstr)\
  112. if(bstr != NULL)\
  113. {\
  114. SysFreeString(bstr);\
  115. bstr = NULL;\
  116. }
  117. #define ON_ERROR_THROW_EXCEPTION( hr )\
  118. if(FAILED(hr))\
  119. {\
  120. WMISaveError(hr);\
  121. _com_issue_error(hr);\
  122. }
  123. #define SAFE_RELEASE_INTERFACE( interfacepointer ) \
  124. if ( (interfacepointer) != NULL ) \
  125. { \
  126. (interfacepointer)->Release(); \
  127. (interfacepointer) = NULL; \
  128. } \
  129. 1
  130. #define SIZE_OF_DYN_ARRAY(array) GetBufferSize((LPVOID)array)/sizeof(WCHAR)
  131. #define SIZE_OF_NEW_ARRAY(array) _msize(array)/sizeof(WCHAR)
  132. #endif