Fix the PSID and PSECURITY_DESCRIPTOR types.

Add PISID and PISECURITY_DESCRIPTOR.
This commit is contained in:
Francois Gouget 2004-08-13 23:55:43 +00:00 committed by Alexandre Julliard
parent a9b4a471a9
commit 870f55fefc
6 changed files with 143 additions and 103 deletions

View File

@ -48,7 +48,7 @@ static BYTE ParseAceStringType(LPCWSTR* StringAcl);
static DWORD ParseAceStringRights(LPCWSTR* StringAcl);
static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
LPCWSTR StringSecurityDescriptor,
PSECURITY_DESCRIPTOR SecurityDescriptor,
SECURITY_DESCRIPTOR* SecurityDescriptor,
LPDWORD cBytes);
static DWORD ParseAclStringFlags(LPCWSTR* StringAcl);
@ -552,7 +552,7 @@ GetLengthSid (PSID pSid)
* revision []
*/
BOOL WINAPI
InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
InitializeSecurityDescriptor( PSECURITY_DESCRIPTOR pDescr, DWORD revision )
{
CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
}
@ -584,7 +584,7 @@ BOOL WINAPI MakeAbsoluteSD (
/******************************************************************************
* GetSecurityDescriptorLength [ADVAPI32.@]
*/
DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
DWORD WINAPI GetSecurityDescriptorLength( PSECURITY_DESCRIPTOR pDescr)
{
return (RtlLengthSecurityDescriptor(pDescr));
}
@ -597,7 +597,7 @@ DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
* lpbOwnerDefaulted []
*/
BOOL WINAPI
GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
GetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pDescr, PSID *pOwner,
LPBOOL lpbOwnerDefaulted )
{
CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
@ -1887,7 +1887,7 @@ lerr:
*/
static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
LPCWSTR StringSecurityDescriptor,
PSECURITY_DESCRIPTOR SecurityDescriptor,
SECURITY_DESCRIPTOR* SecurityDescriptor,
LPDWORD cBytes)
{
BOOL bret = FALSE;
@ -2031,7 +2031,7 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(
PULONG SecurityDescriptorSize)
{
DWORD cBytes;
PSECURITY_DESCRIPTOR psd;
SECURITY_DESCRIPTOR* psd;
BOOL bret = FALSE;
TRACE("%s\n", debugstr_w(StringSecurityDescriptor));
@ -2052,7 +2052,7 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(
NULL, &cBytes))
goto lend;
psd = *SecurityDescriptor = (PSECURITY_DESCRIPTOR) LocalAlloc(
psd = *SecurityDescriptor = (SECURITY_DESCRIPTOR*) LocalAlloc(
GMEM_ZEROINIT, cBytes);
psd->Revision = SID_REVISION;
@ -2114,26 +2114,27 @@ BOOL WINAPI ConvertSidToStringSidW( PSID pSid, LPWSTR *pstr )
WCHAR fmt[] = {
'S','-','%','u','-','%','2','X','%','2','X','%','X','%','X','%','X','%','X',0 };
WCHAR subauthfmt[] = { '-','%','u',0 };
SID* pisid=pSid;
TRACE("%p %p\n", pSid, pstr );
if( !IsValidSid( pSid ) )
return FALSE;
if (pSid->Revision != SDDL_REVISION)
if (pisid->Revision != SDDL_REVISION)
return FALSE;
sz = 14 + pSid->SubAuthorityCount * 11;
sz = 14 + pisid->SubAuthorityCount * 11;
str = LocalAlloc( 0, sz*sizeof(WCHAR) );
sprintfW( str, fmt, pSid->Revision,
pSid->IdentifierAuthority.Value[2],
pSid->IdentifierAuthority.Value[3],
pSid->IdentifierAuthority.Value[0]&0x0f,
pSid->IdentifierAuthority.Value[4]&0x0f,
pSid->IdentifierAuthority.Value[1]&0x0f,
pSid->IdentifierAuthority.Value[5]&0x0f);
for( i=0; i<pSid->SubAuthorityCount; i++ )
sprintfW( str + strlenW(str), subauthfmt, pSid->SubAuthority[i] );
sprintfW( str, fmt, pisid->Revision,
pisid->IdentifierAuthority.Value[2],
pisid->IdentifierAuthority.Value[3],
pisid->IdentifierAuthority.Value[0]&0x0f,
pisid->IdentifierAuthority.Value[4]&0x0f,
pisid->IdentifierAuthority.Value[1]&0x0f,
pisid->IdentifierAuthority.Value[5]&0x0f);
for( i=0; i<pisid->SubAuthorityCount; i++ )
sprintfW( str + strlenW(str), subauthfmt, pisid->SubAuthority[i] );
*pstr = str;
return TRUE;
@ -2190,6 +2191,7 @@ static DWORD ComputeStringSidSize(LPCWSTR StringSid)
static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
{
BOOL bret = FALSE;
SID* pisid=pSid;
if (!StringSid)
{
@ -2198,7 +2200,7 @@ static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
}
*cBytes = ComputeStringSidSize(StringSid);
if (!pSid) /* Simply compute the size */
if (!pisid) /* Simply compute the size */
return TRUE;
if (*StringSid != 'S' || *StringSid != '-') /* S-R-I-S-S */
@ -2207,19 +2209,19 @@ static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
int csubauth = ((*cBytes - sizeof(SID)) / sizeof(DWORD)) + 1;
StringSid += 2; /* Advance to Revision */
pSid->Revision = atoiW(StringSid);
pisid->Revision = atoiW(StringSid);
if (pSid->Revision != SDDL_REVISION)
if (pisid->Revision != SDDL_REVISION)
goto lend; /* ERROR_INVALID_SID */
pSid->SubAuthorityCount = csubauth;
pisid->SubAuthorityCount = csubauth;
while (*StringSid && *StringSid != '-')
StringSid++; /* Advance to identifier authority */
pSid->IdentifierAuthority.Value[5] = atoiW(StringSid);
pisid->IdentifierAuthority.Value[5] = atoiW(StringSid);
if (pSid->IdentifierAuthority.Value[5] > 5)
if (pisid->IdentifierAuthority.Value[5] > 5)
goto lend; /* ERROR_INVALID_SID */
while (*StringSid)
@ -2227,24 +2229,24 @@ static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
while (*StringSid && *StringSid != '-')
StringSid++;
pSid->SubAuthority[i++] = atoiW(StringSid);
pisid->SubAuthority[i++] = atoiW(StringSid);
}
if (i != pSid->SubAuthorityCount)
if (i != pisid->SubAuthorityCount)
goto lend; /* ERROR_INVALID_SID */
bret = TRUE;
}
else /* String constant format - Only available in winxp and above */
{
pSid->Revision = SDDL_REVISION;
pSid->SubAuthorityCount = 1;
pisid->Revision = SDDL_REVISION;
pisid->SubAuthorityCount = 1;
FIXME("String constant not supported: %s\n", debugstr_wn(StringSid, 2));
/* TODO: Lookup string of well-known SIDs in table */
pSid->IdentifierAuthority.Value[5] = 0;
pSid->SubAuthority[0] = 0;
pisid->IdentifierAuthority.Value[5] = 0;
pisid->SubAuthority[0] = 0;
bret = TRUE;
}

View File

@ -179,7 +179,7 @@ NtQuerySecurityObject(
/* owner: administrator S-1-5-20-220*/
if (OWNER_SECURITY_INFORMATION & RequestedInformation)
{
PSID psid = (PSID)&(Buffer[BufferIndex]);
SID* psid = (SID*)&(Buffer[BufferIndex]);
psd->Owner = BufferIndex;
BufferIndex += RtlLengthRequiredSid(2);
@ -194,7 +194,7 @@ NtQuerySecurityObject(
/* group: built in domain S-1-5-12 */
if (GROUP_SECURITY_INFORMATION & RequestedInformation)
{
PSID psid = (PSID) &(Buffer[BufferIndex]);
SID* psid = (SID*) &(Buffer[BufferIndex]);
psd->Group = BufferIndex;
BufferIndex += RtlLengthRequiredSid(1);
@ -211,7 +211,7 @@ NtQuerySecurityObject(
/* acl header */
PACL pacl = (PACL)&(Buffer[BufferIndex]);
PACCESS_ALLOWED_ACE pace;
PSID psid;
SID* psid;
psd->Dacl = BufferIndex;
@ -232,7 +232,7 @@ NtQuerySecurityObject(
pace->SidStart = BufferIndex;
/* SID S-1-5-12 (System) */
psid = (PSID)&(Buffer[BufferIndex]);
psid = (SID*)&(Buffer[BufferIndex]);
BufferIndex += RtlLengthRequiredSid(1);
@ -252,7 +252,7 @@ NtQuerySecurityObject(
pace->SidStart = BufferIndex;
/* S-1-5-12 (Administrators) */
psid = (PSID)&(Buffer[BufferIndex]);
psid = (SID*)&(Buffer[BufferIndex]);
BufferIndex += RtlLengthRequiredSid(2);
@ -273,7 +273,7 @@ NtQuerySecurityObject(
pace->SidStart = BufferIndex;
/* SID S-1-1-0 (Everyone) */
psid = (PSID)&(Buffer[BufferIndex]);
psid = (SID*)&(Buffer[BufferIndex]);
BufferIndex += RtlLengthRequiredSid(1);

View File

@ -73,6 +73,7 @@ BOOLEAN WINAPI RtlAllocateAndInitializeSid (
DWORD nSubAuthority6, DWORD nSubAuthority7,
PSID *pSid )
{
TRACE("(%p, 0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,%p)\n",
pIdentifierAuthority,nSubAuthorityCount,
nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
@ -82,10 +83,10 @@ BOOLEAN WINAPI RtlAllocateAndInitializeSid (
RtlLengthRequiredSid(nSubAuthorityCount))))
return FALSE;
(*pSid)->Revision = SID_REVISION;
((SID*)*pSid)->Revision = SID_REVISION;
if (pIdentifierAuthority)
memcpy(&(*pSid)->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
memcpy(&((SID*)*pSid)->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
*RtlSubAuthorityCountSid(*pSid) = nSubAuthorityCount;
if (nSubAuthorityCount > 0)
@ -145,7 +146,7 @@ BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2)
if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
return FALSE;
if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(pSid1->SubAuthorityCount - 1)) != 0)
if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(((SID*)pSid1)->SubAuthorityCount - 1)) != 0)
return FALSE;
return TRUE;
@ -224,13 +225,15 @@ BOOL WINAPI RtlInitializeSid(
BYTE nSubAuthorityCount)
{
int i;
SID* pisid=pSid;
if (nSubAuthorityCount >= SID_MAX_SUB_AUTHORITIES)
return FALSE;
pSid->Revision = SID_REVISION;
pSid->SubAuthorityCount = nSubAuthorityCount;
pisid->Revision = SID_REVISION;
pisid->SubAuthorityCount = nSubAuthorityCount;
if (pIdentifierAuthority)
memcpy(&pSid->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
memcpy(&pisid->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
for (i = 0; i < nSubAuthorityCount; i++)
*RtlSubAuthoritySid(pSid, i) = 0;
@ -252,7 +255,7 @@ BOOL WINAPI RtlInitializeSid(
*/
LPDWORD WINAPI RtlSubAuthoritySid( PSID pSid, DWORD nSubAuthority )
{
return &(pSid->SubAuthority[nSubAuthority]);
return &(((SID*)pSid)->SubAuthority[nSubAuthority]);
}
/**************************************************************************
@ -268,7 +271,7 @@ LPDWORD WINAPI RtlSubAuthoritySid( PSID pSid, DWORD nSubAuthority )
*/
PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
{
return &(pSid->IdentifierAuthority);
return &(((SID*)pSid)->IdentifierAuthority);
}
/**************************************************************************
@ -284,7 +287,7 @@ PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
*/
LPBYTE WINAPI RtlSubAuthorityCountSid(PSID pSid)
{
return &(pSid->SubAuthorityCount);
return &(((SID*)pSid)->SubAuthorityCount);
}
/**************************************************************************
@ -296,10 +299,10 @@ DWORD WINAPI RtlCopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID
(nDestinationSidLength < RtlLengthSid(pSourceSid)))
return FALSE;
if (nDestinationSidLength < (pSourceSid->SubAuthorityCount*4+8))
if (nDestinationSidLength < (((SID*)pSourceSid)->SubAuthorityCount*4+8))
return FALSE;
memmove(pDestinationSid, pSourceSid, pSourceSid->SubAuthorityCount*4+8);
memmove(pDestinationSid, pSourceSid, ((SID*)pSourceSid)->SubAuthorityCount*4+8);
return TRUE;
}
/******************************************************************************
@ -320,8 +323,8 @@ BOOLEAN WINAPI RtlValidSid( PSID pSid )
__TRY
{
ret = TRUE;
if (!pSid || pSid->Revision != SID_REVISION ||
pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
if (!pSid || ((SID*)pSid)->Revision != SID_REVISION ||
((SID*)pSid)->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
{
ret = FALSE;
}
@ -360,7 +363,7 @@ NTSTATUS WINAPI RtlCreateSecurityDescriptor(
if (rev!=SECURITY_DESCRIPTOR_REVISION)
return STATUS_UNKNOWN_REVISION;
memset(lpsd,'\0',sizeof(*lpsd));
lpsd->Revision = SECURITY_DESCRIPTOR_REVISION;
((SECURITY_DESCRIPTOR*)lpsd)->Revision = SECURITY_DESCRIPTOR_REVISION;
return STATUS_SUCCESS;
}
/**************************************************************************
@ -380,7 +383,7 @@ NTSTATUS WINAPI RtlValidSecurityDescriptor(
{
if ( ! SecurityDescriptor )
return STATUS_INVALID_SECURITY_DESCR;
if ( SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION )
if ( ((SECURITY_DESCRIPTOR*)SecurityDescriptor)->Revision != SECURITY_DESCRIPTOR_REVISION )
return STATUS_UNKNOWN_REVISION;
return STATUS_SUCCESS;
@ -390,28 +393,29 @@ NTSTATUS WINAPI RtlValidSecurityDescriptor(
* RtlLengthSecurityDescriptor [NTDLL.@]
*/
ULONG WINAPI RtlLengthSecurityDescriptor(
PSECURITY_DESCRIPTOR SecurityDescriptor)
PSECURITY_DESCRIPTOR pSecurityDescriptor)
{
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
ULONG offset = 0;
ULONG Size = SECURITY_DESCRIPTOR_MIN_LENGTH;
if ( SecurityDescriptor == NULL )
if ( lpsd == NULL )
return 0;
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
offset = (ULONG) SecurityDescriptor;
if ( lpsd->Control & SE_SELF_RELATIVE)
offset = (ULONG) lpsd;
if ( SecurityDescriptor->Owner != NULL )
Size += RtlLengthSid((PSID)((LPBYTE)SecurityDescriptor->Owner + offset));
if ( lpsd->Owner != NULL )
Size += RtlLengthSid((PSID)((LPBYTE)lpsd->Owner + offset));
if ( SecurityDescriptor->Group != NULL )
Size += RtlLengthSid((PSID)((LPBYTE)SecurityDescriptor->Group + offset));
if ( lpsd->Group != NULL )
Size += RtlLengthSid((PSID)((LPBYTE)lpsd->Group + offset));
if ( SecurityDescriptor->Sacl != NULL )
Size += ((PACL)((LPBYTE)SecurityDescriptor->Sacl + offset))->AclSize;
if ( lpsd->Sacl != NULL )
Size += ((PACL)((LPBYTE)lpsd->Sacl + offset))->AclSize;
if ( SecurityDescriptor->Dacl != NULL )
Size += ((PACL)((LPBYTE)SecurityDescriptor->Dacl + offset))->AclSize;
if ( lpsd->Dacl != NULL )
Size += ((PACL)((LPBYTE)lpsd->Dacl + offset))->AclSize;
return Size;
}
@ -426,23 +430,25 @@ NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(
OUT PACL *pDacl,
OUT PBOOLEAN lpbDaclDefaulted)
{
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
TRACE("(%p,%p,%p,%p)\n",
pSecurityDescriptor, lpbDaclPresent, *pDacl, lpbDaclDefaulted);
if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
if (lpsd->Revision != SECURITY_DESCRIPTOR_REVISION)
return STATUS_UNKNOWN_REVISION ;
if ( (*lpbDaclPresent = (SE_DACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
if ( (*lpbDaclPresent = (SE_DACL_PRESENT & lpsd->Control) ? 1 : 0) )
{
if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
{ *pDacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Dacl);
if ( SE_SELF_RELATIVE & lpsd->Control)
{ *pDacl = (PACL) ((LPBYTE)lpsd + (DWORD)lpsd->Dacl);
}
else
{ *pDacl = pSecurityDescriptor->Dacl;
{ *pDacl = lpsd->Dacl;
}
}
*lpbDaclDefaulted = (( SE_DACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
*lpbDaclDefaulted = (( SE_DACL_DEFAULTED & lpsd->Control ) ? 1 : 0);
return STATUS_SUCCESS;
}
@ -451,11 +457,13 @@ NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(
* RtlSetDaclSecurityDescriptor [NTDLL.@]
*/
NTSTATUS WINAPI RtlSetDaclSecurityDescriptor (
PSECURITY_DESCRIPTOR lpsd,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
BOOLEAN daclpresent,
PACL dacl,
BOOLEAN dacldefaulted )
{
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
return STATUS_UNKNOWN_REVISION;
if (lpsd->Control & SE_SELF_RELATIVE)
@ -487,23 +495,25 @@ NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(
OUT PACL *pSacl,
OUT PBOOLEAN lpbSaclDefaulted)
{
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
TRACE("(%p,%p,%p,%p)\n",
pSecurityDescriptor, lpbSaclPresent, *pSacl, lpbSaclDefaulted);
if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
if (lpsd->Revision != SECURITY_DESCRIPTOR_REVISION)
return STATUS_UNKNOWN_REVISION ;
if ( (*lpbSaclPresent = (SE_SACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
if ( (*lpbSaclPresent = (SE_SACL_PRESENT & lpsd->Control) ? 1 : 0) )
{
if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
{ *pSacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Sacl);
if ( SE_SELF_RELATIVE & lpsd->Control)
{ *pSacl = (PACL) ((LPBYTE)lpsd + (DWORD)lpsd->Sacl);
}
else
{ *pSacl = pSecurityDescriptor->Sacl;
{ *pSacl = lpsd->Sacl;
}
}
*lpbSaclDefaulted = (( SE_SACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
*lpbSaclDefaulted = (( SE_SACL_DEFAULTED & lpsd->Control ) ? 1 : 0);
return STATUS_SUCCESS;
}
@ -512,11 +522,13 @@ NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(
* RtlSetSaclSecurityDescriptor [NTDLL.@]
*/
NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (
PSECURITY_DESCRIPTOR lpsd,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
BOOLEAN saclpresent,
PACL sacl,
BOOLEAN sacldefaulted)
{
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
return STATUS_UNKNOWN_REVISION;
if (lpsd->Control & SE_SELF_RELATIVE)
@ -538,22 +550,24 @@ NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (
* RtlGetOwnerSecurityDescriptor [NTDLL.@]
*/
NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(
PSECURITY_DESCRIPTOR SecurityDescriptor,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
PSID *Owner,
PBOOLEAN OwnerDefaulted)
{
if ( !SecurityDescriptor || !Owner || !OwnerDefaulted )
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
if ( !lpsd || !Owner || !OwnerDefaulted )
return STATUS_INVALID_PARAMETER;
if (SecurityDescriptor->Owner != NULL)
if (lpsd->Owner != NULL)
{
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
*Owner = (PSID)((LPBYTE)SecurityDescriptor +
(ULONG)SecurityDescriptor->Owner);
if (lpsd->Control & SE_SELF_RELATIVE)
*Owner = (PSID)((LPBYTE)lpsd +
(ULONG)lpsd->Owner);
else
*Owner = SecurityDescriptor->Owner;
*Owner = lpsd->Owner;
if ( SecurityDescriptor->Control & SE_OWNER_DEFAULTED )
if ( lpsd->Control & SE_OWNER_DEFAULTED )
*OwnerDefaulted = TRUE;
else
*OwnerDefaulted = FALSE;
@ -568,10 +582,12 @@ NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(
* RtlSetOwnerSecurityDescriptor [NTDLL.@]
*/
NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(
PSECURITY_DESCRIPTOR lpsd,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
PSID owner,
BOOLEAN ownerdefaulted)
{
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
return STATUS_UNKNOWN_REVISION;
if (lpsd->Control & SE_SELF_RELATIVE)
@ -589,10 +605,12 @@ NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(
* RtlSetGroupSecurityDescriptor [NTDLL.@]
*/
NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (
PSECURITY_DESCRIPTOR lpsd,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
PSID group,
BOOLEAN groupdefaulted)
{
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
return STATUS_UNKNOWN_REVISION;
if (lpsd->Control & SE_SELF_RELATIVE)
@ -609,22 +627,24 @@ NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (
* RtlGetGroupSecurityDescriptor [NTDLL.@]
*/
NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(
PSECURITY_DESCRIPTOR SecurityDescriptor,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
PSID *Group,
PBOOLEAN GroupDefaulted)
{
if ( !SecurityDescriptor || !Group || !GroupDefaulted )
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
if ( !lpsd || !Group || !GroupDefaulted )
return STATUS_INVALID_PARAMETER;
if (SecurityDescriptor->Group != NULL)
if (lpsd->Group != NULL)
{
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
*Group = (PSID)((LPBYTE)SecurityDescriptor +
(ULONG)SecurityDescriptor->Group);
if (lpsd->Control & SE_SELF_RELATIVE)
*Group = (PSID)((LPBYTE)lpsd +
(ULONG)lpsd->Group);
else
*Group = SecurityDescriptor->Group;
*Group = lpsd->Group;
if ( SecurityDescriptor->Control & SE_GROUP_DEFAULTED )
if ( lpsd->Control & SE_GROUP_DEFAULTED )
*GroupDefaulted = TRUE;
else
*GroupDefaulted = FALSE;
@ -645,8 +665,8 @@ NTSTATUS WINAPI RtlMakeSelfRelativeSD(
{
ULONG offsetRel;
ULONG length;
PSECURITY_DESCRIPTOR pAbs = pAbsoluteSecurityDescriptor;
PSECURITY_DESCRIPTOR pRel = pSelfRelativeSecurityDescriptor;
SECURITY_DESCRIPTOR* pAbs = pAbsoluteSecurityDescriptor;
SECURITY_DESCRIPTOR* pRel = pSelfRelativeSecurityDescriptor;
TRACE(" %p %p %p(%ld)\n", pAbs, pRel, lpdwBufferLength,
lpdwBufferLength ? *lpdwBufferLength: -1);
@ -729,8 +749,8 @@ NTSTATUS WINAPI RtlSelfRelativeToAbsoluteSD(
OUT LPDWORD lpdwPrimaryGroupSize)
{
NTSTATUS status = STATUS_SUCCESS;
PSECURITY_DESCRIPTOR pAbs = pAbsoluteSecurityDescriptor;
PSECURITY_DESCRIPTOR pRel = pSelfRelativeSecurityDescriptor;
SECURITY_DESCRIPTOR* pAbs = pAbsoluteSecurityDescriptor;
SECURITY_DESCRIPTOR* pRel = pSelfRelativeSecurityDescriptor;
if (!pRel ||
!lpdwAbsoluteSecurityDescriptorSize ||

View File

@ -1280,6 +1280,13 @@ static void test_pack_PIMAGE_VXD_HEADER(void)
TEST_TYPE_POINTER(PIMAGE_VXD_HEADER, 196, 2);
}
static void test_pack_PISECURITY_DESCRIPTOR(void)
{
/* PISECURITY_DESCRIPTOR */
TEST_TYPE(PISECURITY_DESCRIPTOR, 4, 4);
TEST_TYPE_POINTER(PISECURITY_DESCRIPTOR, 20, 4);
}
static void test_pack_PISECURITY_DESCRIPTOR_RELATIVE(void)
{
/* PISECURITY_DESCRIPTOR_RELATIVE */
@ -1287,6 +1294,13 @@ static void test_pack_PISECURITY_DESCRIPTOR_RELATIVE(void)
TEST_TYPE_POINTER(PISECURITY_DESCRIPTOR_RELATIVE, 20, 4);
}
static void test_pack_PISID(void)
{
/* PISID */
TEST_TYPE(PISID, 4, 4);
TEST_TYPE_POINTER(PISID, 12, 4);
}
static void test_pack_PLARGE_INTEGER(void)
{
/* PLARGE_INTEGER */
@ -1411,14 +1425,12 @@ static void test_pack_PSECURITY_DESCRIPTOR(void)
{
/* PSECURITY_DESCRIPTOR */
TEST_TYPE(PSECURITY_DESCRIPTOR, 4, 4);
TEST_TYPE_POINTER(PSECURITY_DESCRIPTOR, 20, 4);
}
static void test_pack_PSID(void)
{
/* PSID */
TEST_TYPE(PSID, 4, 4);
TEST_TYPE_POINTER(PSID, 12, 4);
}
static void test_pack_PSID_IDENTIFIER_AUTHORITY(void)
@ -2217,7 +2229,9 @@ static void test_pack(void)
test_pack_PIMAGE_TLS_CALLBACK();
test_pack_PIMAGE_TLS_DIRECTORY();
test_pack_PIMAGE_VXD_HEADER();
test_pack_PISECURITY_DESCRIPTOR();
test_pack_PISECURITY_DESCRIPTOR_RELATIVE();
test_pack_PISID();
test_pack_PLARGE_INTEGER();
test_pack_PLIST_ENTRY();
test_pack_PLUID();

View File

@ -2616,6 +2616,8 @@ typedef struct tagMESSAGE_RESOURCE_DATA {
/* FIXME: Orphan. What does it point to? */
typedef PVOID PACCESS_TOKEN;
typedef PVOID PSECURITY_DESCRIPTOR;
typedef PVOID PSID;
/*
* TOKEN_INFORMATION_CLASS
@ -2693,7 +2695,7 @@ typedef struct _SID {
BYTE SubAuthorityCount;
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
DWORD SubAuthority[1];
} SID,*PSID;
} SID,*PISID;
#endif /* !defined(SID_DEFINED) */
#define SID_REVISION (1) /* Current revision */
@ -2825,7 +2827,7 @@ typedef struct {
PSID Group;
PACL Sacl;
PACL Dacl;
} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
} SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
#define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))

View File

@ -806,7 +806,9 @@ PIMAGE_TLS_CALLBACK
PIMAGE_TLS_DIRECTORY
PIMAGE_VXD_HEADER
!PIO_COUNTERS
PISECURITY_DESCRIPTOR
PISECURITY_DESCRIPTOR_RELATIVE
PISID
PLARGE_INTEGER
PLIST_ENTRY
PLUID