Alexandre Julliard : kernel32: Also set the preloader range for 64-bit binaries.

Alexandre Julliard julliard at winehq.org
Sun Mar 18 09:02:30 CDT 2018


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Oct 23 11:35:24 2017 +0200

kernel32: Also set the preloader range for 64-bit binaries.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 1d49a57e77c2e18dd0b9e74aa6b71fc95ac57017)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/kernel32/kernel_private.h |  4 ++--
 dlls/kernel32/module.c         | 12 +++++++-----
 dlls/kernel32/process.c        | 20 +++++++++++---------
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h
index 76611d7..7e7ee61 100644
--- a/dlls/kernel32/kernel_private.h
+++ b/dlls/kernel32/kernel_private.h
@@ -84,8 +84,8 @@ struct binary_info
     enum binary_type type;
     DWORD            arch;
     DWORD            flags;
-    void            *res_start;
-    void            *res_end;
+    ULONGLONG        res_start;
+    ULONGLONG        res_end;
 };
 
 /* module.c */
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index badfe1d..3179b67 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -319,6 +319,7 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info )
         {
             IMAGE_OS2_HEADER os2;
             IMAGE_NT_HEADERS32 nt;
+            IMAGE_NT_HEADERS64 nt64;
         } ext_header;
 
         /* We do have a DOS image so we will now try to seek into
@@ -347,16 +348,17 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info )
                 info->arch = ext_header.nt.FileHeader.Machine;
                 if (ext_header.nt.FileHeader.Characteristics & IMAGE_FILE_DLL)
                     info->flags |= BINARY_FLAG_DLL;
-                if (len < sizeof(ext_header.nt))  /* clear remaining part of header if missing */
-                    memset( (char *)&ext_header.nt + len, 0, sizeof(ext_header.nt) - len );
+                if (len < sizeof(ext_header))  /* clear remaining part of header if missing */
+                    memset( (char *)&ext_header + len, 0, sizeof(ext_header) - len );
                 switch (ext_header.nt.OptionalHeader.Magic)
                 {
                 case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
-                    info->res_start = (void *)(ULONG_PTR)ext_header.nt.OptionalHeader.ImageBase;
-                    info->res_end = (void *)((ULONG_PTR)ext_header.nt.OptionalHeader.ImageBase +
-                                                     ext_header.nt.OptionalHeader.SizeOfImage);
+                    info->res_start = ext_header.nt.OptionalHeader.ImageBase;
+                    info->res_end = info->res_start + ext_header.nt.OptionalHeader.SizeOfImage;
                     break;
                 case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
+                    info->res_start = ext_header.nt64.OptionalHeader.ImageBase;
+                    info->res_end = info->res_start + ext_header.nt64.OptionalHeader.SizeOfImage;
                     info->flags |= BINARY_FLAG_64BIT;
                     break;
                 }
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index e1372fb..595adf9 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -207,8 +207,8 @@ static BOOL get_builtin_path( const WCHAR *libname, const WCHAR *ext, WCHAR *fil
     }
     binary_info->type = BINARY_UNIX_LIB;
     binary_info->flags = flags;
-    binary_info->res_start = NULL;
-    binary_info->res_end = NULL;
+    binary_info->res_start = 0;
+    binary_info->res_end = 0;
     /* assume current arch */
 #if defined(__i386__) || defined(__x86_64__)
     binary_info->arch = (flags & BINARY_FLAG_64BIT) ? IMAGE_FILE_MACHINE_AMD64 : IMAGE_FILE_MACHINE_I386;
@@ -1916,8 +1916,9 @@ static pid_t exec_loader( LPCWSTR cmd_line, unsigned int flags, int socketfd,
             signal( SIGPIPE, SIG_DFL );
 
             sprintf( socket_env, "WINESERVERSOCKET=%u", socketfd );
-            sprintf( preloader_reserve, "WINEPRELOADRESERVE=%lx-%lx",
-                     (unsigned long)binary_info->res_start, (unsigned long)binary_info->res_end );
+            sprintf( preloader_reserve, "WINEPRELOADRESERVE=%x%08x-%x%08x",
+                     (ULONG)(binary_info->res_start >> 32), (ULONG)binary_info->res_start,
+                     (ULONG)(binary_info->res_end >> 32), (ULONG)binary_info->res_end );
 
             putenv( preloader_reserve );
             putenv( socket_env );
@@ -2383,10 +2384,10 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A
     else switch (binary_info.type)
     {
     case BINARY_PE:
-        TRACE( "starting %s as Win%d binary (%p-%p, arch %04x%s)\n",
+        TRACE( "starting %s as Win%d binary (%s-%s, arch %04x%s)\n",
                debugstr_w(name), (binary_info.flags & BINARY_FLAG_64BIT) ? 64 : 32,
-               binary_info.res_start, binary_info.res_end, binary_info.arch,
-               (binary_info.flags & BINARY_FLAG_FAKEDLL) ? ", fakedll" : "" );
+               wine_dbgstr_longlong(binary_info.res_start), wine_dbgstr_longlong(binary_info.res_end),
+               binary_info.arch, (binary_info.flags & BINARY_FLAG_FAKEDLL) ? ", fakedll" : "" );
         retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
                                inherit, flags, startup_info, info, unixdir, &binary_info, FALSE );
         break;
@@ -2536,9 +2537,10 @@ static void exec_process( LPCWSTR name )
     switch (binary_info.type)
     {
     case BINARY_PE:
-        TRACE( "starting %s as Win%d binary (%p-%p, arch %04x)\n",
+        TRACE( "starting %s as Win%d binary (%s-%s, arch %04x)\n",
                debugstr_w(name), (binary_info.flags & BINARY_FLAG_64BIT) ? 64 : 32,
-               binary_info.res_start, binary_info.res_end, binary_info.arch );
+               wine_dbgstr_longlong(binary_info.res_start), wine_dbgstr_longlong(binary_info.res_end),
+               binary_info.arch );
         create_process( hFile, name, GetCommandLineW(), NULL, NULL, NULL, NULL,
                         FALSE, 0, &startup_info, &info, NULL, &binary_info, TRUE );
         break;




More information about the wine-cvs mailing list