📄 ac.c
字号:
DWORD dwAceRevision,
DWORD AceFlags,
DWORD AccessMask,
GUID* ObjectTypeGuid,
GUID* InheritedObjectTypeGuid,
PSID pSid,
BOOL bAuditSuccess,
BOOL bAuditFailure)
{
NTSTATUS Status;
Status = RtlAddAuditAccessObjectAce(pAcl,
dwAceRevision,
AceFlags,
AccessMask,
ObjectTypeGuid,
InheritedObjectTypeGuid,
pSid,
bAuditSuccess,
bAuditFailure);
if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
return TRUE;
}
/*
* @implemented
*/
BOOL
WINAPI
AddMandatoryAce(IN OUT PACL pAcl,
IN DWORD dwAceRevision,
IN DWORD AceFlags,
IN DWORD MandatoryPolicy,
IN PSID pLabelSid)
{
NTSTATUS Status;
Status = RtlAddMandatoryAce(pAcl,
dwAceRevision,
AceFlags,
MandatoryPolicy,
SYSTEM_MANDATORY_LABEL_ACE_TYPE,
pLabelSid);
if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
return TRUE;
}
/*
* @implemented
*/
BOOL
STDCALL
DeleteAce (
PACL pAcl,
DWORD dwAceIndex
)
{
NTSTATUS Status;
Status = RtlDeleteAce (pAcl,
dwAceIndex);
if (!NT_SUCCESS(Status))
{
SetLastError (RtlNtStatusToDosError (Status));
return FALSE;
}
return TRUE;
}
/*
* @implemented
*/
BOOL
STDCALL
FindFirstFreeAce (
PACL pAcl,
LPVOID * pAce
)
{
return RtlFirstFreeAce (pAcl,
(PACE*)pAce);
}
/*
* @implemented
*/
BOOL
STDCALL
GetAce (
PACL pAcl,
DWORD dwAceIndex,
LPVOID * pAce
)
{
NTSTATUS Status;
Status = RtlGetAce (pAcl,
dwAceIndex,
pAce);
if (!NT_SUCCESS(Status))
{
SetLastError (RtlNtStatusToDosError (Status));
return FALSE;
}
return TRUE;
}
/*
* @implemented
*/
DWORD
STDCALL
GetInheritanceSourceW (
LPWSTR pObjectName,
SE_OBJECT_TYPE ObjectType,
SECURITY_INFORMATION SecurityInfo,
BOOL Container,
GUID** pObjectClassGuids OPTIONAL,
DWORD GuidCount,
PACL pAcl,
PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL,
PGENERIC_MAPPING pGenericMapping,
PINHERITED_FROMW pInheritArray
)
{
DWORD ErrorCode;
ErrorCode = CheckNtMartaPresent();
if (ErrorCode == ERROR_SUCCESS)
{
/* call the MARTA provider */
ErrorCode = AccGetInheritanceSource(pObjectName,
ObjectType,
SecurityInfo,
Container,
pObjectClassGuids,
GuidCount,
pAcl,
pfnArray,
pGenericMapping,
pInheritArray);
}
return ErrorCode;
}
/*
* @unimplemented
*/
DWORD
STDCALL
GetInheritanceSourceA (
LPSTR pObjectName,
SE_OBJECT_TYPE ObjectType,
SECURITY_INFORMATION SecurityInfo,
BOOL Container,
GUID** pObjectClassGuids OPTIONAL,
DWORD GuidCount,
PACL pAcl,
PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL,
PGENERIC_MAPPING pGenericMapping,
PINHERITED_FROMA pInheritArray
)
{
/* That's all this function does, at least up to w2k3... Even MS was too
lazy to implement it... */
return ERROR_CALL_NOT_IMPLEMENTED;
}
/*
* @implemented
*/
DWORD
STDCALL
FreeInheritedFromArray (
PINHERITED_FROMW pInheritArray,
USHORT AceCnt,
PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL
)
{
DWORD ErrorCode;
ErrorCode = CheckNtMartaPresent();
if (ErrorCode == ERROR_SUCCESS)
{
/* call the MARTA provider */
ErrorCode = AccFreeIndexArray(pInheritArray,
AceCnt,
pfnArray);
}
return ErrorCode;
}
/*
* @implemented
*/
DWORD
STDCALL
SetEntriesInAclW(
ULONG cCountOfExplicitEntries,
PEXPLICIT_ACCESS_W pListOfExplicitEntries,
PACL OldAcl,
PACL* NewAcl)
{
DWORD ErrorCode;
ErrorCode = CheckNtMartaPresent();
if (ErrorCode == ERROR_SUCCESS)
{
/* call the MARTA provider */
ErrorCode = AccRewriteSetEntriesInAcl(cCountOfExplicitEntries,
pListOfExplicitEntries,
OldAcl,
NewAcl);
}
return ErrorCode;
}
static DWORD
InternalTrusteeAToW(IN PTRUSTEE_A pTrusteeA,
OUT PTRUSTEE_W *pTrusteeW)
{
TRUSTEE_FORM TrusteeForm;
INT BufferSize = 0;
PSTR lpStr;
DWORD ErrorCode = ERROR_SUCCESS;
//ASSERT(sizeof(TRUSTEE_W) == sizeof(TRUSTEE_A));
TrusteeForm = GetTrusteeFormA(pTrusteeA);
switch (TrusteeForm)
{
case TRUSTEE_IS_NAME:
{
/* directly copy the array, this works as the size of the EXPLICIT_ACCESS_A
structure matches the size of the EXPLICIT_ACCESS_W version */
lpStr = GetTrusteeNameA(pTrusteeA);
if (lpStr != NULL)
BufferSize = strlen(lpStr) + 1;
*pTrusteeW = RtlAllocateHeap(RtlGetProcessHeap(),
0,
sizeof(TRUSTEE_W) + (BufferSize * sizeof(WCHAR)));
if (*pTrusteeW != NULL)
{
RtlCopyMemory(*pTrusteeW,
pTrusteeA,
FIELD_OFFSET(TRUSTEE_A,
ptstrName));
if (lpStr != NULL)
{
(*pTrusteeW)->ptstrName = (PWSTR)((*pTrusteeW) + 1);
/* convert the trustee's name */
if (MultiByteToWideChar(CP_ACP,
0,
lpStr,
-1,
(*pTrusteeW)->ptstrName,
BufferSize) == 0)
{
goto ConvertErr;
}
}
else
{
RtlFreeHeap(RtlGetProcessHeap(),
0,
*pTrusteeW);
goto NothingToConvert;
}
}
else
ErrorCode = ERROR_NOT_ENOUGH_MEMORY;
break;
}
case TRUSTEE_IS_OBJECTS_AND_NAME:
{
POBJECTS_AND_NAME_A oanA = (POBJECTS_AND_NAME_A)GetTrusteeNameA(pTrusteeA);
POBJECTS_AND_NAME_W oan;
PWSTR StrBuf;
/* calculate the size needed */
if ((oanA->ObjectsPresent & ACE_INHERITED_OBJECT_TYPE_PRESENT) &&
oanA->InheritedObjectTypeName != NULL)
{
BufferSize = strlen(oanA->InheritedObjectTypeName) + 1;
}
if (oanA->ptstrName != NULL)
{
BufferSize += strlen(oanA->ptstrName) + 1;
}
*pTrusteeW = RtlAllocateHeap(RtlGetProcessHeap(),
0,
sizeof(TRUSTEE_W) + sizeof(OBJECTS_AND_NAME_W) +
(BufferSize * sizeof(WCHAR)));
if (*pTrusteeW != NULL)
{
oan = (POBJECTS_AND_NAME_W)((*pTrusteeW) + 1);
StrBuf = (PWSTR)(oan + 1);
/* copy over the parts of the TRUSTEE structure that don't need
to be touched */
RtlCopyMemory(*pTrusteeW,
pTrusteeA,
FIELD_OFFSET(TRUSTEE_A,
ptstrName));
(*pTrusteeW)->ptstrName = (LPWSTR)oan;
/* convert the OBJECTS_AND_NAME_A structure */
oan->ObjectsPresent = oanA->ObjectsPresent;
oan->ObjectType = oanA->ObjectType;
if ((oanA->ObjectsPresent & ACE_INHERITED_OBJECT_TYPE_PRESENT) &&
oanA->InheritedObjectTypeName != NULL)
{
/* convert inherited object type name */
BufferSize = strlen(oanA->InheritedObjectTypeName) + 1;
if (MultiByteToWideChar(CP_ACP,
0,
oanA->InheritedObjectTypeName,
-1,
StrBuf,
BufferSize) == 0)
{
goto ConvertErr;
}
oan->InheritedObjectTypeName = StrBuf;
StrBuf += BufferSize;
}
else
oan->InheritedObjectTypeName = NULL;
if (oanA->ptstrName != NULL)
{
/* convert the trustee name */
BufferSize = strlen(oanA->ptstrName) + 1;
if (MultiByteToWideChar(CP_ACP,
0,
oanA->ptstrName,
-1,
StrBuf,
BufferSize) == 0)
{
ConvertErr:
ErrorCode = GetLastError();
/* cleanup */
RtlFreeHeap(RtlGetProcessHeap(),
0,
*pTrusteeW);
return ErrorCode;
}
oan->ptstrName = StrBuf;
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -