2004-09-06 22:12:25 +00:00
|
|
|
/* $Id: misc.c,v 1.23 2004/09/06 22:12:25 ekohl Exp $
|
2004-02-25 14:25:11 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/advapi32/sec/misc.c
|
|
|
|
* PURPOSE: Miscellaneous security functions
|
2001-11-22 02:37:32 +00:00
|
|
|
*/
|
|
|
|
|
2004-08-15 17:03:15 +00:00
|
|
|
#include "advapi32.h"
|
2004-05-27 14:50:17 +00:00
|
|
|
#include <accctrl.h>
|
2001-11-22 02:37:32 +00:00
|
|
|
|
2004-03-25 11:30:07 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2001-11-22 02:37:32 +00:00
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-20 01:40:19 +00:00
|
|
|
BOOL STDCALL
|
2001-11-22 02:37:32 +00:00
|
|
|
AreAllAccessesGranted(DWORD GrantedAccess,
|
|
|
|
DWORD DesiredAccess)
|
|
|
|
{
|
|
|
|
return((BOOL)RtlAreAllAccessesGranted(GrantedAccess,
|
|
|
|
DesiredAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-20 01:40:19 +00:00
|
|
|
BOOL STDCALL
|
2001-11-22 02:37:32 +00:00
|
|
|
AreAnyAccessesGranted(DWORD GrantedAccess,
|
|
|
|
DWORD DesiredAccess)
|
|
|
|
{
|
|
|
|
return((BOOL)RtlAreAnyAccessesGranted(GrantedAccess,
|
|
|
|
DesiredAccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-25 11:30:07 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetFileSecurityA [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* Obtains Specified information about the security of a file or directory.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpFileName [I] Name of the file to get info for
|
|
|
|
* RequestedInformation [I] SE_ flags from "winnt.h"
|
|
|
|
* pSecurityDescriptor [O] Destination for security information
|
|
|
|
* nLength [I] Length of pSecurityDescriptor
|
|
|
|
* lpnLengthNeeded [O] Destination for length of returned security information
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. pSecurityDescriptor contains the requested information.
|
|
|
|
* Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The information returned is constrained by the callers access rights and
|
|
|
|
* privileges.
|
|
|
|
*
|
2004-09-06 22:12:25 +00:00
|
|
|
* @implemented
|
2004-03-25 11:30:07 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
2004-09-06 22:12:25 +00:00
|
|
|
GetFileSecurityA(LPCSTR lpFileName,
|
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
DWORD nLength,
|
|
|
|
LPDWORD lpnLengthNeeded)
|
2004-03-25 11:30:07 +00:00
|
|
|
{
|
2004-09-06 22:12:25 +00:00
|
|
|
UNICODE_STRING FileName;
|
|
|
|
NTSTATUS Status;
|
|
|
|
BOOL bResult;
|
|
|
|
|
|
|
|
Status = RtlCreateUnicodeStringFromAsciiz(&FileName,
|
|
|
|
(LPSTR)lpFileName);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bResult = GetFileSecurityW(FileName.Buffer,
|
|
|
|
RequestedInformation,
|
|
|
|
pSecurityDescriptor,
|
|
|
|
nLength,
|
|
|
|
lpnLengthNeeded);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&FileName);
|
|
|
|
|
|
|
|
return bResult;
|
2004-03-25 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
2004-09-06 22:12:25 +00:00
|
|
|
|
2004-05-13 20:42:28 +00:00
|
|
|
/*
|
2004-09-06 22:12:25 +00:00
|
|
|
* @implemented
|
2004-05-13 20:42:28 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
2004-09-06 22:12:25 +00:00
|
|
|
GetFileSecurityW(LPCWSTR lpFileName,
|
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
DWORD nLength,
|
|
|
|
LPDWORD lpnLengthNeeded)
|
2004-05-13 20:42:28 +00:00
|
|
|
{
|
2004-09-06 22:12:25 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
IO_STATUS_BLOCK StatusBlock;
|
|
|
|
UNICODE_STRING FileName;
|
|
|
|
ULONG AccessMask = 0;
|
|
|
|
HANDLE FileHandle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DPRINT("GetFileSecurityW() called\n");
|
|
|
|
|
|
|
|
if (RequestedInformation &
|
|
|
|
(OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION))
|
|
|
|
{
|
|
|
|
AccessMask |= STANDARD_RIGHTS_READ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RequestedInformation & SACL_SECURITY_INFORMATION)
|
|
|
|
{
|
|
|
|
AccessMask |= ACCESS_SYSTEM_SECURITY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!RtlDosPathNameToNtPathName_U((LPWSTR)lpFileName,
|
|
|
|
&FileName,
|
|
|
|
NULL,
|
|
|
|
NULL))
|
|
|
|
{
|
|
|
|
DPRINT("Invalid path\n");
|
|
|
|
SetLastError(ERROR_BAD_PATHNAME);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&FileName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
Status = NtOpenFile(&FileHandle,
|
|
|
|
AccessMask,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&StatusBlock,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
|
|
|
0);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT("NtOpenFile() failed (Status %lx)\n", Status);
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&FileName);
|
|
|
|
|
|
|
|
Status = NtQuerySecurityObject(FileHandle,
|
|
|
|
RequestedInformation,
|
|
|
|
pSecurityDescriptor,
|
|
|
|
nLength,
|
|
|
|
lpnLengthNeeded);
|
|
|
|
NtClose(FileHandle);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT("NtQuerySecurityObject() failed (Status %lx)\n", Status);
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-13 20:42:28 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2004-03-25 11:30:07 +00:00
|
|
|
|
2004-09-06 22:12:25 +00:00
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-20 01:40:19 +00:00
|
|
|
BOOL STDCALL
|
2001-11-22 02:37:32 +00:00
|
|
|
GetKernelObjectSecurity(HANDLE Handle,
|
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
DWORD nLength,
|
|
|
|
LPDWORD lpnLengthNeeded)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtQuerySecurityObject(Handle,
|
|
|
|
RequestedInformation,
|
|
|
|
pSecurityDescriptor,
|
|
|
|
nLength,
|
|
|
|
lpnLengthNeeded);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-26 09:50:10 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* SetFileSecurityW [ADVAPI32.@]
|
|
|
|
* Sets the security of a file or directory
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
SetFileSecurityW (LPCWSTR lpFileName,
|
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("SetFileSecurityW : stub\n");
|
2004-05-26 09:50:10 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-25 11:30:07 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* SetFileSecurityA [ADVAPI32.@]
|
|
|
|
* Sets the security of a file or directory
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
SetFileSecurityA (LPCSTR lpFileName,
|
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
|
|
|
{
|
|
|
|
DPRINT("SetFileSecurityA : stub\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2001-11-22 02:37:32 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
SetKernelObjectSecurity(HANDLE Handle,
|
|
|
|
SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtSetSecurityObject(Handle,
|
|
|
|
SecurityInformation,
|
|
|
|
SecurityDescriptor);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
2004-03-25 11:30:07 +00:00
|
|
|
return FALSE;
|
2001-11-22 02:37:32 +00:00
|
|
|
}
|
2004-03-25 11:30:07 +00:00
|
|
|
return TRUE;
|
2001-11-22 02:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2001-11-22 02:37:32 +00:00
|
|
|
VOID STDCALL
|
|
|
|
MapGenericMask(PDWORD AccessMask,
|
|
|
|
PGENERIC_MAPPING GenericMapping)
|
|
|
|
{
|
|
|
|
RtlMapGenericMask(AccessMask,
|
|
|
|
GenericMapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
2004-03-25 11:30:07 +00:00
|
|
|
* @implemented
|
2003-07-10 15:05:55 +00:00
|
|
|
*/
|
2004-02-25 14:25:11 +00:00
|
|
|
BOOL STDCALL
|
2003-01-15 20:05:53 +00:00
|
|
|
ImpersonateLoggedOnUser(HANDLE hToken)
|
|
|
|
{
|
2004-03-25 11:30:07 +00:00
|
|
|
SECURITY_QUALITY_OF_SERVICE Qos;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE NewToken;
|
|
|
|
TOKEN_TYPE Type;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
BOOL Duplicated;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
/* Get the token type */
|
|
|
|
Status = NtQueryInformationToken (hToken,
|
|
|
|
TokenType,
|
|
|
|
&Type,
|
|
|
|
sizeof(TOKEN_TYPE),
|
|
|
|
&ReturnLength);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError (RtlNtStatusToDosError (Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Type == TokenPrimary)
|
|
|
|
{
|
|
|
|
/* Create a duplicate impersonation token */
|
|
|
|
Qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
|
|
|
|
Qos.ImpersonationLevel = SecurityImpersonation;
|
|
|
|
Qos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
|
|
|
|
Qos.EffectiveOnly = FALSE;
|
|
|
|
|
|
|
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
|
|
|
ObjectAttributes.RootDirectory = NULL;
|
|
|
|
ObjectAttributes.ObjectName = NULL;
|
|
|
|
ObjectAttributes.Attributes = 0;
|
|
|
|
ObjectAttributes.SecurityDescriptor = NULL;
|
|
|
|
ObjectAttributes.SecurityQualityOfService = &Qos;
|
|
|
|
|
|
|
|
Status = NtDuplicateToken (hToken,
|
|
|
|
TOKEN_IMPERSONATE | TOKEN_QUERY,
|
|
|
|
&ObjectAttributes,
|
|
|
|
FALSE,
|
|
|
|
TokenImpersonation,
|
|
|
|
&NewToken);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError (RtlNtStatusToDosError (Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Duplicated = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* User the original impersonation token */
|
|
|
|
NewToken = hToken;
|
|
|
|
Duplicated = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Impersonate the the current thread */
|
|
|
|
Status = NtSetInformationThread (NtCurrentThread (),
|
|
|
|
ThreadImpersonationToken,
|
2004-05-26 19:53:48 +00:00
|
|
|
&NewToken,
|
2004-03-25 11:30:07 +00:00
|
|
|
sizeof(HANDLE));
|
|
|
|
|
|
|
|
if (Duplicated == TRUE)
|
|
|
|
{
|
|
|
|
NtClose (NewToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError (RtlNtStatusToDosError (Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2003-01-15 20:05:53 +00:00
|
|
|
}
|
|
|
|
|
2004-02-25 14:25:11 +00:00
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2001-11-22 02:37:32 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = RtlImpersonateSelf(ImpersonationLevel);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
2004-03-25 11:30:07 +00:00
|
|
|
return FALSE;
|
2001-11-22 02:37:32 +00:00
|
|
|
}
|
2004-03-25 11:30:07 +00:00
|
|
|
return TRUE;
|
2001-11-22 02:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 15:05:55 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2001-11-22 02:37:32 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
RevertToSelf(VOID)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE Token = NULL;
|
|
|
|
|
|
|
|
Status = NtSetInformationThread(NtCurrentThread(),
|
|
|
|
ThreadImpersonationToken,
|
|
|
|
&Token,
|
|
|
|
sizeof(HANDLE));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
2004-03-25 11:30:07 +00:00
|
|
|
return FALSE;
|
2001-11-22 02:37:32 +00:00
|
|
|
}
|
2004-03-25 11:30:07 +00:00
|
|
|
return TRUE;
|
2001-11-22 02:37:32 +00:00
|
|
|
}
|
|
|
|
|
2004-02-25 23:54:13 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetUserNameA [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* Get the current user name.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszName [O] Destination for the user name.
|
|
|
|
* lpSize [I/O] Size of lpszName.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: The length of the user name, including terminating NUL.
|
|
|
|
* Failure: ERROR_MORE_DATA if *lpSize is too small.
|
2004-03-08 18:09:05 +00:00
|
|
|
*
|
|
|
|
* @unimplemented
|
2004-02-25 23:54:13 +00:00
|
|
|
*/
|
2004-03-08 18:09:05 +00:00
|
|
|
BOOL WINAPI
|
2004-02-25 23:54:13 +00:00
|
|
|
GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
|
|
|
|
{
|
2004-03-08 18:09:05 +00:00
|
|
|
// size_t len;
|
|
|
|
// char name[] = { "Administrator" };
|
|
|
|
|
|
|
|
/* We need to include the null character when determining the size of the buffer. */
|
|
|
|
// len = strlen(name) + 1;
|
|
|
|
// if (len > *lpSize)
|
|
|
|
// {
|
|
|
|
// SetLastError(ERROR_MORE_DATA);
|
|
|
|
// *lpSize = len;
|
|
|
|
// return 0;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// *lpSize = len;
|
|
|
|
// strcpy(lpszName, name);
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("GetUserNameA: stub\n");
|
2004-03-08 18:09:05 +00:00
|
|
|
return TRUE;
|
2004-02-25 23:54:13 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 18:09:05 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetUserNameW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* See GetUserNameA.
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
|
|
|
|
{
|
|
|
|
// char name[] = { "Administrator" };
|
|
|
|
|
|
|
|
// DWORD len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
|
|
|
|
|
|
|
|
// if (len > *lpSize)
|
|
|
|
// {
|
|
|
|
// SetLastError(ERROR_MORE_DATA);
|
|
|
|
// *lpSize = len;
|
|
|
|
// return FALSE;
|
|
|
|
// }
|
2002-05-05 14:57:45 +00:00
|
|
|
|
2004-03-08 18:09:05 +00:00
|
|
|
// *lpSize = len;
|
|
|
|
// MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, len );
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("GetUserNameW: stub\n");
|
2004-03-08 18:09:05 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-25 11:30:07 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* LookupAccountSidA [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
LookupAccountSidA (LPCSTR lpSystemName,
|
|
|
|
PSID lpSid,
|
|
|
|
LPSTR lpName,
|
|
|
|
LPDWORD cchName,
|
|
|
|
LPSTR lpReferencedDomainName,
|
|
|
|
LPDWORD cchReferencedDomainName,
|
|
|
|
PSID_NAME_USE peUse)
|
|
|
|
{
|
|
|
|
DPRINT1("LookupAccountSidA is unimplemented, but returns success\n");
|
2004-07-09 20:10:45 +00:00
|
|
|
lstrcpynA(lpName, "Administrator", *cchName);
|
|
|
|
lstrcpynA(lpReferencedDomainName, "ReactOS", *cchReferencedDomainName);
|
2004-03-25 11:30:07 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* LookupAccountSidW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
LookupAccountSidW (LPCWSTR lpSystemName,
|
|
|
|
PSID lpSid,
|
|
|
|
LPWSTR lpName,
|
|
|
|
LPDWORD cchName,
|
|
|
|
LPWSTR lpReferencedDomainName,
|
|
|
|
LPDWORD cchReferencedDomainName,
|
|
|
|
PSID_NAME_USE peUse)
|
|
|
|
{
|
|
|
|
DPRINT1("LookupAccountSidW is unimplemented, but returns success\n");
|
2004-07-09 20:10:45 +00:00
|
|
|
lstrcpynW(lpName, L"Administrator", *cchName);
|
|
|
|
lstrcpynW(lpReferencedDomainName, L"ReactOS", *cchReferencedDomainName);
|
2004-03-25 11:30:07 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* LookupPrivilegeValueA EXPORTED
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
LookupPrivilegeValueA (LPCSTR lpSystemName,
|
|
|
|
LPCSTR lpName,
|
|
|
|
PLUID lpLuid)
|
|
|
|
{
|
|
|
|
UNICODE_STRING SystemName;
|
|
|
|
UNICODE_STRING Name;
|
|
|
|
BOOL Result;
|
|
|
|
|
|
|
|
/* Remote system? */
|
|
|
|
if (lpSystemName != NULL)
|
|
|
|
{
|
|
|
|
RtlCreateUnicodeStringFromAsciiz (&SystemName,
|
|
|
|
(LPSTR)lpSystemName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the privilege name is not NULL */
|
|
|
|
if (lpName == NULL)
|
|
|
|
{
|
|
|
|
SetLastError (ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz (&Name,
|
|
|
|
(LPSTR)lpName);
|
|
|
|
|
|
|
|
Result = LookupPrivilegeValueW ((lpSystemName != NULL) ? SystemName.Buffer : NULL,
|
|
|
|
Name.Buffer,
|
|
|
|
lpLuid);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString (&Name);
|
|
|
|
|
|
|
|
/* Remote system? */
|
|
|
|
if (lpSystemName != NULL)
|
|
|
|
{
|
|
|
|
RtlFreeUnicodeString (&SystemName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* LookupPrivilegeValueW EXPORTED
|
|
|
|
*
|
2004-04-12 15:22:53 +00:00
|
|
|
* @unimplemented
|
2004-03-25 11:30:07 +00:00
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
2004-07-06 22:08:48 +00:00
|
|
|
LookupPrivilegeValueW (LPCWSTR SystemName,
|
|
|
|
LPCWSTR PrivName,
|
|
|
|
PLUID Luid)
|
2004-03-25 11:30:07 +00:00
|
|
|
{
|
2004-07-06 22:08:48 +00:00
|
|
|
static const WCHAR * const DefaultPrivNames[] =
|
|
|
|
{
|
|
|
|
L"SeCreateTokenPrivilege",
|
|
|
|
L"SeAssignPrimaryTokenPrivilege",
|
|
|
|
L"SeLockMemoryPrivilege",
|
|
|
|
L"SeIncreaseQuotaPrivilege",
|
|
|
|
L"SeUnsolicitedInputPrivilege",
|
|
|
|
L"SeMachineAccountPrivilege",
|
|
|
|
L"SeTcbPrivilege",
|
|
|
|
L"SeSecurityPrivilege",
|
|
|
|
L"SeTakeOwnershipPrivilege",
|
|
|
|
L"SeLoadDriverPrivilege",
|
|
|
|
L"SeSystemProfilePrivilege",
|
|
|
|
L"SeSystemtimePrivilege",
|
|
|
|
L"SeProfileSingleProcessPrivilege",
|
|
|
|
L"SeIncreaseBasePriorityPrivilege",
|
|
|
|
L"SeCreatePagefilePrivilege",
|
|
|
|
L"SeCreatePermanentPrivilege",
|
|
|
|
L"SeBackupPrivilege",
|
|
|
|
L"SeRestorePrivilege",
|
|
|
|
L"SeShutdownPrivilege",
|
|
|
|
L"SeDebugPrivilege",
|
|
|
|
L"SeAuditPrivilege",
|
|
|
|
L"SeSystemEnvironmentPrivilege",
|
|
|
|
L"SeChangeNotifyPrivilege",
|
|
|
|
L"SeRemoteShutdownPrivilege",
|
|
|
|
L"SeUndockPrivilege",
|
|
|
|
L"SeSyncAgentPrivilege",
|
|
|
|
L"SeEnableDelegationPrivilege",
|
|
|
|
L"SeManageVolumePrivilege",
|
|
|
|
L"SeImpersonatePrivilege",
|
|
|
|
L"SeCreateGlobalPrivilege"
|
|
|
|
};
|
|
|
|
unsigned Priv;
|
|
|
|
|
|
|
|
if (NULL != SystemName && L'\0' != *SystemName)
|
|
|
|
{
|
|
|
|
DPRINT1("LookupPrivilegeValueW: not implemented for remote system\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Priv = 0; Priv < sizeof(DefaultPrivNames) / sizeof(DefaultPrivNames[0]); Priv++)
|
|
|
|
{
|
|
|
|
if (0 == wcscmp(PrivName, DefaultPrivNames[Priv]))
|
|
|
|
{
|
|
|
|
Luid->LowPart = Priv + 1;
|
|
|
|
Luid->HighPart = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT1("LookupPrivilegeValueW: no such privilege %S\n", PrivName);
|
|
|
|
SetLastError(ERROR_NO_SUCH_PRIVILEGE);
|
2004-03-25 11:30:07 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* LookupPrivilegeDisplayNameA EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
LookupPrivilegeDisplayNameA (LPCSTR lpSystemName,
|
|
|
|
LPCSTR lpName,
|
|
|
|
LPSTR lpDisplayName,
|
|
|
|
LPDWORD cbDisplayName,
|
|
|
|
LPDWORD lpLanguageId)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("LookupPrivilegeDisplayNameA: stub\n");
|
2004-03-25 11:30:07 +00:00
|
|
|
SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* LookupPrivilegeDisplayNameW EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
LookupPrivilegeDisplayNameW (LPCWSTR lpSystemName,
|
|
|
|
LPCWSTR lpName,
|
|
|
|
LPWSTR lpDisplayName,
|
|
|
|
LPDWORD cbDisplayName,
|
|
|
|
LPDWORD lpLanguageId)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("LookupPrivilegeDisplayNameW: stub\n");
|
2004-03-25 11:30:07 +00:00
|
|
|
SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* LookupPrivilegeNameA EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
LookupPrivilegeNameA (LPCSTR lpSystemName,
|
|
|
|
PLUID lpLuid,
|
|
|
|
LPSTR lpName,
|
|
|
|
LPDWORD cbName)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("LookupPrivilegeNameA: stub\n");
|
2004-03-25 11:30:07 +00:00
|
|
|
SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* LookupPrivilegeNameW EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
LookupPrivilegeNameW (LPCWSTR lpSystemName,
|
|
|
|
PLUID lpLuid,
|
|
|
|
LPWSTR lpName,
|
|
|
|
LPDWORD cbName)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("LookupPrivilegeNameW: stub\n");
|
2004-03-25 11:30:07 +00:00
|
|
|
SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-26 09:50:10 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetNamedSecurityInfoW EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD STDCALL
|
|
|
|
GetNamedSecurityInfoW(LPWSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID *ppsidOwner,
|
|
|
|
PSID *ppsidGroup,
|
|
|
|
PACL *ppDacl,
|
|
|
|
PACL *ppSacl,
|
|
|
|
PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("GetNamedSecurityInfoW: stub\n");
|
2004-05-26 09:50:10 +00:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetNamedSecurityInfoA EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD STDCALL
|
|
|
|
GetNamedSecurityInfoA(LPSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID *ppsidOwner,
|
|
|
|
PSID *ppsidGroup,
|
|
|
|
PACL *ppDacl,
|
|
|
|
PACL *ppSacl,
|
|
|
|
PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("GetNamedSecurityInfoA: stub\n");
|
2004-05-26 09:50:10 +00:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SetNamedSecurityInfoW EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD STDCALL
|
|
|
|
SetNamedSecurityInfoW(LPWSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID psidOwner,
|
|
|
|
PSID psidGroup,
|
|
|
|
PACL pDacl,
|
|
|
|
PACL pSacl)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("SetNamedSecurityInfoW: stub\n");
|
2004-05-26 09:50:10 +00:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SetNamedSecurityInfoA EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD STDCALL
|
|
|
|
SetNamedSecurityInfoA(LPSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID psidOwner,
|
|
|
|
PSID psidGroup,
|
|
|
|
PACL pDacl,
|
|
|
|
PACL pSacl)
|
|
|
|
{
|
2004-05-27 14:50:17 +00:00
|
|
|
DPRINT1("SetNamedSecurityInfoA: stub\n");
|
2004-05-26 09:50:10 +00:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2004-07-10 14:38:24 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetSecurityInfo EXPORTED
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD STDCALL
|
|
|
|
GetSecurityInfo(HANDLE handle,
|
|
|
|
SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID* ppsidOwner,
|
|
|
|
PSID* ppsidGroup,
|
|
|
|
PACL* ppDacl,
|
|
|
|
PACL* ppSacl,
|
|
|
|
PSECURITY_DESCRIPTOR* ppSecurityDescriptor)
|
|
|
|
{
|
|
|
|
DPRINT1("GetSecurityInfo: stub\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2004-09-06 22:12:25 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ImpersonateNamedPipeClient EXPORTED
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
ImpersonateNamedPipeClient(HANDLE hNamedPipe)
|
|
|
|
{
|
|
|
|
IO_STATUS_BLOCK StatusBlock;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DPRINT("ImpersonateNamedPipeClient() called\n");
|
|
|
|
|
|
|
|
Status = NtFsControlFile(hNamedPipe,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&StatusBlock,
|
|
|
|
FSCTL_PIPE_IMPERSONATE,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
0);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-08 18:09:05 +00:00
|
|
|
/* EOF */
|