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.

74 lines
1.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998 - 1999.
  5. //
  6. // File: secutil.hxx
  7. //
  8. // Contents: security utility routines
  9. //
  10. // History: 10-April-98 dlee Created from 4 other copies in NT
  11. //
  12. //--------------------------------------------------------------------------
  13. #pragma once
  14. #include <aclapi.h>
  15. //
  16. // Structure to hold information about an ACE to be created
  17. //
  18. struct ACE_DATA
  19. {
  20. UCHAR AceType;
  21. UCHAR InheritFlags;
  22. UCHAR AceFlags;
  23. ACCESS_MASK Mask;
  24. SID * pSid;
  25. };
  26. void WINAPI CiCreateSecurityDescriptor( ACE_DATA const * const pAceData,
  27. ULONG cAces,
  28. SID * pOwnerSid,
  29. SID * pGroupSid,
  30. XArray<BYTE> & xAcls );
  31. inline ULONG CopyNamedDacls(
  32. WCHAR const * pwcDestination,
  33. WCHAR const * pwcSource )
  34. {
  35. PACL pDacl = 0;
  36. PSID pOwnerSid = 0;
  37. PSECURITY_DESCRIPTOR pSecurityDescriptor = 0;
  38. ULONG Error = GetNamedSecurityInfo(
  39. (WCHAR *) pwcSource,
  40. SE_REGISTRY_KEY,
  41. DACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION ,
  42. &pOwnerSid,
  43. NULL,
  44. &pDacl,
  45. NULL,
  46. &pSecurityDescriptor );
  47. if ( ERROR_SUCCESS != Error )
  48. return Error;
  49. Error = SetNamedSecurityInfo(
  50. (WCHAR *) pwcDestination,
  51. SE_KERNEL_OBJECT,
  52. DACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION ,
  53. pOwnerSid,
  54. NULL,
  55. pDacl,
  56. NULL );
  57. if ( 0 != pSecurityDescriptor )
  58. LocalFree( pSecurityDescriptor );
  59. return Error;
  60. } //CopyNamedDacls