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.

148 lines
3.5 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. SECOBJ.CPP
  5. Abstract:
  6. Implements classes related to A51 security model
  7. Classes implemented:
  8. CWmiSecurityCheck Main class of security model
  9. History:
  10. 07/20/00 marioh Created.
  11. --*/
  12. #include "precomp.h"
  13. #include <windows.h>
  14. #include <aclapi.h>
  15. #include <winntsec.h>
  16. #include <wbemcli.h>
  17. #include "secobj.h"
  18. //***************************************************************************
  19. //
  20. //***************************************************************************
  21. CWmiSecurityCheck::CWmiSecurityCheck ( )
  22. {
  23. m_lCount =1;
  24. m_pSD = NULL;
  25. m_pParent = NULL;
  26. InitializeCriticalSection (&m_cs);
  27. }
  28. //***************************************************************************
  29. //
  30. //***************************************************************************
  31. CWmiSecurityCheck::~CWmiSecurityCheck ( )
  32. {
  33. // free descriptor
  34. if ( m_pSD != NULL )
  35. delete m_pSD;
  36. DeleteCriticalSection (&m_cs);
  37. }
  38. //***************************************************************************
  39. //
  40. //***************************************************************************
  41. LONG CWmiSecurityCheck::AddRef ( )
  42. {
  43. return InterlockedIncrement ( &m_lCount );
  44. }
  45. //***************************************************************************
  46. //
  47. //***************************************************************************
  48. LONG CWmiSecurityCheck::Release ( )
  49. {
  50. LONG lCount = InterlockedDecrement ( &m_lCount );
  51. if ( lCount == 0 )
  52. delete this;
  53. return lCount;
  54. }
  55. //***************************************************************************
  56. //
  57. //***************************************************************************
  58. HRESULT CWmiSecurityCheck::SetScopeSD ( PSECURITY_DESCRIPTOR pSD )
  59. {
  60. HRESULT hRes = S_OK;
  61. if ( pSD != NULL )
  62. {
  63. // Copy the SD for local purposes
  64. SIZE_T dwSize = GetSecurityDescriptorLength(pSD); // Get the SD Length
  65. SECURITY_DESCRIPTOR* piSD = (SECURITY_DESCRIPTOR*) new BYTE[dwSize]; // Allocate mem for SD copy
  66. ZeroMemory(piSD, dwSize); // Clear memory
  67. CopyMemory(piSD, pSD, dwSize); // Copy the original SD
  68. m_pSD = new CNtSecurityDescriptor (piSD); // Initialize new SD wrapper with SD
  69. if (m_pSD==NULL)
  70. hRes = WBEM_E_OUT_OF_MEMORY; // Failed due to out of memory
  71. }
  72. return hRes;
  73. }
  74. //***************************************************************************
  75. //
  76. //***************************************************************************
  77. HRESULT CWmiSecurityCheck::SpawnSubscope ( CWmiSecurityCheck** ppSecObj)
  78. {
  79. HRESULT hRes = S_OK;
  80. // Initialize new instance of CWmiSecurityCheck
  81. *ppSecObj = new CWmiSecurityCheck;
  82. if ( ppSecObj == NULL ) // Failed due to out of memory
  83. hRes = WBEM_E_OUT_OF_MEMORY;
  84. else
  85. {
  86. (*ppSecObj)->m_pParent = this; // Set the backlink for synthezised SD builds
  87. }
  88. return hRes;
  89. }
  90. //***************************************************************************
  91. //
  92. //***************************************************************************
  93. HRESULT CWmiSecurityCheck::AccessCheck ( DWORD dwMask, PSECURITY_DESCRIPTOR pSD)
  94. {
  95. HRESULT hRes = S_OK;
  96. // Stub
  97. return hRes;
  98. }
  99. //***************************************************************************
  100. //
  101. //***************************************************************************
  102. HRESULT CWmiSecurityCheck::ComputeEffectiveSD ( PSECURITY_DESCRIPTOR pSD, DWORD dwSdSize )
  103. {
  104. HRESULT hRes = S_OK;
  105. // Stub
  106. return hRes;
  107. }