server: Support loading 32-bit resource-only dlls into 64-bit process

Albert Szilvasy albert.szilvasy at autodesk.com
Fri Apr 25 17:53:08 CDT 2014


Hi there,

This is my first ever wine submission... Please be gentle.
Tested on CentOS 6.5.

The change below modifies wineserver such that it will allow loading 32-bit PE images into a 64-bit process as long as the 32-bit image contains no code (i.e. resource-only). Windows allows this and so should wine.
---
 server/mapping.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/server/mapping.c b/server/mapping.c
index 64b3003..d2f324f 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -409,8 +409,15 @@ static unsigned int get_image_params( struct mapping *mapping, int unix_fd, int
         if (nt.opt.hdr32.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC) return STATUS_INVALID_IMAGE_FORMAT;
         break;
     case CPU_x86_64:
-        if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_AMD64) return STATUS_INVALID_IMAGE_FORMAT;
-        if (nt.opt.hdr64.Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC) return STATUS_INVALID_IMAGE_FORMAT;
+    	if (nt.FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64 &&
+            nt.opt.hdr64.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
+        	break;
+        /* loading 32-bit resource-only DLLs on 64-bit is allowed */
+        if (nt.FileHeader.Machine == IMAGE_FILE_MACHINE_I386 &&
+            nt.opt.hdr32.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC &&
+            nt.opt.hdr32.AddressOfEntryPoint == 0)
+        	break;
+        return STATUS_INVALID_IMAGE_FORMAT;
         break;
     case CPU_POWERPC:
         if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_POWERPC) return STATUS_INVALID_IMAGE_FORMAT;
--




More information about the wine-patches mailing list