Vitaliy Margolen : kernel32: Use NULL attributes if name and SA are not not specified.

Alexandre Julliard julliard at winehq.org
Wed Sep 17 07:15:04 CDT 2008


Module: wine
Branch: master
Commit: c51ca178929dd8f901cc2085d597f8ac71166f61
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c51ca178929dd8f901cc2085d597f8ac71166f61

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Sun Sep 14 11:02:25 2008 -0600

kernel32: Use NULL attributes if name and SA are not not specified.

---

 dlls/kernel32/virtual.c |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c
index 9c5080f..38a408a 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




More information about the wine-cvs mailing list