diff --git a/reactos/dll/win32/advapi32/sec/ac.c b/reactos/dll/win32/advapi32/sec/ac.c index 97052cd2a7b..168737224e4 100644 --- a/reactos/dll/win32/advapi32/sec/ac.c +++ b/reactos/dll/win32/advapi32/sec/ac.c @@ -18,26 +18,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); */ BOOL STDCALL -GetAclInformation ( - PACL pAcl, - LPVOID pAclInformation, - DWORD nAclInformationLength, - ACL_INFORMATION_CLASS dwAclInformationClass - ) +GetAclInformation(PACL pAcl, + LPVOID pAclInformation, + DWORD nAclInformationLength, + ACL_INFORMATION_CLASS dwAclInformationClass) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlQueryInformationAcl (pAcl, - pAclInformation, - nAclInformationLength, - dwAclInformationClass); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlQueryInformationAcl(pAcl, + pAclInformation, + nAclInformationLength, + dwAclInformationClass); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -46,24 +44,22 @@ GetAclInformation ( */ BOOL STDCALL -InitializeAcl ( - PACL pAcl, - DWORD nAclLength, - DWORD dwAclRevision - ) +InitializeAcl(PACL pAcl, + DWORD nAclLength, + DWORD dwAclRevision) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlCreateAcl (pAcl, - nAclLength, - dwAclRevision); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlCreateAcl(pAcl, + nAclLength, + dwAclRevision); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -72,11 +68,9 @@ InitializeAcl ( */ BOOL STDCALL -IsValidAcl ( - PACL pAcl - ) +IsValidAcl(PACL pAcl) { - return RtlValidAcl (pAcl); + return RtlValidAcl (pAcl); } @@ -85,26 +79,24 @@ IsValidAcl ( */ BOOL STDCALL -SetAclInformation ( - PACL pAcl, - LPVOID pAclInformation, - DWORD nAclInformationLength, - ACL_INFORMATION_CLASS dwAclInformationClass - ) +SetAclInformation(PACL pAcl, + LPVOID pAclInformation, + DWORD nAclInformationLength, + ACL_INFORMATION_CLASS dwAclInformationClass) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlSetInformationAcl (pAcl, - pAclInformation, - nAclInformationLength, - dwAclInformationClass); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlSetInformationAcl(pAcl, + pAclInformation, + nAclInformationLength, + dwAclInformationClass); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -115,26 +107,24 @@ SetAclInformation ( */ BOOL STDCALL -AddAccessAllowedAce ( - PACL pAcl, - DWORD dwAceRevision, - DWORD AccessMask, - PSID pSid - ) +AddAccessAllowedAce(PACL pAcl, + DWORD dwAceRevision, + DWORD AccessMask, + PSID pSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAccessAllowedAce (pAcl, - dwAceRevision, - AccessMask, - pSid); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlAddAccessAllowedAce(pAcl, + dwAceRevision, + AccessMask, + pSid); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -143,25 +133,25 @@ AddAccessAllowedAce ( */ BOOL STDCALL AddAccessAllowedAceEx(PACL pAcl, - DWORD dwAceRevision, - DWORD AceFlags, - DWORD AccessMask, - PSID pSid) + DWORD dwAceRevision, + DWORD AceFlags, + DWORD AccessMask, + PSID pSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAccessAllowedAceEx(pAcl, - dwAceRevision, - AceFlags, - AccessMask, - pSid); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + Status = RtlAddAccessAllowedAceEx(pAcl, + dwAceRevision, + AceFlags, + AccessMask, + pSid); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -170,31 +160,30 @@ AddAccessAllowedAceEx(PACL pAcl, */ BOOL STDCALL -AddAccessAllowedObjectAce( - PACL pAcl, - DWORD dwAceRevision, - DWORD AceFlags, - DWORD AccessMask, - GUID* ObjectTypeGuid, - GUID* InheritedObjectTypeGuid, - PSID pSid) +AddAccessAllowedObjectAce(PACL pAcl, + DWORD dwAceRevision, + DWORD AceFlags, + DWORD AccessMask, + GUID *ObjectTypeGuid, + GUID *InheritedObjectTypeGuid, + PSID pSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAccessAllowedObjectAce(pAcl, - dwAceRevision, - AceFlags, - AccessMask, - ObjectTypeGuid, - InheritedObjectTypeGuid, - pSid); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + Status = RtlAddAccessAllowedObjectAce(pAcl, + dwAceRevision, + AceFlags, + AccessMask, + ObjectTypeGuid, + InheritedObjectTypeGuid, + pSid); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -203,26 +192,24 @@ AddAccessAllowedObjectAce( */ BOOL STDCALL -AddAccessDeniedAce ( - PACL pAcl, - DWORD dwAceRevision, - DWORD AccessMask, - PSID pSid - ) +AddAccessDeniedAce(PACL pAcl, + DWORD dwAceRevision, + DWORD AccessMask, + PSID pSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAccessDeniedAce (pAcl, - dwAceRevision, - AccessMask, - pSid); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlAddAccessDeniedAce(pAcl, + dwAceRevision, + AccessMask, + pSid); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -231,25 +218,25 @@ AddAccessDeniedAce ( */ BOOL STDCALL AddAccessDeniedAceEx(PACL pAcl, - DWORD dwAceRevision, - DWORD AceFlags, - DWORD AccessMask, - PSID pSid) + DWORD dwAceRevision, + DWORD AceFlags, + DWORD AccessMask, + PSID pSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAccessDeniedAceEx(pAcl, - dwAceRevision, - AceFlags, - AccessMask, - pSid); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + Status = RtlAddAccessDeniedAceEx(pAcl, + dwAceRevision, + AceFlags, + AccessMask, + pSid); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -258,31 +245,30 @@ AddAccessDeniedAceEx(PACL pAcl, */ BOOL STDCALL -AddAccessDeniedObjectAce( - PACL pAcl, - DWORD dwAceRevision, - DWORD AceFlags, - DWORD AccessMask, - GUID* ObjectTypeGuid, - GUID* InheritedObjectTypeGuid, - PSID pSid) +AddAccessDeniedObjectAce(PACL pAcl, + DWORD dwAceRevision, + DWORD AceFlags, + DWORD AccessMask, + GUID* ObjectTypeGuid, + GUID* InheritedObjectTypeGuid, + PSID pSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAccessDeniedObjectAce(pAcl, - dwAceRevision, - AceFlags, - AccessMask, - ObjectTypeGuid, - InheritedObjectTypeGuid, - pSid); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + Status = RtlAddAccessDeniedObjectAce(pAcl, + dwAceRevision, + AceFlags, + AccessMask, + ObjectTypeGuid, + InheritedObjectTypeGuid, + pSid); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -291,28 +277,26 @@ AddAccessDeniedObjectAce( */ BOOL STDCALL -AddAce ( - PACL pAcl, - DWORD dwAceRevision, - DWORD dwStartingAceIndex, - LPVOID pAceList, - DWORD nAceListLength - ) +AddAce(PACL pAcl, + DWORD dwAceRevision, + DWORD dwStartingAceIndex, + LPVOID pAceList, + DWORD nAceListLength) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAce (pAcl, - dwAceRevision, - dwStartingAceIndex, - pAceList, - nAceListLength); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlAddAce(pAcl, + dwAceRevision, + dwStartingAceIndex, + pAceList, + nAceListLength); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -321,30 +305,28 @@ AddAce ( */ BOOL STDCALL -AddAuditAccessAce ( - PACL pAcl, - DWORD dwAceRevision, - DWORD dwAccessMask, - PSID pSid, - BOOL bAuditSuccess, - BOOL bAuditFailure - ) +AddAuditAccessAce(PACL pAcl, + DWORD dwAceRevision, + DWORD dwAccessMask, + PSID pSid, + BOOL bAuditSuccess, + BOOL bAuditFailure) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAuditAccessAce (pAcl, - dwAceRevision, - dwAccessMask, - pSid, - bAuditSuccess, - bAuditFailure); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlAddAuditAccessAce(pAcl, + dwAceRevision, + dwAccessMask, + pSid, + bAuditSuccess, + bAuditFailure); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -353,29 +335,29 @@ AddAuditAccessAce ( */ BOOL STDCALL AddAuditAccessAceEx(PACL pAcl, - DWORD dwAceRevision, - DWORD AceFlags, - DWORD dwAccessMask, - PSID pSid, - BOOL bAuditSuccess, - BOOL bAuditFailure) + DWORD dwAceRevision, + DWORD AceFlags, + DWORD dwAccessMask, + PSID pSid, + BOOL bAuditSuccess, + BOOL bAuditFailure) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAuditAccessAceEx(pAcl, - dwAceRevision, - AceFlags, - dwAccessMask, - pSid, - bAuditSuccess, - bAuditFailure); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + Status = RtlAddAuditAccessAceEx(pAcl, + dwAceRevision, + AceFlags, + dwAccessMask, + pSid, + bAuditSuccess, + bAuditFailure); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -384,35 +366,34 @@ AddAuditAccessAceEx(PACL pAcl, */ BOOL STDCALL -AddAuditAccessObjectAce( - PACL pAcl, - DWORD dwAceRevision, - DWORD AceFlags, - DWORD AccessMask, - GUID* ObjectTypeGuid, - GUID* InheritedObjectTypeGuid, - PSID pSid, - BOOL bAuditSuccess, - BOOL bAuditFailure) +AddAuditAccessObjectAce(PACL pAcl, + DWORD dwAceRevision, + DWORD AceFlags, + DWORD AccessMask, + GUID *ObjectTypeGuid, + GUID *InheritedObjectTypeGuid, + PSID pSid, + BOOL bAuditSuccess, + BOOL bAuditFailure) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAddAuditAccessObjectAce(pAcl, - dwAceRevision, - AceFlags, - AccessMask, - ObjectTypeGuid, - InheritedObjectTypeGuid, - pSid, - bAuditSuccess, - bAuditFailure); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + Status = RtlAddAuditAccessObjectAce(pAcl, + dwAceRevision, + AceFlags, + AccessMask, + ObjectTypeGuid, + InheritedObjectTypeGuid, + pSid, + bAuditSuccess, + bAuditFailure); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -450,22 +431,20 @@ AddMandatoryAce(IN OUT PACL pAcl, */ BOOL STDCALL -DeleteAce ( - PACL pAcl, - DWORD dwAceIndex - ) +DeleteAce(PACL pAcl, + DWORD dwAceIndex) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlDeleteAce (pAcl, - dwAceIndex); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlDeleteAce(pAcl, + dwAceIndex); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -474,13 +453,11 @@ DeleteAce ( */ BOOL STDCALL -FindFirstFreeAce ( - PACL pAcl, - LPVOID * pAce - ) +FindFirstFreeAce(PACL pAcl, + LPVOID *pAce) { - return RtlFirstFreeAce (pAcl, - (PACE*)pAce); + return RtlFirstFreeAce(pAcl, + (PACE*)pAce); } @@ -489,24 +466,22 @@ FindFirstFreeAce ( */ BOOL STDCALL -GetAce ( - PACL pAcl, - DWORD dwAceIndex, - LPVOID * pAce - ) +GetAce(PACL pAcl, + DWORD dwAceIndex, + LPVOID *pAce) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlGetAce (pAcl, - dwAceIndex, - pAce); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlGetAce(pAcl, + dwAceIndex, + pAce); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -515,18 +490,16 @@ GetAce ( */ DWORD STDCALL -GetInheritanceSourceW ( - LPWSTR pObjectName, - SE_OBJECT_TYPE ObjectType, - SECURITY_INFORMATION SecurityInfo, - BOOL Container, - GUID** pObjectClassGuids OPTIONAL, - DWORD GuidCount, - PACL pAcl, - PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL, - PGENERIC_MAPPING pGenericMapping, - PINHERITED_FROMW pInheritArray - ) +GetInheritanceSourceW(LPWSTR pObjectName, + SE_OBJECT_TYPE ObjectType, + SECURITY_INFORMATION SecurityInfo, + BOOL Container, + GUID **pObjectClassGuids OPTIONAL, + DWORD GuidCount, + PACL pAcl, + PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL, + PGENERIC_MAPPING pGenericMapping, + PINHERITED_FROMW pInheritArray) { DWORD ErrorCode; @@ -555,18 +528,16 @@ GetInheritanceSourceW ( */ DWORD STDCALL -GetInheritanceSourceA ( - LPSTR pObjectName, - SE_OBJECT_TYPE ObjectType, - SECURITY_INFORMATION SecurityInfo, - BOOL Container, - GUID** pObjectClassGuids OPTIONAL, - DWORD GuidCount, - PACL pAcl, - PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL, - PGENERIC_MAPPING pGenericMapping, - PINHERITED_FROMA pInheritArray - ) +GetInheritanceSourceA(LPSTR pObjectName, + SE_OBJECT_TYPE ObjectType, + SECURITY_INFORMATION SecurityInfo, + BOOL Container, + GUID **pObjectClassGuids OPTIONAL, + DWORD GuidCount, + PACL pAcl, + PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL, + PGENERIC_MAPPING pGenericMapping, + PINHERITED_FROMA pInheritArray) { /* That's all this function does, at least up to w2k3... Even MS was too lazy to implement it... */ @@ -579,11 +550,9 @@ GetInheritanceSourceA ( */ DWORD STDCALL -FreeInheritedFromArray ( - PINHERITED_FROMW pInheritArray, - USHORT AceCnt, - PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL - ) +FreeInheritedFromArray(PINHERITED_FROMW pInheritArray, + USHORT AceCnt, + PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL) { DWORD ErrorCode; @@ -605,11 +574,10 @@ FreeInheritedFromArray ( */ DWORD STDCALL -SetEntriesInAclW( - ULONG cCountOfExplicitEntries, - PEXPLICIT_ACCESS_W pListOfExplicitEntries, - PACL OldAcl, - PACL* NewAcl) +SetEntriesInAclW(ULONG cCountOfExplicitEntries, + PEXPLICIT_ACCESS_W pListOfExplicitEntries, + PACL OldAcl, + PACL *NewAcl) { DWORD ErrorCode; @@ -1013,11 +981,10 @@ RawTrusteeCopy: */ DWORD STDCALL -SetEntriesInAclA( - ULONG cCountOfExplicitEntries, - PEXPLICIT_ACCESS_A pListOfExplicitEntries, - PACL OldAcl, - PACL* NewAcl) +SetEntriesInAclA(ULONG cCountOfExplicitEntries, + PEXPLICIT_ACCESS_A pListOfExplicitEntries, + PACL OldAcl, + PACL *NewAcl) { PEXPLICIT_ACCESS_W ListOfExplicitEntriesW = NULL; DWORD ErrorCode; @@ -1025,7 +992,6 @@ SetEntriesInAclA( ErrorCode = InternalExplicitAccessAToW(cCountOfExplicitEntries, pListOfExplicitEntries, &ListOfExplicitEntriesW); - if (ErrorCode == ERROR_SUCCESS) { ErrorCode = SetEntriesInAclW(cCountOfExplicitEntries, @@ -1048,11 +1014,9 @@ SetEntriesInAclA( */ DWORD STDCALL -GetExplicitEntriesFromAclW( - PACL pacl, - PULONG pcCountOfExplicitEntries, - PEXPLICIT_ACCESS_W* pListOfExplicitEntries - ) +GetExplicitEntriesFromAclW(PACL pacl, + PULONG pcCountOfExplicitEntries, + PEXPLICIT_ACCESS_W *pListOfExplicitEntries) { DWORD ErrorCode; @@ -1078,8 +1042,8 @@ GetEffectiveRightsFromAclW(IN PACL pacl, IN PTRUSTEE_W pTrustee, OUT PACCESS_MASK pAccessRights) { - FIXME("%s() not implemented!\n", __FUNCTION__); - return ERROR_CALL_NOT_IMPLEMENTED; + FIXME("%s() not implemented!\n", __FUNCTION__); + return ERROR_CALL_NOT_IMPLEMENTED; } @@ -1123,8 +1087,8 @@ GetAuditedPermissionsFromAclW(IN PACL pacl, OUT PACCESS_MASK pSuccessfulAuditedRights, OUT PACCESS_MASK pFailedAuditRights) { - FIXME("%s() not implemented!\n", __FUNCTION__); - return ERROR_CALL_NOT_IMPLEMENTED; + FIXME("%s() not implemented!\n", __FUNCTION__); + return ERROR_CALL_NOT_IMPLEMENTED; } diff --git a/reactos/dll/win32/advapi32/sec/audit.c b/reactos/dll/win32/advapi32/sec/audit.c index 121a2bbfeba..550988407e4 100644 --- a/reactos/dll/win32/advapi32/sec/audit.c +++ b/reactos/dll/win32/advapi32/sec/audit.c @@ -22,65 +22,65 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); * @implemented */ BOOL STDCALL -AccessCheckAndAuditAlarmA (LPCSTR SubsystemName, - LPVOID HandleId, - LPSTR ObjectTypeName, - LPSTR ObjectName, - PSECURITY_DESCRIPTOR SecurityDescriptor, - DWORD DesiredAccess, - PGENERIC_MAPPING GenericMapping, - BOOL ObjectCreation, - LPDWORD GrantedAccess, - LPBOOL AccessStatus, - LPBOOL pfGenerateOnClose) +AccessCheckAndAuditAlarmA(LPCSTR SubsystemName, + LPVOID HandleId, + LPSTR ObjectTypeName, + LPSTR ObjectName, + PSECURITY_DESCRIPTOR SecurityDescriptor, + DWORD DesiredAccess, + PGENERIC_MAPPING GenericMapping, + BOOL ObjectCreation, + LPDWORD GrantedAccess, + LPBOOL AccessStatus, + LPBOOL pfGenerateOnClose) { - UNICODE_STRING SubsystemNameU; - UNICODE_STRING ObjectTypeNameU; - UNICODE_STRING ObjectNameU; - NTSTATUS LocalAccessStatus; - BOOLEAN GenerateOnClose; - NTSTATUS Status; + UNICODE_STRING SubsystemNameU; + UNICODE_STRING ObjectTypeNameU; + UNICODE_STRING ObjectNameU; + NTSTATUS LocalAccessStatus; + BOOLEAN GenerateOnClose; + NTSTATUS Status; - RtlCreateUnicodeStringFromAsciiz (&SubsystemNameU, - (PCHAR)SubsystemName); - RtlCreateUnicodeStringFromAsciiz (&ObjectTypeNameU, - (PCHAR)ObjectTypeName); - RtlCreateUnicodeStringFromAsciiz (&ObjectNameU, - (PCHAR)ObjectName); + RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU, + (PCHAR)SubsystemName); + RtlCreateUnicodeStringFromAsciiz(&ObjectTypeNameU, + (PCHAR)ObjectTypeName); + RtlCreateUnicodeStringFromAsciiz(&ObjectNameU, + (PCHAR)ObjectName); - Status = NtAccessCheckAndAuditAlarm (&SubsystemNameU, - HandleId, - &ObjectTypeNameU, - &ObjectNameU, - SecurityDescriptor, - DesiredAccess, - GenericMapping, - ObjectCreation, - GrantedAccess, - &LocalAccessStatus, - &GenerateOnClose); - RtlFreeUnicodeString (&SubsystemNameU); - RtlFreeUnicodeString (&ObjectTypeNameU); - RtlFreeUnicodeString (&ObjectNameU); + Status = NtAccessCheckAndAuditAlarm(&SubsystemNameU, + HandleId, + &ObjectTypeNameU, + &ObjectNameU, + SecurityDescriptor, + DesiredAccess, + GenericMapping, + ObjectCreation, + GrantedAccess, + &LocalAccessStatus, + &GenerateOnClose); + RtlFreeUnicodeString(&SubsystemNameU); + RtlFreeUnicodeString(&ObjectTypeNameU); + RtlFreeUnicodeString(&ObjectNameU); - *pfGenerateOnClose = (BOOL)GenerateOnClose; + *pfGenerateOnClose = (BOOL)GenerateOnClose; - if (!NT_SUCCESS (Status)) + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - if (!NT_SUCCESS (LocalAccessStatus)) + if (!NT_SUCCESS (LocalAccessStatus)) { - *AccessStatus = FALSE; - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + *AccessStatus = FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - *AccessStatus = TRUE; + *AccessStatus = TRUE; - return TRUE; + return TRUE; } @@ -88,62 +88,62 @@ AccessCheckAndAuditAlarmA (LPCSTR SubsystemName, * @implemented */ BOOL STDCALL -AccessCheckAndAuditAlarmW (LPCWSTR SubsystemName, - LPVOID HandleId, - LPWSTR ObjectTypeName, - LPWSTR ObjectName, - PSECURITY_DESCRIPTOR SecurityDescriptor, - DWORD DesiredAccess, - PGENERIC_MAPPING GenericMapping, - BOOL ObjectCreation, - LPDWORD GrantedAccess, - LPBOOL AccessStatus, - LPBOOL pfGenerateOnClose) +AccessCheckAndAuditAlarmW(LPCWSTR SubsystemName, + LPVOID HandleId, + LPWSTR ObjectTypeName, + LPWSTR ObjectName, + PSECURITY_DESCRIPTOR SecurityDescriptor, + DWORD DesiredAccess, + PGENERIC_MAPPING GenericMapping, + BOOL ObjectCreation, + LPDWORD GrantedAccess, + LPBOOL AccessStatus, + LPBOOL pfGenerateOnClose) { - UNICODE_STRING SubsystemNameU; - UNICODE_STRING ObjectTypeNameU; - UNICODE_STRING ObjectNameU; - NTSTATUS LocalAccessStatus; - BOOLEAN GenerateOnClose; - NTSTATUS Status; + UNICODE_STRING SubsystemNameU; + UNICODE_STRING ObjectTypeNameU; + UNICODE_STRING ObjectNameU; + NTSTATUS LocalAccessStatus; + BOOLEAN GenerateOnClose; + NTSTATUS Status; - RtlInitUnicodeString (&SubsystemNameU, - (PWSTR)SubsystemName); - RtlInitUnicodeString (&ObjectTypeNameU, - (PWSTR)ObjectTypeName); - RtlInitUnicodeString (&ObjectNameU, - (PWSTR)ObjectName); + RtlInitUnicodeString(&SubsystemNameU, + (PWSTR)SubsystemName); + RtlInitUnicodeString(&ObjectTypeNameU, + (PWSTR)ObjectTypeName); + RtlInitUnicodeString(&ObjectNameU, + (PWSTR)ObjectName); - Status = NtAccessCheckAndAuditAlarm (&SubsystemNameU, - HandleId, - &ObjectTypeNameU, - &ObjectNameU, - SecurityDescriptor, - DesiredAccess, - GenericMapping, - ObjectCreation, - GrantedAccess, - &LocalAccessStatus, - &GenerateOnClose); + Status = NtAccessCheckAndAuditAlarm(&SubsystemNameU, + HandleId, + &ObjectTypeNameU, + &ObjectNameU, + SecurityDescriptor, + DesiredAccess, + GenericMapping, + ObjectCreation, + GrantedAccess, + &LocalAccessStatus, + &GenerateOnClose); - *pfGenerateOnClose = (BOOL)GenerateOnClose; + *pfGenerateOnClose = (BOOL)GenerateOnClose; - if (!NT_SUCCESS (Status)) + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - if (!NT_SUCCESS (LocalAccessStatus)) + if (!NT_SUCCESS(LocalAccessStatus)) { - *AccessStatus = FALSE; - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + *AccessStatus = FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - *AccessStatus = TRUE; + *AccessStatus = TRUE; - return TRUE; + return TRUE; } @@ -151,58 +151,32 @@ AccessCheckAndAuditAlarmW (LPCWSTR SubsystemName, * @implemented */ BOOL STDCALL -ObjectCloseAuditAlarmA (LPCSTR SubsystemName, - LPVOID HandleId, - BOOL GenerateOnClose) +ObjectCloseAuditAlarmA(LPCSTR SubsystemName, + LPVOID HandleId, + BOOL GenerateOnClose) { - UNICODE_STRING Name; - NTSTATUS Status; + UNICODE_STRING Name; + NTSTATUS Status; - Status = RtlCreateUnicodeStringFromAsciiz (&Name, - (PCHAR)SubsystemName); - if (!NT_SUCCESS (Status)) + Status = RtlCreateUnicodeStringFromAsciiz(&Name, + (PCHAR)SubsystemName); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - Status = NtCloseObjectAuditAlarm (&Name, - HandleId, - GenerateOnClose); - RtlFreeUnicodeString(&Name); - if (!NT_SUCCESS (Status)) + Status = NtCloseObjectAuditAlarm(&Name, + HandleId, + GenerateOnClose); + RtlFreeUnicodeString(&Name); + if (!NT_SUCCESS (Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; -} - -/* - * @implemented - */ -BOOL STDCALL -ObjectCloseAuditAlarmW (LPCWSTR SubsystemName, - LPVOID HandleId, - BOOL GenerateOnClose) -{ - UNICODE_STRING Name; - NTSTATUS Status; - - RtlInitUnicodeString (&Name, - (PWSTR)SubsystemName); - - Status = NtCloseObjectAuditAlarm (&Name, - HandleId, - GenerateOnClose); - if (!NT_SUCCESS (Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - return TRUE; + return TRUE; } @@ -210,32 +184,26 @@ ObjectCloseAuditAlarmW (LPCWSTR SubsystemName, * @implemented */ BOOL STDCALL -ObjectDeleteAuditAlarmA (LPCSTR SubsystemName, - LPVOID HandleId, - BOOL GenerateOnClose) +ObjectCloseAuditAlarmW(LPCWSTR SubsystemName, + LPVOID HandleId, + BOOL GenerateOnClose) { - UNICODE_STRING Name; - NTSTATUS Status; + UNICODE_STRING Name; + NTSTATUS Status; - Status = RtlCreateUnicodeStringFromAsciiz (&Name, - (PCHAR)SubsystemName); - if (!NT_SUCCESS (Status)) + RtlInitUnicodeString(&Name, + (PWSTR)SubsystemName); + + Status = NtCloseObjectAuditAlarm(&Name, + HandleId, + GenerateOnClose); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - Status = NtDeleteObjectAuditAlarm (&Name, - HandleId, - GenerateOnClose); - RtlFreeUnicodeString(&Name); - if (!NT_SUCCESS (Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - return TRUE; + return TRUE; } @@ -243,26 +211,32 @@ ObjectDeleteAuditAlarmA (LPCSTR SubsystemName, * @implemented */ BOOL STDCALL -ObjectDeleteAuditAlarmW (LPCWSTR SubsystemName, - LPVOID HandleId, - BOOL GenerateOnClose) +ObjectDeleteAuditAlarmA(LPCSTR SubsystemName, + LPVOID HandleId, + BOOL GenerateOnClose) { - UNICODE_STRING Name; - NTSTATUS Status; + UNICODE_STRING Name; + NTSTATUS Status; - RtlInitUnicodeString (&Name, - (PWSTR)SubsystemName); - - Status = NtDeleteObjectAuditAlarm (&Name, - HandleId, - GenerateOnClose); - if (!NT_SUCCESS (Status)) + Status = RtlCreateUnicodeStringFromAsciiz(&Name, + (PCHAR)SubsystemName); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + Status = NtDeleteObjectAuditAlarm(&Name, + HandleId, + GenerateOnClose); + RtlFreeUnicodeString(&Name); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; } @@ -270,53 +244,26 @@ ObjectDeleteAuditAlarmW (LPCWSTR SubsystemName, * @implemented */ BOOL STDCALL -ObjectOpenAuditAlarmA (LPCSTR SubsystemName, - LPVOID HandleId, - LPSTR ObjectTypeName, - LPSTR ObjectName, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - HANDLE ClientToken, - DWORD DesiredAccess, - DWORD GrantedAccess, - PPRIVILEGE_SET Privileges, - BOOL ObjectCreation, - BOOL AccessGranted, - LPBOOL GenerateOnClose) +ObjectDeleteAuditAlarmW(LPCWSTR SubsystemName, + LPVOID HandleId, + BOOL GenerateOnClose) { - UNICODE_STRING SubsystemNameU; - UNICODE_STRING ObjectTypeNameU; - UNICODE_STRING ObjectNameU; - NTSTATUS Status; + UNICODE_STRING Name; + NTSTATUS Status; - RtlCreateUnicodeStringFromAsciiz (&SubsystemNameU, - (PCHAR)SubsystemName); - RtlCreateUnicodeStringFromAsciiz (&ObjectTypeNameU, - (PCHAR)ObjectTypeName); - RtlCreateUnicodeStringFromAsciiz (&ObjectNameU, - (PCHAR)ObjectName); + RtlInitUnicodeString(&Name, + (PWSTR)SubsystemName); - Status = NtOpenObjectAuditAlarm (&SubsystemNameU, - HandleId, - &ObjectTypeNameU, - &ObjectNameU, - pSecurityDescriptor, - ClientToken, - DesiredAccess, - GrantedAccess, - Privileges, - ObjectCreation, - AccessGranted, - (PBOOLEAN)GenerateOnClose); - RtlFreeUnicodeString (&SubsystemNameU); - RtlFreeUnicodeString (&ObjectTypeNameU); - RtlFreeUnicodeString (&ObjectNameU); - if (!NT_SUCCESS (Status)) + Status = NtDeleteObjectAuditAlarm(&Name, + HandleId, + GenerateOnClose); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -324,50 +271,53 @@ ObjectOpenAuditAlarmA (LPCSTR SubsystemName, * @implemented */ BOOL STDCALL -ObjectOpenAuditAlarmW (LPCWSTR SubsystemName, - LPVOID HandleId, - LPWSTR ObjectTypeName, - LPWSTR ObjectName, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - HANDLE ClientToken, - DWORD DesiredAccess, - DWORD GrantedAccess, - PPRIVILEGE_SET Privileges, - BOOL ObjectCreation, - BOOL AccessGranted, - LPBOOL GenerateOnClose) +ObjectOpenAuditAlarmA(LPCSTR SubsystemName, + LPVOID HandleId, + LPSTR ObjectTypeName, + LPSTR ObjectName, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + HANDLE ClientToken, + DWORD DesiredAccess, + DWORD GrantedAccess, + PPRIVILEGE_SET Privileges, + BOOL ObjectCreation, + BOOL AccessGranted, + LPBOOL GenerateOnClose) { - UNICODE_STRING SubsystemNameU; - UNICODE_STRING ObjectTypeNameU; - UNICODE_STRING ObjectNameU; - NTSTATUS Status; + UNICODE_STRING SubsystemNameU; + UNICODE_STRING ObjectTypeNameU; + UNICODE_STRING ObjectNameU; + NTSTATUS Status; - RtlInitUnicodeString (&SubsystemNameU, - (PWSTR)SubsystemName); - RtlInitUnicodeString (&ObjectTypeNameU, - (PWSTR)ObjectTypeName); - RtlInitUnicodeString (&ObjectNameU, - (PWSTR)ObjectName); + RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU, + (PCHAR)SubsystemName); + RtlCreateUnicodeStringFromAsciiz(&ObjectTypeNameU, + (PCHAR)ObjectTypeName); + RtlCreateUnicodeStringFromAsciiz(&ObjectNameU, + (PCHAR)ObjectName); - Status = NtOpenObjectAuditAlarm (&SubsystemNameU, - HandleId, - &ObjectTypeNameU, - &ObjectNameU, - pSecurityDescriptor, - ClientToken, - DesiredAccess, - GrantedAccess, - Privileges, - ObjectCreation, - AccessGranted, - (PBOOLEAN)GenerateOnClose); - if (!NT_SUCCESS (Status)) + Status = NtOpenObjectAuditAlarm(&SubsystemNameU, + HandleId, + &ObjectTypeNameU, + &ObjectNameU, + pSecurityDescriptor, + ClientToken, + DesiredAccess, + GrantedAccess, + Privileges, + ObjectCreation, + AccessGranted, + (PBOOLEAN)GenerateOnClose); + RtlFreeUnicodeString(&SubsystemNameU); + RtlFreeUnicodeString(&ObjectTypeNameU); + RtlFreeUnicodeString(&ObjectNameU); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -375,33 +325,50 @@ ObjectOpenAuditAlarmW (LPCWSTR SubsystemName, * @implemented */ BOOL STDCALL -ObjectPrivilegeAuditAlarmA (LPCSTR SubsystemName, - LPVOID HandleId, - HANDLE ClientToken, - DWORD DesiredAccess, - PPRIVILEGE_SET Privileges, - BOOL AccessGranted) +ObjectOpenAuditAlarmW(LPCWSTR SubsystemName, + LPVOID HandleId, + LPWSTR ObjectTypeName, + LPWSTR ObjectName, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + HANDLE ClientToken, + DWORD DesiredAccess, + DWORD GrantedAccess, + PPRIVILEGE_SET Privileges, + BOOL ObjectCreation, + BOOL AccessGranted, + LPBOOL GenerateOnClose) { - UNICODE_STRING SubsystemNameU; - NTSTATUS Status; + UNICODE_STRING SubsystemNameU; + UNICODE_STRING ObjectTypeNameU; + UNICODE_STRING ObjectNameU; + NTSTATUS Status; - RtlCreateUnicodeStringFromAsciiz (&SubsystemNameU, - (PCHAR)SubsystemName); + RtlInitUnicodeString(&SubsystemNameU, + (PWSTR)SubsystemName); + RtlInitUnicodeString(&ObjectTypeNameU, + (PWSTR)ObjectTypeName); + RtlInitUnicodeString(&ObjectNameU, + (PWSTR)ObjectName); - Status = NtPrivilegeObjectAuditAlarm (&SubsystemNameU, - HandleId, - ClientToken, - DesiredAccess, - Privileges, - AccessGranted); - RtlFreeUnicodeString (&SubsystemNameU); - if (!NT_SUCCESS (Status)) + Status = NtOpenObjectAuditAlarm(&SubsystemNameU, + HandleId, + &ObjectTypeNameU, + &ObjectNameU, + pSecurityDescriptor, + ClientToken, + DesiredAccess, + GrantedAccess, + Privileges, + ObjectCreation, + AccessGranted, + (PBOOLEAN)GenerateOnClose); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -409,32 +376,33 @@ ObjectPrivilegeAuditAlarmA (LPCSTR SubsystemName, * @implemented */ BOOL STDCALL -ObjectPrivilegeAuditAlarmW (LPCWSTR SubsystemName, - LPVOID HandleId, - HANDLE ClientToken, - DWORD DesiredAccess, - PPRIVILEGE_SET Privileges, - BOOL AccessGranted) +ObjectPrivilegeAuditAlarmA(LPCSTR SubsystemName, + LPVOID HandleId, + HANDLE ClientToken, + DWORD DesiredAccess, + PPRIVILEGE_SET Privileges, + BOOL AccessGranted) { - UNICODE_STRING SubsystemNameU; - NTSTATUS Status; + UNICODE_STRING SubsystemNameU; + NTSTATUS Status; - RtlInitUnicodeString (&SubsystemNameU, - (PWSTR)SubsystemName); + RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU, + (PCHAR)SubsystemName); - Status = NtPrivilegeObjectAuditAlarm (&SubsystemNameU, - HandleId, - ClientToken, - DesiredAccess, - Privileges, - AccessGranted); - if (!NT_SUCCESS (Status)) + Status = NtPrivilegeObjectAuditAlarm(&SubsystemNameU, + HandleId, + ClientToken, + DesiredAccess, + Privileges, + AccessGranted); + RtlFreeUnicodeString (&SubsystemNameU); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -442,35 +410,32 @@ ObjectPrivilegeAuditAlarmW (LPCWSTR SubsystemName, * @implemented */ BOOL STDCALL -PrivilegedServiceAuditAlarmA (LPCSTR SubsystemName, - LPCSTR ServiceName, - HANDLE ClientToken, - PPRIVILEGE_SET Privileges, - BOOL AccessGranted) +ObjectPrivilegeAuditAlarmW(LPCWSTR SubsystemName, + LPVOID HandleId, + HANDLE ClientToken, + DWORD DesiredAccess, + PPRIVILEGE_SET Privileges, + BOOL AccessGranted) { - UNICODE_STRING SubsystemNameU; - UNICODE_STRING ServiceNameU; - NTSTATUS Status; + UNICODE_STRING SubsystemNameU; + NTSTATUS Status; - RtlCreateUnicodeStringFromAsciiz (&SubsystemNameU, - (PCHAR)SubsystemName); - RtlCreateUnicodeStringFromAsciiz (&ServiceNameU, - (PCHAR)ServiceName); + RtlInitUnicodeString(&SubsystemNameU, + (PWSTR)SubsystemName); - Status = NtPrivilegedServiceAuditAlarm (&SubsystemNameU, - &ServiceNameU, - ClientToken, - Privileges, - AccessGranted); - RtlFreeUnicodeString (&SubsystemNameU); - RtlFreeUnicodeString (&ServiceNameU); - if (!NT_SUCCESS (Status)) + Status = NtPrivilegeObjectAuditAlarm(&SubsystemNameU, + HandleId, + ClientToken, + DesiredAccess, + Privileges, + AccessGranted); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -478,33 +443,69 @@ PrivilegedServiceAuditAlarmA (LPCSTR SubsystemName, * @implemented */ BOOL STDCALL -PrivilegedServiceAuditAlarmW (LPCWSTR SubsystemName, - LPCWSTR ServiceName, - HANDLE ClientToken, - PPRIVILEGE_SET Privileges, - BOOL AccessGranted) +PrivilegedServiceAuditAlarmA(LPCSTR SubsystemName, + LPCSTR ServiceName, + HANDLE ClientToken, + PPRIVILEGE_SET Privileges, + BOOL AccessGranted) { - UNICODE_STRING SubsystemNameU; - UNICODE_STRING ServiceNameU; - NTSTATUS Status; + UNICODE_STRING SubsystemNameU; + UNICODE_STRING ServiceNameU; + NTSTATUS Status; - RtlInitUnicodeString (&SubsystemNameU, - (PWSTR)SubsystemName); - RtlInitUnicodeString (&ServiceNameU, - (PWSTR)ServiceName); + RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU, + (PCHAR)SubsystemName); + RtlCreateUnicodeStringFromAsciiz(&ServiceNameU, + (PCHAR)ServiceName); - Status = NtPrivilegedServiceAuditAlarm (&SubsystemNameU, - &ServiceNameU, - ClientToken, - Privileges, - AccessGranted); - if (!NT_SUCCESS (Status)) + Status = NtPrivilegedServiceAuditAlarm(&SubsystemNameU, + &ServiceNameU, + ClientToken, + Privileges, + AccessGranted); + RtlFreeUnicodeString(&SubsystemNameU); + RtlFreeUnicodeString(&ServiceNameU); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; +} + + +/* + * @implemented + */ +BOOL STDCALL +PrivilegedServiceAuditAlarmW(LPCWSTR SubsystemName, + LPCWSTR ServiceName, + HANDLE ClientToken, + PPRIVILEGE_SET Privileges, + BOOL AccessGranted) +{ + UNICODE_STRING SubsystemNameU; + UNICODE_STRING ServiceNameU; + NTSTATUS Status; + + RtlInitUnicodeString(&SubsystemNameU, + (PWSTR)SubsystemName); + RtlInitUnicodeString(&ServiceNameU, + (PWSTR)ServiceName); + + Status = NtPrivilegedServiceAuditAlarm(&SubsystemNameU, + &ServiceNameU, + ClientToken, + Privileges, + AccessGranted); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; } @@ -530,9 +531,9 @@ AccessCheckByTypeResultListAndAuditAlarmByHandleW(IN LPCWSTR SubsystemName, OUT LPDWORD AccessStatusList, OUT LPBOOL pfGenerateOnClose) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -558,9 +559,9 @@ AccessCheckByTypeResultListAndAuditAlarmByHandleA(IN LPCSTR SubsystemName, OUT LPDWORD AccessStatusList, OUT LPBOOL pfGenerateOnClose) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -585,9 +586,9 @@ AccessCheckByTypeResultListAndAuditAlarmW(IN LPCWSTR SubsystemName, OUT LPDWORD AccessStatusList, OUT LPBOOL pfGenerateOnClose) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -612,9 +613,9 @@ AccessCheckByTypeResultListAndAuditAlarmA(IN LPCSTR SubsystemName, OUT LPDWORD AccessStatusList, OUT LPBOOL pfGenerateOnClose) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -639,9 +640,9 @@ AccessCheckByTypeAndAuditAlarmW(IN LPCWSTR SubsystemName, OUT LPBOOL AccessStatus, OUT LPBOOL pfGenerateOnClose) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -666,10 +667,9 @@ AccessCheckByTypeAndAuditAlarmA(IN LPCSTR SubsystemName, OUT LPBOOL AccessStatus, OUT LPBOOL pfGenerateOnClose) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } - /* EOF */ diff --git a/reactos/dll/win32/advapi32/sec/misc.c b/reactos/dll/win32/advapi32/sec/misc.c index 2455a7c1608..c86dc7209d9 100644 --- a/reactos/dll/win32/advapi32/sec/misc.c +++ b/reactos/dll/win32/advapi32/sec/misc.c @@ -12,7 +12,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); /* Needed for LookupAccountNameW implementation from Wine */ -typedef struct _AccountSid { +typedef struct _AccountSid +{ WELL_KNOWN_SID_TYPE type; LPCWSTR account; LPCWSTR domain; @@ -139,6 +140,7 @@ static PNTMARTA NtMarta = NULL; return GetLastError(); \ } + static DWORD LoadAndInitializeNtMarta(VOID) { @@ -180,6 +182,7 @@ LoadAndInitializeNtMarta(VOID) return ERROR_SUCCESS; } + DWORD CheckNtMartaPresent(VOID) { @@ -221,7 +224,9 @@ CheckNtMartaPresent(VOID) return ErrorCode; } -VOID UnloadNtMarta(VOID) + +VOID +UnloadNtMarta(VOID) { if (InterlockedExchangePointer(&NtMarta, NULL) != NULL) @@ -230,29 +235,32 @@ VOID UnloadNtMarta(VOID) } } + /******************************************************************************/ /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL AreAllAccessesGranted(DWORD GrantedAccess, - DWORD DesiredAccess) + DWORD DesiredAccess) { - return((BOOL)RtlAreAllAccessesGranted(GrantedAccess, - DesiredAccess)); + return (BOOL)RtlAreAllAccessesGranted(GrantedAccess, + DesiredAccess); } /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL AreAnyAccessesGranted(DWORD GrantedAccess, - DWORD DesiredAccess) + DWORD DesiredAccess) { - return((BOOL)RtlAreAnyAccessesGranted(GrantedAccess, - DesiredAccess)); + return (BOOL)RtlAreAnyAccessesGranted(GrantedAccess, + DesiredAccess); } @@ -278,142 +286,145 @@ AreAnyAccessesGranted(DWORD GrantedAccess, * * @implemented */ -BOOL WINAPI +BOOL +WINAPI GetFileSecurityA(LPCSTR lpFileName, - SECURITY_INFORMATION RequestedInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded) + SECURITY_INFORMATION RequestedInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded) { - UNICODE_STRING FileName; - NTSTATUS Status; - BOOL bResult; + UNICODE_STRING FileName; + NTSTATUS Status; + BOOL bResult; - Status = RtlCreateUnicodeStringFromAsciiz(&FileName, - (LPSTR)lpFileName); - if (!NT_SUCCESS(Status)) + Status = RtlCreateUnicodeStringFromAsciiz(&FileName, + (LPSTR)lpFileName); + if (!NT_SUCCESS(Status)) { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - bResult = GetFileSecurityW(FileName.Buffer, - RequestedInformation, - pSecurityDescriptor, - nLength, - lpnLengthNeeded); + bResult = GetFileSecurityW(FileName.Buffer, + RequestedInformation, + pSecurityDescriptor, + nLength, + lpnLengthNeeded); - RtlFreeUnicodeString(&FileName); + RtlFreeUnicodeString(&FileName); - return bResult; + return bResult; } /* * @implemented */ -BOOL WINAPI +BOOL +WINAPI GetFileSecurityW(LPCWSTR lpFileName, - SECURITY_INFORMATION RequestedInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded) + SECURITY_INFORMATION RequestedInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded) { - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK StatusBlock; - UNICODE_STRING FileName; - ULONG AccessMask = 0; - HANDLE FileHandle; - NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK StatusBlock; + UNICODE_STRING FileName; + ULONG AccessMask = 0; + HANDLE FileHandle; + NTSTATUS Status; - TRACE("GetFileSecurityW() called\n"); + TRACE("GetFileSecurityW() called\n"); - if (RequestedInformation & - (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION)) + if (RequestedInformation & + (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION)) { - AccessMask |= READ_CONTROL; + AccessMask |= READ_CONTROL; } - if (RequestedInformation & SACL_SECURITY_INFORMATION) + if (RequestedInformation & SACL_SECURITY_INFORMATION) { - AccessMask |= ACCESS_SYSTEM_SECURITY; + AccessMask |= ACCESS_SYSTEM_SECURITY; } - if (!RtlDosPathNameToNtPathName_U(lpFileName, - &FileName, - NULL, - NULL)) + if (!RtlDosPathNameToNtPathName_U(lpFileName, + &FileName, + NULL, + NULL)) { - ERR("Invalid path\n"); - SetLastError(ERROR_INVALID_NAME); - return FALSE; + ERR("Invalid path\n"); + SetLastError(ERROR_INVALID_NAME); + return FALSE; } - InitializeObjectAttributes(&ObjectAttributes, - &FileName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); + InitializeObjectAttributes(&ObjectAttributes, + &FileName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); - Status = NtOpenFile(&FileHandle, - AccessMask, - &ObjectAttributes, - &StatusBlock, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - 0); + Status = NtOpenFile(&FileHandle, + AccessMask, + &ObjectAttributes, + &StatusBlock, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + 0); - RtlFreeHeap(RtlGetProcessHeap(), - 0, - FileName.Buffer); + RtlFreeHeap(RtlGetProcessHeap(), + 0, + FileName.Buffer); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { - ERR("NtOpenFile() failed (Status %lx)\n", Status); - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + ERR("NtOpenFile() failed (Status %lx)\n", Status); + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - Status = NtQuerySecurityObject(FileHandle, - RequestedInformation, - pSecurityDescriptor, - nLength, - lpnLengthNeeded); - NtClose(FileHandle); - - if (!NT_SUCCESS(Status)) + Status = NtQuerySecurityObject(FileHandle, + RequestedInformation, + pSecurityDescriptor, + nLength, + lpnLengthNeeded); + NtClose(FileHandle); + if (!NT_SUCCESS(Status)) { - ERR("NtQuerySecurityObject() failed (Status %lx)\n", Status); - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + ERR("NtQuerySecurityObject() failed (Status %lx)\n", Status); + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL GetKernelObjectSecurity(HANDLE Handle, - SECURITY_INFORMATION RequestedInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded) + SECURITY_INFORMATION RequestedInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded) { - NTSTATUS Status; + NTSTATUS Status; - Status = NtQuerySecurityObject(Handle, - RequestedInformation, - pSecurityDescriptor, - nLength, - lpnLengthNeeded); - if (!NT_SUCCESS(Status)) + Status = NtQuerySecurityObject(Handle, + RequestedInformation, + pSecurityDescriptor, + nLength, + lpnLengthNeeded); + if (!NT_SUCCESS(Status)) { - SetLastError(RtlNtStatusToDosError(Status)); - return(FALSE); + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return(TRUE); + + return TRUE; } @@ -423,30 +434,31 @@ GetKernelObjectSecurity(HANDLE Handle, * * @implemented */ -BOOL STDCALL -SetFileSecurityA (LPCSTR lpFileName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor) +BOOL +STDCALL +SetFileSecurityA(LPCSTR lpFileName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor) { - UNICODE_STRING FileName; - NTSTATUS Status; - BOOL bResult; + UNICODE_STRING FileName; + NTSTATUS Status; + BOOL bResult; - Status = RtlCreateUnicodeStringFromAsciiz(&FileName, - (LPSTR)lpFileName); - if (!NT_SUCCESS(Status)) + Status = RtlCreateUnicodeStringFromAsciiz(&FileName, + (LPSTR)lpFileName); + if (!NT_SUCCESS(Status)) { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - bResult = SetFileSecurityW(FileName.Buffer, - SecurityInformation, - pSecurityDescriptor); + bResult = SetFileSecurityW(FileName.Buffer, + SecurityInformation, + pSecurityDescriptor); - RtlFreeUnicodeString(&FileName); + RtlFreeUnicodeString(&FileName); - return bResult; + return bResult; } @@ -456,105 +468,108 @@ SetFileSecurityA (LPCSTR lpFileName, * * @implemented */ -BOOL STDCALL -SetFileSecurityW (LPCWSTR lpFileName, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor) +BOOL +STDCALL +SetFileSecurityW(LPCWSTR lpFileName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor) { - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK StatusBlock; - UNICODE_STRING FileName; - ULONG AccessMask = 0; - HANDLE FileHandle; - NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK StatusBlock; + UNICODE_STRING FileName; + ULONG AccessMask = 0; + HANDLE FileHandle; + NTSTATUS Status; - TRACE("SetFileSecurityW() called\n"); + TRACE("SetFileSecurityW() called\n"); - if (SecurityInformation & - (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION)) + if (SecurityInformation & + (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION)) { - AccessMask |= WRITE_OWNER; + AccessMask |= WRITE_OWNER; } - if (SecurityInformation & DACL_SECURITY_INFORMATION) + if (SecurityInformation & DACL_SECURITY_INFORMATION) { - AccessMask |= WRITE_DAC; + AccessMask |= WRITE_DAC; } - if (SecurityInformation & SACL_SECURITY_INFORMATION) + if (SecurityInformation & SACL_SECURITY_INFORMATION) { - AccessMask |= ACCESS_SYSTEM_SECURITY; + AccessMask |= ACCESS_SYSTEM_SECURITY; } - if (!RtlDosPathNameToNtPathName_U(lpFileName, - &FileName, - NULL, - NULL)) + if (!RtlDosPathNameToNtPathName_U(lpFileName, + &FileName, + NULL, + NULL)) { - ERR("Invalid path\n"); - SetLastError(ERROR_INVALID_NAME); - return FALSE; + ERR("Invalid path\n"); + SetLastError(ERROR_INVALID_NAME); + return FALSE; } - InitializeObjectAttributes(&ObjectAttributes, - &FileName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); + InitializeObjectAttributes(&ObjectAttributes, + &FileName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); - Status = NtOpenFile(&FileHandle, - AccessMask, - &ObjectAttributes, - &StatusBlock, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - 0); + Status = NtOpenFile(&FileHandle, + AccessMask, + &ObjectAttributes, + &StatusBlock, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + 0); - RtlFreeHeap(RtlGetProcessHeap(), - 0, - FileName.Buffer); + RtlFreeHeap(RtlGetProcessHeap(), + 0, + FileName.Buffer); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { - ERR("NtOpenFile() failed (Status %lx)\n", Status); - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + ERR("NtOpenFile() failed (Status %lx)\n", Status); + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - Status = NtSetSecurityObject(FileHandle, - SecurityInformation, - pSecurityDescriptor); - NtClose(FileHandle); + Status = NtSetSecurityObject(FileHandle, + SecurityInformation, + pSecurityDescriptor); + NtClose(FileHandle); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { - ERR("NtSetSecurityObject() failed (Status %lx)\n", Status); - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + ERR("NtSetSecurityObject() failed (Status %lx)\n", Status); + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL SetKernelObjectSecurity(HANDLE Handle, - SECURITY_INFORMATION SecurityInformation, - PSECURITY_DESCRIPTOR SecurityDescriptor) + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR SecurityDescriptor) { - NTSTATUS Status; + NTSTATUS Status; - Status = NtSetSecurityObject(Handle, - SecurityInformation, - SecurityDescriptor); - if (!NT_SUCCESS(Status)) + Status = NtSetSecurityObject(Handle, + SecurityInformation, + SecurityDescriptor); + if (!NT_SUCCESS(Status)) { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + + return TRUE; } @@ -568,6 +583,89 @@ ImpersonateAnonymousToken(IN HANDLE ThreadHandle) NTSTATUS Status; Status = NtImpersonateAnonymousToken(ThreadHandle); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; +} + + +/* + * @implemented + */ +BOOL +STDCALL +ImpersonateLoggedOnUser(HANDLE hToken) +{ + 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)) { @@ -582,123 +680,44 @@ ImpersonateAnonymousToken(IN HANDLE ThreadHandle) /* * @implemented */ -BOOL STDCALL -ImpersonateLoggedOnUser(HANDLE hToken) -{ - 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; -} - - -/* - * @implemented - */ -BOOL STDCALL +BOOL +STDCALL ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlImpersonateSelf(ImpersonationLevel); - if (!NT_SUCCESS(Status)) + Status = RtlImpersonateSelf(ImpersonationLevel); + if (!NT_SUCCESS(Status)) { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + + return TRUE; } /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL RevertToSelf(VOID) { - NTSTATUS Status; - HANDLE Token = NULL; + NTSTATUS Status; + HANDLE Token = NULL; - Status = NtSetInformationThread(NtCurrentThread(), - ThreadImpersonationToken, - &Token, - sizeof(HANDLE)); - if (!NT_SUCCESS(Status)) + Status = NtSetInformationThread(NtCurrentThread(), + ThreadImpersonationToken, + &Token, + sizeof(HANDLE)); + if (!NT_SUCCESS(Status)) { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + + return TRUE; } @@ -714,42 +733,45 @@ RevertToSelf(VOID) * * @implemented */ -BOOL WINAPI -GetUserNameA( LPSTR lpszName, LPDWORD lpSize ) +BOOL +WINAPI +GetUserNameA(LPSTR lpszName, + LPDWORD lpSize) { - UNICODE_STRING NameW; - ANSI_STRING NameA; - BOOL Ret; + UNICODE_STRING NameW; + ANSI_STRING NameA; + BOOL Ret; - /* apparently Win doesn't check whether lpSize is valid at all! */ + /* apparently Win doesn't check whether lpSize is valid at all! */ - NameW.MaximumLength = (*lpSize) * sizeof(WCHAR); - NameW.Buffer = LocalAlloc(LMEM_FIXED, NameW.MaximumLength); - if(NameW.Buffer == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } + NameW.MaximumLength = (*lpSize) * sizeof(WCHAR); + NameW.Buffer = LocalAlloc(LMEM_FIXED, NameW.MaximumLength); + if(NameW.Buffer == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } - NameA.Length = 0; - NameA.MaximumLength = ((*lpSize) < 0xFFFF ? (USHORT)(*lpSize) : 0xFFFF); - NameA.Buffer = lpszName; + NameA.Length = 0; + NameA.MaximumLength = ((*lpSize) < 0xFFFF ? (USHORT)(*lpSize) : 0xFFFF); + NameA.Buffer = lpszName; - Ret = GetUserNameW(NameW.Buffer, - lpSize); - if(Ret) - { - NameW.Length = (*lpSize - 1) * sizeof(WCHAR); - RtlUnicodeStringToAnsiString(&NameA, &NameW, FALSE); + Ret = GetUserNameW(NameW.Buffer, + lpSize); + if(Ret) + { + NameW.Length = (*lpSize - 1) * sizeof(WCHAR); + RtlUnicodeStringToAnsiString(&NameA, &NameW, FALSE); - *lpSize = NameA.Length + 1; - } + *lpSize = NameA.Length + 1; + } - LocalFree(NameW.Buffer); + LocalFree(NameW.Buffer); - return Ret; + return Ret; } + /****************************************************************************** * GetUserNameW [ADVAPI32.@] * @@ -757,8 +779,10 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize ) * * @implemented */ -BOOL WINAPI -GetUserNameW ( LPWSTR lpszName, LPDWORD lpSize ) +BOOL +WINAPI +GetUserNameW(LPWSTR lpszName, + LPDWORD lpSize ) { HANDLE hToken = INVALID_HANDLE_VALUE; DWORD tu_len = 0; @@ -862,14 +886,15 @@ GetUserNameW ( LPWSTR lpszName, LPDWORD lpSize ) * * @implemented */ -BOOL STDCALL -LookupAccountSidA (LPCSTR lpSystemName, - PSID lpSid, - LPSTR lpName, - LPDWORD cchName, - LPSTR lpReferencedDomainName, - LPDWORD cchReferencedDomainName, - PSID_NAME_USE peUse) +BOOL +STDCALL +LookupAccountSidA(LPCSTR lpSystemName, + PSID lpSid, + LPSTR lpName, + LPDWORD cchName, + LPSTR lpReferencedDomainName, + LPDWORD cchReferencedDomainName, + PSID_NAME_USE peUse) { UNICODE_STRING NameW, ReferencedDomainNameW, SystemNameW; DWORD szName, szReferencedDomainName; @@ -1003,14 +1028,13 @@ LookupAccountSidA (LPCSTR lpSystemName, * @implemented */ BOOL WINAPI -LookupAccountSidW ( - LPCWSTR pSystemName, - PSID pSid, - LPWSTR pAccountName, - LPDWORD pdwAccountName, - LPWSTR pDomainName, - LPDWORD pdwDomainName, - PSID_NAME_USE peUse ) +LookupAccountSidW(LPCWSTR pSystemName, + PSID pSid, + LPWSTR pAccountName, + LPDWORD pdwAccountName, + LPWSTR pDomainName, + LPDWORD pdwDomainName, + PSID_NAME_USE peUse) { LSA_UNICODE_STRING SystemName; LSA_OBJECT_ATTRIBUTES ObjectAttributes = {0}; @@ -1098,14 +1122,15 @@ LookupAccountSidW ( * * @implemented */ -BOOL STDCALL -LookupAccountNameA (LPCSTR SystemName, - LPCSTR AccountName, - PSID Sid, - LPDWORD SidLength, - LPSTR ReferencedDomainName, - LPDWORD hReferencedDomainNameLength, - PSID_NAME_USE SidNameUse) +BOOL +STDCALL +LookupAccountNameA(LPCSTR SystemName, + LPCSTR AccountName, + PSID Sid, + LPDWORD SidLength, + LPSTR ReferencedDomainName, + LPDWORD hReferencedDomainNameLength, + PSID_NAME_USE SidNameUse) { BOOL ret; UNICODE_STRING lpSystemW; @@ -1116,15 +1141,28 @@ LookupAccountNameA (LPCSTR SystemName, RtlCreateUnicodeStringFromAsciiz(&lpAccountW, AccountName); if (ReferencedDomainName) - lpReferencedDomainNameW = HeapAlloc(GetProcessHeap(), 0, *hReferencedDomainNameLength * sizeof(WCHAR)); + lpReferencedDomainNameW = HeapAlloc(GetProcessHeap(), + 0, + *hReferencedDomainNameLength * sizeof(WCHAR)); - ret = LookupAccountNameW(lpSystemW.Buffer, lpAccountW.Buffer, Sid, SidLength, lpReferencedDomainNameW, - hReferencedDomainNameLength, SidNameUse); + ret = LookupAccountNameW(lpSystemW.Buffer, + lpAccountW.Buffer, + Sid, + SidLength, + lpReferencedDomainNameW, + hReferencedDomainNameLength, + SidNameUse); if (ret && lpReferencedDomainNameW) { - WideCharToMultiByte(CP_ACP, 0, lpReferencedDomainNameW, *hReferencedDomainNameLength, - ReferencedDomainName, *hReferencedDomainNameLength, NULL, NULL); + WideCharToMultiByte(CP_ACP, + 0, + lpReferencedDomainNameW, + *hReferencedDomainNameLength, + ReferencedDomainName, + *hReferencedDomainNameLength, + NULL, + NULL); } RtlFreeUnicodeString(&lpSystemW); @@ -1140,9 +1178,15 @@ LookupAccountNameA (LPCSTR SystemName, * * @unimplemented */ -BOOL WINAPI LookupAccountNameW(LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID Sid, - LPDWORD cbSid, LPWSTR ReferencedDomainName, - LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse) +BOOL +WINAPI +LookupAccountNameW(LPCWSTR lpSystemName, + LPCWSTR lpAccountName, + PSID Sid, + LPDWORD cbSid, + LPWSTR ReferencedDomainName, + LPDWORD cchReferencedDomainName, + PSID_NAME_USE peUse) { /* Default implementation: Always return a default SID */ SID_IDENTIFIER_AUTHORITY identifierAuthority = {SECURITY_NT_AUTHORITY}; @@ -1174,30 +1218,32 @@ BOOL WINAPI LookupAccountNameW(LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID &pSid); if (!ret) - return FALSE; + return FALSE; if (!RtlValidSid(pSid)) { - FreeSid(pSid); - return FALSE; + FreeSid(pSid); + return FALSE; } if (Sid != NULL && (*cbSid >= GetLengthSid(pSid))) - CopySid(*cbSid, Sid, pSid); + CopySid(*cbSid, Sid, pSid); + if (*cbSid < GetLengthSid(pSid)) { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - ret = FALSE; + SetLastError(ERROR_INSUFFICIENT_BUFFER); + ret = FALSE; } + *cbSid = GetLengthSid(pSid); - + if (ReferencedDomainName != NULL && (*cchReferencedDomainName > wcslen(dm))) - wcscpy(ReferencedDomainName, dm); + wcscpy(ReferencedDomainName, dm); if (*cchReferencedDomainName <= wcslen(dm)) { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - ret = FALSE; + SetLastError(ERROR_INSUFFICIENT_BUFFER); + ret = FALSE; } *cchReferencedDomainName = wcslen(dm)+1; @@ -1213,45 +1259,46 @@ BOOL WINAPI LookupAccountNameW(LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID * * @implemented */ -BOOL STDCALL -LookupPrivilegeValueA (LPCSTR lpSystemName, - LPCSTR lpName, - PLUID lpLuid) +BOOL +STDCALL +LookupPrivilegeValueA(LPCSTR lpSystemName, + LPCSTR lpName, + PLUID lpLuid) { - UNICODE_STRING SystemName; - UNICODE_STRING Name; - BOOL Result; + UNICODE_STRING SystemName; + UNICODE_STRING Name; + BOOL Result; - /* Remote system? */ - if (lpSystemName != NULL) + /* Remote system? */ + if (lpSystemName != NULL) { - RtlCreateUnicodeStringFromAsciiz (&SystemName, - (LPSTR)lpSystemName); + RtlCreateUnicodeStringFromAsciiz(&SystemName, + (LPSTR)lpSystemName); } - /* Check the privilege name is not NULL */ - if (lpName == NULL) + /* Check the privilege name is not NULL */ + if (lpName == NULL) { - SetLastError (ERROR_INVALID_PARAMETER); - return FALSE; + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; } - RtlCreateUnicodeStringFromAsciiz (&Name, - (LPSTR)lpName); + RtlCreateUnicodeStringFromAsciiz(&Name, + (LPSTR)lpName); - Result = LookupPrivilegeValueW ((lpSystemName != NULL) ? SystemName.Buffer : NULL, - Name.Buffer, - lpLuid); + Result = LookupPrivilegeValueW((lpSystemName != NULL) ? SystemName.Buffer : NULL, + Name.Buffer, + lpLuid); - RtlFreeUnicodeString (&Name); + RtlFreeUnicodeString(&Name); - /* Remote system? */ - if (lpSystemName != NULL) + /* Remote system? */ + if (lpSystemName != NULL) { - RtlFreeUnicodeString (&SystemName); + RtlFreeUnicodeString(&SystemName); } - return Result; + return Result; } @@ -1260,10 +1307,11 @@ LookupPrivilegeValueA (LPCSTR lpSystemName, * * @unimplemented */ -BOOL STDCALL -LookupPrivilegeValueW (LPCWSTR SystemName, - LPCWSTR PrivName, - PLUID Luid) +BOOL +STDCALL +LookupPrivilegeValueW(LPCWSTR SystemName, + LPCWSTR PrivName, + PLUID Luid) { static const WCHAR * const DefaultPrivNames[] = { @@ -1328,16 +1376,17 @@ LookupPrivilegeValueW (LPCWSTR SystemName, * * @unimplemented */ -BOOL STDCALL -LookupPrivilegeDisplayNameA (LPCSTR lpSystemName, - LPCSTR lpName, - LPSTR lpDisplayName, - LPDWORD cbDisplayName, - LPDWORD lpLanguageId) +BOOL +STDCALL +LookupPrivilegeDisplayNameA(LPCSTR lpSystemName, + LPCSTR lpName, + LPSTR lpDisplayName, + LPDWORD cbDisplayName, + LPDWORD lpLanguageId) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -1346,16 +1395,17 @@ LookupPrivilegeDisplayNameA (LPCSTR lpSystemName, * * @unimplemented */ -BOOL STDCALL -LookupPrivilegeDisplayNameW (LPCWSTR lpSystemName, - LPCWSTR lpName, - LPWSTR lpDisplayName, - LPDWORD cbDisplayName, - LPDWORD lpLanguageId) +BOOL +STDCALL +LookupPrivilegeDisplayNameW(LPCWSTR lpSystemName, + LPCWSTR lpName, + LPWSTR lpDisplayName, + LPDWORD cbDisplayName, + LPDWORD lpLanguageId) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -1364,15 +1414,16 @@ LookupPrivilegeDisplayNameW (LPCWSTR lpSystemName, * * @unimplemented */ -BOOL STDCALL -LookupPrivilegeNameA (LPCSTR lpSystemName, - PLUID lpLuid, - LPSTR lpName, - LPDWORD cbName) +BOOL +STDCALL +LookupPrivilegeNameA(LPCSTR lpSystemName, + PLUID lpLuid, + LPSTR lpName, + LPDWORD cbName) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -1381,24 +1432,25 @@ LookupPrivilegeNameA (LPCSTR lpSystemName, * * @unimplemented */ -BOOL STDCALL -LookupPrivilegeNameW (LPCWSTR lpSystemName, - PLUID lpLuid, - LPWSTR lpName, - LPDWORD cbName) +BOOL +STDCALL +LookupPrivilegeNameW(LPCWSTR lpSystemName, + PLUID lpLuid, + LPWSTR lpName, + LPDWORD cbName) { - FIXME("%s() not implemented!\n", __FUNCTION__); - SetLastError (ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + FIXME("%s() not implemented!\n", __FUNCTION__); + SetLastError (ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } static DWORD pGetSecurityInfoCheck(SECURITY_INFORMATION SecurityInfo, - PSID* ppsidOwner, - PSID* ppsidGroup, - PACL* ppDacl, - PACL* ppSacl, + PSID *ppsidOwner, + PSID *ppsidGroup, + PACL *ppDacl, + PACL *ppSacl, PSECURITY_DESCRIPTOR* ppSecurityDescriptor) { if ((SecurityInfo & (OWNER_SECURITY_INFORMATION | @@ -1574,7 +1626,8 @@ ProtectSacl: * * @implemented */ -DWORD STDCALL +DWORD +STDCALL GetNamedSecurityInfoW(LPWSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, @@ -1624,7 +1677,8 @@ GetNamedSecurityInfoW(LPWSTR pObjectName, * * @implemented */ -DWORD STDCALL +DWORD +STDCALL GetNamedSecurityInfoA(LPSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, @@ -1665,7 +1719,8 @@ GetNamedSecurityInfoA(LPSTR pObjectName, * * @implemented */ -DWORD STDCALL +DWORD +STDCALL SetNamedSecurityInfoW(LPWSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, @@ -1712,7 +1767,8 @@ SetNamedSecurityInfoW(LPWSTR pObjectName, * * @implemented */ -DWORD STDCALL +DWORD +STDCALL SetNamedSecurityInfoA(LPSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, @@ -1751,15 +1807,16 @@ SetNamedSecurityInfoA(LPSTR pObjectName, * * @implemented */ -DWORD STDCALL +DWORD +STDCALL GetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, - PSID* ppsidOwner, - PSID* ppsidGroup, - PACL* ppDacl, - PACL* ppSacl, - PSECURITY_DESCRIPTOR* ppSecurityDescriptor) + PSID *ppsidOwner, + PSID *ppsidGroup, + PACL *ppDacl, + PACL *ppSacl, + PSECURITY_DESCRIPTOR *ppSecurityDescriptor) { DWORD ErrorCode; @@ -1847,40 +1904,40 @@ SetSecurityInfo(HANDLE handle, /****************************************************************************** * GetSecurityInfoExW EXPORTED */ -DWORD WINAPI GetSecurityInfoExA( - HANDLE hObject, - SE_OBJECT_TYPE ObjectType, - SECURITY_INFORMATION SecurityInfo, - LPCSTR lpProvider, - LPCSTR lpProperty, - PACTRL_ACCESSA *ppAccessList, - PACTRL_AUDITA *ppAuditList, - LPSTR *lppOwner, - LPSTR *lppGroup - ) +DWORD +WINAPI +GetSecurityInfoExA(HANDLE hObject, + SE_OBJECT_TYPE ObjectType, + SECURITY_INFORMATION SecurityInfo, + LPCSTR lpProvider, + LPCSTR lpProperty, + PACTRL_ACCESSA *ppAccessList, + PACTRL_AUDITA *ppAuditList, + LPSTR *lppOwner, + LPSTR *lppGroup) { - FIXME("%s() not implemented!\n", __FUNCTION__); - return ERROR_BAD_PROVIDER; + FIXME("%s() not implemented!\n", __FUNCTION__); + return ERROR_BAD_PROVIDER; } /****************************************************************************** * GetSecurityInfoExW EXPORTED */ -DWORD WINAPI GetSecurityInfoExW( - HANDLE hObject, - SE_OBJECT_TYPE ObjectType, - SECURITY_INFORMATION SecurityInfo, - LPCWSTR lpProvider, - LPCWSTR lpProperty, - PACTRL_ACCESSW *ppAccessList, - PACTRL_AUDITW *ppAuditList, - LPWSTR *lppOwner, - LPWSTR *lppGroup - ) +DWORD +WINAPI +GetSecurityInfoExW(HANDLE hObject, + SE_OBJECT_TYPE ObjectType, + SECURITY_INFORMATION SecurityInfo, + LPCWSTR lpProvider, + LPCWSTR lpProperty, + PACTRL_ACCESSW *ppAccessList, + PACTRL_AUDITW *ppAuditList, + LPWSTR *lppOwner, + LPWSTR *lppGroup) { - FIXME("%s() not implemented!\n", __FUNCTION__); - return ERROR_BAD_PROVIDER; + FIXME("%s() not implemented!\n", __FUNCTION__); + return ERROR_BAD_PROVIDER; } @@ -1889,38 +1946,40 @@ DWORD WINAPI GetSecurityInfoExW( * * @implemented */ -BOOL STDCALL +BOOL +STDCALL ImpersonateNamedPipeClient(HANDLE hNamedPipe) { - IO_STATUS_BLOCK StatusBlock; - NTSTATUS Status; + IO_STATUS_BLOCK StatusBlock; + NTSTATUS Status; - TRACE("ImpersonateNamedPipeClient() called\n"); + TRACE("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; - } + 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; + return TRUE; } /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR ParentDescriptor, PSECURITY_DESCRIPTOR CreatorDescriptor, PSECURITY_DESCRIPTOR *NewDescriptor, @@ -1949,7 +2008,8 @@ CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR ParentDescriptor, /* * @unimplemented */ -BOOL STDCALL +BOOL +STDCALL CreatePrivateObjectSecurityEx(PSECURITY_DESCRIPTOR ParentDescriptor, PSECURITY_DESCRIPTOR CreatorDescriptor, PSECURITY_DESCRIPTOR* NewDescriptor, @@ -1967,7 +2027,8 @@ CreatePrivateObjectSecurityEx(PSECURITY_DESCRIPTOR ParentDescriptor, /* * @unimplemented */ -BOOL STDCALL +BOOL +STDCALL CreatePrivateObjectSecurityWithMultipleInheritance(PSECURITY_DESCRIPTOR ParentDescriptor, PSECURITY_DESCRIPTOR CreatorDescriptor, PSECURITY_DESCRIPTOR* NewDescriptor, @@ -1986,7 +2047,8 @@ CreatePrivateObjectSecurityWithMultipleInheritance(PSECURITY_DESCRIPTOR ParentDe /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR *ObjectDescriptor) { NTSTATUS Status; @@ -2005,7 +2067,8 @@ DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR *ObjectDescriptor) /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR ObjectDescriptor, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR ResultantDescriptor, @@ -2032,7 +2095,8 @@ GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR ObjectDescriptor, /* * @implemented */ -BOOL STDCALL +BOOL +STDCALL SetPrivateObjectSecurity(SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR ModificationDescriptor, PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, @@ -2059,7 +2123,8 @@ SetPrivateObjectSecurity(SECURITY_INFORMATION SecurityInformation, /* * @implemented */ -DWORD STDCALL +DWORD +STDCALL TreeResetNamedSecurityInfoW(LPWSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, @@ -2191,7 +2256,8 @@ InternalfnProgressW(LPWSTR pObjectName, /* * @implemented */ -DWORD STDCALL +DWORD +STDCALL TreeResetNamedSecurityInfoA(LPSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, diff --git a/reactos/dll/win32/advapi32/sec/sec.c b/reactos/dll/win32/advapi32/sec/sec.c index 8eea6e427a1..aafb6b4a43c 100644 --- a/reactos/dll/win32/advapi32/sec/sec.c +++ b/reactos/dll/win32/advapi32/sec/sec.c @@ -21,24 +21,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); */ BOOL STDCALL -GetSecurityDescriptorControl ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - PSECURITY_DESCRIPTOR_CONTROL pControl, - LPDWORD lpdwRevision - ) +GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSECURITY_DESCRIPTOR_CONTROL pControl, + LPDWORD lpdwRevision) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlGetControlSecurityDescriptor (pSecurityDescriptor, - pControl, - (PULONG)lpdwRevision); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlGetControlSecurityDescriptor(pSecurityDescriptor, + pControl, + (PULONG)lpdwRevision); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -47,31 +45,29 @@ GetSecurityDescriptorControl ( */ BOOL STDCALL -GetSecurityDescriptorDacl ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - LPBOOL lpbDaclPresent, - PACL *pDacl, - LPBOOL lpbDaclDefaulted - ) +GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + LPBOOL lpbDaclPresent, + PACL *pDacl, + LPBOOL lpbDaclDefaulted) { - BOOLEAN DaclPresent; - BOOLEAN DaclDefaulted; - NTSTATUS Status; + BOOLEAN DaclPresent; + BOOLEAN DaclDefaulted; + NTSTATUS Status; - Status = RtlGetDaclSecurityDescriptor (pSecurityDescriptor, - &DaclPresent, - pDacl, - &DaclDefaulted); - *lpbDaclPresent = (BOOL)DaclPresent; - *lpbDaclDefaulted = (BOOL)DaclDefaulted; + Status = RtlGetDaclSecurityDescriptor(pSecurityDescriptor, + &DaclPresent, + pDacl, + &DaclDefaulted); + *lpbDaclPresent = (BOOL)DaclPresent; + *lpbDaclDefaulted = (BOOL)DaclDefaulted; - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -80,27 +76,25 @@ GetSecurityDescriptorDacl ( */ BOOL STDCALL -GetSecurityDescriptorGroup ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - PSID *pGroup, - LPBOOL lpbGroupDefaulted - ) +GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSID *pGroup, + LPBOOL lpbGroupDefaulted) { - BOOLEAN GroupDefaulted; - NTSTATUS Status; + BOOLEAN GroupDefaulted; + NTSTATUS Status; - Status = RtlGetGroupSecurityDescriptor (pSecurityDescriptor, - pGroup, - &GroupDefaulted); - *lpbGroupDefaulted = (BOOL)GroupDefaulted; + Status = RtlGetGroupSecurityDescriptor(pSecurityDescriptor, + pGroup, + &GroupDefaulted); + *lpbGroupDefaulted = (BOOL)GroupDefaulted; - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -109,27 +103,25 @@ GetSecurityDescriptorGroup ( */ BOOL STDCALL -GetSecurityDescriptorOwner ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - PSID *pOwner, - LPBOOL lpbOwnerDefaulted - ) +GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSID *pOwner, + LPBOOL lpbOwnerDefaulted) { - BOOLEAN OwnerDefaulted; - NTSTATUS Status; + BOOLEAN OwnerDefaulted; + NTSTATUS Status; - Status = RtlGetOwnerSecurityDescriptor (pSecurityDescriptor, - pOwner, - &OwnerDefaulted); - *lpbOwnerDefaulted = (BOOL)OwnerDefaulted; + Status = RtlGetOwnerSecurityDescriptor(pSecurityDescriptor, + pOwner, + &OwnerDefaulted); + *lpbOwnerDefaulted = (BOOL)OwnerDefaulted; - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -138,15 +130,14 @@ GetSecurityDescriptorOwner ( */ DWORD STDCALL -GetSecurityDescriptorRMControl ( - PSECURITY_DESCRIPTOR SecurityDescriptor, - PUCHAR RMControl) +GetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, + PUCHAR RMControl) { - if (!RtlGetSecurityDescriptorRMControl(SecurityDescriptor, - RMControl)) - return ERROR_INVALID_DATA; + if (!RtlGetSecurityDescriptorRMControl(SecurityDescriptor, + RMControl)) + return ERROR_INVALID_DATA; - return ERROR_SUCCESS; + return ERROR_SUCCESS; } @@ -155,31 +146,29 @@ GetSecurityDescriptorRMControl ( */ BOOL STDCALL -GetSecurityDescriptorSacl ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - LPBOOL lpbSaclPresent, - PACL *pSacl, - LPBOOL lpbSaclDefaulted - ) +GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + LPBOOL lpbSaclPresent, + PACL *pSacl, + LPBOOL lpbSaclDefaulted) { - BOOLEAN SaclPresent; - BOOLEAN SaclDefaulted; - NTSTATUS Status; + BOOLEAN SaclPresent; + BOOLEAN SaclDefaulted; + NTSTATUS Status; - Status = RtlGetSaclSecurityDescriptor (pSecurityDescriptor, - &SaclPresent, - pSacl, - &SaclDefaulted); - *lpbSaclPresent = (BOOL)SaclPresent; - *lpbSaclDefaulted = (BOOL)SaclDefaulted; + Status = RtlGetSaclSecurityDescriptor(pSecurityDescriptor, + &SaclPresent, + pSacl, + &SaclDefaulted); + *lpbSaclPresent = (BOOL)SaclPresent; + *lpbSaclDefaulted = (BOOL)SaclDefaulted; - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -188,22 +177,20 @@ GetSecurityDescriptorSacl ( */ BOOL STDCALL -InitializeSecurityDescriptor ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD dwRevision - ) +InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD dwRevision) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlCreateSecurityDescriptor (pSecurityDescriptor, - dwRevision); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlCreateSecurityDescriptor(pSecurityDescriptor, + dwRevision); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -212,17 +199,15 @@ InitializeSecurityDescriptor ( */ BOOL STDCALL -IsValidSecurityDescriptor ( - PSECURITY_DESCRIPTOR pSecurityDescriptor - ) +IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor) { - BOOLEAN Result; + BOOLEAN Result; - Result = RtlValidSecurityDescriptor (pSecurityDescriptor); - if (Result == FALSE) - SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR)); + Result = RtlValidSecurityDescriptor (pSecurityDescriptor); + if (Result == FALSE) + SetLastError(RtlNtStatusToDosError(STATUS_INVALID_SECURITY_DESCR)); - return (BOOL)Result; + return (BOOL)Result; } @@ -231,19 +216,17 @@ IsValidSecurityDescriptor ( */ BOOL STDCALL -MakeAbsoluteSD ( - PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, - PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, - LPDWORD lpdwAbsoluteSecurityDescriptorSize, - PACL pDacl, - LPDWORD lpdwDaclSize, - PACL pSacl, - LPDWORD lpdwSaclSize, - PSID pOwner, - LPDWORD lpdwOwnerSize, - PSID pPrimaryGroup, - LPDWORD lpdwPrimaryGroupSize - ) +MakeAbsoluteSD(PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, + PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, + LPDWORD lpdwAbsoluteSecurityDescriptorSize, + PACL pDacl, + LPDWORD lpdwDaclSize, + PACL pSacl, + LPDWORD lpdwSaclSize, + PSID pOwner, + LPDWORD lpdwOwnerSize, + PSID pPrimaryGroup, + LPDWORD lpdwPrimaryGroupSize) { NTSTATUS Status; @@ -280,13 +263,13 @@ MakeAbsoluteSD2(IN OUT PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, Status = RtlSelfRelativeToAbsoluteSD2(pSelfRelativeSecurityDescriptor, lpdwBufferSize); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -295,24 +278,22 @@ MakeAbsoluteSD2(IN OUT PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, */ BOOL STDCALL -MakeSelfRelativeSD ( - PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, - PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, - LPDWORD lpdwBufferLength - ) +MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, + PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, + LPDWORD lpdwBufferLength) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor, - pSelfRelativeSecurityDescriptor, - (PULONG)lpdwBufferLength); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlAbsoluteToSelfRelativeSD(pAbsoluteSecurityDescriptor, + pSelfRelativeSecurityDescriptor, + (PULONG)lpdwBufferLength); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -321,23 +302,22 @@ MakeSelfRelativeSD ( */ BOOL STDCALL -SetSecurityDescriptorControl ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, - SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet) +SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, + SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlSetControlSecurityDescriptor(pSecurityDescriptor, - ControlBitsOfInterest, - ControlBitsToSet); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlSetControlSecurityDescriptor(pSecurityDescriptor, + ControlBitsOfInterest, + ControlBitsToSet); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -346,26 +326,24 @@ SetSecurityDescriptorControl ( */ BOOL STDCALL -SetSecurityDescriptorDacl ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - BOOL bDaclPresent, - PACL pDacl, - BOOL bDaclDefaulted - ) +SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + BOOL bDaclPresent, + PACL pDacl, + BOOL bDaclDefaulted) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlSetDaclSecurityDescriptor (pSecurityDescriptor, - bDaclPresent, - pDacl, - bDaclDefaulted); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlSetDaclSecurityDescriptor(pSecurityDescriptor, + bDaclPresent, + pDacl, + bDaclDefaulted); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -374,24 +352,22 @@ SetSecurityDescriptorDacl ( */ BOOL STDCALL -SetSecurityDescriptorGroup ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - PSID pGroup, - BOOL bGroupDefaulted - ) +SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSID pGroup, + BOOL bGroupDefaulted) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor, - pGroup, - bGroupDefaulted); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlSetGroupSecurityDescriptor(pSecurityDescriptor, + pGroup, + bGroupDefaulted); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -400,24 +376,22 @@ SetSecurityDescriptorGroup ( */ BOOL STDCALL -SetSecurityDescriptorOwner ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - PSID pOwner, - BOOL bOwnerDefaulted - ) +SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSID pOwner, + BOOL bOwnerDefaulted) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlSetOwnerSecurityDescriptor (pSecurityDescriptor, - pOwner, - bOwnerDefaulted); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, + pOwner, + bOwnerDefaulted); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -426,14 +400,13 @@ SetSecurityDescriptorOwner ( */ DWORD STDCALL -SetSecurityDescriptorRMControl ( - PSECURITY_DESCRIPTOR SecurityDescriptor, - PUCHAR RMControl) +SetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, + PUCHAR RMControl) { - RtlSetSecurityDescriptorRMControl(SecurityDescriptor, - RMControl); + RtlSetSecurityDescriptorRMControl(SecurityDescriptor, + RMControl); - return ERROR_SUCCESS; + return ERROR_SUCCESS; } @@ -442,26 +415,24 @@ SetSecurityDescriptorRMControl ( */ BOOL STDCALL -SetSecurityDescriptorSacl ( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - BOOL bSaclPresent, - PACL pSacl, - BOOL bSaclDefaulted - ) +SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + BOOL bSaclPresent, + PACL pSacl, + BOOL bSaclDefaulted) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlSetSaclSecurityDescriptor (pSecurityDescriptor, - bSaclPresent, - pSacl, - bSaclDefaulted); - if (!NT_SUCCESS(Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } + Status = RtlSetSaclSecurityDescriptor(pSecurityDescriptor, + bSaclPresent, + pSacl, + bSaclDefaulted); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } - return TRUE; + return TRUE; } @@ -574,10 +545,12 @@ BOOL WINAPI DecryptFileW(LPCWSTR lpFileName, DWORD dwReserved) return TRUE; } + /* * @implemented */ -BOOL WINAPI DecryptFileA(LPCSTR lpFileName, DWORD dwReserved) +BOOL WINAPI +DecryptFileA(LPCSTR lpFileName, DWORD dwReserved) { UNICODE_STRING FileName; NTSTATUS Status; @@ -597,20 +570,24 @@ BOOL WINAPI DecryptFileA(LPCSTR lpFileName, DWORD dwReserved) return ret; } + /* * @unimplemented */ -BOOL WINAPI EncryptFileW(LPCWSTR lpFileName) +BOOL WINAPI +EncryptFileW(LPCWSTR lpFileName) { FIXME("%s() not implemented!\n", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return TRUE; } + /* * @implemented */ -BOOL WINAPI EncryptFileA(LPCSTR lpFileName) +BOOL WINAPI +EncryptFileA(LPCSTR lpFileName) { UNICODE_STRING FileName; NTSTATUS Status; @@ -630,24 +607,32 @@ BOOL WINAPI EncryptFileA(LPCSTR lpFileName) return ret; } -BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorW( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD dword, - SECURITY_INFORMATION SecurityInformation, - LPWSTR* lpwstr, - PULONG pulong) + +/* + * @unimplemented + */ +BOOL WINAPI +ConvertSecurityDescriptorToStringSecurityDescriptorW(PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD dword, + SECURITY_INFORMATION SecurityInformation, + LPWSTR *lpwstr, + PULONG pulong) { FIXME("%s() not implemented!\n", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } -BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorA( - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD dword, - SECURITY_INFORMATION SecurityInformation, - LPSTR* lpstr, - PULONG pulong) + +/* + * @unimplemented + */ +BOOL WINAPI +ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD dword, + SECURITY_INFORMATION SecurityInformation, + LPSTR *lpstr, + PULONG pulong) { FIXME("%s() not implemented!\n", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); diff --git a/reactos/dll/win32/advapi32/sec/sid.c b/reactos/dll/win32/advapi32/sec/sid.c index c5d016381ca..10e703f7795 100644 --- a/reactos/dll/win32/advapi32/sec/sid.c +++ b/reactos/dll/win32/advapi32/sec/sid.c @@ -536,16 +536,16 @@ ParseAceString( BOOL STDCALL AllocateLocallyUniqueId(PLUID Luid) { - NTSTATUS Status; + NTSTATUS Status; - Status = NtAllocateLocallyUniqueId (Luid); - if (!NT_SUCCESS (Status)) + Status = NtAllocateLocallyUniqueId (Luid); + if (!NT_SUCCESS (Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -553,38 +553,38 @@ 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, - dwSubAuthority2, - dwSubAuthority3, - dwSubAuthority4, - dwSubAuthority5, - dwSubAuthority6, - dwSubAuthority7, - pSid); - if (!NT_SUCCESS (Status)) + Status = RtlAllocateAndInitializeSid(pIdentifierAuthority, + nSubAuthorityCount, + dwSubAuthority0, + dwSubAuthority1, + dwSubAuthority2, + dwSubAuthority3, + dwSubAuthority4, + dwSubAuthority5, + dwSubAuthority6, + dwSubAuthority7, + pSid); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -592,23 +592,25 @@ AllocateAndInitializeSid (PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, * @implemented */ BOOL STDCALL -CopySid (DWORD nDestinationSidLength, - PSID pDestinationSid, - PSID pSourceSid) +CopySid(DWORD nDestinationSidLength, + PSID pDestinationSid, + PSID pSourceSid) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlCopySid (nDestinationSidLength, - pDestinationSid, - pSourceSid); - if (!NT_SUCCESS (Status)) + Status = RtlCopySid(nDestinationSidLength, + pDestinationSid, + pSourceSid); + if (!NT_SUCCESS (Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } return TRUE; } + + /****************************************************************************** * ConvertStringSecurityDescriptorToSecurityDescriptorW [ADVAPI32.@] * @implemented @@ -830,10 +832,10 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA( * @implemented */ BOOL STDCALL -EqualPrefixSid (PSID pSid1, - PSID pSid2) +EqualPrefixSid(PSID pSid1, + PSID pSid2) { - return RtlEqualPrefixSid (pSid1, pSid2); + return RtlEqualPrefixSid (pSid1, pSid2); } @@ -841,10 +843,10 @@ EqualPrefixSid (PSID pSid1, * @implemented */ BOOL STDCALL -EqualSid (PSID pSid1, - PSID pSid2) +EqualSid(PSID pSid1, + PSID pSid2) { - return RtlEqualSid (pSid1, pSid2); + return RtlEqualSid (pSid1, pSid2); } @@ -856,9 +858,9 @@ EqualSid (PSID pSid1, * even thou it's defined to return a PVOID... */ PVOID STDCALL -FreeSid (PSID pSid) +FreeSid(PSID pSid) { - return RtlFreeSid (pSid); + return RtlFreeSid(pSid); } @@ -866,9 +868,9 @@ FreeSid (PSID pSid) * @implemented */ DWORD STDCALL -GetLengthSid (PSID pSid) +GetLengthSid(PSID pSid) { - return (DWORD)RtlLengthSid (pSid); + return (DWORD)RtlLengthSid(pSid); } @@ -876,9 +878,9 @@ GetLengthSid (PSID pSid) * @implemented */ PSID_IDENTIFIER_AUTHORITY STDCALL -GetSidIdentifierAuthority (PSID pSid) +GetSidIdentifierAuthority(PSID pSid) { - return RtlIdentifierAuthoritySid (pSid); + return RtlIdentifierAuthoritySid(pSid); } @@ -886,9 +888,9 @@ GetSidIdentifierAuthority (PSID pSid) * @implemented */ DWORD STDCALL -GetSidLengthRequired (UCHAR nSubAuthorityCount) +GetSidLengthRequired(UCHAR nSubAuthorityCount) { - return (DWORD)RtlLengthRequiredSid (nSubAuthorityCount); + return (DWORD)RtlLengthRequiredSid(nSubAuthorityCount); } @@ -896,10 +898,10 @@ GetSidLengthRequired (UCHAR nSubAuthorityCount) * @implemented */ PDWORD STDCALL -GetSidSubAuthority (PSID pSid, - DWORD nSubAuthority) +GetSidSubAuthority(PSID pSid, + DWORD nSubAuthority) { - return (PDWORD)RtlSubAuthoritySid (pSid, nSubAuthority); + return (PDWORD)RtlSubAuthoritySid(pSid, nSubAuthority); } @@ -907,9 +909,9 @@ GetSidSubAuthority (PSID pSid, * @implemented */ PUCHAR STDCALL -GetSidSubAuthorityCount (PSID pSid) +GetSidSubAuthorityCount(PSID pSid) { - return RtlSubAuthorityCountSid (pSid); + return RtlSubAuthorityCountSid(pSid); } @@ -917,22 +919,22 @@ GetSidSubAuthorityCount (PSID pSid) * @implemented */ BOOL STDCALL -InitializeSid (PSID Sid, - PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, - BYTE nSubAuthorityCount) +InitializeSid(PSID Sid, + PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, + BYTE nSubAuthorityCount) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlInitializeSid (Sid, - pIdentifierAuthority, - nSubAuthorityCount); - if (!NT_SUCCESS (Status)) + Status = RtlInitializeSid(Sid, + pIdentifierAuthority, + nSubAuthorityCount); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -940,60 +942,63 @@ InitializeSid (PSID Sid, * @implemented */ BOOL STDCALL -IsValidSid (PSID pSid) +IsValidSid(PSID pSid) { - return (BOOL)RtlValidSid (pSid); + return (BOOL)RtlValidSid(pSid); } + /* * @implemented */ BOOL STDCALL -ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid) +ConvertSidToStringSidW(PSID Sid, + LPWSTR *StringSid) { - NTSTATUS Status; - UNICODE_STRING UnicodeString; - WCHAR FixedBuffer[64]; + NTSTATUS Status; + UNICODE_STRING UnicodeString; + WCHAR FixedBuffer[64]; - if (! RtlValidSid(Sid)) + if (!RtlValidSid(Sid)) { - SetLastError(ERROR_INVALID_SID); - return FALSE; + SetLastError(ERROR_INVALID_SID); + return FALSE; } - UnicodeString.Length = 0; - UnicodeString.MaximumLength = sizeof(FixedBuffer); - UnicodeString.Buffer = FixedBuffer; - Status = RtlConvertSidToUnicodeString(&UnicodeString, Sid, FALSE); - if (STATUS_BUFFER_TOO_SMALL == Status) + UnicodeString.Length = 0; + UnicodeString.MaximumLength = sizeof(FixedBuffer); + UnicodeString.Buffer = FixedBuffer; + Status = RtlConvertSidToUnicodeString(&UnicodeString, Sid, FALSE); + if (STATUS_BUFFER_TOO_SMALL == Status) { - Status = RtlConvertSidToUnicodeString(&UnicodeString, Sid, TRUE); - } - if (! NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + Status = RtlConvertSidToUnicodeString(&UnicodeString, Sid, TRUE); } - *StringSid = LocalAlloc(LMEM_FIXED, UnicodeString.Length + sizeof(WCHAR)); - if (NULL == *StringSid) + if (!NT_SUCCESS(Status)) { - if (UnicodeString.Buffer != FixedBuffer) + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + *StringSid = LocalAlloc(LMEM_FIXED, UnicodeString.Length + sizeof(WCHAR)); + if (NULL == *StringSid) + { + if (UnicodeString.Buffer != FixedBuffer) { - RtlFreeUnicodeString(&UnicodeString); + RtlFreeUnicodeString(&UnicodeString); } SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - MoveMemory(*StringSid, UnicodeString.Buffer, UnicodeString.Length); - ZeroMemory((PCHAR) *StringSid + UnicodeString.Length, sizeof(WCHAR)); - if (UnicodeString.Buffer != FixedBuffer) + MoveMemory(*StringSid, UnicodeString.Buffer, UnicodeString.Length); + ZeroMemory((PCHAR) *StringSid + UnicodeString.Length, sizeof(WCHAR)); + if (UnicodeString.Buffer != FixedBuffer) { - RtlFreeUnicodeString(&UnicodeString); + RtlFreeUnicodeString(&UnicodeString); } - return TRUE; + return TRUE; } @@ -1001,41 +1006,43 @@ ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid) * @implemented */ BOOL STDCALL -ConvertSidToStringSidA(PSID Sid, LPSTR *StringSid) +ConvertSidToStringSidA(PSID Sid, + LPSTR *StringSid) { - LPWSTR StringSidW; - int Len; + LPWSTR StringSidW; + int Len; - if (! ConvertSidToStringSidW(Sid, &StringSidW)) + if (!ConvertSidToStringSidW(Sid, &StringSidW)) { - return FALSE; + return FALSE; } - Len = WideCharToMultiByte(CP_ACP, 0, StringSidW, -1, NULL, 0, NULL, NULL); - if (Len <= 0) + Len = WideCharToMultiByte(CP_ACP, 0, StringSidW, -1, NULL, 0, NULL, NULL); + if (Len <= 0) { - LocalFree(StringSidW); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - *StringSid = LocalAlloc(LMEM_FIXED, Len); - if (NULL == *StringSid) - { - LocalFree(StringSidW); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; + LocalFree(StringSidW); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; } - if (! WideCharToMultiByte(CP_ACP, 0, StringSidW, -1, *StringSid, Len, NULL, NULL)) + *StringSid = LocalAlloc(LMEM_FIXED, Len); + if (NULL == *StringSid) { - LocalFree(StringSid); - LocalFree(StringSidW); - return FALSE; + LocalFree(StringSidW); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; } - LocalFree(StringSidW); + if (!WideCharToMultiByte(CP_ACP, 0, StringSidW, -1, *StringSid, Len, NULL, NULL)) + { + LocalFree(StringSid); + LocalFree(StringSidW); + return FALSE; + } - return TRUE; + LocalFree(StringSidW); + + return TRUE; } @@ -1077,22 +1084,27 @@ CreateWellKnownSid(IN WELL_KNOWN_SID_TYPE WellKnownSidType, int i; TRACE("(%d, %s, %p, %p)\n", WellKnownSidType, debugstr_sid(DomainSid), pSid, cbSid); - if (DomainSid != NULL) { + if (DomainSid != NULL) + { FIXME("Only local computer supported!\n"); SetLastError(ERROR_INVALID_PARAMETER); /* FIXME */ return FALSE; } - if (cbSid == NULL || pSid == NULL) { + if (cbSid == NULL || pSid == NULL) + { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++) { - if (WellKnownSids[i].Type == WellKnownSidType) { + for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++) + { + if (WellKnownSids[i].Type == WellKnownSidType) + { DWORD length = GetSidLengthRequired(WellKnownSids[i].Sid.SubAuthorityCount); - if (*cbSid < length) { + if (*cbSid < length) + { SetLastError(ERROR_INSUFFICIENT_BUFFER); return FALSE; } @@ -1118,10 +1130,14 @@ IsWellKnownSid(IN PSID pSid, int i; TRACE("(%s, %d)\n", debugstr_sid(pSid), WellKnownSidType); - for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++) + for (i = 0; i < sizeof(WellKnownSids) / sizeof(WellKnownSids[0]); i++) + { if (WellKnownSids[i].Type == WellKnownSidType) + { if (EqualSid(pSid, (PSID)((ULONG_PTR)&WellKnownSids[i].Sid.Revision))) return TRUE; + } + } return FALSE; } @@ -1131,9 +1147,8 @@ IsWellKnownSid(IN PSID pSid, * @implemented */ BOOL STDCALL -ConvertStringSidToSidA( - IN LPCSTR StringSid, - OUT PSID* sid) +ConvertStringSidToSidA(IN LPCSTR StringSid, + OUT PSID* sid) { BOOL bRetVal = FALSE; @@ -1150,10 +1165,12 @@ ConvertStringSidToSidA( return bRetVal; } + /****************************************************************************** * ComputeStringSidSize */ -static DWORD ComputeStringSidSize(LPCWSTR StringSid) +static DWORD +ComputeStringSidSize(LPCWSTR StringSid) { DWORD size = sizeof(SID); @@ -1229,16 +1246,15 @@ static const RECORD SidTable[] = * @implemented */ BOOL WINAPI -ConvertStringSidToSidW( - IN LPCWSTR StringSid, - OUT PSID* sid) +ConvertStringSidToSidW(IN LPCWSTR StringSid, + OUT PSID* sid) { - DWORD size; - DWORD i, cBytes, identAuth, csubauth; - BOOL ret; - SID* pisid; + DWORD size; + DWORD i, cBytes, identAuth, csubauth; + BOOL ret; + SID* pisid; - TRACE("%s %p\n", debugstr_w(StringSid), sid); + TRACE("%s %p\n", debugstr_w(StringSid), sid); if (!StringSid) { diff --git a/reactos/dll/win32/advapi32/sec/trustee.c b/reactos/dll/win32/advapi32/sec/trustee.c index 14c815958e5..c8dad098768 100644 --- a/reactos/dll/win32/advapi32/sec/trustee.c +++ b/reactos/dll/win32/advapi32/sec/trustee.c @@ -20,8 +20,8 @@ VOID WINAPI BuildImpersonateTrusteeA(PTRUSTEE_A pTrustee, PTRUSTEE_A pImpersonateTrustee) { - pTrustee->pMultipleTrustee = pImpersonateTrustee; - pTrustee->MultipleTrusteeOperation = TRUSTEE_IS_IMPERSONATE; + pTrustee->pMultipleTrustee = pImpersonateTrustee; + pTrustee->MultipleTrusteeOperation = TRUSTEE_IS_IMPERSONATE; } @@ -32,8 +32,8 @@ VOID WINAPI BuildImpersonateTrusteeW(PTRUSTEE_W pTrustee, PTRUSTEE_W pImpersonateTrustee) { - pTrustee->pMultipleTrustee = pImpersonateTrustee; - pTrustee->MultipleTrusteeOperation = TRUSTEE_IS_IMPERSONATE; + pTrustee->pMultipleTrustee = pImpersonateTrustee; + pTrustee->MultipleTrusteeOperation = TRUSTEE_IS_IMPERSONATE; } @@ -131,7 +131,8 @@ BuildImpersonateExplicitAccessWithNameW(PEXPLICIT_ACCESS_W pExplicitAccess, * BuildTrusteeWithSidA [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithSidA(PTRUSTEE_A pTrustee, PSID pSid) +BuildTrusteeWithSidA(PTRUSTEE_A pTrustee, + PSID pSid) { TRACE("%p %p\n", pTrustee, pSid); @@ -147,7 +148,8 @@ BuildTrusteeWithSidA(PTRUSTEE_A pTrustee, PSID pSid) * BuildTrusteeWithSidW [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithSidW(PTRUSTEE_W pTrustee, PSID pSid) +BuildTrusteeWithSidW(PTRUSTEE_W pTrustee, + PSID pSid) { TRACE("%p %p\n", pTrustee, pSid); @@ -163,7 +165,8 @@ BuildTrusteeWithSidW(PTRUSTEE_W pTrustee, PSID pSid) * BuildTrusteeWithNameA [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithNameA(PTRUSTEE_A pTrustee, LPSTR name) +BuildTrusteeWithNameA(PTRUSTEE_A pTrustee, + LPSTR name) { TRACE("%p %s\n", pTrustee, name); @@ -179,7 +182,8 @@ BuildTrusteeWithNameA(PTRUSTEE_A pTrustee, LPSTR name) * BuildTrusteeWithNameW [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithNameW(PTRUSTEE_W pTrustee, LPWSTR name) +BuildTrusteeWithNameW(PTRUSTEE_W pTrustee, + LPWSTR name) { TRACE("%p %s\n", pTrustee, name); @@ -195,9 +199,12 @@ BuildTrusteeWithNameW(PTRUSTEE_W pTrustee, LPWSTR name) * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithObjectsAndNameA(PTRUSTEEA pTrustee, POBJECTS_AND_NAME_A pObjName, - SE_OBJECT_TYPE ObjectType, LPSTR ObjectTypeName, - LPSTR InheritedObjectTypeName, LPSTR Name) +BuildTrusteeWithObjectsAndNameA(PTRUSTEEA pTrustee, + POBJECTS_AND_NAME_A pObjName, + SE_OBJECT_TYPE ObjectType, + LPSTR ObjectTypeName, + LPSTR InheritedObjectTypeName, + LPSTR Name) { DWORD ObjectsPresent = 0; @@ -233,9 +240,12 @@ BuildTrusteeWithObjectsAndNameA(PTRUSTEEA pTrustee, POBJECTS_AND_NAME_A pObjName * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithObjectsAndNameW(PTRUSTEEW pTrustee, POBJECTS_AND_NAME_W pObjName, - SE_OBJECT_TYPE ObjectType, LPWSTR ObjectTypeName, - LPWSTR InheritedObjectTypeName, LPWSTR Name) +BuildTrusteeWithObjectsAndNameW(PTRUSTEEW pTrustee, + POBJECTS_AND_NAME_W pObjName, + SE_OBJECT_TYPE ObjectType, + LPWSTR ObjectTypeName, + LPWSTR InheritedObjectTypeName, + LPWSTR Name) { DWORD ObjectsPresent = 0; @@ -271,8 +281,11 @@ BuildTrusteeWithObjectsAndNameW(PTRUSTEEW pTrustee, POBJECTS_AND_NAME_W pObjName * BuildTrusteeWithObjectsAndSidA [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithObjectsAndSidA(PTRUSTEEA pTrustee, POBJECTS_AND_SID pObjSid, - GUID* pObjectGuid, GUID* pInheritedObjectGuid, PSID pSid) +BuildTrusteeWithObjectsAndSidA(PTRUSTEEA pTrustee, + POBJECTS_AND_SID pObjSid, + GUID *pObjectGuid, + GUID *pInheritedObjectGuid, + PSID pSid) { DWORD ObjectsPresent = 0; @@ -317,8 +330,11 @@ BuildTrusteeWithObjectsAndSidA(PTRUSTEEA pTrustee, POBJECTS_AND_SID pObjSid, * BuildTrusteeWithObjectsAndSidW [ADVAPI32.@] */ VOID WINAPI -BuildTrusteeWithObjectsAndSidW(PTRUSTEEW pTrustee, POBJECTS_AND_SID pObjSid, - GUID* pObjectGuid, GUID* pInheritedObjectGuid, PSID pSid) +BuildTrusteeWithObjectsAndSidW(PTRUSTEEW pTrustee, + POBJECTS_AND_SID pObjSid, + GUID *pObjectGuid, + GUID *pInheritedObjectGuid, + PSID pSid) { DWORD ObjectsPresent = 0; @@ -365,7 +381,7 @@ BuildTrusteeWithObjectsAndSidW(PTRUSTEEW pTrustee, POBJECTS_AND_SID pObjSid, PTRUSTEEA WINAPI GetMultipleTrusteeA(PTRUSTEE_A pTrustee) { - return pTrustee->pMultipleTrustee; + return pTrustee->pMultipleTrustee; } @@ -375,7 +391,7 @@ GetMultipleTrusteeA(PTRUSTEE_A pTrustee) PTRUSTEEW WINAPI GetMultipleTrusteeW(PTRUSTEE_W pTrustee) { - return pTrustee->pMultipleTrustee; + return pTrustee->pMultipleTrustee; } @@ -385,7 +401,7 @@ GetMultipleTrusteeW(PTRUSTEE_W pTrustee) MULTIPLE_TRUSTEE_OPERATION WINAPI GetMultipleTrusteeOperationA(PTRUSTEE_A pTrustee) { - return pTrustee->MultipleTrusteeOperation; + return pTrustee->MultipleTrusteeOperation; } @@ -395,7 +411,7 @@ GetMultipleTrusteeOperationA(PTRUSTEE_A pTrustee) MULTIPLE_TRUSTEE_OPERATION WINAPI GetMultipleTrusteeOperationW(PTRUSTEE_W pTrustee) { - return pTrustee->MultipleTrusteeOperation; + return pTrustee->MultipleTrusteeOperation; } @@ -405,7 +421,7 @@ GetMultipleTrusteeOperationW(PTRUSTEE_W pTrustee) TRUSTEE_FORM WINAPI GetTrusteeFormA(PTRUSTEE_A pTrustee) { - return pTrustee->TrusteeForm; + return pTrustee->TrusteeForm; } @@ -415,7 +431,7 @@ GetTrusteeFormA(PTRUSTEE_A pTrustee) TRUSTEE_FORM WINAPI GetTrusteeFormW(PTRUSTEE_W pTrustee) { - return pTrustee->TrusteeForm; + return pTrustee->TrusteeForm; } @@ -445,7 +461,7 @@ GetTrusteeNameW(PTRUSTEE_W pTrustee) TRUSTEE_TYPE WINAPI GetTrusteeTypeA(PTRUSTEE_A pTrustee) { - return pTrustee->TrusteeType; + return pTrustee->TrusteeType; } @@ -455,7 +471,7 @@ GetTrusteeTypeA(PTRUSTEE_A pTrustee) TRUSTEE_TYPE WINAPI GetTrusteeTypeW(PTRUSTEE_W pTrustee) { - return pTrustee->TrusteeType; + return pTrustee->TrusteeType; } /* EOF */ diff --git a/reactos/dll/win32/advapi32/service/eventlog.c b/reactos/dll/win32/advapi32/service/eventlog.c index c0f28f8174e..a842c421ab4 100644 --- a/reactos/dll/win32/advapi32/service/eventlog.c +++ b/reactos/dll/win32/advapi32/service/eventlog.c @@ -40,9 +40,8 @@ static RPC_UNICODE_STRING EmptyString = { 0, 0, L"" }; * BackupEventLogA [ADVAPI32.@] */ BOOL WINAPI -BackupEventLogA( - IN HANDLE hEventLog, - IN LPCSTR lpBackupFileName) +BackupEventLogA(IN HANDLE hEventLog, + IN LPCSTR lpBackupFileName) { PLOG_INFO pLog; NTSTATUS Status; @@ -60,16 +59,16 @@ BackupEventLogA( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrBackupELFA( - pLog->BindingHandle, - pLog->LogHandle, - &BackupFileName); + Status = ElfrBackupELFA(pLog->BindingHandle, + pLog->LogHandle, + &BackupFileName); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } + return TRUE; } @@ -81,9 +80,8 @@ BackupEventLogA( * lpBackupFileName [] */ BOOL WINAPI -BackupEventLogW( - IN HANDLE hEventLog, - IN LPCWSTR lpBackupFileName) +BackupEventLogW(IN HANDLE hEventLog, + IN LPCWSTR lpBackupFileName) { PLOG_INFO pLog; NTSTATUS Status; @@ -101,16 +99,16 @@ BackupEventLogW( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrBackupELFW( - pLog->BindingHandle, - pLog->LogHandle, - &BackupFileName); + Status = ElfrBackupELFW(pLog->BindingHandle, + pLog->LogHandle, + &BackupFileName); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } + return TRUE; } @@ -119,9 +117,8 @@ BackupEventLogW( * ClearEventLogA [ADVAPI32.@] */ BOOL WINAPI -ClearEventLogA( - IN HANDLE hEventLog, - IN LPCSTR lpBackupFileName) +ClearEventLogA(IN HANDLE hEventLog, + IN LPCSTR lpBackupFileName) { PLOG_INFO pLog; NTSTATUS Status; @@ -139,16 +136,16 @@ ClearEventLogA( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrClearELFA( - pLog->BindingHandle, - pLog->LogHandle, - &BackupFileName); + Status = ElfrClearELFA(pLog->BindingHandle, + pLog->LogHandle, + &BackupFileName); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } + return TRUE; } @@ -157,9 +154,8 @@ ClearEventLogA( * ClearEventLogW [ADVAPI32.@] */ BOOL WINAPI -ClearEventLogW( - IN HANDLE hEventLog, - IN LPCWSTR lpBackupFileName) +ClearEventLogW(IN HANDLE hEventLog, + IN LPCWSTR lpBackupFileName) { PLOG_INFO pLog; NTSTATUS Status; @@ -177,16 +173,16 @@ ClearEventLogW( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrClearELFW( - pLog->BindingHandle, - pLog->LogHandle, - &BackupFileName); + Status = ElfrClearELFW(pLog->BindingHandle, + pLog->LogHandle, + &BackupFileName); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } + return TRUE; } @@ -195,8 +191,7 @@ ClearEventLogW( * CloseEventLog [ADVAPI32.@] */ BOOL WINAPI -CloseEventLog( - IN HANDLE hEventLog) +CloseEventLog(IN HANDLE hEventLog) { PLOG_INFO pLog; NTSTATUS Status; @@ -217,9 +212,8 @@ CloseEventLog( } else { - Status = ElfrCloseEL( - pLog->BindingHandle, - &pLog->LogHandle); + Status = ElfrCloseEL(pLog->BindingHandle, + &pLog->LogHandle); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -243,8 +237,7 @@ CloseEventLog( * RETURNS STD */ BOOL WINAPI -DeregisterEventSource( - IN HANDLE hEventLog) +DeregisterEventSource(IN HANDLE hEventLog) { PLOG_INFO pLog; NTSTATUS Status; @@ -255,14 +248,14 @@ DeregisterEventSource( if (!pLog) return TRUE; - Status = ElfrDeregisterEventSource( - pLog->BindingHandle, - &pLog->LogHandle); + Status = ElfrDeregisterEventSource(pLog->BindingHandle, + &pLog->LogHandle); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } + return TRUE; } @@ -275,9 +268,8 @@ DeregisterEventSource( * NumberOfRecords [] */ BOOL WINAPI -GetNumberOfEventLogRecords( - IN HANDLE hEventLog, - OUT PDWORD NumberOfRecords) +GetNumberOfEventLogRecords(IN HANDLE hEventLog, + OUT PDWORD NumberOfRecords) { PLOG_INFO pLog; NTSTATUS Status; @@ -291,10 +283,10 @@ GetNumberOfEventLogRecords( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrNumberOfRecords( - pLog->BindingHandle, - pLog->LogHandle, - &Records); + + Status = ElfrNumberOfRecords(pLog->BindingHandle, + pLog->LogHandle, + &Records); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -302,6 +294,7 @@ GetNumberOfEventLogRecords( } *NumberOfRecords = Records; + return TRUE; } @@ -314,9 +307,8 @@ GetNumberOfEventLogRecords( * OldestRecord [] */ BOOL WINAPI -GetOldestEventLogRecord( - IN HANDLE hEventLog, - OUT PDWORD OldestRecord) +GetOldestEventLogRecord(IN HANDLE hEventLog, + OUT PDWORD OldestRecord) { PLOG_INFO pLog; NTSTATUS Status; @@ -330,10 +322,10 @@ GetOldestEventLogRecord( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrOldestRecord( - pLog->BindingHandle, - pLog->LogHandle, - &Oldest); + + Status = ElfrOldestRecord(pLog->BindingHandle, + pLog->LogHandle, + &Oldest); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -341,6 +333,7 @@ GetOldestEventLogRecord( } *OldestRecord = Oldest; + return TRUE; } @@ -353,9 +346,8 @@ GetOldestEventLogRecord( * hEvent [] */ BOOL WINAPI -NotifyChangeEventLog( - IN HANDLE hEventLog, - IN HANDLE hEvent) +NotifyChangeEventLog(IN HANDLE hEventLog, + IN HANDLE hEvent) { /* Use ElfrChangeNotify */ UNIMPLEMENTED; @@ -368,9 +360,8 @@ NotifyChangeEventLog( * OpenBackupEventLogA [ADVAPI32.@] */ HANDLE WINAPI -OpenBackupEventLogA( - IN LPCSTR lpUNCServerName, - IN LPCSTR lpFileName) +OpenBackupEventLogA(IN LPCSTR lpUNCServerName, + IN LPCSTR lpFileName) { UNICODE_STRING UNCServerName; UNICODE_STRING FileName; @@ -383,6 +374,7 @@ OpenBackupEventLogA( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } + if (!RtlCreateUnicodeStringFromAsciiz(&FileName, lpFileName)) { RtlFreeUnicodeString(&UNCServerName); @@ -390,9 +382,8 @@ OpenBackupEventLogA( return NULL; } - Handle = OpenBackupEventLogW( - UNCServerName.Buffer, - FileName.Buffer); + Handle = OpenBackupEventLogW(UNCServerName.Buffer, + FileName.Buffer); RtlFreeUnicodeString(&UNCServerName); RtlFreeUnicodeString(&FileName); @@ -409,9 +400,8 @@ OpenBackupEventLogA( * lpFileName [] */ HANDLE WINAPI -OpenBackupEventLogW( - IN LPCWSTR lpUNCServerName, - IN LPCWSTR lpFileName) +OpenBackupEventLogW(IN LPCWSTR lpUNCServerName, + IN LPCWSTR lpFileName) { PLOG_INFO pLog; NTSTATUS Status; @@ -429,6 +419,7 @@ OpenBackupEventLogW( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } + ZeroMemory(pLog, sizeof(LOG_INFO)); if (lpUNCServerName == NULL || *lpUNCServerName == 0) @@ -454,20 +445,19 @@ OpenBackupEventLogW( } } - Status = ElfrOpenBELW( - pLog->BindingHandle, - (LPWSTR)lpUNCServerName, - &FileName, - 0, - 0, - &pLog->LogHandle); - + Status = ElfrOpenBELW(pLog->BindingHandle, + (LPWSTR)lpUNCServerName, + &FileName, + 0, + 0, + &pLog->LogHandle); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); HeapFree(GetProcessHeap(), 0, pLog); return NULL; } + return pLog; } @@ -476,9 +466,8 @@ OpenBackupEventLogW( * OpenEventLogA [ADVAPI32.@] */ HANDLE WINAPI -OpenEventLogA( - IN LPCSTR lpUNCServerName, - IN LPCSTR lpSourceName) +OpenEventLogA(IN LPCSTR lpUNCServerName, + IN LPCSTR lpSourceName) { UNICODE_STRING UNCServerName; UNICODE_STRING SourceName; @@ -489,6 +478,7 @@ OpenEventLogA( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } + if (!RtlCreateUnicodeStringFromAsciiz(&SourceName, lpSourceName)) { RtlFreeUnicodeString(&UNCServerName); @@ -496,7 +486,8 @@ OpenEventLogA( return NULL; } - Handle = OpenEventLogW(UNCServerName.Buffer, SourceName.Buffer); + Handle = OpenEventLogW(UNCServerName.Buffer, + SourceName.Buffer); RtlFreeUnicodeString(&UNCServerName); RtlFreeUnicodeString(&SourceName); @@ -513,9 +504,8 @@ OpenEventLogA( * lpSourceName [] */ HANDLE WINAPI -OpenEventLogW( - IN LPCWSTR lpUNCServerName, - IN LPCWSTR lpSourceName) +OpenEventLogW(IN LPCWSTR lpUNCServerName, + IN LPCWSTR lpSourceName) { PLOG_INFO pLog; NTSTATUS Status; @@ -533,6 +523,7 @@ OpenEventLogW( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } + ZeroMemory(pLog, sizeof(LOG_INFO)); if (lpUNCServerName == NULL || *lpUNCServerName == 0) @@ -558,21 +549,20 @@ OpenEventLogW( } } - Status = ElfrOpenELW( - pLog->BindingHandle, - (LPWSTR)lpUNCServerName, - &SourceName, - &EmptyString, - 0, - 0, - &pLog->LogHandle); - + Status = ElfrOpenELW(pLog->BindingHandle, + (LPWSTR)lpUNCServerName, + &SourceName, + &EmptyString, + 0, + 0, + &pLog->LogHandle); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); HeapFree(GetProcessHeap(), 0, pLog); return NULL; } + return pLog; } @@ -581,14 +571,13 @@ OpenEventLogW( * ReadEventLogA [ADVAPI32.@] */ BOOL WINAPI -ReadEventLogA( - IN HANDLE hEventLog, - IN DWORD dwReadFlags, - IN DWORD dwRecordOffset, - OUT LPVOID lpBuffer, - IN DWORD nNumberOfBytesToRead, - OUT DWORD *pnBytesRead, - OUT DWORD *pnMinNumberOfBytesNeeded) +ReadEventLogA(IN HANDLE hEventLog, + IN DWORD dwReadFlags, + IN DWORD dwRecordOffset, + OUT LPVOID lpBuffer, + IN DWORD nNumberOfBytesToRead, + OUT DWORD *pnBytesRead, + OUT DWORD *pnMinNumberOfBytesNeeded) { PLOG_INFO pLog; NTSTATUS Status; @@ -604,15 +593,15 @@ ReadEventLogA( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrReadELA( - pLog->BindingHandle, - pLog->LogHandle, - dwReadFlags, - dwRecordOffset, - nNumberOfBytesToRead, - lpBuffer, - &bytesRead, - &minNumberOfBytesNeeded); + + Status = ElfrReadELA(pLog->BindingHandle, + pLog->LogHandle, + dwReadFlags, + dwRecordOffset, + nNumberOfBytesToRead, + lpBuffer, + &bytesRead, + &minNumberOfBytesNeeded); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -621,6 +610,7 @@ ReadEventLogA( *pnBytesRead = (DWORD)bytesRead; *pnMinNumberOfBytesNeeded = (DWORD)minNumberOfBytesNeeded; + return TRUE; } @@ -638,14 +628,13 @@ ReadEventLogA( * pnMinNumberOfBytesNeeded [] */ BOOL WINAPI -ReadEventLogW( - IN HANDLE hEventLog, - IN DWORD dwReadFlags, - IN DWORD dwRecordOffset, - OUT LPVOID lpBuffer, - IN DWORD nNumberOfBytesToRead, - OUT DWORD *pnBytesRead, - OUT DWORD *pnMinNumberOfBytesNeeded) +ReadEventLogW(IN HANDLE hEventLog, + IN DWORD dwReadFlags, + IN DWORD dwRecordOffset, + OUT LPVOID lpBuffer, + IN DWORD nNumberOfBytesToRead, + OUT DWORD *pnBytesRead, + OUT DWORD *pnMinNumberOfBytesNeeded) { PLOG_INFO pLog; NTSTATUS Status; @@ -661,15 +650,15 @@ ReadEventLogW( SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - Status = ElfrReadELW( - pLog->BindingHandle, - pLog->LogHandle, - dwReadFlags, - dwRecordOffset, - nNumberOfBytesToRead, - lpBuffer, - &bytesRead, - &minNumberOfBytesNeeded); + + Status = ElfrReadELW(pLog->BindingHandle, + pLog->LogHandle, + dwReadFlags, + dwRecordOffset, + nNumberOfBytesToRead, + lpBuffer, + &bytesRead, + &minNumberOfBytesNeeded); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -678,6 +667,7 @@ ReadEventLogW( *pnBytesRead = (DWORD)bytesRead; *pnMinNumberOfBytesNeeded = (DWORD)minNumberOfBytesNeeded; + return TRUE; } @@ -686,9 +676,8 @@ ReadEventLogW( * RegisterEventSourceA [ADVAPI32.@] */ HANDLE WINAPI -RegisterEventSourceA( - IN LPCSTR lpUNCServerName, - IN LPCSTR lpSourceName) +RegisterEventSourceA(IN LPCSTR lpUNCServerName, + IN LPCSTR lpSourceName) { UNICODE_STRING UNCServerName; UNICODE_STRING SourceName; @@ -701,6 +690,7 @@ RegisterEventSourceA( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } + if (!RtlCreateUnicodeStringFromAsciiz(&SourceName, lpSourceName)) { RtlFreeUnicodeString(&UNCServerName); @@ -708,7 +698,8 @@ RegisterEventSourceA( return NULL; } - Handle = RegisterEventSourceW(UNCServerName.Buffer, SourceName.Buffer); + Handle = RegisterEventSourceW(UNCServerName.Buffer, + SourceName.Buffer); RtlFreeUnicodeString(&UNCServerName); RtlFreeUnicodeString(&SourceName); @@ -730,9 +721,8 @@ RegisterEventSourceA( * Failure: NULL */ HANDLE WINAPI -RegisterEventSourceW( - IN LPCWSTR lpUNCServerName, - IN LPCWSTR lpSourceName) +RegisterEventSourceW(IN LPCWSTR lpUNCServerName, + IN LPCWSTR lpSourceName) { PLOG_INFO pLog; NTSTATUS Status; @@ -750,6 +740,7 @@ RegisterEventSourceW( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } + ZeroMemory(pLog, sizeof(LOG_INFO)); if (lpUNCServerName == NULL || *lpUNCServerName == 0) @@ -775,21 +766,20 @@ RegisterEventSourceW( } } - Status = ElfrRegisterEventSourceW( - pLog->BindingHandle, - (LPWSTR)lpUNCServerName, - &SourceName, - &EmptyString, - 0, - 0, - &pLog->LogHandle); - + Status = ElfrRegisterEventSourceW(pLog->BindingHandle, + (LPWSTR)lpUNCServerName, + &SourceName, + &EmptyString, + 0, + 0, + &pLog->LogHandle); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); HeapFree(GetProcessHeap(), 0, pLog); return NULL; } + return pLog; } @@ -798,16 +788,15 @@ RegisterEventSourceW( * ReportEventA [ADVAPI32.@] */ BOOL WINAPI -ReportEventA( - IN HANDLE hEventLog, - IN WORD wType, - IN WORD wCategory, - IN DWORD dwEventID, - IN PSID lpUserSid, - IN WORD wNumStrings, - IN DWORD dwDataSize, - IN LPCSTR *lpStrings, - IN LPVOID lpRawData) +ReportEventA(IN HANDLE hEventLog, + IN WORD wType, + IN WORD wCategory, + IN DWORD dwEventID, + IN PSID lpUserSid, + IN WORD wNumStrings, + IN DWORD dwDataSize, + IN LPCSTR *lpStrings, + IN LPVOID lpRawData) { LPCWSTR *wideStrArray; UNICODE_STRING str; @@ -820,10 +809,9 @@ ReportEventA( if (lpStrings == NULL) return TRUE; - wideStrArray = HeapAlloc( - GetProcessHeap(), - HEAP_ZERO_MEMORY, - sizeof(LPCWSTR) * wNumStrings); + wideStrArray = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(LPCWSTR) * wNumStrings); for (i = 0; i < wNumStrings; i++) { @@ -834,16 +822,15 @@ ReportEventA( if (i == wNumStrings) { - ret = ReportEventW( - hEventLog, - wType, - wCategory, - dwEventID, - lpUserSid, - wNumStrings, - dwDataSize, - wideStrArray, - lpRawData); + ret = ReportEventW(hEventLog, + wType, + wCategory, + dwEventID, + lpUserSid, + wNumStrings, + dwDataSize, + wideStrArray, + lpRawData); } else { @@ -855,17 +842,15 @@ ReportEventA( { if (wideStrArray[i]) { - HeapFree( - GetProcessHeap(), - 0, - (PVOID)wideStrArray[i]); + HeapFree(GetProcessHeap(), + 0, + (PVOID)wideStrArray[i]); } } - HeapFree( - GetProcessHeap(), - 0, - wideStrArray); + HeapFree(GetProcessHeap(), + 0, + wideStrArray); return ret; } @@ -886,16 +871,15 @@ ReportEventA( * lpRawData [] */ BOOL WINAPI -ReportEventW( - IN HANDLE hEventLog, - IN WORD wType, - IN WORD wCategory, - IN DWORD dwEventID, - IN PSID lpUserSid, - IN WORD wNumStrings, - IN DWORD dwDataSize, - IN LPCWSTR *lpStrings, - IN LPVOID lpRawData) +ReportEventW(IN HANDLE hEventLog, + IN WORD wType, + IN WORD wCategory, + IN DWORD dwEventID, + IN PSID lpUserSid, + IN WORD wNumStrings, + IN DWORD dwDataSize, + IN LPCWSTR *lpStrings, + IN LPVOID lpRawData) { #if 0 PLOG_INFO pLog; @@ -914,34 +898,33 @@ ReportEventW( return FALSE; } - Strings = HeapAlloc( - GetProcessHeap(), - 0, - wNumStrings * sizeof(UNICODE_STRING)); + Strings = HeapAlloc(GetProcessHeap(), + 0, + wNumStrings * sizeof(UNICODE_STRING)); if (!Strings) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } + for (i = 0; i < wNumStrings; i++) RtlInitUnicodeString(&Strings[i], lpStrings[i]); - Status = ElfrReportEventW( - pLog->BindingHandle, - pLog->LogHandle, - 0, /* FIXME: Time */ - wType, - wCategory, - dwEventID, - wNumStrings, - dwDataSize, - L"", /* FIXME: ComputerName */ - lpUserSid, - (LPWSTR *)lpStrings, /* FIXME: should be Strings */ - lpRawData, - 0, - NULL, - NULL); + Status = ElfrReportEventW(pLog->BindingHandle, + pLog->LogHandle, + 0, /* FIXME: Time */ + wType, + wCategory, + dwEventID, + wNumStrings, + dwDataSize, + L"", /* FIXME: ComputerName */ + lpUserSid, + (LPWSTR *)lpStrings, /* FIXME: should be Strings */ + lpRawData, + 0, + NULL, + NULL); HeapFree(GetProcessHeap(), 0, Strings); if (!NT_SUCCESS(Status)) @@ -949,6 +932,7 @@ ReportEventW( SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } + return TRUE; #else int i; diff --git a/reactos/dll/win32/advapi32/token/privilege.c b/reactos/dll/win32/advapi32/token/privilege.c index 7d460256e0b..f89d55c8977 100644 --- a/reactos/dll/win32/advapi32/token/privilege.c +++ b/reactos/dll/win32/advapi32/token/privilege.c @@ -18,25 +18,25 @@ * @implemented */ BOOL STDCALL -PrivilegeCheck (HANDLE ClientToken, - PPRIVILEGE_SET RequiredPrivileges, - LPBOOL pfResult) +PrivilegeCheck(HANDLE ClientToken, + PPRIVILEGE_SET RequiredPrivileges, + LPBOOL pfResult) { - BOOLEAN Result; - NTSTATUS Status; + BOOLEAN Result; + NTSTATUS Status; - Status = NtPrivilegeCheck (ClientToken, - RequiredPrivileges, - &Result); - if (!NT_SUCCESS (Status)) + Status = NtPrivilegeCheck(ClientToken, + RequiredPrivileges, + &Result); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - *pfResult = (BOOL) Result; + *pfResult = (BOOL)Result; - return TRUE; + return TRUE; } /* EOF */ diff --git a/reactos/dll/win32/advapi32/token/token.c b/reactos/dll/win32/advapi32/token/token.c index c7115b08398..ca4d3fa10be 100644 --- a/reactos/dll/win32/advapi32/token/token.c +++ b/reactos/dll/win32/advapi32/token/token.c @@ -17,25 +17,90 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); * @implemented */ BOOL STDCALL -AdjustTokenGroups (HANDLE TokenHandle, - BOOL ResetToDefault, - PTOKEN_GROUPS NewState, - DWORD BufferLength, - PTOKEN_GROUPS PreviousState, - PDWORD ReturnLength) +AdjustTokenGroups(HANDLE TokenHandle, + BOOL ResetToDefault, + PTOKEN_GROUPS NewState, + DWORD BufferLength, + PTOKEN_GROUPS PreviousState, + PDWORD ReturnLength) { - NTSTATUS Status; + NTSTATUS Status; - Status = NtAdjustGroupsToken (TokenHandle, - ResetToDefault, - NewState, - BufferLength, - PreviousState, - (PULONG)ReturnLength); - if (!NT_SUCCESS (Status)) + Status = NtAdjustGroupsToken(TokenHandle, + ResetToDefault, + NewState, + BufferLength, + PreviousState, + (PULONG)ReturnLength); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; +} + + +/* + * @implemented + */ +BOOL STDCALL +AdjustTokenPrivileges(HANDLE TokenHandle, + BOOL DisableAllPrivileges, + PTOKEN_PRIVILEGES NewState, + DWORD BufferLength, + PTOKEN_PRIVILEGES PreviousState, + PDWORD ReturnLength) +{ + NTSTATUS Status; + + Status = NtAdjustPrivilegesToken(TokenHandle, + DisableAllPrivileges, + NewState, + BufferLength, + PreviousState, + (PULONG)ReturnLength); + if (STATUS_NOT_ALL_ASSIGNED == Status) + { + SetLastError(ERROR_NOT_ALL_ASSIGNED); + return TRUE; + } + + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + /* AdjustTokenPrivileges is documented to do this */ + SetLastError(ERROR_SUCCESS); + + return TRUE; +} + + +/* + * @implemented + */ +BOOL STDCALL +GetTokenInformation(HANDLE TokenHandle, + TOKEN_INFORMATION_CLASS TokenInformationClass, + LPVOID TokenInformation, + DWORD TokenInformationLength, + PDWORD ReturnLength) +{ + NTSTATUS Status; + + Status = NtQueryInformationToken(TokenHandle, + TokenInformationClass, + TokenInformation, + TokenInformationLength, + (PULONG)ReturnLength); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } return TRUE; @@ -46,34 +111,24 @@ AdjustTokenGroups (HANDLE TokenHandle, * @implemented */ BOOL STDCALL -AdjustTokenPrivileges (HANDLE TokenHandle, - BOOL DisableAllPrivileges, - PTOKEN_PRIVILEGES NewState, - DWORD BufferLength, - PTOKEN_PRIVILEGES PreviousState, - PDWORD ReturnLength) +SetTokenInformation(HANDLE TokenHandle, + TOKEN_INFORMATION_CLASS TokenInformationClass, + LPVOID TokenInformation, + DWORD TokenInformationLength) { - NTSTATUS Status; + NTSTATUS Status; - Status = NtAdjustPrivilegesToken (TokenHandle, - DisableAllPrivileges, - NewState, - BufferLength, - PreviousState, - (PULONG)ReturnLength); - if (STATUS_NOT_ALL_ASSIGNED == Status) + Status = NtSetInformationToken(TokenHandle, + TokenInformationClass, + TokenInformation, + TokenInformationLength); + if (!NT_SUCCESS(Status)) { - SetLastError(ERROR_NOT_ALL_ASSIGNED); - return TRUE; - } - if (! NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - SetLastError(ERROR_SUCCESS); /* AdjustTokenPrivileges is documented to do this */ - return TRUE; + return TRUE; } @@ -81,26 +136,42 @@ AdjustTokenPrivileges (HANDLE TokenHandle, * @implemented */ BOOL STDCALL -GetTokenInformation (HANDLE TokenHandle, - TOKEN_INFORMATION_CLASS TokenInformationClass, - LPVOID TokenInformation, - DWORD TokenInformationLength, - PDWORD ReturnLength) +AccessCheck(PSECURITY_DESCRIPTOR pSecurityDescriptor, + HANDLE ClientToken, + DWORD DesiredAccess, + PGENERIC_MAPPING GenericMapping, + PPRIVILEGE_SET PrivilegeSet, + LPDWORD PrivilegeSetLength, + LPDWORD GrantedAccess, + LPBOOL AccessStatus) { - NTSTATUS Status; + NTSTATUS Status; + NTSTATUS AccessStat; - Status = NtQueryInformationToken (TokenHandle, - TokenInformationClass, - TokenInformation, - TokenInformationLength, - (PULONG)ReturnLength); - if (!NT_SUCCESS (Status)) + Status = NtAccessCheck(pSecurityDescriptor, + ClientToken, + DesiredAccess, + GenericMapping, + PrivilegeSet, + (PULONG)PrivilegeSetLength, + (PACCESS_MASK)GrantedAccess, + &AccessStat); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + if (!NT_SUCCESS(AccessStat)) + { + SetLastError(RtlNtStatusToDosError(Status)); + *AccessStatus = FALSE; + return TRUE; + } + + *AccessStatus = TRUE; + + return TRUE; } @@ -108,115 +179,22 @@ GetTokenInformation (HANDLE TokenHandle, * @implemented */ BOOL STDCALL -SetTokenInformation (HANDLE TokenHandle, - TOKEN_INFORMATION_CLASS TokenInformationClass, - LPVOID TokenInformation, - DWORD TokenInformationLength) -{ - NTSTATUS Status; - - Status = NtSetInformationToken (TokenHandle, - TokenInformationClass, - TokenInformation, - TokenInformationLength); - if (!NT_SUCCESS (Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -BOOL STDCALL -AccessCheck (PSECURITY_DESCRIPTOR pSecurityDescriptor, - HANDLE ClientToken, - DWORD DesiredAccess, - PGENERIC_MAPPING GenericMapping, - PPRIVILEGE_SET PrivilegeSet, - LPDWORD PrivilegeSetLength, - LPDWORD GrantedAccess, - LPBOOL AccessStatus) -{ - NTSTATUS Status; - NTSTATUS AccessStat; - - Status = NtAccessCheck (pSecurityDescriptor, - ClientToken, - DesiredAccess, - GenericMapping, - PrivilegeSet, - (PULONG)PrivilegeSetLength, - (PACCESS_MASK)GrantedAccess, - &AccessStat); - if (!NT_SUCCESS (Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - if (!NT_SUCCESS (AccessStat)) - { - SetLastError (RtlNtStatusToDosError (Status)); - *AccessStatus = FALSE; - return TRUE; - } - - *AccessStatus = TRUE; - - return TRUE; -} - - -/* - * @implemented - */ -BOOL STDCALL -OpenProcessToken (HANDLE ProcessHandle, - DWORD DesiredAccess, - PHANDLE TokenHandle) -{ - NTSTATUS Status; - - Status = NtOpenProcessToken (ProcessHandle, - DesiredAccess, - TokenHandle); - if (!NT_SUCCESS (Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -BOOL STDCALL -OpenThreadToken (HANDLE ThreadHandle, +OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, - BOOL OpenAsSelf, PHANDLE TokenHandle) { - NTSTATUS Status; + NTSTATUS Status; - Status = NtOpenThreadToken (ThreadHandle, - DesiredAccess, - OpenAsSelf, - TokenHandle); - if (!NT_SUCCESS(Status)) + Status = NtOpenProcessToken(ProcessHandle, + DesiredAccess, + TokenHandle); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -224,25 +202,24 @@ OpenThreadToken (HANDLE ThreadHandle, * @implemented */ BOOL STDCALL -SetThreadToken (IN PHANDLE ThreadHandle OPTIONAL, - IN HANDLE TokenHandle) +OpenThreadToken(HANDLE ThreadHandle, + DWORD DesiredAccess, + BOOL OpenAsSelf, + PHANDLE TokenHandle) { - NTSTATUS Status; - HANDLE hThread; + NTSTATUS Status; - hThread = ((ThreadHandle != NULL) ? *ThreadHandle : NtCurrentThread()); - - Status = NtSetInformationThread (hThread, - ThreadImpersonationToken, - &TokenHandle, - sizeof(HANDLE)); - if (!NT_SUCCESS(Status)) + Status = NtOpenThreadToken(ThreadHandle, + DesiredAccess, + OpenAsSelf, + TokenHandle); + if (!NT_SUCCESS(Status)) { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - return TRUE; + return TRUE; } @@ -250,54 +227,25 @@ SetThreadToken (IN PHANDLE ThreadHandle OPTIONAL, * @implemented */ BOOL STDCALL -DuplicateTokenEx (IN HANDLE ExistingTokenHandle, - IN DWORD dwDesiredAccess, - IN LPSECURITY_ATTRIBUTES lpTokenAttributes OPTIONAL, - IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, - IN TOKEN_TYPE TokenType, - OUT PHANDLE DuplicateTokenHandle) +SetThreadToken(IN PHANDLE ThreadHandle OPTIONAL, + IN HANDLE TokenHandle) { - OBJECT_ATTRIBUTES ObjectAttributes; - NTSTATUS Status; - SECURITY_QUALITY_OF_SERVICE Sqos; + NTSTATUS Status; + HANDLE hThread; - Sqos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE); - Sqos.ImpersonationLevel = ImpersonationLevel; - Sqos.ContextTrackingMode = 0; - Sqos.EffectiveOnly = FALSE; + hThread = (ThreadHandle != NULL) ? *ThreadHandle : NtCurrentThread(); - if (lpTokenAttributes != NULL) + Status = NtSetInformationThread(hThread, + ThreadImpersonationToken, + &TokenHandle, + sizeof(HANDLE)); + if (!NT_SUCCESS(Status)) { - InitializeObjectAttributes(&ObjectAttributes, - NULL, - lpTokenAttributes->bInheritHandle ? OBJ_INHERIT : 0, - NULL, - lpTokenAttributes->lpSecurityDescriptor); - } - else - { - InitializeObjectAttributes(&ObjectAttributes, - NULL, - 0, - NULL, - NULL); + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } - ObjectAttributes.SecurityQualityOfService = &Sqos; - - Status = NtDuplicateToken (ExistingTokenHandle, - dwDesiredAccess, - &ObjectAttributes, - FALSE, - TokenType, - DuplicateTokenHandle); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - - return TRUE; + return TRUE; } @@ -305,16 +253,71 @@ DuplicateTokenEx (IN HANDLE ExistingTokenHandle, * @implemented */ BOOL STDCALL -DuplicateToken (IN HANDLE ExistingTokenHandle, - IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, - OUT PHANDLE DuplicateTokenHandle) +DuplicateTokenEx(IN HANDLE ExistingTokenHandle, + IN DWORD dwDesiredAccess, + IN LPSECURITY_ATTRIBUTES lpTokenAttributes OPTIONAL, + IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, + IN TOKEN_TYPE TokenType, + OUT PHANDLE DuplicateTokenHandle) { - return DuplicateTokenEx (ExistingTokenHandle, - TOKEN_IMPERSONATE | TOKEN_QUERY, - NULL, - ImpersonationLevel, - TokenImpersonation, - DuplicateTokenHandle); + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + SECURITY_QUALITY_OF_SERVICE Sqos; + + Sqos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE); + Sqos.ImpersonationLevel = ImpersonationLevel; + Sqos.ContextTrackingMode = 0; + Sqos.EffectiveOnly = FALSE; + + if (lpTokenAttributes != NULL) + { + InitializeObjectAttributes(&ObjectAttributes, + NULL, + lpTokenAttributes->bInheritHandle ? OBJ_INHERIT : 0, + NULL, + lpTokenAttributes->lpSecurityDescriptor); + } + else + { + InitializeObjectAttributes(&ObjectAttributes, + NULL, + 0, + NULL, + NULL); + } + + ObjectAttributes.SecurityQualityOfService = &Sqos; + + Status = NtDuplicateToken(ExistingTokenHandle, + dwDesiredAccess, + &ObjectAttributes, + FALSE, + TokenType, + DuplicateTokenHandle); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; +} + + +/* + * @implemented + */ +BOOL STDCALL +DuplicateToken(IN HANDLE ExistingTokenHandle, + IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, + OUT PHANDLE DuplicateTokenHandle) +{ + return DuplicateTokenEx(ExistingTokenHandle, + TOKEN_IMPERSONATE | TOKEN_QUERY, + NULL, + ImpersonationLevel, + TokenImpersonation, + DuplicateTokenHandle); } @@ -476,7 +479,6 @@ CheckTokenMembership(IN HANDLE ExistingTokenHandle, &PrivBufferSize, &GrantedAccess, &AccessStatus); - if (NT_SUCCESS(Status) && NT_SUCCESS(AccessStatus) && (GrantedAccess == 0x1)) { *IsMember = TRUE; @@ -511,87 +513,83 @@ Cleanup: BOOL STDCALL IsTokenRestricted(HANDLE TokenHandle) { - ULONG RetLength; - PTOKEN_GROUPS lpGroups; - NTSTATUS Status; - BOOL Ret = FALSE; + ULONG RetLength; + PTOKEN_GROUPS lpGroups; + NTSTATUS Status; + BOOL Ret = FALSE; - /* determine the required buffer size and allocate enough memory to read the - list of restricted SIDs */ - - Status = NtQueryInformationToken(TokenHandle, - TokenRestrictedSids, - NULL, - 0, - &RetLength); - if (Status != STATUS_BUFFER_TOO_SMALL) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + /* determine the required buffer size and allocate enough memory to read the + list of restricted SIDs */ + Status = NtQueryInformationToken(TokenHandle, + TokenRestrictedSids, + NULL, + 0, + &RetLength); + if (Status != STATUS_BUFFER_TOO_SMALL) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } AllocAndReadRestrictedSids: - lpGroups = (PTOKEN_GROUPS)HeapAlloc(GetProcessHeap(), - 0, - RetLength); - if (lpGroups == NULL) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } + lpGroups = (PTOKEN_GROUPS)HeapAlloc(GetProcessHeap(), + 0, + RetLength); + if (lpGroups == NULL) + { + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } - /* actually read the list of the restricted SIDs */ + /* actually read the list of the restricted SIDs */ + Status = NtQueryInformationToken(TokenHandle, + TokenRestrictedSids, + lpGroups, + RetLength, + &RetLength); + if (NT_SUCCESS(Status)) + { + Ret = (lpGroups->GroupCount != 0); + } + else if (Status == STATUS_BUFFER_TOO_SMALL) + { + /* looks like the token was modified in the meanwhile, let's just try again */ + HeapFree(GetProcessHeap(), + 0, + lpGroups); - Status = NtQueryInformationToken(TokenHandle, - TokenRestrictedSids, - lpGroups, - RetLength, - &RetLength); - if (NT_SUCCESS(Status)) - { - Ret = (lpGroups->GroupCount != 0); - } - else if (Status == STATUS_BUFFER_TOO_SMALL) - { - /* looks like the token was modified in the meanwhile, let's just try again */ + goto AllocAndReadRestrictedSids; + } + else + { + SetLastError(RtlNtStatusToDosError(Status)); + } + /* free allocated memory */ HeapFree(GetProcessHeap(), 0, lpGroups); - goto AllocAndReadRestrictedSids; - } - else - { - SetLastError(RtlNtStatusToDosError(Status)); - } - - /* free allocated memory */ - - HeapFree(GetProcessHeap(), - 0, - lpGroups); - - return Ret; + return Ret; } + BOOL STDCALL -CreateRestrictedToken( - HANDLE TokenHandle, - DWORD Flags, - DWORD DisableSidCount, - PSID_AND_ATTRIBUTES pSidAndAttributes, - DWORD DeletePrivilegeCount, - PLUID_AND_ATTRIBUTES pLUIDAndAttributes, - DWORD RestrictedSidCount, - PSID_AND_ATTRIBUTES pSIDAndAttributes, - PHANDLE NewTokenHandle -) +CreateRestrictedToken(HANDLE TokenHandle, + DWORD Flags, + DWORD DisableSidCount, + PSID_AND_ATTRIBUTES pSidAndAttributes, + DWORD DeletePrivilegeCount, + PLUID_AND_ATTRIBUTES pLUIDAndAttributes, + DWORD RestrictedSidCount, + PSID_AND_ATTRIBUTES pSIDAndAttributes, + PHANDLE NewTokenHandle) { UNIMPLEMENTED; return FALSE; } + /* * @unimplemented */ @@ -670,6 +668,7 @@ GetSiteSidFromToken(IN HANDLE TokenHandle) return PSiteSid; } + BOOL WINAPI CreateProcessWithTokenW(IN HANDLE hToken,