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.

71 lines
2.6 KiB

  1. #ifndef _utils_h_
  2. #define _utils_h_
  3. #define MAX_BUF_SIZE 1024
  4. #define MAX_KEY_NAME_SIZE 32
  5. #define MAX_KEY_TYPE_SIZE 32
  6. class CUtils
  7. {
  8. public:
  9. static bool GetClass(LPCWSTR,WMI_CLASS**);
  10. static bool GetAssociation(LPCWSTR, WMI_ASSOCIATION**);
  11. static KeyRef* GetKey(ParsedObjectPath*, WCHAR*);
  12. static void GetMetabasePath(IWbemClassObject*, ParsedObjectPath*, WMI_CLASS*, _bstr_t&);
  13. static void GetToken(WCHAR**, WCHAR*);
  14. void ExecMethodAsync(BSTR, BSTR, IWbemContext*, IWbemClassObject*, IWbemObjectSink*, CWbemServices* );
  15. void DeleteObjectAsync(CWbemServices*, ParsedObjectPath*, CMetabase&);
  16. void PutObjectAsync(IWbemClassObject*, IWbemClassObject*, ParsedObjectPath*, long);
  17. void EnumObjectAsync(BSTR, CWbemServices*, IWbemObjectSink FAR*);
  18. HRESULT GetObjectAsync(CWbemServices*, IWbemClassObject**, ParsedObjectPath*, CMetabase&);
  19. void MzCat (WCHAR**, const WCHAR*);
  20. bool TypeStringToEnum(enum_KEY_TYPE&, LPCWSTR);
  21. bool TypeEnumToString(LPWSTR, enum_KEY_TYPE);
  22. void Throw_Exception(HRESULT, METABASE_PROPERTY*);
  23. private:
  24. bool GetMethod(LPCWSTR, WMI_METHOD**, WMI_METHOD**);
  25. void ExecFtpServiceMethod(LPCWSTR, LPCWSTR, LPCWSTR, IWbemContext*, IWbemClassObject*, IWbemObjectSink*, CWbemServices*);
  26. void ExecWebServiceMethod(LPCWSTR, LPCWSTR, LPCWSTR, IWbemContext*, IWbemClassObject*, IWbemObjectSink*, CWbemServices*);
  27. void ExecWebAppMethod(LPCWSTR, LPCWSTR, LPCWSTR, IWbemContext*, IWbemClassObject*, IWbemObjectSink*, CWbemServices*);
  28. void ExecComputerMethod(LPCWSTR, LPCWSTR, LPCWSTR, IWbemContext*, IWbemClassObject*, IWbemObjectSink*, CWbemServices*);
  29. void ExecCertMapperMethod(LPCWSTR, LPCWSTR, LPCWSTR, IWbemContext*, IWbemClassObject*, IWbemObjectSink*, CWbemServices*);
  30. void FindUniqueServerName(LPCWSTR, _bstr_t&);
  31. private:
  32. static CSynchObject s_synObject;
  33. };
  34. class CIIsProvException
  35. {
  36. public:
  37. CIIsProvException() {m_hr = ERROR_SUCCESS; m_psz = NULL;};
  38. HRESULT m_hr;
  39. WCHAR* m_psz;
  40. };
  41. #define THROW_ON_FALSE(b) \
  42. if (!b) \
  43. throw(WBEM_E_FAILED);
  44. // if client calcelled, stop and return successfully
  45. #define THROW_ON_ERROR(hr) \
  46. if (hr != ERROR_SUCCESS) \
  47. throw(hr == WBEM_E_CALL_CANCELLED ? WBEM_NO_ERROR : hr);
  48. #define THROW_E_ON_ERROR(hr, pmbp) \
  49. if (hr != ERROR_SUCCESS) \
  50. { \
  51. CUtils obj; \
  52. obj.Throw_Exception(hr, pmbp); \
  53. }
  54. #endif