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.

103 lines
3.4 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. Win9xSecurity.h
  5. Abstract:
  6. This class handles the importing of Win9x security data that was extracted from an old MMF format repository.
  7. History:
  8. 03/17/2001 shbrown - created
  9. --*/
  10. #ifndef __wmi_win9xsecurity_h__
  11. #define __wmi_win9xsecurity_h__
  12. #include <wbemint.h>
  13. #include <strutils.h>
  14. #include <ql.h>
  15. #include "a51rep.h"
  16. #include "flexarry.h"
  17. #include "winntsec.h"
  18. #ifndef FULL_RIGHTS
  19. #define FULL_RIGHTS WBEM_METHOD_EXECUTE | WBEM_FULL_WRITE_REP | WBEM_PARTIAL_WRITE_REP | \
  20. WBEM_WRITE_PROVIDER | WRITE_DAC | READ_CONTROL | WBEM_ENABLE | WBEM_REMOTE_ACCESS
  21. #endif
  22. #define BLOB9X_FILENAME L"\\WBEM9xUpgd.dat"
  23. #define BLOB9X_SIGNATURE "9xUpgrade" //NOTE! MAXIMUM OF 10 CHARACTERS (INCLUDING TERMINATOR!)
  24. #define BLOB9X_TYPE_SECURITY_BLOB 1
  25. #define BLOB9X_TYPE_SECURITY_INSTANCE 2
  26. #define BLOB9X_TYPE_END_OF_FILE 3
  27. typedef struct _BLOB9X_HEADER
  28. {
  29. char szSignature[10];
  30. } BLOB9X_HEADER;
  31. typedef struct _BLOB9X_SPACER
  32. {
  33. DWORD dwSpacerType;
  34. DWORD dwNamespaceNameSize;
  35. DWORD dwParentClassNameSize;
  36. DWORD dwBlobSize;
  37. } BLOB9X_SPACER;
  38. class CWin9xSecurity
  39. {
  40. public:
  41. CWin9xSecurity(CLifeControl* pControl, CRepository * pRepository)
  42. : m_h9xBlobFile(INVALID_HANDLE_VALUE), m_pControl(pControl), m_pRepository(pRepository) {};
  43. bool Win9xBlobFileExists();
  44. HRESULT ImportWin9xSecurity();
  45. private:
  46. HANDLE m_h9xBlobFile;
  47. CLifeControl* m_pControl;
  48. CRepository * m_pRepository;
  49. HRESULT DecodeWin9xBlobFile();
  50. bool ReadWin9xHeader();
  51. HRESULT ProcessWin9xBlob(BLOB9X_SPACER* pHeader);
  52. HRESULT ProcessWin9xSecurityInstance(CNamespaceHandle* pNamespaceHandle, wchar_t* wszParentClass, char* pObjectBlob, DWORD dwBlobSize);
  53. CNtAce* ConvertOldObjectToAce(_IWmiObject* pObj, bool bGroup);
  54. HRESULT StoreAce(CNtAce* pAce);
  55. bool StripMatchingEntries(CNtSecurityDescriptor& sd, const wchar_t* wszAccountName);
  56. bool AddAceToSD(CNtSecurityDescriptor& sd, CNtAce* pAce);
  57. HRESULT ProcessWin9xSecurityBlob(CNamespaceHandle* pNamespaceHandle, const wchar_t* wszNamespaceName, const char* pObjectBlob);
  58. bool ConvertSecurityBlob(const char* pOrgNsSecurity, char** ppNewNsSecurity);
  59. HRESULT TransformBlobToSD(bool bRoot, CNamespaceHandle* pParentNamespaceHandle, const char* pNsSecurity, DWORD dwStoredAsNT, CNtSecurityDescriptor& mmfNsSD);
  60. HRESULT SetNamespaceSecurity(CNamespaceHandle* pNamespaceHandle, CNtSecurityDescriptor& mmfNsSD);
  61. bool AddDefaultRootAces(CNtAcl * pacl );
  62. HRESULT GetParentsInheritableAces(CNamespaceHandle* pParentNamespaceHandle, CNtSecurityDescriptor &sd);
  63. bool StripOutInheritedAces(CNtSecurityDescriptor &sd);
  64. HRESULT GetSDFromNamespace(CNamespaceHandle* pNamespaceHandle, CNtSecurityDescriptor& sd);
  65. bool CopyInheritAces(CNtSecurityDescriptor& sd, CNtSecurityDescriptor& sdParent);
  66. BOOL SetOwnerAndGroup(CNtSecurityDescriptor &sd);
  67. HRESULT RecursiveInheritSecurity(CNamespaceHandle* pParentNamespaceHandle, const wchar_t *wszNamespace);
  68. BOOL DeleteWin9xBlobFile();
  69. bool GetRepositoryDirectory(wchar_t wszRepositoryDirectory[MAX_PATH+1]);
  70. bool IsProtected ( CNtSecurityDescriptor& sd ) ;
  71. };
  72. // Helper for ConvertSecurityBlob
  73. // A variation of the CFlexArray which deletes the entries
  74. class CFlexAceArray : public CFlexArray
  75. {
  76. public:
  77. CFlexAceArray(){};
  78. ~CFlexAceArray();
  79. bool SerializeWinNTSecurityBlob(char** pData);
  80. bool DeserializeWin9xSecurityBlob(const char* pData);
  81. };
  82. #endif