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

View File

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

View File

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

View File

@ -1280,6 +1280,13 @@ static void test_pack_PIMAGE_VXD_HEADER(void)
TEST_TYPE_POINTER(PIMAGE_VXD_HEADER, 196, 2); 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) static void test_pack_PISECURITY_DESCRIPTOR_RELATIVE(void)
{ {
/* PISECURITY_DESCRIPTOR_RELATIVE */ /* PISECURITY_DESCRIPTOR_RELATIVE */
@ -1287,6 +1294,13 @@ static void test_pack_PISECURITY_DESCRIPTOR_RELATIVE(void)
TEST_TYPE_POINTER(PISECURITY_DESCRIPTOR_RELATIVE, 20, 4); 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) static void test_pack_PLARGE_INTEGER(void)
{ {
/* PLARGE_INTEGER */ /* PLARGE_INTEGER */
@ -1411,14 +1425,12 @@ static void test_pack_PSECURITY_DESCRIPTOR(void)
{ {
/* PSECURITY_DESCRIPTOR */ /* PSECURITY_DESCRIPTOR */
TEST_TYPE(PSECURITY_DESCRIPTOR, 4, 4); TEST_TYPE(PSECURITY_DESCRIPTOR, 4, 4);
TEST_TYPE_POINTER(PSECURITY_DESCRIPTOR, 20, 4);
} }
static void test_pack_PSID(void) static void test_pack_PSID(void)
{ {
/* PSID */ /* PSID */
TEST_TYPE(PSID, 4, 4); TEST_TYPE(PSID, 4, 4);
TEST_TYPE_POINTER(PSID, 12, 4);
} }
static void test_pack_PSID_IDENTIFIER_AUTHORITY(void) 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_CALLBACK();
test_pack_PIMAGE_TLS_DIRECTORY(); test_pack_PIMAGE_TLS_DIRECTORY();
test_pack_PIMAGE_VXD_HEADER(); test_pack_PIMAGE_VXD_HEADER();
test_pack_PISECURITY_DESCRIPTOR();
test_pack_PISECURITY_DESCRIPTOR_RELATIVE(); test_pack_PISECURITY_DESCRIPTOR_RELATIVE();
test_pack_PISID();
test_pack_PLARGE_INTEGER(); test_pack_PLARGE_INTEGER();
test_pack_PLIST_ENTRY(); test_pack_PLIST_ENTRY();
test_pack_PLUID(); test_pack_PLUID();

View File

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

View File

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