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); ...@@ -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) ...@@ -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 ( ...@@ -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) ...@@ -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: ...@@ -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( ...@@ -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( ...@@ -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 ) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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;
} }
......
...@@ -179,7 +179,7 @@ NtQuerySecurityObject( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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( ...@@ -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);
......
...@@ -1280,6 +1280,13 @@ static void test_pack_PIMAGE_VXD_HEADER(void) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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();
......
...@@ -2616,6 +2616,8 @@ typedef struct tagMESSAGE_RESOURCE_DATA { ...@@ -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 { ...@@ -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 { ...@@ -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))
......
...@@ -806,7 +806,9 @@ PIMAGE_TLS_CALLBACK ...@@ -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
......
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