Commit 870f55fe authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Fix the PSID and PSECURITY_DESCRIPTOR types.

Add PISID and PISECURITY_DESCRIPTOR.
parent a9b4a471
......@@ -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;
}
......
......@@ -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);
......
......@@ -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();
......
......@@ -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))
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment