Alexandre Julliard : ntdll: Avoid accessing builtin views outside of the critical section.

Alexandre Julliard julliard at winehq.org
Mon Sep 11 15:08:00 CDT 2017


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Sep 11 19:50:30 2017 +0200

ntdll: Avoid accessing builtin views outside of the critical section.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/virtual.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 0505617..6065b79 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1634,25 +1634,25 @@ NTSTATUS virtual_create_builtin_view( void *module )
     server_enter_uninterrupted_section( &csVirtual, &sigset );
     status = create_view( &view, base, size, SEC_IMAGE | SEC_FILE | VPROT_SYSTEM |
                           VPROT_COMMITTED | VPROT_READ | VPROT_WRITECOPY | VPROT_EXEC );
-    if (!status) TRACE( "created %p-%p\n", base, (char *)base + size );
-    server_leave_uninterrupted_section( &csVirtual, &sigset );
-
-    if (status) return status;
+    if (!status)
+    {
+        TRACE( "created %p-%p\n", base, (char *)base + size );
 
-    /* The PE header is always read-only, no write, no execute. */
-    set_page_vprot( view->base, page_size, VPROT_COMMITTED | VPROT_READ );
+        /* The PE header is always read-only, no write, no execute. */
+        set_page_vprot( base, page_size, VPROT_COMMITTED | VPROT_READ );
 
-    sec = (IMAGE_SECTION_HEADER *)((char *)&nt->OptionalHeader + nt->FileHeader.SizeOfOptionalHeader);
-    for (i = 0; i < nt->FileHeader.NumberOfSections; i++)
-    {
-        BYTE flags = VPROT_COMMITTED;
+        sec = (IMAGE_SECTION_HEADER *)((char *)&nt->OptionalHeader + nt->FileHeader.SizeOfOptionalHeader);
+        for (i = 0; i < nt->FileHeader.NumberOfSections; i++)
+        {
+            BYTE flags = VPROT_COMMITTED;
 
-        if (sec[i].Characteristics & IMAGE_SCN_MEM_EXECUTE) flags |= VPROT_EXEC;
-        if (sec[i].Characteristics & IMAGE_SCN_MEM_READ) flags |= VPROT_READ;
-        if (sec[i].Characteristics & IMAGE_SCN_MEM_WRITE) flags |= VPROT_WRITE;
-        set_page_vprot( (char *)view->base + sec[i].VirtualAddress, sec[i].Misc.VirtualSize, flags );
+            if (sec[i].Characteristics & IMAGE_SCN_MEM_EXECUTE) flags |= VPROT_EXEC;
+            if (sec[i].Characteristics & IMAGE_SCN_MEM_READ) flags |= VPROT_READ;
+            if (sec[i].Characteristics & IMAGE_SCN_MEM_WRITE) flags |= VPROT_WRITE;
+            set_page_vprot( (char *)base + sec[i].VirtualAddress, sec[i].Misc.VirtualSize, flags );
+        }
     }
-
+    server_leave_uninterrupted_section( &csVirtual, &sigset );
     return status;
 }
 




More information about the wine-cvs mailing list