1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* Security functions
|
|
|
|
*
|
|
|
|
* Copyright 1996-1998 Marcus Meissner
|
2003-11-11 23:03:24 +01:00
|
|
|
* Copyright 2003 CodeWeavers Inc. (Ulrich Czekalla)
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
|
2002-08-09 03:07:29 +02:00
|
|
|
#include "config.h"
|
2002-08-29 01:42:34 +02:00
|
|
|
#include "wine/port.h"
|
2002-08-09 03:07:29 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-03-09 18:47:51 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <math.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2002-05-09 22:30:52 +02:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
1999-03-09 18:47:51 +01:00
|
|
|
#include "windef.h"
|
2000-06-02 00:47:13 +02:00
|
|
|
#include "ntdll_misc.h"
|
2008-07-03 12:57:43 +02:00
|
|
|
#include "wine/exception.h"
|
2003-11-17 21:31:29 +01:00
|
|
|
#include "wine/library.h"
|
2005-07-11 22:42:12 +02:00
|
|
|
#include "wine/unicode.h"
|
2003-11-17 21:31:29 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
#define NT_SUCCESS(status) (status == STATUS_SUCCESS)
|
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
#define SELF_RELATIVE_FIELD(sd,field) ((BYTE *)(sd) + ((SECURITY_DESCRIPTOR_RELATIVE *)(sd))->field)
|
|
|
|
|
2007-10-31 07:17:31 +01:00
|
|
|
/* helper function to retrieve active length of an ACL */
|
|
|
|
static size_t acl_bytesInUse(PACL pAcl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
size_t bytesInUse = sizeof(ACL);
|
|
|
|
PACE_HEADER ace = (PACE_HEADER) (pAcl + 1);
|
|
|
|
for (i = 0; i < pAcl->AceCount; i++)
|
|
|
|
{
|
|
|
|
bytesInUse += ace->AceSize;
|
|
|
|
ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
|
|
|
}
|
|
|
|
return bytesInUse;
|
|
|
|
}
|
|
|
|
|
2005-06-20 12:34:30 +02:00
|
|
|
/* helper function to copy an ACL */
|
|
|
|
static BOOLEAN copy_acl(DWORD nDestinationAclLength, PACL pDestinationAcl, PACL pSourceAcl)
|
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if (!pSourceAcl || !RtlValidAcl(pSourceAcl))
|
|
|
|
return FALSE;
|
2007-12-28 18:21:48 +01:00
|
|
|
|
|
|
|
size = pSourceAcl->AclSize;
|
2005-06-20 12:34:30 +02:00
|
|
|
if (nDestinationAclLength < size)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memmove(pDestinationAcl, pSourceAcl, size);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-24 14:20:15 +02:00
|
|
|
/* generically adds an ACE to an ACL */
|
|
|
|
static NTSTATUS add_access_ace(PACL pAcl, DWORD dwAceRevision, DWORD dwAceFlags,
|
|
|
|
DWORD dwAccessMask, PSID pSid, DWORD dwAceType)
|
|
|
|
{
|
|
|
|
ACE_HEADER *pAceHeader;
|
2005-06-29 22:14:16 +02:00
|
|
|
DWORD dwLengthSid;
|
2005-06-24 14:20:15 +02:00
|
|
|
DWORD dwAceSize;
|
2005-06-29 22:14:16 +02:00
|
|
|
DWORD *pAccessMask;
|
|
|
|
DWORD *pSidStart;
|
2005-06-24 14:20:15 +02:00
|
|
|
|
2005-06-29 22:14:16 +02:00
|
|
|
if (!RtlValidSid(pSid))
|
2005-06-24 14:20:15 +02:00
|
|
|
return STATUS_INVALID_SID;
|
|
|
|
|
|
|
|
if (pAcl->AclRevision > MAX_ACL_REVISION || dwAceRevision > MAX_ACL_REVISION)
|
|
|
|
return STATUS_REVISION_MISMATCH;
|
|
|
|
|
|
|
|
if (!RtlValidAcl(pAcl))
|
|
|
|
return STATUS_INVALID_ACL;
|
|
|
|
|
|
|
|
if (!RtlFirstFreeAce(pAcl, &pAceHeader))
|
|
|
|
return STATUS_INVALID_ACL;
|
|
|
|
|
|
|
|
if (!pAceHeader)
|
|
|
|
return STATUS_ALLOTTED_SPACE_EXCEEDED;
|
|
|
|
|
|
|
|
/* calculate generic size of the ACE */
|
2005-06-29 22:14:16 +02:00
|
|
|
dwLengthSid = RtlLengthSid(pSid);
|
|
|
|
dwAceSize = sizeof(ACE_HEADER) + sizeof(DWORD) + dwLengthSid;
|
2005-09-12 17:14:06 +02:00
|
|
|
if ((char *)pAceHeader + dwAceSize > (char *)pAcl + pAcl->AclSize)
|
2005-06-24 14:20:15 +02:00
|
|
|
return STATUS_ALLOTTED_SPACE_EXCEEDED;
|
|
|
|
|
2005-06-29 22:14:16 +02:00
|
|
|
/* fill the new ACE */
|
2005-06-24 14:20:15 +02:00
|
|
|
pAceHeader->AceType = dwAceType;
|
|
|
|
pAceHeader->AceFlags = dwAceFlags;
|
|
|
|
pAceHeader->AceSize = dwAceSize;
|
2005-06-29 22:14:16 +02:00
|
|
|
|
|
|
|
/* skip past the ACE_HEADER of the ACE */
|
|
|
|
pAccessMask = (DWORD *)(pAceHeader + 1);
|
2005-06-24 14:20:15 +02:00
|
|
|
*pAccessMask = dwAccessMask;
|
|
|
|
|
2005-06-29 22:14:16 +02:00
|
|
|
/* skip past ACE->Mask */
|
|
|
|
pSidStart = pAccessMask + 1;
|
2009-03-17 00:12:11 +01:00
|
|
|
RtlCopySid(dwLengthSid, pSidStart, pSid);
|
2005-06-24 14:20:15 +02:00
|
|
|
|
2005-06-29 22:14:16 +02:00
|
|
|
pAcl->AclRevision = max(pAcl->AclRevision, dwAceRevision);
|
2005-06-24 14:20:15 +02:00
|
|
|
pAcl->AceCount++;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* SID FUNCTIONS
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlAllocateAndInitializeSid [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
|
|
|
*/
|
2004-12-22 16:31:16 +01:00
|
|
|
NTSTATUS WINAPI RtlAllocateAndInitializeSid (
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
|
|
|
BYTE nSubAuthorityCount,
|
|
|
|
DWORD nSubAuthority0, DWORD nSubAuthority1,
|
|
|
|
DWORD nSubAuthority2, DWORD nSubAuthority3,
|
|
|
|
DWORD nSubAuthority4, DWORD nSubAuthority5,
|
|
|
|
DWORD nSubAuthority6, DWORD nSubAuthority7,
|
|
|
|
PSID *pSid )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-11-15 13:03:46 +01:00
|
|
|
SID *tmp_sid;
|
2004-08-14 01:55:43 +02:00
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p, 0x%04x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,%p)\n",
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
pIdentifierAuthority,nSubAuthorityCount,
|
|
|
|
nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
|
|
|
|
nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, pSid);
|
|
|
|
|
2005-11-15 13:03:46 +01:00
|
|
|
if (nSubAuthorityCount > 8) return STATUS_INVALID_SID;
|
|
|
|
|
|
|
|
if (!(tmp_sid= RtlAllocateHeap( GetProcessHeap(), 0,
|
|
|
|
RtlLengthRequiredSid(nSubAuthorityCount))))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
tmp_sid->Revision = SID_REVISION;
|
|
|
|
|
|
|
|
if (pIdentifierAuthority)
|
2008-03-08 16:37:05 +01:00
|
|
|
tmp_sid->IdentifierAuthority = *pIdentifierAuthority;
|
2005-11-15 13:03:46 +01:00
|
|
|
tmp_sid->SubAuthorityCount = nSubAuthorityCount;
|
|
|
|
|
|
|
|
switch( nSubAuthorityCount )
|
|
|
|
{
|
|
|
|
case 8: tmp_sid->SubAuthority[7]= nSubAuthority7;
|
2011-10-08 18:51:42 +02:00
|
|
|
/* fall through */
|
2005-11-15 13:03:46 +01:00
|
|
|
case 7: tmp_sid->SubAuthority[6]= nSubAuthority6;
|
2011-10-08 18:51:42 +02:00
|
|
|
/* fall through */
|
2005-11-15 13:03:46 +01:00
|
|
|
case 6: tmp_sid->SubAuthority[5]= nSubAuthority5;
|
2011-10-08 18:51:42 +02:00
|
|
|
/* fall through */
|
2005-11-15 13:03:46 +01:00
|
|
|
case 5: tmp_sid->SubAuthority[4]= nSubAuthority4;
|
2011-10-08 18:51:42 +02:00
|
|
|
/* fall through */
|
2005-11-15 13:03:46 +01:00
|
|
|
case 4: tmp_sid->SubAuthority[3]= nSubAuthority3;
|
2011-10-08 18:51:42 +02:00
|
|
|
/* fall through */
|
2005-11-15 13:03:46 +01:00
|
|
|
case 3: tmp_sid->SubAuthority[2]= nSubAuthority2;
|
2011-10-08 18:51:42 +02:00
|
|
|
/* fall through */
|
2005-11-15 13:03:46 +01:00
|
|
|
case 2: tmp_sid->SubAuthority[1]= nSubAuthority1;
|
2011-10-08 18:51:42 +02:00
|
|
|
/* fall through */
|
2005-11-15 13:03:46 +01:00
|
|
|
case 1: tmp_sid->SubAuthority[0]= nSubAuthority0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*pSid = tmp_sid;
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
2005-11-15 13:03:46 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlEqualSid [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Determine if two SIDs are equal.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid1 [I] Source SID
|
|
|
|
* pSid2 [I] SID to compare with
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE, if pSid1 is equal to pSid2,
|
|
|
|
* FALSE otherwise.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
BOOL WINAPI RtlEqualSid( PSID pSid1, PSID pSid2 )
|
|
|
|
{
|
|
|
|
if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
|
|
|
|
return FALSE;
|
|
|
|
|
2000-07-25 17:10:52 +02:00
|
|
|
if (memcmp(pSid1, pSid2, RtlLengthSid(pSid1)) != 0)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* RtlEqualPrefixSid [NTDLL.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
|
|
|
if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
|
|
|
|
return FALSE;
|
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(((SID*)pSid1)->SubAuthorityCount - 1)) != 0)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlFreeSid [NTDLL.@]
|
2003-03-17 22:21:00 +01:00
|
|
|
*
|
|
|
|
* Free the resources used by a SID.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid [I] SID to Free.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* STATUS_SUCCESS.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD WINAPI RtlFreeSid(PSID pSid)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
TRACE("(%p)\n", pSid);
|
2004-03-12 02:59:35 +01:00
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, pSid );
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlLengthRequiredSid [NTDLL.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Determine the amount of memory a SID will use
|
|
|
|
*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* PARAMS
|
2003-03-17 22:21:00 +01:00
|
|
|
* nrofsubauths [I] Number of Sub Authorities in the SID.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The size, in bytes, of a SID with nrofsubauths Sub Authorities.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
DWORD WINAPI RtlLengthRequiredSid(DWORD nrofsubauths)
|
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return (nrofsubauths-1)*sizeof(DWORD) + sizeof(SID);
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlLengthSid [NTDLL.@]
|
2003-03-17 22:21:00 +01:00
|
|
|
*
|
|
|
|
* Determine the amount of memory a SID is using
|
|
|
|
*
|
|
|
|
* PARAMS
|
2005-02-25 15:07:56 +01:00
|
|
|
* pSid [I] SID to get the size of.
|
2003-03-17 22:21:00 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The size, in bytes, of pSid.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
DWORD WINAPI RtlLengthSid(PSID pSid)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
TRACE("sid=%p\n",pSid);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!pSid) return 0;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlLengthRequiredSid(*RtlSubAuthorityCountSid(pSid));
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlInitializeSid [NTDLL.@]
|
2003-03-17 22:21:00 +01:00
|
|
|
*
|
|
|
|
* Initialise a SID.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid [I] SID to initialise
|
|
|
|
* pIdentifierAuthority [I] Identifier Authority
|
|
|
|
* nSubAuthorityCount [I] Number of Sub Authorities
|
|
|
|
*
|
|
|
|
* RETURNS
|
2005-02-25 15:07:56 +01:00
|
|
|
* Success: TRUE. pSid is initialised with the details given.
|
2003-03-17 22:21:00 +01:00
|
|
|
* Failure: FALSE, if nSubAuthorityCount is >= SID_MAX_SUB_AUTHORITIES.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
BOOL WINAPI RtlInitializeSid(
|
|
|
|
PSID pSid,
|
|
|
|
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
|
|
|
BYTE nSubAuthorityCount)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
int i;
|
2004-08-14 01:55:43 +02:00
|
|
|
SID* pisid=pSid;
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
if (nSubAuthorityCount >= SID_MAX_SUB_AUTHORITIES)
|
|
|
|
return FALSE;
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
pisid->Revision = SID_REVISION;
|
|
|
|
pisid->SubAuthorityCount = nSubAuthorityCount;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
if (pIdentifierAuthority)
|
2008-03-08 16:37:05 +01:00
|
|
|
pisid->IdentifierAuthority = *pIdentifierAuthority;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
for (i = 0; i < nSubAuthorityCount; i++)
|
2000-07-25 17:10:52 +02:00
|
|
|
*RtlSubAuthoritySid(pSid, i) = 0;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
return TRUE;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlSubAuthoritySid [NTDLL.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Return the Sub Authority of a SID
|
|
|
|
*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* PARAMS
|
2003-03-17 22:21:00 +01:00
|
|
|
* pSid [I] SID to get the Sub Authority from.
|
|
|
|
* nSubAuthority [I] Sub Authority number.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* A pointer to The Sub Authority value of pSid.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
LPDWORD WINAPI RtlSubAuthoritySid( PSID pSid, DWORD nSubAuthority )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
return &(((SID*)pSid)->SubAuthority[nSubAuthority]);
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlIdentifierAuthoritySid [NTDLL.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Return the Identifier Authority of a SID.
|
|
|
|
*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* PARAMS
|
2003-03-17 22:21:00 +01:00
|
|
|
* pSid [I] SID to get the Identifier Authority from.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* A pointer to the Identifier Authority value of pSid.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
return &(((SID*)pSid)->IdentifierAuthority);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
1999-03-09 18:47:51 +01:00
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlSubAuthorityCountSid [NTDLL.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Get the number of Sub Authorities in a SID.
|
|
|
|
*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* PARAMS
|
2003-03-17 22:21:00 +01:00
|
|
|
* pSid [I] SID to get the count from.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* A pointer to the Sub Authority count of pSid.
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
|
|
|
LPBYTE WINAPI RtlSubAuthorityCountSid(PSID pSid)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
return &(((SID*)pSid)->SubAuthorityCount);
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlCopySid [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
BOOLEAN WINAPI RtlCopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
|
|
|
if (!pSourceSid || !RtlValidSid(pSourceSid) ||
|
|
|
|
(nDestinationSidLength < RtlLengthSid(pSourceSid)))
|
|
|
|
return FALSE;
|
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
if (nDestinationSidLength < (((SID*)pSourceSid)->SubAuthorityCount*4+8))
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
memmove(pDestinationSid, pSourceSid, ((SID*)pSourceSid)->SubAuthorityCount*4+8);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlValidSid [NTDLL.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Determine if a SID is valid.
|
|
|
|
*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* PARAMS
|
2003-03-17 22:21:00 +01:00
|
|
|
* pSid [I] SID to check
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if pSid is valid,
|
|
|
|
* FALSE otherwise.
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2003-05-01 02:29:26 +02:00
|
|
|
BOOLEAN WINAPI RtlValidSid( PSID pSid )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-09-29 02:31:57 +02:00
|
|
|
BOOL ret;
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
2004-08-14 01:55:43 +02:00
|
|
|
if (!pSid || ((SID*)pSid)->Revision != SID_REVISION ||
|
|
|
|
((SID*)pSid)->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
|
2000-09-29 02:31:57 +02:00
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2005-12-16 17:17:57 +01:00
|
|
|
__EXCEPT_PAGE_FAULT
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
|
|
|
WARN("(%p): invalid pointer!\n", pSid);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-09-29 02:31:57 +02:00
|
|
|
__ENDTRY
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* security descriptor functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlCreateSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Initialise a SECURITY_DESCRIPTOR.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpsd [O] Descriptor to initialise.
|
|
|
|
* rev [I] Revision, must be set to SECURITY_DESCRIPTOR_REVISION.
|
|
|
|
*
|
2005-11-09 11:30:57 +01:00
|
|
|
* RETURNS
|
2003-03-17 22:21:00 +01:00
|
|
|
* Success: STATUS_SUCCESS.
|
|
|
|
* Failure: STATUS_UNKNOWN_REVISION if rev is incorrect.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlCreateSecurityDescriptor(
|
|
|
|
PSECURITY_DESCRIPTOR lpsd,
|
|
|
|
DWORD rev)
|
|
|
|
{
|
|
|
|
if (rev!=SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
2004-08-16 21:59:09 +02:00
|
|
|
memset(lpsd,'\0',sizeof(SECURITY_DESCRIPTOR));
|
2004-08-14 01:55:43 +02:00
|
|
|
((SECURITY_DESCRIPTOR*)lpsd)->Revision = SECURITY_DESCRIPTOR_REVISION;
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2005-06-20 12:34:30 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RtlCopySecurityDescriptor [NTDLL.@]
|
|
|
|
*
|
|
|
|
* Copies an absolute or sefl-relative SECURITY_DESCRIPTOR.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSourceSD [O] SD to copy from.
|
|
|
|
* pDestinationSD [I] Destination SD.
|
|
|
|
*
|
2005-11-09 11:30:57 +01:00
|
|
|
* RETURNS
|
2005-06-20 12:34:30 +02:00
|
|
|
* Success: STATUS_SUCCESS.
|
|
|
|
* Failure: STATUS_UNKNOWN_REVISION if rev is incorrect.
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlCopySecurityDescriptor(PSECURITY_DESCRIPTOR pSourceSD, PSECURITY_DESCRIPTOR pDestinationSD)
|
|
|
|
{
|
|
|
|
PSID Owner, Group;
|
|
|
|
PACL Dacl, Sacl;
|
|
|
|
DWORD length;
|
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
if (((SECURITY_DESCRIPTOR *)pSourceSD)->Control & SE_SELF_RELATIVE)
|
2005-06-20 12:34:30 +02:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *src = pSourceSD;
|
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *dst = pDestinationSD;
|
2005-06-20 12:34:30 +02:00
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
if (src->Revision != SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
2005-06-20 12:34:30 +02:00
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
*dst = *src;
|
|
|
|
if (src->Owner)
|
|
|
|
{
|
|
|
|
Owner = (PSID)SELF_RELATIVE_FIELD( src, Owner );
|
|
|
|
length = RtlLengthSid( Owner );
|
|
|
|
RtlCopySid(length, SELF_RELATIVE_FIELD( dst, Owner ), Owner);
|
|
|
|
}
|
|
|
|
if (src->Group)
|
|
|
|
{
|
|
|
|
Group = (PSID)SELF_RELATIVE_FIELD( src, Group );
|
|
|
|
length = RtlLengthSid( Group );
|
|
|
|
RtlCopySid(length, SELF_RELATIVE_FIELD( dst, Group ), Group);
|
|
|
|
}
|
2010-02-18 12:57:33 +01:00
|
|
|
if ((src->Control & SE_SACL_PRESENT) && src->Sacl)
|
2009-06-16 13:29:05 +02:00
|
|
|
{
|
|
|
|
Sacl = (PACL)SELF_RELATIVE_FIELD( src, Sacl );
|
|
|
|
copy_acl(Sacl->AclSize, (PACL)SELF_RELATIVE_FIELD( dst, Sacl ), Sacl);
|
|
|
|
}
|
2010-02-18 12:57:33 +01:00
|
|
|
if ((src->Control & SE_DACL_PRESENT) && src->Dacl)
|
2009-06-16 13:29:05 +02:00
|
|
|
{
|
|
|
|
Dacl = (PACL)SELF_RELATIVE_FIELD( src, Dacl );
|
|
|
|
copy_acl(Dacl->AclSize, (PACL)SELF_RELATIVE_FIELD( dst, Dacl ), Dacl);
|
|
|
|
}
|
2005-06-20 12:34:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
SECURITY_DESCRIPTOR *src = pSourceSD;
|
|
|
|
SECURITY_DESCRIPTOR *dst = pDestinationSD;
|
2005-06-20 12:34:30 +02:00
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
if (src->Revision != SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
2005-06-20 12:34:30 +02:00
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
*dst = *src;
|
|
|
|
if (src->Owner)
|
2005-06-20 12:34:30 +02:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
length = RtlLengthSid( src->Owner );
|
|
|
|
dst->Owner = RtlAllocateHeap(GetProcessHeap(), 0, length);
|
|
|
|
RtlCopySid(length, dst->Owner, src->Owner);
|
2005-06-20 12:34:30 +02:00
|
|
|
}
|
2009-06-16 13:29:05 +02:00
|
|
|
if (src->Group)
|
2005-06-20 12:34:30 +02:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
length = RtlLengthSid( src->Group );
|
|
|
|
dst->Group = RtlAllocateHeap(GetProcessHeap(), 0, length);
|
|
|
|
RtlCopySid(length, dst->Group, src->Group);
|
2005-06-20 12:34:30 +02:00
|
|
|
}
|
2009-06-16 13:29:05 +02:00
|
|
|
if (src->Control & SE_SACL_PRESENT)
|
2005-06-20 12:34:30 +02:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
length = src->Sacl->AclSize;
|
|
|
|
dst->Sacl = RtlAllocateHeap(GetProcessHeap(), 0, length);
|
|
|
|
copy_acl(length, dst->Sacl, src->Sacl);
|
2005-06-20 12:34:30 +02:00
|
|
|
}
|
2009-06-16 13:29:05 +02:00
|
|
|
if (src->Control & SE_DACL_PRESENT)
|
2005-06-20 12:34:30 +02:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
length = src->Dacl->AclSize;
|
|
|
|
dst->Dacl = RtlAllocateHeap(GetProcessHeap(), 0, length);
|
|
|
|
copy_acl(length, dst->Dacl, src->Dacl);
|
2005-06-20 12:34:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlValidSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
2003-03-17 22:21:00 +01:00
|
|
|
* Determine if a SECURITY_DESCRIPTOR is valid.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* SecurityDescriptor [I] Descriptor to check.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: STATUS_SUCCESS.
|
|
|
|
* Failure: STATUS_INVALID_SECURITY_DESCR or STATUS_UNKNOWN_REVISION.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlValidSecurityDescriptor(
|
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor)
|
|
|
|
{
|
|
|
|
if ( ! SecurityDescriptor )
|
|
|
|
return STATUS_INVALID_SECURITY_DESCR;
|
2004-08-14 01:55:43 +02:00
|
|
|
if ( ((SECURITY_DESCRIPTOR*)SecurityDescriptor)->Revision != SECURITY_DESCRIPTOR_REVISION )
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_UNKNOWN_REVISION;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-10-12 05:21:30 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlValidRelativeSecurityDescriptor [NTDLL.@]
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlValidRelativeSecurityDescriptor(PSECURITY_DESCRIPTOR descriptor,
|
|
|
|
ULONG length, SECURITY_INFORMATION info)
|
|
|
|
{
|
|
|
|
FIXME("%p,%u,%d: semi-stub\n", descriptor, length, info);
|
|
|
|
return RtlValidSecurityDescriptor(descriptor) == STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlLengthSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
ULONG WINAPI RtlLengthSecurityDescriptor(
|
2004-08-14 01:55:43 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
ULONG size;
|
2003-11-05 02:41:20 +01:00
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
if ( pSecurityDescriptor == NULL )
|
1999-03-09 18:47:51 +01:00
|
|
|
return 0;
|
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
if (((SECURITY_DESCRIPTOR *)pSecurityDescriptor)->Control & SE_SELF_RELATIVE)
|
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *sd = pSecurityDescriptor;
|
|
|
|
size = sizeof(*sd);
|
|
|
|
if (sd->Owner) size += RtlLengthSid((PSID)SELF_RELATIVE_FIELD(sd,Owner));
|
|
|
|
if (sd->Group) size += RtlLengthSid((PSID)SELF_RELATIVE_FIELD(sd,Group));
|
|
|
|
if ((sd->Control & SE_SACL_PRESENT) && sd->Sacl)
|
|
|
|
size += ((PACL)SELF_RELATIVE_FIELD(sd,Sacl))->AclSize;
|
|
|
|
if ((sd->Control & SE_DACL_PRESENT) && sd->Dacl)
|
|
|
|
size += ((PACL)SELF_RELATIVE_FIELD(sd,Dacl))->AclSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR *sd = pSecurityDescriptor;
|
|
|
|
size = sizeof(*sd);
|
|
|
|
if (sd->Owner) size += RtlLengthSid( sd->Owner );
|
|
|
|
if (sd->Group) size += RtlLengthSid( sd->Group );
|
|
|
|
if ((sd->Control & SE_SACL_PRESENT) && sd->Sacl) size += sd->Sacl->AclSize;
|
|
|
|
if ((sd->Control & SE_DACL_PRESENT) && sd->Dacl) size += sd->Dacl->AclSize;
|
|
|
|
}
|
|
|
|
return size;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlGetDaclSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(
|
|
|
|
IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
OUT PBOOLEAN lpbDaclPresent,
|
|
|
|
OUT PACL *pDacl,
|
|
|
|
OUT PBOOLEAN lpbDaclDefaulted)
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
1999-05-23 12:25:25 +02:00
|
|
|
TRACE("(%p,%p,%p,%p)\n",
|
2005-01-20 11:37:36 +01:00
|
|
|
pSecurityDescriptor, lpbDaclPresent, pDacl, lpbDaclDefaulted);
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
if (lpsd->Revision != SECURITY_DESCRIPTOR_REVISION)
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_UNKNOWN_REVISION ;
|
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
if ( (*lpbDaclPresent = (SE_DACL_PRESENT & lpsd->Control) ? 1 : 0) )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2011-03-09 13:44:11 +01:00
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *sdr = pSecurityDescriptor;
|
|
|
|
if (sdr->Dacl) *pDacl = (PACL)SELF_RELATIVE_FIELD( sdr, Dacl );
|
|
|
|
else *pDacl = NULL;
|
|
|
|
}
|
|
|
|
else *pDacl = lpsd->Dacl;
|
|
|
|
|
|
|
|
*lpbDaclDefaulted = (lpsd->Control & SE_DACL_DEFAULTED) != 0;
|
2009-01-03 16:35:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pDacl = NULL;
|
|
|
|
*lpbDaclDefaulted = 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlSetDaclSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlSetDaclSecurityDescriptor (
|
2004-08-14 01:55:43 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-03-09 18:47:51 +01:00
|
|
|
BOOLEAN daclpresent,
|
|
|
|
PACL dacl,
|
|
|
|
BOOLEAN dacldefaulted )
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
return STATUS_INVALID_SECURITY_DESCR;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!daclpresent)
|
2007-10-16 10:50:28 +02:00
|
|
|
{
|
|
|
|
lpsd->Control &= ~SE_DACL_PRESENT;
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
lpsd->Control |= SE_DACL_PRESENT;
|
|
|
|
lpsd->Dacl = dacl;
|
|
|
|
|
|
|
|
if (dacldefaulted)
|
|
|
|
lpsd->Control |= SE_DACL_DEFAULTED;
|
|
|
|
else
|
|
|
|
lpsd->Control &= ~SE_DACL_DEFAULTED;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlGetSaclSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(
|
|
|
|
IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
OUT PBOOLEAN lpbSaclPresent,
|
|
|
|
OUT PACL *pSacl,
|
|
|
|
OUT PBOOLEAN lpbSaclDefaulted)
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
1999-05-23 12:25:25 +02:00
|
|
|
TRACE("(%p,%p,%p,%p)\n",
|
2007-10-31 07:17:31 +01:00
|
|
|
pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted);
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
if (lpsd->Revision != SECURITY_DESCRIPTOR_REVISION)
|
2005-01-20 11:37:36 +01:00
|
|
|
return STATUS_UNKNOWN_REVISION;
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
if ( (*lpbSaclPresent = (SE_SACL_PRESENT & lpsd->Control) ? 1 : 0) )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2011-03-09 13:44:11 +01:00
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *sdr = pSecurityDescriptor;
|
|
|
|
if (sdr->Sacl) *pSacl = (PACL)SELF_RELATIVE_FIELD( sdr, Sacl );
|
|
|
|
else *pSacl = NULL;
|
|
|
|
}
|
|
|
|
else *pSacl = lpsd->Sacl;
|
|
|
|
|
|
|
|
*lpbSaclDefaulted = (lpsd->Control & SE_SACL_DEFAULTED) != 0;
|
2005-01-20 11:37:36 +01:00
|
|
|
}
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlSetSaclSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (
|
2004-08-14 01:55:43 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-03-09 18:47:51 +01:00
|
|
|
BOOLEAN saclpresent,
|
|
|
|
PACL sacl,
|
|
|
|
BOOLEAN sacldefaulted)
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
return STATUS_INVALID_SECURITY_DESCR;
|
|
|
|
if (!saclpresent) {
|
|
|
|
lpsd->Control &= ~SE_SACL_PRESENT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lpsd->Control |= SE_SACL_PRESENT;
|
|
|
|
lpsd->Sacl = sacl;
|
|
|
|
if (sacldefaulted)
|
|
|
|
lpsd->Control |= SE_SACL_DEFAULTED;
|
|
|
|
else
|
|
|
|
lpsd->Control &= ~SE_SACL_DEFAULTED;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlGetOwnerSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(
|
2004-08-14 01:55:43 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-03-09 18:47:51 +01:00
|
|
|
PSID *Owner,
|
|
|
|
PBOOLEAN OwnerDefaulted)
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
|
|
|
if ( !lpsd || !Owner || !OwnerDefaulted )
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
2007-09-27 19:36:58 +02:00
|
|
|
if ( lpsd->Control & SE_OWNER_DEFAULTED )
|
|
|
|
*OwnerDefaulted = TRUE;
|
|
|
|
else
|
|
|
|
*OwnerDefaulted = FALSE;
|
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *sd = pSecurityDescriptor;
|
|
|
|
if (sd->Owner) *Owner = (PSID)SELF_RELATIVE_FIELD( sd, Owner );
|
|
|
|
else *Owner = NULL;
|
2003-11-05 02:41:20 +01:00
|
|
|
}
|
2009-06-16 13:29:05 +02:00
|
|
|
else
|
|
|
|
*Owner = lpsd->Owner;
|
2003-11-05 02:41:20 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlSetOwnerSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(
|
2004-08-14 01:55:43 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-03-09 18:47:51 +01:00
|
|
|
PSID owner,
|
|
|
|
BOOLEAN ownerdefaulted)
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
return STATUS_INVALID_SECURITY_DESCR;
|
|
|
|
|
|
|
|
lpsd->Owner = owner;
|
|
|
|
if (ownerdefaulted)
|
|
|
|
lpsd->Control |= SE_OWNER_DEFAULTED;
|
|
|
|
else
|
|
|
|
lpsd->Control &= ~SE_OWNER_DEFAULTED;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlSetGroupSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (
|
2004-08-14 01:55:43 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-03-09 18:47:51 +01:00
|
|
|
PSID group,
|
|
|
|
BOOLEAN groupdefaulted)
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
return STATUS_INVALID_SECURITY_DESCR;
|
|
|
|
|
|
|
|
lpsd->Group = group;
|
|
|
|
if (groupdefaulted)
|
|
|
|
lpsd->Control |= SE_GROUP_DEFAULTED;
|
|
|
|
else
|
|
|
|
lpsd->Control &= ~SE_GROUP_DEFAULTED;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2005-01-20 11:37:36 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlGetGroupSecurityDescriptor [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(
|
2004-08-14 01:55:43 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-03-09 18:47:51 +01:00
|
|
|
PSID *Group,
|
|
|
|
PBOOLEAN GroupDefaulted)
|
|
|
|
{
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* lpsd=pSecurityDescriptor;
|
|
|
|
|
|
|
|
if ( !lpsd || !Group || !GroupDefaulted )
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
2007-09-27 19:36:58 +02:00
|
|
|
if ( lpsd->Control & SE_GROUP_DEFAULTED )
|
|
|
|
*GroupDefaulted = TRUE;
|
|
|
|
else
|
|
|
|
*GroupDefaulted = FALSE;
|
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
if (lpsd->Control & SE_SELF_RELATIVE)
|
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *sd = pSecurityDescriptor;
|
|
|
|
if (sd->Group) *Group = (PSID)SELF_RELATIVE_FIELD( sd, Group );
|
|
|
|
else *Group = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*Group = lpsd->Group;
|
2003-11-05 02:41:20 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_SUCCESS;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-03-09 18:47:51 +01:00
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/**************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlMakeSelfRelativeSD [NTDLL.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlMakeSelfRelativeSD(
|
|
|
|
IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
|
|
|
|
IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
|
|
|
|
IN OUT LPDWORD lpdwBufferLength)
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
DWORD offsetRel;
|
2003-11-05 02:41:20 +01:00
|
|
|
ULONG length;
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* pAbs = pAbsoluteSecurityDescriptor;
|
2009-06-16 13:29:05 +02:00
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *pRel = pSelfRelativeSecurityDescriptor;
|
2003-11-05 02:41:20 +01:00
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE(" %p %p %p(%d)\n", pAbs, pRel, lpdwBufferLength,
|
2003-11-05 02:41:20 +01:00
|
|
|
lpdwBufferLength ? *lpdwBufferLength: -1);
|
|
|
|
|
|
|
|
if (!lpdwBufferLength || !pAbs)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
length = RtlLengthSecurityDescriptor(pAbs);
|
|
|
|
if (*lpdwBufferLength < length)
|
|
|
|
{
|
|
|
|
*lpdwBufferLength = length;
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pRel)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (pAbs->Control & SE_SELF_RELATIVE)
|
|
|
|
{
|
|
|
|
memcpy(pRel, pAbs, length);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
pRel->Revision = pAbs->Revision;
|
|
|
|
pRel->Sbz1 = pAbs->Sbz1;
|
|
|
|
pRel->Control = pAbs->Control | SE_SELF_RELATIVE;
|
|
|
|
|
2009-06-16 13:29:05 +02:00
|
|
|
offsetRel = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
|
2007-09-27 19:34:53 +02:00
|
|
|
if (pAbs->Owner)
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Owner = offsetRel;
|
2007-09-27 19:34:53 +02:00
|
|
|
length = RtlLengthSid(pAbs->Owner);
|
|
|
|
memcpy((LPBYTE)pRel + offsetRel, pAbs->Owner, length);
|
|
|
|
offsetRel += length;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Owner = 0;
|
2007-09-27 19:34:53 +02:00
|
|
|
}
|
2003-11-05 02:41:20 +01:00
|
|
|
|
2007-09-27 19:34:53 +02:00
|
|
|
if (pAbs->Group)
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Group = offsetRel;
|
2007-09-27 19:34:53 +02:00
|
|
|
length = RtlLengthSid(pAbs->Group);
|
|
|
|
memcpy((LPBYTE)pRel + offsetRel, pAbs->Group, length);
|
2003-11-05 02:41:20 +01:00
|
|
|
offsetRel += length;
|
2007-09-27 19:34:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Group = 0;
|
2007-09-27 19:34:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pAbs->Sacl)
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Sacl = offsetRel;
|
2003-11-05 02:41:20 +01:00
|
|
|
length = pAbs->Sacl->AclSize;
|
|
|
|
memcpy((LPBYTE)pRel + offsetRel, pAbs->Sacl, length);
|
2007-09-27 19:34:53 +02:00
|
|
|
offsetRel += length;
|
2003-11-05 02:41:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Sacl = 0;
|
2003-11-05 02:41:20 +01:00
|
|
|
}
|
|
|
|
|
2007-09-27 19:34:53 +02:00
|
|
|
if (pAbs->Dacl)
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Dacl = offsetRel;
|
2003-11-05 02:41:20 +01:00
|
|
|
length = pAbs->Dacl->AclSize;
|
|
|
|
memcpy((LPBYTE)pRel + offsetRel, pAbs->Dacl, length);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
pRel->Dacl = 0;
|
2003-11-05 02:41:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-01-20 11:37:36 +01:00
|
|
|
* RtlSelfRelativeToAbsoluteSD [NTDLL.@]
|
|
|
|
*/
|
2003-11-05 02:41:20 +01:00
|
|
|
NTSTATUS WINAPI RtlSelfRelativeToAbsoluteSD(
|
|
|
|
IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
|
|
|
|
OUT PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
|
|
|
|
OUT LPDWORD lpdwAbsoluteSecurityDescriptorSize,
|
|
|
|
OUT PACL pDacl,
|
|
|
|
OUT LPDWORD lpdwDaclSize,
|
|
|
|
OUT PACL pSacl,
|
|
|
|
OUT LPDWORD lpdwSaclSize,
|
|
|
|
OUT PSID pOwner,
|
|
|
|
OUT LPDWORD lpdwOwnerSize,
|
|
|
|
OUT PSID pPrimaryGroup,
|
|
|
|
OUT LPDWORD lpdwPrimaryGroupSize)
|
|
|
|
{
|
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* pAbs = pAbsoluteSecurityDescriptor;
|
2009-06-16 13:29:05 +02:00
|
|
|
SECURITY_DESCRIPTOR_RELATIVE* pRel = pSelfRelativeSecurityDescriptor;
|
2003-11-05 02:41:20 +01:00
|
|
|
|
|
|
|
if (!pRel ||
|
|
|
|
!lpdwAbsoluteSecurityDescriptorSize ||
|
|
|
|
!lpdwDaclSize ||
|
|
|
|
!lpdwSaclSize ||
|
|
|
|
!lpdwOwnerSize ||
|
|
|
|
!lpdwPrimaryGroupSize ||
|
|
|
|
~pRel->Control & SE_SELF_RELATIVE)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* Confirm buffers are sufficiently large */
|
|
|
|
if (*lpdwAbsoluteSecurityDescriptorSize < sizeof(SECURITY_DESCRIPTOR))
|
|
|
|
{
|
|
|
|
*lpdwAbsoluteSecurityDescriptorSize = sizeof(SECURITY_DESCRIPTOR);
|
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
2010-02-18 12:57:33 +01:00
|
|
|
if ((pRel->Control & SE_DACL_PRESENT) && pRel->Dacl &&
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwDaclSize < ((PACL)SELF_RELATIVE_FIELD(pRel,Dacl))->AclSize)
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwDaclSize = ((PACL)SELF_RELATIVE_FIELD(pRel,Dacl))->AclSize;
|
2003-11-05 02:41:20 +01:00
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
2010-02-18 12:57:33 +01:00
|
|
|
if ((pRel->Control & SE_SACL_PRESENT) && pRel->Sacl &&
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwSaclSize < ((PACL)SELF_RELATIVE_FIELD(pRel,Sacl))->AclSize)
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwSaclSize = ((PACL)SELF_RELATIVE_FIELD(pRel,Sacl))->AclSize;
|
2003-11-05 02:41:20 +01:00
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pRel->Owner &&
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwOwnerSize < RtlLengthSid((PSID)SELF_RELATIVE_FIELD(pRel,Owner)))
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwOwnerSize = RtlLengthSid((PSID)SELF_RELATIVE_FIELD(pRel,Owner));
|
2003-11-05 02:41:20 +01:00
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pRel->Group &&
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwPrimaryGroupSize < RtlLengthSid((PSID)SELF_RELATIVE_FIELD(pRel,Group)))
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
*lpdwPrimaryGroupSize = RtlLengthSid((PSID)SELF_RELATIVE_FIELD(pRel,Group));
|
2003-11-05 02:41:20 +01:00
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
return status;
|
|
|
|
|
2007-03-24 17:32:41 +01:00
|
|
|
/* Copy structures, and clear the ones we don't set */
|
2003-11-05 02:41:20 +01:00
|
|
|
pAbs->Revision = pRel->Revision;
|
|
|
|
pAbs->Control = pRel->Control & ~SE_SELF_RELATIVE;
|
2007-03-24 17:32:41 +01:00
|
|
|
pAbs->Sacl = NULL;
|
|
|
|
pAbs->Dacl = NULL;
|
|
|
|
pAbs->Owner = NULL;
|
|
|
|
pAbs->Group = NULL;
|
2003-11-05 02:41:20 +01:00
|
|
|
|
2010-02-18 12:57:33 +01:00
|
|
|
if ((pRel->Control & SE_SACL_PRESENT) && pRel->Sacl)
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
PACL pAcl = (PACL)SELF_RELATIVE_FIELD( pRel, Sacl );
|
2003-11-05 02:41:20 +01:00
|
|
|
|
|
|
|
memcpy(pSacl, pAcl, pAcl->AclSize);
|
|
|
|
pAbs->Sacl = pSacl;
|
|
|
|
}
|
|
|
|
|
2010-02-18 12:57:33 +01:00
|
|
|
if ((pRel->Control & SE_DACL_PRESENT) && pRel->Dacl)
|
2003-11-05 02:41:20 +01:00
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
PACL pAcl = (PACL)SELF_RELATIVE_FIELD( pRel, Dacl );
|
2003-11-05 02:41:20 +01:00
|
|
|
memcpy(pDacl, pAcl, pAcl->AclSize);
|
|
|
|
pAbs->Dacl = pDacl;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pRel->Owner)
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
PSID psid = (PSID)SELF_RELATIVE_FIELD( pRel, Owner );
|
2003-11-05 02:41:20 +01:00
|
|
|
memcpy(pOwner, psid, RtlLengthSid(psid));
|
|
|
|
pAbs->Owner = pOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pRel->Group)
|
|
|
|
{
|
2009-06-16 13:29:05 +02:00
|
|
|
PSID psid = (PSID)SELF_RELATIVE_FIELD( pRel, Group );
|
2003-11-05 02:41:20 +01:00
|
|
|
memcpy(pPrimaryGroup, psid, RtlLengthSid(psid));
|
|
|
|
pAbs->Group = pPrimaryGroup;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
2005-05-31 11:32:12 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlGetControlSecurityDescriptor (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlGetControlSecurityDescriptor(
|
2005-06-12 13:07:37 +02:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
2005-05-31 11:32:12 +02:00
|
|
|
PSECURITY_DESCRIPTOR_CONTROL pControl,
|
|
|
|
LPDWORD lpdwRevision)
|
|
|
|
{
|
2005-06-12 13:07:37 +02:00
|
|
|
SECURITY_DESCRIPTOR *lpsd = pSecurityDescriptor;
|
2005-05-31 11:32:12 +02:00
|
|
|
|
2005-06-12 13:07:37 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",pSecurityDescriptor,pControl,lpdwRevision);
|
2005-05-31 11:32:12 +02:00
|
|
|
|
|
|
|
*lpdwRevision = lpsd->Revision;
|
2005-06-12 13:07:37 +02:00
|
|
|
|
|
|
|
if (*lpdwRevision != SECURITY_DESCRIPTOR_REVISION)
|
|
|
|
return STATUS_UNKNOWN_REVISION;
|
|
|
|
|
2005-05-31 11:32:12 +02:00
|
|
|
*pControl = lpsd->Control;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-10-23 16:19:00 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlSetControlSecurityDescriptor (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlSetControlSecurityDescriptor(
|
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet)
|
|
|
|
{
|
2008-10-17 19:44:14 +02:00
|
|
|
SECURITY_DESCRIPTOR_CONTROL const immutable
|
|
|
|
= SE_OWNER_DEFAULTED | SE_GROUP_DEFAULTED
|
|
|
|
| SE_DACL_PRESENT | SE_DACL_DEFAULTED
|
|
|
|
| SE_SACL_PRESENT | SE_SACL_DEFAULTED
|
|
|
|
| SE_RM_CONTROL_VALID | SE_SELF_RELATIVE
|
|
|
|
;
|
|
|
|
|
|
|
|
SECURITY_DESCRIPTOR *lpsd = SecurityDescriptor;
|
|
|
|
|
|
|
|
TRACE("(%p 0x%04x 0x%04x)\n", SecurityDescriptor,
|
|
|
|
ControlBitsOfInterest, ControlBitsToSet);
|
|
|
|
|
|
|
|
if ((ControlBitsOfInterest | ControlBitsToSet) & immutable)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
lpsd->Control |= (ControlBitsOfInterest & ControlBitsToSet);
|
|
|
|
lpsd->Control &= ~(ControlBitsOfInterest & ~ControlBitsToSet);
|
|
|
|
|
2007-10-23 16:19:00 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-03-30 12:22:51 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RtlAbsoluteToSelfRelativeSD [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAbsoluteToSelfRelativeSD(
|
|
|
|
PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
|
|
|
|
PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
|
|
|
|
PULONG BufferLength)
|
|
|
|
{
|
2005-06-13 13:34:02 +02:00
|
|
|
SECURITY_DESCRIPTOR *abs = AbsoluteSecurityDescriptor;
|
|
|
|
|
|
|
|
TRACE("%p %p %p\n", AbsoluteSecurityDescriptor,
|
2005-03-30 12:22:51 +02:00
|
|
|
SelfRelativeSecurityDescriptor, BufferLength);
|
2005-06-13 13:34:02 +02:00
|
|
|
|
|
|
|
if (abs->Control & SE_SELF_RELATIVE)
|
|
|
|
return STATUS_BAD_DESCRIPTOR_FORMAT;
|
|
|
|
|
|
|
|
return RtlMakeSelfRelativeSD(AbsoluteSecurityDescriptor,
|
|
|
|
SelfRelativeSecurityDescriptor, BufferLength);
|
2005-03-30 12:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* access control list's
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlCreateAcl [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* This should return NTSTATUS
|
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
NTSTATUS WINAPI RtlCreateAcl(PACL acl,DWORD size,DWORD rev)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("%p 0x%08x 0x%08x\n", acl, size, rev);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2007-10-23 14:38:07 +02:00
|
|
|
if (rev < MIN_ACL_REVISION || rev > MAX_ACL_REVISION)
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
if (size<sizeof(ACL))
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
if (size>0xFFFF)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
memset(acl,'\0',sizeof(ACL));
|
|
|
|
acl->AclRevision = rev;
|
|
|
|
acl->AclSize = size;
|
|
|
|
acl->AceCount = 0;
|
2003-03-17 22:21:00 +01:00
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlFirstFreeAce [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
* looks for the AceCount+1 ACE, and if it is still within the alloced
|
|
|
|
* ACL, return a pointer to it
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlFirstFreeAce(
|
|
|
|
PACL acl,
|
|
|
|
PACE_HEADER *x)
|
|
|
|
{
|
|
|
|
PACE_HEADER ace;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
*x = 0;
|
|
|
|
ace = (PACE_HEADER)(acl+1);
|
|
|
|
for (i=0;i<acl->AceCount;i++) {
|
2005-09-12 17:14:06 +02:00
|
|
|
if ((BYTE *)ace >= (BYTE *)acl + acl->AclSize)
|
2014-01-27 22:26:53 +01:00
|
|
|
return FALSE;
|
1999-03-09 18:47:51 +01:00
|
|
|
ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
|
|
|
}
|
2005-09-12 17:14:06 +02:00
|
|
|
if ((BYTE *)ace >= (BYTE *)acl + acl->AclSize)
|
2014-01-27 22:26:53 +01:00
|
|
|
return FALSE;
|
1999-03-09 18:47:51 +01:00
|
|
|
*x = ace;
|
2014-01-27 22:26:53 +01:00
|
|
|
return TRUE;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlAddAce [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAce(
|
|
|
|
PACL acl,
|
|
|
|
DWORD rev,
|
|
|
|
DWORD xnrofaces,
|
|
|
|
PACE_HEADER acestart,
|
|
|
|
DWORD acelen)
|
|
|
|
{
|
|
|
|
PACE_HEADER ace,targetace;
|
|
|
|
int nrofaces;
|
|
|
|
|
2015-03-28 15:26:37 +01:00
|
|
|
if (!RtlValidAcl(acl))
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
if (!RtlFirstFreeAce(acl,&targetace))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
nrofaces=0;ace=acestart;
|
2005-09-12 17:14:06 +02:00
|
|
|
while (((BYTE *)ace - (BYTE *)acestart) < acelen) {
|
1999-03-09 18:47:51 +01:00
|
|
|
nrofaces++;
|
|
|
|
ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
|
|
|
}
|
2005-09-12 17:14:06 +02:00
|
|
|
if ((BYTE *)targetace + acelen > (BYTE *)acl + acl->AclSize) /* too much aces */
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
2009-03-17 00:12:11 +01:00
|
|
|
memcpy(targetace,acestart,acelen);
|
1999-03-09 18:47:51 +01:00
|
|
|
acl->AceCount+=nrofaces;
|
2015-03-28 15:26:37 +01:00
|
|
|
if (rev > acl->AclRevision)
|
|
|
|
acl->AclRevision = rev;
|
1999-03-09 18:47:51 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlDeleteAce [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlDeleteAce(PACL pAcl, DWORD dwAceIndex)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
PACE_HEADER pAce;
|
|
|
|
|
|
|
|
status = RtlGetAce(pAcl,dwAceIndex,(LPVOID*)&pAce);
|
|
|
|
|
|
|
|
if (STATUS_SUCCESS == status)
|
|
|
|
{
|
|
|
|
PACE_HEADER pcAce;
|
|
|
|
DWORD len = 0;
|
|
|
|
|
2006-05-01 10:08:58 +02:00
|
|
|
/* skip over the ACE we are deleting */
|
2003-11-11 23:03:24 +01:00
|
|
|
pcAce = (PACE_HEADER)(((BYTE*)pAce)+pAce->AceSize);
|
2006-05-01 10:08:58 +02:00
|
|
|
dwAceIndex++;
|
|
|
|
|
|
|
|
/* calculate the length of the rest */
|
2003-11-11 23:03:24 +01:00
|
|
|
for (; dwAceIndex < pAcl->AceCount; dwAceIndex++)
|
|
|
|
{
|
|
|
|
len += pcAce->AceSize;
|
|
|
|
pcAce = (PACE_HEADER)(((BYTE*)pcAce) + pcAce->AceSize);
|
|
|
|
}
|
|
|
|
|
2006-05-01 10:08:58 +02:00
|
|
|
/* slide them all backwards */
|
|
|
|
memmove(pAce, ((BYTE*)pAce)+pAce->AceSize, len);
|
|
|
|
pAcl->AceCount--;
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("pAcl=%p dwAceIndex=%d status=0x%08x\n", pAcl, dwAceIndex, status);
|
2005-01-20 11:37:36 +01:00
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlAddAccessAllowedAce [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2003-05-01 02:29:26 +02:00
|
|
|
NTSTATUS WINAPI RtlAddAccessAllowedAce(
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
2003-06-16 21:44:06 +02:00
|
|
|
{
|
|
|
|
return RtlAddAccessAllowedAceEx( pAcl, dwAceRevision, 0, AccessMask, pSid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlAddAccessAllowedAceEx [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAccessAllowedAceEx(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AceFlags,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,0x%08x,%p)\n", pAcl, dwAceRevision, AccessMask, pSid);
|
2005-06-28 12:54:29 +02:00
|
|
|
|
|
|
|
return add_access_ace(pAcl, dwAceRevision, AceFlags,
|
|
|
|
AccessMask, pSid, ACCESS_ALLOWED_ACE_TYPE);
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
|
2016-03-01 22:34:05 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlAddAccessAllowedObjectAce [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAccessAllowedObjectAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD dwAceFlags,
|
|
|
|
IN DWORD dwAccessMask,
|
|
|
|
IN GUID* pObjectTypeGuid,
|
|
|
|
IN GUID* pInheritedObjectTypeGuid,
|
|
|
|
IN PSID pSid)
|
|
|
|
{
|
|
|
|
FIXME("%p %x %x %x %p %p %p - stub\n", pAcl, dwAceRevision, dwAceFlags, dwAccessMask,
|
|
|
|
pObjectTypeGuid, pInheritedObjectTypeGuid, pSid);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-05-01 02:29:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlAddAccessDeniedAce [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAccessDeniedAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
2003-06-16 21:44:06 +02:00
|
|
|
{
|
|
|
|
return RtlAddAccessDeniedAceEx( pAcl, dwAceRevision, 0, AccessMask, pSid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlAddAccessDeniedAceEx [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAccessDeniedAceEx(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AceFlags,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
2003-05-01 02:29:26 +02:00
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,0x%08x,%p)\n", pAcl, dwAceRevision, AccessMask, pSid);
|
2005-06-28 12:54:29 +02:00
|
|
|
|
|
|
|
return add_access_ace(pAcl, dwAceRevision, AceFlags,
|
|
|
|
AccessMask, pSid, ACCESS_DENIED_ACE_TYPE);
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
|
2016-03-04 08:40:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlAddAccessDeniedObjectAce [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAccessDeniedObjectAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD dwAceFlags,
|
|
|
|
IN DWORD dwAccessMask,
|
|
|
|
IN GUID* pObjectTypeGuid,
|
|
|
|
IN GUID* pInheritedObjectTypeGuid,
|
|
|
|
IN PSID pSid)
|
|
|
|
{
|
|
|
|
FIXME("%p %x %x %x %p %p %p - stub\n", pAcl, dwAceRevision, dwAceFlags, dwAccessMask,
|
|
|
|
pObjectTypeGuid, pInheritedObjectTypeGuid, pSid);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-06-23 13:03:30 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlAddAuditAccessAce [NTDLL.@]
|
|
|
|
*/
|
2007-09-25 02:20:36 +02:00
|
|
|
NTSTATUS WINAPI RtlAddAuditAccessAceEx(
|
2005-06-23 13:03:30 +02:00
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
2007-09-25 02:20:36 +02:00
|
|
|
IN DWORD dwAceFlags,
|
2005-06-23 13:03:30 +02:00
|
|
|
IN DWORD dwAccessMask,
|
|
|
|
IN PSID pSid,
|
|
|
|
IN BOOL bAuditSuccess,
|
|
|
|
IN BOOL bAuditFailure)
|
|
|
|
{
|
2007-09-25 02:20:36 +02:00
|
|
|
TRACE("(%p,%d,0x%08x,0x%08x,%p,%u,%u)\n",pAcl,dwAceRevision,dwAceFlags,dwAccessMask,
|
2005-06-24 14:20:15 +02:00
|
|
|
pSid,bAuditSuccess,bAuditFailure);
|
|
|
|
|
|
|
|
if (bAuditSuccess)
|
|
|
|
dwAceFlags |= SUCCESSFUL_ACCESS_ACE_FLAG;
|
|
|
|
|
|
|
|
if (bAuditFailure)
|
|
|
|
dwAceFlags |= FAILED_ACCESS_ACE_FLAG;
|
|
|
|
|
|
|
|
return add_access_ace(pAcl, dwAceRevision, dwAceFlags,
|
|
|
|
dwAccessMask, pSid, SYSTEM_AUDIT_ACE_TYPE);
|
2005-06-23 13:03:30 +02:00
|
|
|
}
|
2007-09-25 02:20:36 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RtlAddAuditAccessAce [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAuditAccessAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD dwAccessMask,
|
|
|
|
IN PSID pSid,
|
|
|
|
IN BOOL bAuditSuccess,
|
|
|
|
IN BOOL bAuditFailure)
|
|
|
|
{
|
|
|
|
return RtlAddAuditAccessAceEx(pAcl, dwAceRevision, 0, dwAccessMask, pSid, bAuditSuccess, bAuditFailure);
|
|
|
|
}
|
2016-02-25 09:10:32 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlAddAuditAccessObjectAce [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAddAuditAccessObjectAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD dwAceFlags,
|
|
|
|
IN DWORD dwAccessMask,
|
|
|
|
IN GUID* pObjectTypeGuid,
|
|
|
|
IN GUID* pInheritedObjectTypeGuid,
|
|
|
|
IN PSID pSid,
|
|
|
|
IN BOOL bAuditSuccess,
|
|
|
|
IN BOOL bAuditFailure)
|
|
|
|
{
|
|
|
|
FIXME("%p %x %x %x %p %p %p %d %d - stub\n", pAcl, dwAceRevision, dwAceFlags, dwAccessMask,
|
|
|
|
pObjectTypeGuid, pInheritedObjectTypeGuid, pSid, bAuditSuccess, bAuditFailure);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-05-01 02:29:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlValidAcl [NTDLL.@]
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlValidAcl(PACL pAcl)
|
|
|
|
{
|
|
|
|
BOOLEAN ret;
|
|
|
|
TRACE("(%p)\n", pAcl);
|
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
PACE_HEADER ace;
|
|
|
|
int i;
|
|
|
|
|
2007-10-23 14:39:02 +02:00
|
|
|
if (pAcl->AclRevision < MIN_ACL_REVISION ||
|
|
|
|
pAcl->AclRevision > MAX_ACL_REVISION)
|
2003-05-01 02:29:26 +02:00
|
|
|
ret = FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ace = (PACE_HEADER)(pAcl+1);
|
|
|
|
ret = TRUE;
|
|
|
|
for (i=0;i<=pAcl->AceCount;i++)
|
|
|
|
{
|
|
|
|
if ((char *)ace > (char *)pAcl + pAcl->AclSize)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2009-11-29 11:28:32 +01:00
|
|
|
if (i != pAcl->AceCount)
|
|
|
|
ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-16 17:17:57 +01:00
|
|
|
__EXCEPT_PAGE_FAULT
|
2003-05-01 02:29:26 +02:00
|
|
|
{
|
|
|
|
WARN("(%p): invalid pointer!\n", pAcl);
|
2014-01-27 22:26:53 +01:00
|
|
|
return FALSE;
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlGetAce [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
NTSTATUS WINAPI RtlGetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2003-05-01 02:29:26 +02:00
|
|
|
PACE_HEADER ace;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,%d,%p)\n",pAcl,dwAceIndex,pAce);
|
2003-05-01 02:29:26 +02:00
|
|
|
|
2008-01-22 16:36:09 +01:00
|
|
|
if (dwAceIndex >= pAcl->AceCount)
|
2003-05-01 02:29:26 +02:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
ace = (PACE_HEADER)(pAcl + 1);
|
|
|
|
for (;dwAceIndex;dwAceIndex--)
|
|
|
|
ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
|
|
|
|
2009-03-17 00:12:11 +01:00
|
|
|
*pAce = ace;
|
2003-05-01 02:29:26 +02:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* misc
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlAdjustPrivilege [NTDLL.@]
|
2005-06-12 12:44:01 +02:00
|
|
|
*
|
|
|
|
* Enables or disables a privilege from the calling thread or process.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* Privilege [I] Privilege index to change.
|
|
|
|
* Enable [I] If TRUE, then enable the privilege otherwise disable.
|
|
|
|
* CurrentThread [I] If TRUE, then enable in calling thread, otherwise process.
|
|
|
|
* Enabled [O] Whether privilege was previously enabled or disabled.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: STATUS_SUCCESS.
|
|
|
|
* Failure: NTSTATUS code.
|
|
|
|
*
|
|
|
|
* SEE ALSO
|
|
|
|
* NtAdjustPrivilegesToken, NtOpenThreadToken, NtOpenProcessToken.
|
|
|
|
*
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2005-06-12 12:44:01 +02:00
|
|
|
NTSTATUS WINAPI
|
|
|
|
RtlAdjustPrivilege(ULONG Privilege,
|
|
|
|
BOOLEAN Enable,
|
|
|
|
BOOLEAN CurrentThread,
|
|
|
|
PBOOLEAN Enabled)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-06-12 12:44:01 +02:00
|
|
|
TOKEN_PRIVILEGES NewState;
|
|
|
|
TOKEN_PRIVILEGES OldState;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
HANDLE TokenHandle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%d, %s, %s, %p)\n", Privilege, Enable ? "TRUE" : "FALSE",
|
2005-06-12 12:44:01 +02:00
|
|
|
CurrentThread ? "TRUE" : "FALSE", Enabled);
|
|
|
|
|
|
|
|
if (CurrentThread)
|
|
|
|
{
|
|
|
|
Status = NtOpenThreadToken(GetCurrentThread(),
|
|
|
|
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
|
|
|
FALSE,
|
|
|
|
&TokenHandle);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Status = NtOpenProcessToken(GetCurrentProcess(),
|
|
|
|
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
|
|
|
&TokenHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
WARN("Retrieving token handle failed (Status %x)\n", Status);
|
2005-06-12 12:44:01 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
OldState.PrivilegeCount = 1;
|
|
|
|
|
|
|
|
NewState.PrivilegeCount = 1;
|
|
|
|
NewState.Privileges[0].Luid.LowPart = Privilege;
|
|
|
|
NewState.Privileges[0].Luid.HighPart = 0;
|
|
|
|
NewState.Privileges[0].Attributes = (Enable) ? SE_PRIVILEGE_ENABLED : 0;
|
|
|
|
|
|
|
|
Status = NtAdjustPrivilegesToken(TokenHandle,
|
|
|
|
FALSE,
|
|
|
|
&NewState,
|
|
|
|
sizeof(TOKEN_PRIVILEGES),
|
|
|
|
&OldState,
|
|
|
|
&ReturnLength);
|
|
|
|
NtClose (TokenHandle);
|
|
|
|
if (Status == STATUS_NOT_ALL_ASSIGNED)
|
|
|
|
{
|
|
|
|
TRACE("Failed to assign all privileges\n");
|
|
|
|
return STATUS_PRIVILEGE_NOT_HELD;
|
|
|
|
}
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
WARN("NtAdjustPrivilegesToken() failed (Status %x)\n", Status);
|
2005-06-12 12:44:01 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OldState.PrivilegeCount == 0)
|
|
|
|
*Enabled = Enable;
|
|
|
|
else
|
|
|
|
*Enabled = (OldState.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED);
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* RtlImpersonateSelf [NTDLL.@]
|
2005-06-20 13:44:45 +02:00
|
|
|
*
|
|
|
|
* Makes an impersonation token that represents the process user and assigns
|
|
|
|
* to the current thread.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ImpersonationLevel [I] Level at which to impersonate.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: STATUS_SUCCESS.
|
|
|
|
* Failure: NTSTATUS code.
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2005-06-20 13:44:45 +02:00
|
|
|
NTSTATUS WINAPI
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
|
|
|
{
|
2005-06-20 13:44:45 +02:00
|
|
|
NTSTATUS Status;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE ProcessToken;
|
|
|
|
HANDLE ImpersonationToken;
|
|
|
|
|
|
|
|
TRACE("(%08x)\n", ImpersonationLevel);
|
|
|
|
|
|
|
|
Status = NtOpenProcessToken( NtCurrentProcess(), TOKEN_DUPLICATE,
|
|
|
|
&ProcessToken);
|
|
|
|
if (Status != STATUS_SUCCESS)
|
|
|
|
return Status;
|
|
|
|
|
|
|
|
InitializeObjectAttributes( &ObjectAttributes, NULL, 0, NULL, NULL );
|
|
|
|
|
|
|
|
Status = NtDuplicateToken( ProcessToken,
|
|
|
|
TOKEN_IMPERSONATE,
|
|
|
|
&ObjectAttributes,
|
|
|
|
ImpersonationLevel,
|
|
|
|
TokenImpersonation,
|
|
|
|
&ImpersonationToken );
|
|
|
|
if (Status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
NtClose( ProcessToken );
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = NtSetInformationThread( GetCurrentThread(),
|
|
|
|
ThreadImpersonationToken,
|
|
|
|
&ImpersonationToken,
|
|
|
|
sizeof(ImpersonationToken) );
|
|
|
|
|
|
|
|
NtClose( ImpersonationToken );
|
|
|
|
NtClose( ProcessToken );
|
|
|
|
|
|
|
|
return Status;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
2015-05-21 06:42:16 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtImpersonateAnonymousToken [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI
|
|
|
|
NtImpersonateAnonymousToken(HANDLE thread)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", thread);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtAccessCheck [NTDLL.@]
|
2003-03-17 22:21:00 +01:00
|
|
|
* ZwAccessCheck [NTDLL.@]
|
2005-05-24 14:32:18 +02:00
|
|
|
*
|
|
|
|
* Checks that a user represented by a token is allowed to access an object
|
|
|
|
* represented by a security descriptor.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* SecurityDescriptor [I] The security descriptor of the object to check.
|
|
|
|
* ClientToken [I] Token of the user accessing the object.
|
|
|
|
* DesiredAccess [I] The desired access to the object.
|
|
|
|
* GenericMapping [I] Mapping used to transform access rights in the SD to their specific forms.
|
|
|
|
* PrivilegeSet [I/O] Privileges used during the access check.
|
|
|
|
* ReturnLength [O] Number of bytes stored into PrivilegeSet.
|
|
|
|
* GrantedAccess [O] The actual access rights granted.
|
|
|
|
* AccessStatus [O] The status of the access check.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* NTSTATUS code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* DesiredAccess may be MAXIMUM_ALLOWED, in which case the function determines
|
|
|
|
* the maximum access rights allowed by the SD and returns them in
|
|
|
|
* GrantedAccess.
|
|
|
|
* The SecurityDescriptor must have a valid owner and groups present,
|
|
|
|
* otherwise the function will fail.
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
NTSTATUS WINAPI
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
NtAccessCheck(
|
2005-05-24 14:32:18 +02:00
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
|
|
HANDLE ClientToken,
|
|
|
|
ACCESS_MASK DesiredAccess,
|
|
|
|
PGENERIC_MAPPING GenericMapping,
|
|
|
|
PPRIVILEGE_SET PrivilegeSet,
|
|
|
|
PULONG ReturnLength,
|
|
|
|
PULONG GrantedAccess,
|
|
|
|
NTSTATUS *AccessStatus)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2005-05-24 14:32:18 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
2007-01-21 21:37:05 +01:00
|
|
|
TRACE("(%p, %p, %08x, %p, %p, %p, %p, %p)\n",
|
2005-05-24 14:32:18 +02:00
|
|
|
SecurityDescriptor, ClientToken, DesiredAccess, GenericMapping,
|
|
|
|
PrivilegeSet, ReturnLength, GrantedAccess, AccessStatus);
|
|
|
|
|
2009-01-13 20:54:32 +01:00
|
|
|
if (!PrivilegeSet || !ReturnLength)
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
|
|
|
|
2005-05-24 14:32:18 +02:00
|
|
|
SERVER_START_REQ( access_check )
|
|
|
|
{
|
|
|
|
struct security_descriptor sd;
|
2005-05-31 11:32:12 +02:00
|
|
|
PSID owner;
|
|
|
|
PSID group;
|
|
|
|
PACL sacl;
|
|
|
|
PACL dacl;
|
|
|
|
BOOLEAN defaulted, present;
|
|
|
|
DWORD revision;
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL control;
|
2005-05-24 14:32:18 +02:00
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ClientToken );
|
2005-05-24 14:32:18 +02:00
|
|
|
req->desired_access = DesiredAccess;
|
|
|
|
req->mapping_read = GenericMapping->GenericRead;
|
|
|
|
req->mapping_write = GenericMapping->GenericWrite;
|
|
|
|
req->mapping_execute = GenericMapping->GenericExecute;
|
|
|
|
req->mapping_all = GenericMapping->GenericAll;
|
|
|
|
|
|
|
|
/* marshal security descriptor */
|
2005-05-31 11:32:12 +02:00
|
|
|
RtlGetControlSecurityDescriptor( SecurityDescriptor, &control, &revision );
|
|
|
|
sd.control = control & ~SE_SELF_RELATIVE;
|
|
|
|
RtlGetOwnerSecurityDescriptor( SecurityDescriptor, &owner, &defaulted );
|
|
|
|
sd.owner_len = RtlLengthSid( owner );
|
|
|
|
RtlGetGroupSecurityDescriptor( SecurityDescriptor, &group, &defaulted );
|
|
|
|
sd.group_len = RtlLengthSid( group );
|
|
|
|
RtlGetSaclSecurityDescriptor( SecurityDescriptor, &present, &sacl, &defaulted );
|
2007-10-31 07:17:31 +01:00
|
|
|
sd.sacl_len = ((present && sacl) ? acl_bytesInUse(sacl) : 0);
|
2005-05-31 11:32:12 +02:00
|
|
|
RtlGetDaclSecurityDescriptor( SecurityDescriptor, &present, &dacl, &defaulted );
|
2007-10-31 07:17:31 +01:00
|
|
|
sd.dacl_len = ((present && dacl) ? acl_bytesInUse(dacl) : 0);
|
2005-05-31 11:32:12 +02:00
|
|
|
|
2005-05-24 14:32:18 +02:00
|
|
|
wine_server_add_data( req, &sd, sizeof(sd) );
|
2005-05-31 11:32:12 +02:00
|
|
|
wine_server_add_data( req, owner, sd.owner_len );
|
|
|
|
wine_server_add_data( req, group, sd.group_len );
|
|
|
|
wine_server_add_data( req, sacl, sd.sacl_len );
|
|
|
|
wine_server_add_data( req, dacl, sd.dacl_len );
|
2005-05-24 14:32:18 +02:00
|
|
|
|
2008-07-11 11:41:42 +02:00
|
|
|
wine_server_set_reply( req, PrivilegeSet->Privilege, *ReturnLength - FIELD_OFFSET( PRIVILEGE_SET, Privilege ) );
|
2005-05-24 14:32:18 +02:00
|
|
|
|
|
|
|
status = wine_server_call( req );
|
|
|
|
|
|
|
|
*ReturnLength = FIELD_OFFSET( PRIVILEGE_SET, Privilege ) + reply->privileges_len;
|
|
|
|
PrivilegeSet->PrivilegeCount = reply->privileges_len / sizeof(LUID_AND_ATTRIBUTES);
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
2007-01-21 21:37:22 +01:00
|
|
|
{
|
2005-05-24 14:32:18 +02:00
|
|
|
*AccessStatus = reply->access_status;
|
2007-01-21 21:37:22 +01:00
|
|
|
*GrantedAccess = reply->access_granted;
|
|
|
|
}
|
2005-05-24 14:32:18 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
return status;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtSetSecurityObject [NTDLL.@]
|
2007-02-08 05:43:11 +01:00
|
|
|
* ZwSetSecurityObject [NTDLL.@]
|
|
|
|
*
|
|
|
|
* Sets specified parts of the object's security descriptor.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* Handle [I] Handle to the object to change security descriptor of.
|
|
|
|
* SecurityInformation [I] Specifies which parts of the security descriptor to set.
|
|
|
|
* SecurityDescriptor [I] New parts of a security descriptor for the object.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* NTSTATUS code.
|
|
|
|
*
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
2007-02-08 05:43:11 +01:00
|
|
|
NTSTATUS WINAPI NtSetSecurityObject(HANDLE Handle,
|
|
|
|
SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2007-02-08 05:43:11 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
struct security_descriptor sd;
|
2007-05-22 22:33:27 +02:00
|
|
|
PACL dacl = NULL, sacl = NULL;
|
|
|
|
PSID owner = NULL, group = NULL;
|
2007-02-08 05:43:11 +01:00
|
|
|
BOOLEAN defaulted, present;
|
|
|
|
DWORD revision;
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL control;
|
|
|
|
|
|
|
|
TRACE("%p 0x%08x %p\n", Handle, SecurityInformation, SecurityDescriptor);
|
|
|
|
|
|
|
|
if (!SecurityDescriptor) return STATUS_ACCESS_VIOLATION;
|
|
|
|
|
|
|
|
memset( &sd, 0, sizeof(sd) );
|
2007-02-27 15:28:18 +01:00
|
|
|
status = RtlGetControlSecurityDescriptor( SecurityDescriptor, &control, &revision );
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
2007-02-08 05:43:11 +01:00
|
|
|
sd.control = control & ~SE_SELF_RELATIVE;
|
|
|
|
|
|
|
|
if (SecurityInformation & OWNER_SECURITY_INFORMATION)
|
|
|
|
{
|
2007-02-27 15:28:18 +01:00
|
|
|
status = RtlGetOwnerSecurityDescriptor( SecurityDescriptor, &owner, &defaulted );
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
2007-02-08 05:43:11 +01:00
|
|
|
if (!(sd.owner_len = RtlLengthSid( owner )))
|
|
|
|
return STATUS_INVALID_SECURITY_DESCR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecurityInformation & GROUP_SECURITY_INFORMATION)
|
|
|
|
{
|
2007-02-27 15:28:18 +01:00
|
|
|
status = RtlGetGroupSecurityDescriptor( SecurityDescriptor, &group, &defaulted );
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
2007-02-08 05:43:11 +01:00
|
|
|
if (!(sd.group_len = RtlLengthSid( group )))
|
|
|
|
return STATUS_INVALID_SECURITY_DESCR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecurityInformation & SACL_SECURITY_INFORMATION)
|
|
|
|
{
|
2007-02-27 15:28:18 +01:00
|
|
|
status = RtlGetSaclSecurityDescriptor( SecurityDescriptor, &present, &sacl, &defaulted );
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
2007-10-31 07:17:31 +01:00
|
|
|
sd.sacl_len = (sacl && present) ? acl_bytesInUse(sacl) : 0;
|
2007-02-08 05:43:11 +01:00
|
|
|
sd.control |= SE_SACL_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecurityInformation & DACL_SECURITY_INFORMATION)
|
|
|
|
{
|
2007-02-27 15:28:18 +01:00
|
|
|
status = RtlGetDaclSecurityDescriptor( SecurityDescriptor, &present, &dacl, &defaulted );
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
2007-10-31 07:17:31 +01:00
|
|
|
sd.dacl_len = (dacl && present) ? acl_bytesInUse(dacl) : 0;
|
2007-02-08 05:43:11 +01:00
|
|
|
sd.control |= SE_DACL_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_security_object )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( Handle );
|
2007-02-08 05:43:11 +01:00
|
|
|
req->security_info = SecurityInformation;
|
|
|
|
|
|
|
|
wine_server_add_data( req, &sd, sizeof(sd) );
|
|
|
|
wine_server_add_data( req, owner, sd.owner_len );
|
|
|
|
wine_server_add_data( req, group, sd.group_len );
|
|
|
|
wine_server_add_data( req, sacl, sd.sacl_len );
|
|
|
|
wine_server_add_data( req, dacl, sd.dacl_len );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
return status;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
2000-06-02 00:47:13 +02:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlConvertSidToUnicodeString (NTDLL.@)
|
2002-05-09 22:30:52 +02:00
|
|
|
*
|
|
|
|
* The returned SID is used to access the USER registry hive usually
|
|
|
|
*
|
|
|
|
* the native function returns something like
|
|
|
|
* "S-1-5-21-0000000000-000000000-0000000000-500";
|
2000-06-02 00:47:13 +02:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlConvertSidToUnicodeString(
|
2002-05-09 22:30:52 +02:00
|
|
|
PUNICODE_STRING String,
|
2005-07-11 22:42:12 +02:00
|
|
|
PSID pSid,
|
2002-05-09 22:30:52 +02:00
|
|
|
BOOLEAN AllocateString)
|
2000-06-02 00:47:13 +02:00
|
|
|
{
|
2005-07-11 22:42:12 +02:00
|
|
|
static const WCHAR formatW[] = {'-','%','u',0};
|
|
|
|
WCHAR buffer[2 + 10 + 10 + 10 * SID_MAX_SUB_AUTHORITIES];
|
|
|
|
WCHAR *p = buffer;
|
2009-03-17 00:12:11 +01:00
|
|
|
const SID *sid = pSid;
|
2005-07-11 22:42:12 +02:00
|
|
|
DWORD i, len;
|
|
|
|
|
|
|
|
*p++ = 'S';
|
|
|
|
p += sprintfW( p, formatW, sid->Revision );
|
|
|
|
p += sprintfW( p, formatW, MAKELONG( MAKEWORD( sid->IdentifierAuthority.Value[5],
|
|
|
|
sid->IdentifierAuthority.Value[4] ),
|
|
|
|
MAKEWORD( sid->IdentifierAuthority.Value[3],
|
|
|
|
sid->IdentifierAuthority.Value[2] )));
|
|
|
|
for (i = 0; i < sid->SubAuthorityCount; i++)
|
|
|
|
p += sprintfW( p, formatW, sid->SubAuthority[i] );
|
|
|
|
|
|
|
|
len = (p + 1 - buffer) * sizeof(WCHAR);
|
2000-06-02 00:47:13 +02:00
|
|
|
|
2004-05-07 06:01:28 +02:00
|
|
|
String->Length = len - sizeof(WCHAR);
|
|
|
|
if (AllocateString)
|
|
|
|
{
|
|
|
|
String->MaximumLength = len;
|
|
|
|
if (!(String->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
else if (len > String->MaximumLength) return STATUS_BUFFER_OVERFLOW;
|
2000-06-02 00:47:13 +02:00
|
|
|
|
2005-07-11 22:42:12 +02:00
|
|
|
memcpy( String->Buffer, buffer, len );
|
2004-05-07 06:01:28 +02:00
|
|
|
return STATUS_SUCCESS;
|
2000-06-02 00:47:13 +02:00
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlQueryInformationAcl (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlQueryInformationAcl(
|
|
|
|
PACL pAcl,
|
|
|
|
LPVOID pAclInformation,
|
|
|
|
DWORD nAclInformationLength,
|
|
|
|
ACL_INFORMATION_CLASS dwAclInformationClass)
|
|
|
|
{
|
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("pAcl=%p pAclInfo=%p len=%d, class=%d\n",
|
2003-11-11 23:03:24 +01:00
|
|
|
pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass);
|
|
|
|
|
|
|
|
switch (dwAclInformationClass)
|
|
|
|
{
|
|
|
|
case AclRevisionInformation:
|
|
|
|
{
|
2009-03-17 00:12:11 +01:00
|
|
|
PACL_REVISION_INFORMATION paclrev = pAclInformation;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
if (nAclInformationLength < sizeof(ACL_REVISION_INFORMATION))
|
|
|
|
status = STATUS_INVALID_PARAMETER;
|
|
|
|
else
|
|
|
|
paclrev->AclRevision = pAcl->AclRevision;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AclSizeInformation:
|
|
|
|
{
|
2009-03-17 00:12:11 +01:00
|
|
|
PACL_SIZE_INFORMATION paclsize = pAclInformation;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
if (nAclInformationLength < sizeof(ACL_SIZE_INFORMATION))
|
|
|
|
status = STATUS_INVALID_PARAMETER;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
paclsize->AceCount = pAcl->AceCount;
|
2007-10-31 07:17:31 +01:00
|
|
|
paclsize->AclBytesInUse = acl_bytesInUse(pAcl);
|
2003-11-11 23:03:24 +01:00
|
|
|
if (pAcl->AclSize < paclsize->AclBytesInUse)
|
|
|
|
{
|
2007-10-31 07:17:31 +01:00
|
|
|
WARN("Acl uses %d bytes, but only has %d allocated! Returning smaller of the two values.\n", pAcl->AclSize, paclsize->AclBytesInUse);
|
2003-11-11 23:03:24 +01:00
|
|
|
paclsize->AclBytesFree = 0;
|
|
|
|
paclsize->AclBytesInUse = pAcl->AclSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
paclsize->AclBytesFree = pAcl->AclSize - paclsize->AclBytesInUse;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("Unknown AclInformationClass value: %d\n", dwAclInformationClass);
|
|
|
|
status = STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
2013-03-26 23:38:08 +01:00
|
|
|
|
|
|
|
BOOL WINAPI RtlConvertToAutoInheritSecurityObject(
|
|
|
|
PSECURITY_DESCRIPTOR pdesc,
|
|
|
|
PSECURITY_DESCRIPTOR cdesc,
|
|
|
|
PSECURITY_DESCRIPTOR* ndesc,
|
|
|
|
GUID* objtype,
|
|
|
|
BOOL isdir,
|
|
|
|
PGENERIC_MAPPING genmap )
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p %p %d %p - stub\n", pdesc, cdesc, ndesc, objtype, isdir, genmap);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|