From c51ca178929dd8f901cc2085d597f8ac71166f61 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Sun, 14 Sep 2008 11:02:25 -0600 Subject: [PATCH] kernel32: Use NULL attributes if name and SA are not not specified. --- dlls/kernel32/virtual.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c index 9c5080ff861..38a408a14fe 100644 --- a/dlls/kernel32/virtual.c +++ b/dlls/kernel32/virtual.c @@ -338,26 +338,10 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa, static const int sec_flags = SEC_FILE | SEC_IMAGE | SEC_RESERVE | SEC_COMMIT | SEC_NOCACHE; HANDLE ret; - OBJECT_ATTRIBUTES attr; - UNICODE_STRING nameW; NTSTATUS status; DWORD access, sec_type; LARGE_INTEGER size; - attr.Length = sizeof(attr); - attr.RootDirectory = 0; - attr.ObjectName = NULL; - attr.Attributes = OBJ_OPENIF | ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); - attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; - attr.SecurityQualityOfService = NULL; - - if (name) - { - RtlInitUnicodeString( &nameW, name ); - attr.ObjectName = &nameW; - attr.RootDirectory = get_BaseNamedObjects_handle(); - } - sec_type = protect & sec_flags; protect &= ~sec_flags; if (!sec_type) sec_type = SEC_COMMIT; @@ -402,7 +386,27 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa, size.u.LowPart = size_low; size.u.HighPart = size_high; - status = NtCreateSection( &ret, access, &attr, &size, protect, sec_type, hFile ); + if (sa || name) + { + OBJECT_ATTRIBUTES attr; + UNICODE_STRING nameW; + + attr.Length = sizeof(attr); + attr.RootDirectory = 0; + attr.ObjectName = NULL; + attr.Attributes = OBJ_OPENIF | ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); + attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; + attr.SecurityQualityOfService = NULL; + if (name) + { + RtlInitUnicodeString( &nameW, name ); + attr.ObjectName = &nameW; + attr.RootDirectory = get_BaseNamedObjects_handle(); + } + status = NtCreateSection( &ret, access, &attr, &size, protect, sec_type, hFile ); + } + else status = NtCreateSection( &ret, access, NULL, &size, protect, sec_type, hFile ); + if (status == STATUS_OBJECT_NAME_EXISTS) SetLastError( ERROR_ALREADY_EXISTS ); else