From 9e558fcc6a4903efac798f4c40d9911fff18fc68 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 25 Mar 2004 11:30:07 +0000 Subject: [PATCH] - Implement ImpersonateLoggedOnUser(). - Moved some security related functions to better places. svn path=/trunk/; revision=8870 --- reactos/lib/advapi32/makefile | 6 +- reactos/lib/advapi32/sec/misc.c | 311 +++++++++++++++++++- reactos/lib/advapi32/sec/sec.c | 46 +-- reactos/lib/advapi32/sec/sid.c | 371 ++++++++++-------------- reactos/lib/advapi32/service/eventlog.c | 303 ++++++++++++------- reactos/lib/advapi32/token/privilege.c | 131 +-------- reactos/lib/advapi32/token/token.c | 4 +- 7 files changed, 663 insertions(+), 509 deletions(-) diff --git a/reactos/lib/advapi32/makefile b/reactos/lib/advapi32/makefile index eabcfe6330a..b744dab612a 100644 --- a/reactos/lib/advapi32/makefile +++ b/reactos/lib/advapi32/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.38 2004/03/10 21:56:04 navaraf Exp $ +# $Id: makefile,v 1.39 2004/03/25 11:30:07 ekohl Exp $ PATH_TO_TOP = ../.. @@ -34,10 +34,10 @@ SECURITY_OBJECTS = \ sec/sid.o SERVICE_OBJECTS = \ + service/eventlog.o \ service/scm.o \ service/sctrl.o \ - service/undoc.o \ - service/eventlog.o + service/undoc.o TOKEN_OBJECTS = \ token/privilege.o \ diff --git a/reactos/lib/advapi32/sec/misc.c b/reactos/lib/advapi32/sec/misc.c index b0119b3f3c3..069c76eed77 100644 --- a/reactos/lib/advapi32/sec/misc.c +++ b/reactos/lib/advapi32/sec/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.11 2004/03/08 18:09:05 sedwards Exp $ +/* $Id: misc.c,v 1.12 2004/03/25 11:30:07 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -6,11 +6,13 @@ * PURPOSE: Miscellaneous security functions */ -#include #define NTOS_MODE_USER #include #include +#define NDEBUG +#include + /* * @implemented @@ -36,6 +38,40 @@ AreAnyAccessesGranted(DWORD GrantedAccess, } +/****************************************************************************** + * 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. + * + * @unimplemented + */ +BOOL WINAPI +GetFileSecurityA (LPCSTR lpFileName, + SECURITY_INFORMATION RequestedInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded) +{ + DPRINT("GetFileSecurityW : stub\n"); + return TRUE; +} + + /* * @implemented */ @@ -62,6 +98,22 @@ GetKernelObjectSecurity(HANDLE Handle, } +/****************************************************************************** + * 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; +} + + /* * @implemented */ @@ -78,9 +130,9 @@ SetKernelObjectSecurity(HANDLE Handle, if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); - return(FALSE); + return FALSE; } - return(TRUE); + return TRUE; } @@ -97,12 +149,85 @@ MapGenericMask(PDWORD AccessMask, /* - * @unimplemented + * @implemented */ BOOL STDCALL ImpersonateLoggedOnUser(HANDLE hToken) { - return FALSE; + 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, + NewToken, + sizeof(HANDLE)); + + if (Duplicated == TRUE) + { + NtClose (NewToken); + } + + if (!NT_SUCCESS(Status)) + { + SetLastError (RtlNtStatusToDosError (Status)); + return FALSE; + } + + return TRUE; } @@ -118,9 +243,9 @@ ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); - return(FALSE); + return FALSE; } - return(TRUE); + return TRUE; } @@ -140,9 +265,9 @@ RevertToSelf(VOID) if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); - return(FALSE); + return FALSE; } - return(TRUE); + return TRUE; } @@ -207,4 +332,170 @@ GetUserNameW( LPWSTR lpszName, LPDWORD lpSize ) return TRUE; } + +/****************************************************************************** + * 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"); + 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"); + 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 + * + * @unimplemented + */ +BOOL STDCALL +LookupPrivilegeValueW (LPCWSTR lpSystemName, + LPCWSTR lpName, + PLUID lpLuid) +{ + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/********************************************************************** + * LookupPrivilegeDisplayNameA EXPORTED + * + * @unimplemented + */ +BOOL STDCALL +LookupPrivilegeDisplayNameA (LPCSTR lpSystemName, + LPCSTR lpName, + LPSTR lpDisplayName, + LPDWORD cbDisplayName, + LPDWORD lpLanguageId) +{ + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/********************************************************************** + * LookupPrivilegeDisplayNameW EXPORTED + * + * @unimplemented + */ +BOOL STDCALL +LookupPrivilegeDisplayNameW (LPCWSTR lpSystemName, + LPCWSTR lpName, + LPWSTR lpDisplayName, + LPDWORD cbDisplayName, + LPDWORD lpLanguageId) +{ + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/********************************************************************** + * LookupPrivilegeNameA EXPORTED + * + * @unimplemented + */ +BOOL STDCALL +LookupPrivilegeNameA (LPCSTR lpSystemName, + PLUID lpLuid, + LPSTR lpName, + LPDWORD cbName) +{ + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/********************************************************************** + * LookupPrivilegeNameW EXPORTED + * + * @unimplemented + */ +BOOL STDCALL +LookupPrivilegeNameW (LPCWSTR lpSystemName, + PLUID lpLuid, + LPWSTR lpName, + LPDWORD cbName) +{ + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + /* EOF */ diff --git a/reactos/lib/advapi32/sec/sec.c b/reactos/lib/advapi32/sec/sec.c index 7937b602e5f..77d3b21f0d7 100644 --- a/reactos/lib/advapi32/sec/sec.c +++ b/reactos/lib/advapi32/sec/sec.c @@ -1,4 +1,4 @@ -/* $Id: sec.c,v 1.19 2004/02/25 23:54:13 sedwards Exp $ +/* $Id: sec.c,v 1.20 2004/03/25 11:30:07 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -11,41 +11,11 @@ * Created 01/11/98 */ -#include #define NTOS_MODE_USER #include #include -/****************************************************************************** - * 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. - */ -BOOL WINAPI -GetFileSecurityA( LPCSTR lpFileName, - SECURITY_INFORMATION RequestedInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, LPDWORD lpnLengthNeeded ) -{ - DPRINT("GetFileSecurityW : stub\n"); - return TRUE; -} - +#include /* * @implemented @@ -320,18 +290,6 @@ MakeSelfRelativeSD ( return TRUE; } -/****************************************************************************** - * SetFileSecurityA [ADVAPI32.@] - * Sets the security of a file or directory - */ -BOOL STDCALL SetFileSecurityA( LPCSTR lpFileName, - SECURITY_INFORMATION RequestedInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor) -{ - DPRINT("SetFileSecurityA : stub\n"); - return TRUE; -} - /* * @implemented diff --git a/reactos/lib/advapi32/sec/sid.c b/reactos/lib/advapi32/sec/sid.c index 652d66379c1..5ddeb7ecb79 100644 --- a/reactos/lib/advapi32/sec/sid.c +++ b/reactos/lib/advapi32/sec/sid.c @@ -1,4 +1,4 @@ -/* $Id: sid.c,v 1.11 2004/03/10 21:34:42 fireball Exp $ +/* $Id: sid.c,v 1.12 2004/03/25 11:30:07 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -18,15 +18,16 @@ BOOL STDCALL AllocateLocallyUniqueId(PLUID Luid) { - NTSTATUS Status; + NTSTATUS Status; - Status = NtAllocateLocallyUniqueId(Luid); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return(FALSE); - } - return(TRUE); + Status = NtAllocateLocallyUniqueId (Luid); + if (!NT_SUCCESS (Status)) + { + SetLastError (RtlNtStatusToDosError (Status)); + return FALSE; + } + + return TRUE; } @@ -34,26 +35,24 @@ AllocateLocallyUniqueId(PLUID Luid) * @implemented */ BOOL STDCALL -AllocateAndInitializeSid ( - PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, - BYTE nSubAuthorityCount, - DWORD dwSubAuthority0, - DWORD dwSubAuthority1, - DWORD dwSubAuthority2, - DWORD dwSubAuthority3, - DWORD dwSubAuthority4, - DWORD dwSubAuthority5, - DWORD dwSubAuthority6, - DWORD dwSubAuthority7, - PSID *pSid -) +AllocateAndInitializeSid (PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, + BYTE nSubAuthorityCount, + DWORD dwSubAuthority0, + DWORD dwSubAuthority1, + DWORD dwSubAuthority2, + DWORD dwSubAuthority3, + DWORD dwSubAuthority4, + DWORD dwSubAuthority5, + DWORD dwSubAuthority6, + DWORD dwSubAuthority7, + PSID *pSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAllocateAndInitializeSid (pIdentifierAuthority, - nSubAuthorityCount, - dwSubAuthority0, - dwSubAuthority1, + Status = RtlAllocateAndInitializeSid (pIdentifierAuthority, + nSubAuthorityCount, + dwSubAuthority0, + dwSubAuthority1, dwSubAuthority2, dwSubAuthority3, dwSubAuthority4, @@ -61,171 +60,13 @@ AllocateAndInitializeSid ( dwSubAuthority6, dwSubAuthority7, pSid); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + if (!NT_SUCCESS (Status)) + { + SetLastError (RtlNtStatusToDosError (Status)); + return FALSE; + } - return TRUE; -} - - -/* - * @implemented - */ -BOOL -STDCALL -CopySid ( - DWORD nDestinationSidLength, - PSID pDestinationSid, - PSID pSourceSid -) -{ - NTSTATUS Status; - - Status = RtlCopySid (nDestinationSidLength, - pDestinationSid, - pSourceSid); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -BOOL -STDCALL -EqualPrefixSid ( - PSID pSid1, - PSID pSid2 - ) -{ - return RtlEqualPrefixSid (pSid1, pSid2); -} - -/* - * @implemented - */ -BOOL -STDCALL -EqualSid ( - PSID pSid1, - PSID pSid2 - ) -{ - return RtlEqualSid (pSid1, pSid2); -} - - -/* - * @implemented - */ -PVOID -STDCALL -FreeSid ( - PSID pSid - ) -{ - return RtlFreeSid (pSid); -} - - -/* - * @implemented - */ -DWORD -STDCALL -GetLengthSid ( - PSID pSid - ) -{ - return (DWORD)RtlLengthSid (pSid); -} - - -/* - * @implemented - */ -PSID_IDENTIFIER_AUTHORITY -STDCALL -GetSidIdentifierAuthority ( - PSID pSid - ) -{ - return RtlIdentifierAuthoritySid (pSid); -} - - -/* - * @implemented - */ -DWORD -STDCALL -GetSidLengthRequired ( - UCHAR nSubAuthorityCount - ) -{ - return (DWORD)RtlLengthRequiredSid (nSubAuthorityCount); -} - - -/* - * @implemented - */ -PDWORD -STDCALL -GetSidSubAuthority ( - PSID pSid, - DWORD nSubAuthority - ) -{ - return (PDWORD)RtlSubAuthoritySid (pSid, nSubAuthority); -} - - -/* - * @implemented - */ -PUCHAR -STDCALL -GetSidSubAuthorityCount ( - PSID pSid - ) -{ - return RtlSubAuthorityCountSid (pSid); -} - - -/* - * @implemented - */ -BOOL -STDCALL -InitializeSid ( - PSID Sid, - PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, - BYTE nSubAuthorityCount - ) -{ - NTSTATUS Status; - - Status = RtlInitializeSid (Sid, - pIdentifierAuthority, - nSubAuthorityCount); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - return TRUE; + return TRUE; } @@ -233,40 +74,138 @@ InitializeSid ( * @implemented */ BOOL STDCALL -IsValidSid(PSID pSid) +CopySid (DWORD nDestinationSidLength, + PSID pDestinationSid, + PSID pSourceSid) { - return((BOOL)RtlValidSid(pSid)); -} + NTSTATUS Status; -/****************************************************************************** - * LookupAccountSidA [ADVAPI32.@] - * - * @unimplemented - */ -BOOL STDCALL -LookupAccountSidA(LPCSTR lpSystemName, PSID lpSid, LPSTR lpName, - LPDWORD cchName, LPSTR lpReferencedDomainName, - LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse) + Status = RtlCopySid (nDestinationSidLength, + pDestinationSid, + pSourceSid); + if (!NT_SUCCESS (Status)) + { + SetLastError (RtlNtStatusToDosError (Status)); + return FALSE; + } - -{ - DPRINT1("LookupAccountSidA is unimplemented, but returns success\n"); - return TRUE; + return TRUE; } -/****************************************************************************** - * LookupAccountSidW [ADVAPI32.@] - * - * @unimplemented +/* + * @implemented */ BOOL STDCALL -LookupAccountSidW(LPCWSTR lpSystemName, PSID lpSid, LPWSTR lpName, - LPDWORD cchName, LPWSTR lpReferencedDomainName, - LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse) +EqualPrefixSid (PSID pSid1, + PSID pSid2) { - DPRINT1("LookupAccountSidW is unimplemented, but returns success\n"); - return TRUE; + return RtlEqualPrefixSid (pSid1, pSid2); +} + + +/* + * @implemented + */ +BOOL STDCALL +EqualSid (PSID pSid1, + PSID pSid2) +{ + return RtlEqualSid (pSid1, pSid2); +} + + +/* + * @implemented + */ +PVOID STDCALL +FreeSid (PSID pSid) +{ + return RtlFreeSid (pSid); +} + + +/* + * @implemented + */ +DWORD STDCALL +GetLengthSid (PSID pSid) +{ + return (DWORD)RtlLengthSid (pSid); +} + + +/* + * @implemented + */ +PSID_IDENTIFIER_AUTHORITY STDCALL +GetSidIdentifierAuthority (PSID pSid) +{ + return RtlIdentifierAuthoritySid (pSid); +} + + +/* + * @implemented + */ +DWORD STDCALL +GetSidLengthRequired (UCHAR nSubAuthorityCount) +{ + return (DWORD)RtlLengthRequiredSid (nSubAuthorityCount); +} + + +/* + * @implemented + */ +PDWORD STDCALL +GetSidSubAuthority (PSID pSid, + DWORD nSubAuthority) +{ + return (PDWORD)RtlSubAuthoritySid (pSid, nSubAuthority); +} + + +/* + * @implemented + */ +PUCHAR STDCALL +GetSidSubAuthorityCount (PSID pSid) +{ + return RtlSubAuthorityCountSid (pSid); +} + + +/* + * @implemented + */ +BOOL STDCALL +InitializeSid (PSID Sid, + PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, + BYTE nSubAuthorityCount) +{ + NTSTATUS Status; + + Status = RtlInitializeSid (Sid, + pIdentifierAuthority, + nSubAuthorityCount); + if (!NT_SUCCESS (Status)) + { + SetLastError (RtlNtStatusToDosError (Status)); + return FALSE; + } + + return TRUE; +} + + +/* + * @implemented + */ +BOOL STDCALL +IsValidSid (PSID pSid) +{ + return (BOOL)RtlValidSid (pSid); } /* EOF */ diff --git a/reactos/lib/advapi32/service/eventlog.c b/reactos/lib/advapi32/service/eventlog.c index e1eed3b6728..4c8266b69d6 100644 --- a/reactos/lib/advapi32/service/eventlog.c +++ b/reactos/lib/advapi32/service/eventlog.c @@ -20,29 +20,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define __USE_W32API -#define _WIN32_WINNT 0x0501 +#define NTOS_MODE_USER +#include +#include #include -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "winreg.h" -#include "wine/winternl.h" +#define NDEBUG +#include -#define YDEBUG -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(advapi); -WINE_DECLARE_DEBUG_CHANNEL(eventlog); /****************************************************************************** * BackupEventLogA [ADVAPI32.@] */ -BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) +BOOL WINAPI +BackupEventLogA (HANDLE hEventLog, + LPCSTR lpBackupFileName) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } /****************************************************************************** @@ -53,39 +48,49 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) * lpBackupFileName [] */ BOOL WINAPI -BackupEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName ) +BackupEventLogW (HANDLE hEventLog, + LPCWSTR lpBackupFileName) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * ClearEventLogA [ADVAPI32.@] */ -BOOL WINAPI ClearEventLogA ( HANDLE hEventLog, LPCSTR lpBackupFileName ) +BOOL WINAPI +ClearEventLogA (HANDLE hEventLog, + LPCSTR lpBackupFileName) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * ClearEventLogW [ADVAPI32.@] */ -BOOL WINAPI ClearEventLogW ( HANDLE hEventLog, LPCWSTR lpBackupFileName ) +BOOL WINAPI +ClearEventLogW (HANDLE hEventLog, + LPCWSTR lpBackupFileName) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * CloseEventLog [ADVAPI32.@] */ -BOOL WINAPI CloseEventLog ( HANDLE hEventLog ) +BOOL WINAPI +CloseEventLog (HANDLE hEventLog) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * DeregisterEventSource [ADVAPI32.@] * Closes a handle to the specified event log @@ -95,12 +100,14 @@ BOOL WINAPI CloseEventLog ( HANDLE hEventLog ) * * RETURNS STD */ -BOOL WINAPI DeregisterEventSource( HANDLE hEventLog ) +BOOL WINAPI +DeregisterEventSource (HANDLE hEventLog) { - FIXME("(%p): stub\n",hEventLog); - return TRUE; + DPRINT1("(%p): stub\n",hEventLog); + return TRUE; } + /****************************************************************************** * GetNumberOfEventLogRecords [ADVAPI32.@] * @@ -109,12 +116,14 @@ BOOL WINAPI DeregisterEventSource( HANDLE hEventLog ) * NumberOfRecords [] */ BOOL WINAPI -GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords ) +GetNumberOfEventLogRecords (HANDLE hEventLog, + PDWORD NumberOfRecords) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * GetOldestEventLogRecord [ADVAPI32.@] * @@ -123,12 +132,14 @@ GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords ) * OldestRecord [] */ BOOL WINAPI -GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord ) +GetOldestEventLogRecord (HANDLE hEventLog, + PDWORD OldestRecord) { - FIXME(":stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * NotifyChangeEventLog [ADVAPI32.@] * @@ -136,22 +147,27 @@ GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord ) * hEventLog [] * hEvent [] */ -BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent ) +BOOL WINAPI +NotifyChangeEventLog (HANDLE hEventLog, + HANDLE hEvent) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * OpenBackupEventLogA [ADVAPI32.@] */ HANDLE WINAPI -OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) +OpenBackupEventLogA (LPCSTR lpUNCServerName, + LPCSTR lpFileName) { - FIXME("stub\n"); - return (HANDLE)1; + DPRINT1("stub\n"); + return (HANDLE)1; } + /****************************************************************************** * OpenBackupEventLogW [ADVAPI32.@] * @@ -160,21 +176,27 @@ OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) * lpFileName [] */ HANDLE WINAPI -OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName ) +OpenBackupEventLogW (LPCWSTR lpUNCServerName, + LPCWSTR lpFileName) { - FIXME("stub\n"); - return (HANDLE)1; + DPRINT1("stub\n"); + return (HANDLE)1; } + /****************************************************************************** * OpenEventLogA [ADVAPI32.@] */ -HANDLE WINAPI OpenEventLogA(LPCSTR uncname,LPCSTR source) +HANDLE WINAPI +OpenEventLogA (LPCSTR lpUNCServerName, + LPCSTR lpSourceName) { - FIXME("(%s,%s),stub!\n",uncname,source); - return (HANDLE)0xcafe4242; + DPRINT1("(%s,%s),stub!\n", + lpUNCServerName, lpSourceName); + return (HANDLE)0xcafe4242; } + /****************************************************************************** * OpenEventLogW [ADVAPI32.@] * @@ -183,22 +205,31 @@ HANDLE WINAPI OpenEventLogA(LPCSTR uncname,LPCSTR source) * source [] */ HANDLE WINAPI -OpenEventLogW( LPCWSTR uncname, LPCWSTR source ) +OpenEventLogW (LPCWSTR lpUNCServerName, + LPCWSTR lpSourceName) { - FIXME("stub\n"); - return (HANDLE)1; + DPRINT1("stub\n"); + return (HANDLE)1; } + /****************************************************************************** * ReadEventLogA [ADVAPI32.@] */ -BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset, - LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded ) +BOOL WINAPI +ReadEventLogA (HANDLE hEventLog, + DWORD dwReadFlags, + DWORD dwRecordOffset, + LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + DWORD *pnBytesRead, + DWORD *pnMinNumberOfBytesNeeded) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * ReadEventLogW [ADVAPI32.@] * @@ -212,31 +243,45 @@ BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOf * pnMinNumberOfBytesNeeded [] */ BOOL WINAPI -ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset, - LPVOID lpBuffer, DWORD nNumberOfBytesToRead, - DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded ) +ReadEventLogW (HANDLE hEventLog, + DWORD dwReadFlags, + DWORD dwRecordOffset, + LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + DWORD *pnBytesRead, + DWORD *pnMinNumberOfBytesNeeded) { - FIXME("stub\n"); - return TRUE; + DPRINT1("stub\n"); + return TRUE; } + /****************************************************************************** * RegisterEventSourceA [ADVAPI32.@] */ -HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName ) +HANDLE WINAPI +RegisterEventSourceA (LPCSTR lpUNCServerName, + LPCSTR lpSourceName) { - - UNICODE_STRING lpUNCServerNameW; - UNICODE_STRING lpSourceNameW; - HANDLE ret; - RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName); - RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName); - ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer); - RtlFreeUnicodeString (&lpUNCServerNameW); - RtlFreeUnicodeString (&lpSourceNameW); - return ret; + UNICODE_STRING UNCServerName; + UNICODE_STRING SourceName; + HANDLE ret; + + RtlCreateUnicodeStringFromAsciiz (&UNCServerName, + (PSTR)lpUNCServerName); + RtlCreateUnicodeStringFromAsciiz (&SourceName, + (PSTR)lpSourceName); + + ret = RegisterEventSourceW (UNCServerName.Buffer, + SourceName.Buffer); + + RtlFreeUnicodeString (&UNCServerName); + RtlFreeUnicodeString (&SourceName); + + return ret; } + /****************************************************************************** * RegisterEventSourceW [ADVAPI32.@] * Returns a registered handle to an event log @@ -250,43 +295,79 @@ HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName * Failure: NULL */ HANDLE WINAPI -RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR lpSourceName ) +RegisterEventSourceW (LPCWSTR lpUNCServerName, + LPCWSTR lpSourceName) { - FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName), - debugstr_w(lpSourceName)); - return (HANDLE)1; + DPRINT1("(%S, %S): stub\n", + lpUNCServerName, lpSourceName); + return (HANDLE)1; } + /****************************************************************************** * ReportEventA [ADVAPI32.@] */ -BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID, - PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCSTR *lpStrings, LPVOID lpRawData) +BOOL WINAPI +ReportEventA (HANDLE hEventLog, + WORD wType, + WORD wCategory, + DWORD dwEventID, + PSID lpUserSid, + WORD wNumStrings, + DWORD dwDataSize, + LPCSTR *lpStrings, + LPVOID lpRawData) { - LPCWSTR *wideStrArray; - UNICODE_STRING str; - int i; - BOOL ret; + LPCWSTR *wideStrArray; + UNICODE_STRING str; + int i; + BOOL ret; - if (wNumStrings == 0) return TRUE; - if (!lpStrings) return TRUE; + if (wNumStrings == 0) + return TRUE; - wideStrArray = HeapAlloc(GetProcessHeap(), 0, sizeof(LPCWSTR) * wNumStrings); - for (i = 0; i < wNumStrings; i++) + if (lpStrings == NULL) + return TRUE; + + wideStrArray = HeapAlloc (GetProcessHeap (), + 0, + sizeof(LPCWSTR) * wNumStrings); + + for (i = 0; i < wNumStrings; i++) { - RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]); + RtlCreateUnicodeStringFromAsciiz (&str, + (PSTR)lpStrings[i]); wideStrArray[i] = str.Buffer; } - ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid, - wNumStrings, dwDataSize, wideStrArray, lpRawData); - for (i = 0; i < wNumStrings; i++) + + ret = ReportEventW (hEventLog, + wType, + wCategory, + dwEventID, + lpUserSid, + wNumStrings, + dwDataSize, + wideStrArray, + lpRawData); + + for (i = 0; i < wNumStrings; i++) { - if (wideStrArray[i]) HeapFree( GetProcessHeap(), 0, (LPSTR)wideStrArray[i] ); + if (wideStrArray[i]) + { + HeapFree (GetProcessHeap (), + 0, + (LPSTR)wideStrArray[i]); + } } - HeapFree(GetProcessHeap(), 0, wideStrArray); - return ret; + + HeapFree (GetProcessHeap(), + 0, + wideStrArray); + + return ret; } + /****************************************************************************** * ReportEventW [ADVAPI32.@] * @@ -302,35 +383,47 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d * lpRawData [] */ BOOL WINAPI -ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory, - DWORD dwEventID, PSID lpUserSid, WORD wNumStrings, - DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData ) +ReportEventW (HANDLE hEventLog, + WORD wType, + WORD wCategory, + DWORD dwEventID, + PSID lpUserSid, + WORD wNumStrings, + DWORD dwDataSize, + LPCWSTR *lpStrings, + LPVOID lpRawData) { - int i; + int i; /* partial stub */ - if (wNumStrings == 0) return TRUE; - if (!lpStrings) return TRUE; + if (wNumStrings == 0) + return TRUE; - for (i = 0; i < wNumStrings; i++) + if (lpStrings == NULL) + return TRUE; + + for (i = 0; i < wNumStrings; i++) { - switch (wType) + switch (wType) { case EVENTLOG_SUCCESS: - TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i])); + DPRINT1("Success: %S\n", lpStrings[i]); break; + case EVENTLOG_ERROR_TYPE: - ERR_(eventlog)("%s\n", debugstr_w(lpStrings[i])); + DPRINT1("Error: %S\n", lpStrings[i]); break; + case EVENTLOG_WARNING_TYPE: - WARN_(eventlog)("%s\n", debugstr_w(lpStrings[i])); + DPRINT1("Warning: %S\n", lpStrings[i]); break; + default: - TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i])); + DPRINT1("Type %hu: %S\n", wType, lpStrings[i]); break; } } - return TRUE; + return TRUE; } diff --git a/reactos/lib/advapi32/token/privilege.c b/reactos/lib/advapi32/token/privilege.c index f290550c675..0a904961a1d 100644 --- a/reactos/lib/advapi32/token/privilege.c +++ b/reactos/lib/advapi32/token/privilege.c @@ -1,4 +1,4 @@ -/* $Id: privilege.c,v 1.6 2004/02/25 14:25:11 ekohl Exp $ +/* $Id: privilege.c,v 1.7 2004/03/25 11:30:07 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -8,138 +8,11 @@ * UPDATE HISTORY: * 20010317 ea stubs */ + #include #include -/********************************************************************** - * 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 - * - * @unimplemented - */ -BOOL STDCALL -LookupPrivilegeValueW (LPCWSTR lpSystemName, - LPCWSTR lpName, - PLUID lpLuid) -{ - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/********************************************************************** - * LookupPrivilegeDisplayNameA EXPORTED - * - * @unimplemented - */ -BOOL STDCALL -LookupPrivilegeDisplayNameA (LPCSTR lpSystemName, - LPCSTR lpName, - LPSTR lpDisplayName, - LPDWORD cbDisplayName, - LPDWORD lpLanguageId) -{ - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/********************************************************************** - * LookupPrivilegeDisplayNameW EXPORTED - * - * @unimplemented - */ -BOOL STDCALL -LookupPrivilegeDisplayNameW (LPCWSTR lpSystemName, - LPCWSTR lpName, - LPWSTR lpDisplayName, - LPDWORD cbDisplayName, - LPDWORD lpLanguageId) -{ - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/********************************************************************** - * LookupPrivilegeNameA EXPORTED - * - * @unimplemented - */ -BOOL STDCALL -LookupPrivilegeNameA (LPCSTR lpSystemName, - PLUID lpLuid, - LPSTR lpName, - LPDWORD cbName) -{ - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/********************************************************************** - * LookupPrivilegeNameW EXPORTED - * - * @unimplemented - */ -BOOL STDCALL -LookupPrivilegeNameW (LPCWSTR lpSystemName, - PLUID lpLuid, - LPWSTR lpName, - LPDWORD cbName) -{ - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - /********************************************************************** * PrivilegeCheck EXPORTED * diff --git a/reactos/lib/advapi32/token/token.c b/reactos/lib/advapi32/token/token.c index 2127c56d8a1..2d48b6d853e 100644 --- a/reactos/lib/advapi32/token/token.c +++ b/reactos/lib/advapi32/token/token.c @@ -1,4 +1,4 @@ -/* $Id: token.c,v 1.9 2004/02/25 14:25:11 ekohl Exp $ +/* $Id: token.c,v 1.10 2004/03/25 11:30:07 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -283,7 +283,7 @@ DuplicateToken (HANDLE ExistingTokenHandle, PHANDLE DuplicateTokenHandle) { return DuplicateTokenEx (ExistingTokenHandle, - TOKEN_DUPLICATE|TOKEN_IMPERSONATE|TOKEN_QUERY, + TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY, NULL, ImpersonationLevel, TokenImpersonation,