From 0b0554b8ee72ab17fc1aab3ba2336342dfc2a8a4 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sun, 22 Jan 2006 03:07:21 +0000 Subject: [PATCH] implement the object type SE_KERNEL_OBJECT for GetSecurityInfo() svn path=/trunk/; revision=20967 --- reactos/lib/ntmarta/ntmarta.c | 77 ++++++++++++++++++++++++++++++++++- reactos/lib/ntmarta/ntmarta.h | 3 ++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/reactos/lib/ntmarta/ntmarta.c b/reactos/lib/ntmarta/ntmarta.c index 405398a8b98..bdb2f8dc8ab 100644 --- a/reactos/lib/ntmarta/ntmarta.c +++ b/reactos/lib/ntmarta/ntmarta.c @@ -48,8 +48,81 @@ AccRewriteGetHandleRights(HANDLE handle, PACL* ppSacl, PSECURITY_DESCRIPTOR* ppSecurityDescriptor) { - UNIMPLEMENTED; - return ERROR_CALL_NOT_IMPLEMENTED; + PSECURITY_DESCRIPTOR pSD = NULL; + ULONG RequiredSize, SDSize = 0; + NTSTATUS Status; + DWORD LastErr; + DWORD Ret = ERROR_SUCCESS; + + /* save the last error code */ + LastErr = GetLastError(); + +AllocBuffer: + /* allocate a buffer large enough to hold the + security descriptor we need to return */ + SDSize += 0x100; + if (pSD != NULL) + { + pSD = LocalAlloc(LMEM_FIXED, + (SIZE_T)SDSize); + } + else + { + pSD = LocalReAlloc((HLOCAL)pSD, + (SIZE_T)SDSize, + LMEM_MOVEABLE); + } + + if (pSD == NULL) + { + Ret = GetLastError(); + goto Cleanup; + } + + /* perform the actual query depending on the object type */ + switch (ObjectType) + { + case SE_KERNEL_OBJECT: + { + Status = NtQuerySecurityObject(handle, + SecurityInfo, + pSD, + SDSize, + &RequiredSize); + if (Status == STATUS_BUFFER_TOO_SMALL) + { + /* not enough memory, increase the size of + the buffer and try again */ + ASSERT(RequiredSize > SDSize); + SDSize = RequiredSize; + goto AllocBuffer; + } + Ret = RtlNtStatusToDosError(Status); + break; + } + + default: + { + UNIMPLEMENTED; + Ret = ERROR_CALL_NOT_IMPLEMENTED; + break; + } + } + +Cleanup: + if (Ret == ERROR_SUCCESS) + { + *ppSecurityDescriptor = pSD; + } + else if (pSD != NULL) + { + LocalFree((HLOCAL)pSD); + } + + /* restore the last error code */ + SetLastError(LastErr); + + return Ret; } diff --git a/reactos/lib/ntmarta/ntmarta.h b/reactos/lib/ntmarta/ntmarta.h index 46a0390c818..1a14f9ed559 100644 --- a/reactos/lib/ntmarta/ntmarta.h +++ b/reactos/lib/ntmarta/ntmarta.h @@ -1,4 +1,7 @@ +#define WIN32_NO_STATUS +#define NTOS_MODE_USER #include +#include #include #ifndef HAS_FN_PROGRESSW