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.

108 lines
2.3 KiB

  1. // Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  2. // Helpers.h: Prototypes for helper functions for JobObjectProv component.
  3. #pragma once
  4. _COM_SMARTPTR_TYPEDEF(IWbemClassObject, __uuidof(IWbemClassObject));
  5. _COM_SMARTPTR_TYPEDEF(IWbemLocator, __uuidof(IWbemLocator));
  6. _COM_SMARTPTR_TYPEDEF(IWbemServices, __uuidof(IWbemServices));
  7. #define JOB_OBJECT_STATUS_OBJECT L"Win32_JobObjectStatus"
  8. #define JOB_OBJECT_NAMESPACE L"root\\cimv2"
  9. class SmartCloseHANDLE
  10. {
  11. private:
  12. HANDLE m_h;
  13. public:
  14. SmartCloseHANDLE():m_h(INVALID_HANDLE_VALUE){}
  15. SmartCloseHANDLE(HANDLE h):m_h(h){}
  16. ~SmartCloseHANDLE(){if (m_h!=INVALID_HANDLE_VALUE) CloseHandle(m_h);}
  17. HANDLE operator =(HANDLE h) {if (m_h!=INVALID_HANDLE_VALUE) CloseHandle(m_h); m_h=h; return h;}
  18. operator HANDLE() const {return m_h;}
  19. HANDLE* operator &() {if (m_h!=INVALID_HANDLE_VALUE) CloseHandle(m_h); m_h = INVALID_HANDLE_VALUE; return &m_h;}
  20. };
  21. HRESULT CreateInst(
  22. IWbemServices *pNamespace,
  23. IWbemClassObject **pNewInst,
  24. BSTR bstrClassName,
  25. IWbemContext *pCtx);
  26. HRESULT GetObjInstKeyVal(
  27. const BSTR ObjectPath,
  28. LPCWSTR wstrClassName,
  29. LPCWSTR wstrKeyPropName,
  30. LPWSTR wstrObjInstKeyVal,
  31. long lBufLen);
  32. HRESULT GetJobObjectList(
  33. std::vector<_bstr_t>& rgbstrtJOList);
  34. bool WINAPI WhackToken(
  35. LPWSTR str,
  36. LPWSTR token);
  37. bool WINAPI StrToIdentifierAuthority(
  38. LPCWSTR str,
  39. SID_IDENTIFIER_AUTHORITY& identifierAuthority);
  40. PSID WINAPI StrToSID(LPCWSTR wstrIncommingSid);
  41. void StringFromSid(PSID psid, _bstr_t& strSID);
  42. void RemoveQuotes(LPWSTR wstrObjInstKeyVal);
  43. HRESULT CheckImpersonationLevel();
  44. HRESULT SetStatusObject(
  45. IWbemContext* pContext,
  46. IWbemServices* pSvcs,
  47. DWORD dwError,
  48. LPCWSTR wstrErrorDescription,
  49. LPCWSTR wstrOperation,
  50. LPCWSTR wstrNamespace,
  51. IWbemClassObject** ppStatusObjOut);
  52. IWbemClassObject* GetStatusObject(
  53. IWbemContext* pContext,
  54. IWbemServices* pSvcs);
  55. void UndecorateJOName(
  56. LPCWSTR wstrDecoratedName,
  57. CHString& chstrUndecoratedJOName);
  58. void DecorateJOName(
  59. LPCWSTR wstrUndecoratedName,
  60. CHString& chstrDecoratedJOName);
  61. void UndecorateNamesInNamedJONameList(
  62. std::vector<_bstr_t>& rgNamedJOs);
  63. HRESULT WinErrorToWBEMhResult(LONG error);
  64. bool GetNameAndDomainFromPSID(
  65. PSID psid,
  66. CHString& chstrName,
  67. CHString& chstrDomain);