Alexandre Julliard : ntdll: Add a helper function to map a section.

Alexandre Julliard julliard at winehq.org
Mon Mar 21 17:20:25 CDT 2022


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Mar 21 11:50:33 2022 +0100

ntdll: Add a helper function to map a section.

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

---

 dlls/ntdll/unix/env.c          | 7 +++----
 dlls/ntdll/unix/loader.c       | 6 +-----
 dlls/ntdll/unix/unix_private.h | 8 ++++++++
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c
index 3f9f7f1b3b7..227bcdbfa0f 100644
--- a/dlls/ntdll/unix/env.c
+++ b/dlls/ntdll/unix/env.c
@@ -2458,10 +2458,9 @@ NTSTATUS WINAPI NtGetNlsSectionPtr( ULONG type, ULONG id, void *unknown, void **
     }
     if (!status)
     {
-        *ptr = NULL;
-        *size = 0;
-        status = NtMapViewOfSection( handle, GetCurrentProcess(), ptr, 0, 0, NULL, size,
-                                     ViewShare, 0, PAGE_READONLY );
+        status = map_section( handle, ptr, size, PAGE_READONLY );
+        NtClose( handle );
+    }
     }
     NtClose( handle );
     return status;
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index 5eb201bd90b..97fb624d6d2 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -2032,11 +2032,7 @@ static void load_apiset_dll(void)
     }
     if (!status)
     {
-        ptr = NULL;
-        size = 0;
-        status = NtMapViewOfSection( mapping, NtCurrentProcess(), &ptr,
-                                     is_win64 && wow_peb ? 0x7fffffff : 0, 0, NULL,
-                                     &size, ViewShare, 0, PAGE_READONLY );
+        status = map_section( mapping, &ptr, &size, PAGE_READONLY );
         NtClose( mapping );
     }
     if (!status)
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index b1595c792c0..434f98cdc5a 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -450,4 +450,12 @@ static inline void init_unicode_string( UNICODE_STRING *str, const WCHAR *data )
     str->Buffer = (WCHAR *)data;
 }
 
+static inline NTSTATUS map_section( HANDLE mapping, void **ptr, SIZE_T *size, ULONG protect )
+{
+    *ptr = NULL;
+    *size = 0;
+    return NtMapViewOfSection( mapping, NtCurrentProcess(), ptr, is_win64 && wow_peb ? 0x7fffffff : 0,
+                               0, NULL, size, ViewShare, 0, protect );
+}
+
 #endif /* __NTDLL_UNIX_PRIVATE_H */




More information about the wine-cvs mailing list