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.

194 lines
6.6 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1996.
  5. //
  6. // File: APIUTIL.HXX
  7. //
  8. // Contents: Private definitions and function prototypes used by the
  9. // access control API utility funcitons
  10. //
  11. // History: 14-Sep-96 MacM Created
  12. //
  13. //--------------------------------------------------------------------
  14. #ifndef __APIUTIL_HXX__
  15. #define __APIUTIL_HXX__
  16. //#include <martaexp.hxx>
  17. #include <martaexp.h>
  18. #define SE_AUDIT_BOTH 99
  19. typedef struct _ACCESS_ENTRY
  20. {
  21. ACCESS_MODE AccessMode;
  22. DWORD InheritType;
  23. ACCESS_MASK AccessMask;
  24. TRUSTEE Trustee;
  25. } ACCESS_ENTRY, *PACCESS_ENTRY;
  26. //
  27. // This structure is used hold information regarding the
  28. // functions imported from the NTMARTA dll
  29. //
  30. typedef struct _MARTA_NTMARTA_INFO
  31. {
  32. HMODULE hDll; // Module handle of the DLL
  33. // after being loaded
  34. pfNTMartaLookupTrustee pfTrustee; // AccLookupAccountTrustee
  35. pfNTMartaLookupName pfName; // AccLookupAccountName
  36. pfNTMartaLookupSid pfSid; // AccLookupAccountSid
  37. pfNTMartaSetAList pfSetAList; // AccSetEntriesInAList
  38. pfNTMartaAToSD pfAToSD; // AccConvertAccessToSecurityDescriptor
  39. pfNTMartaSDToA pfSDToA; // AccConvertSDToAccess
  40. pfNTMartaAclToA pfAclToA; // AccConvertAclToAccess
  41. pfNTMartaGetAccess pfGetAccess; // AccGetAccessForTrustee
  42. pfNTMartaGetExplicit pfGetExplicit; // AccGetExplicitEntries
  43. pfNTMartaGetNamedRights pfrGetNamedRights; // AccRewriteGetRights
  44. pfNTMartaSetNamedRights pfrSetNamedRights; // AccRewriteSetRights
  45. pfNTMartaGetHandleRights pfrGetHandleRights; // AccRewriteGetHandleRights
  46. pfNTMartaSetHandleRights pfrSetHandleRights; // AccRewriteSetHandleRights
  47. pfNTMartaSetEntriesInAcl pfrSetEntriesInAcl; // AccRewriteSetEntriesInAcl
  48. pfNTMartaGetExplicitEntriesFromAcl pfrGetExplicitEntriesFromAcl; // AccRewriteGetExplicitEntriesFromAcl
  49. pfNTMartaTreeResetNamedSecurityInfo pfrTreeResetNamedSecurityInfo; // AccTreeResetNamedSecurityInfo
  50. pfNTMartaGetInheritanceSource pfrGetInheritanceSource; // AccGetInheritanceSource
  51. pfNTMartaFreeIndexArray pfrFreeIndexArray; // AccFreeIndexArray
  52. } MARTA_NTMARTA_INFO, *PMARTA_NTMARTA_INFO;
  53. extern MARTA_NTMARTA_INFO gNtMartaInfo;
  54. //
  55. // This node is used by ConvertAListToNamedBasedx
  56. //
  57. typedef struct _CONVERT_ALIST_NODE
  58. {
  59. PWSTR *ppwszInfoAddress;
  60. PWSTR pwszOldValue;
  61. PULONG pulVal1Address;
  62. ULONG ulOldVal1;
  63. PULONG pulVal2Address;
  64. ULONG ulOldVal2;
  65. } CONVERT_ALIST_NODE, *PCONVERT_ALIST_NODE;
  66. //
  67. // This macro will load the providers if it hasn't already done so, and exit
  68. // on failure
  69. //
  70. #define LOAD_PROVIDERS(err) \
  71. err = AccProvpInitProviders(&gAccProviders); \
  72. if(err != ERROR_SUCCESS) \
  73. { \
  74. return(err); \
  75. }
  76. //
  77. // Function prototypes
  78. //
  79. VOID
  80. CleanupConvertNode(PVOID pvNode);
  81. inline
  82. DWORD
  83. AllocAndInsertCNode(CSList &SaveList,
  84. PWSTR *ppwszAddress,
  85. PWSTR pwszOldValue,
  86. PWSTR pwszNewValue,
  87. PULONG pulVal1Address = NULL,
  88. ULONG ulOldVal1 = 0,
  89. ULONG ulNewVal1 = 0,
  90. PULONG pulVal2Address = NULL,
  91. ULONG ulOldVal2 = 0,
  92. ULONG ulNewVal2 = 0);
  93. DWORD
  94. GetTrusteeWForSid(PSID pSid,
  95. PTRUSTEEW pTrusteeW);
  96. DWORD
  97. ConvertStringWToStringA(IN PWSTR pwszString,
  98. OUT PSTR *ppszString);
  99. DWORD
  100. ConvertStringAToStringW(IN PSTR pszString,
  101. OUT PWSTR *ppwszString);
  102. DWORD
  103. ConvertTrusteeAToTrusteeW(IN PTRUSTEE_A pTrusteeA,
  104. OUT PTRUSTEE_W pTrusteeW,
  105. IN BOOL fSidToName);
  106. DWORD
  107. ConvertTrusteeWToTrusteeA(IN PTRUSTEE_W pTrusteeW,
  108. OUT PTRUSTEE_A pTrusteeA,
  109. IN BOOL fSidToName);
  110. DWORD
  111. ConvertAListWToAlistAInplace(IN PACTRL_ACCESSW pAListW);
  112. DWORD
  113. ConvertAListToNamedBasedW(IN PACTRL_ACCESSW pAListW,
  114. IN CSList& ChangedList);
  115. DWORD
  116. ConvertAListAToNamedBasedW(IN PACTRL_ACCESSA pAListA,
  117. IN CSList& ChangedList,
  118. IN BOOL fSidToName,
  119. OUT PACTRL_ACCESSW *ppAListW);
  120. DWORD
  121. ConvertTrusteeWToTrusteeA(IN PTRUSTEE_W pTrusteeW,
  122. OUT PTRUSTEE_A *ppTrusteeA);
  123. DWORD
  124. ConvertExplicitAccessAToExplicitAccessW(IN ULONG cAccesses,
  125. IN PEXPLICIT_ACCESS_A pAccessA,
  126. OUT PEXPLICIT_ACCESS_W *ppAccessW);
  127. DWORD
  128. ConvertExplicitAccessWToExplicitAccessA(IN ULONG cAccesses,
  129. IN PEXPLICIT_ACCESS_W pAccessW,
  130. OUT PEXPLICIT_ACCESS_A *ppAccessA);
  131. VOID
  132. ConvertAccessRightToAccessMask(IN ACCESS_RIGHTS AccessRight,
  133. OUT PACCESS_MASK pAccessMask);
  134. extern "C"
  135. {
  136. VOID
  137. ConvertAccessMaskToAccessRight(IN ACCESS_MASK AccessMask,
  138. OUT PACCESS_RIGHTS pAccessRight);
  139. }
  140. DWORD
  141. ConvertExplicitAccessAToW(IN ULONG cEntries,
  142. IN PEXPLICIT_ACCESS_A pExplicit,
  143. IN CSList& ChangedList);
  144. DWORD
  145. ConvertAccessWToExplicitW(IN PACTRL_ACCESSW pAccess,
  146. OUT PULONG pcEntries,
  147. OUT PEXPLICIT_ACCESS *ppExplicit);
  148. DWORD
  149. ConvertAccessWToExplicitA(IN PACTRL_ACCESSW pAccess,
  150. OUT PULONG pcEntries,
  151. OUT PEXPLICIT_ACCESSA *ppExplicit);
  152. DWORD
  153. Win32ExplicitAccessToAccessEntry(IN ULONG cCount,
  154. IN PEXPLICIT_ACCESS pExplicitAccessList,
  155. OUT PACCESS_ENTRY *pAccessEntryList);
  156. DWORD
  157. AccessEntryToWin32ExplicitAccess(IN ULONG cCountOfAccessEntries,
  158. IN PACCESS_ENTRY pListOfAccessEntries,
  159. OUT PEXPLICIT_ACCESS *pListOfExplicitAccesses);
  160. #endif // ifdef __APIUTIL_HXX__