Alexandre Julliard : ntdll: Allow loading 32-bit IL-only binaries on 64-bit.
Alexandre Julliard
julliard at winehq.org
Wed Feb 28 15:39:33 CST 2018
Module: wine
Branch: master
Commit: 97b0907439183cb86e6c05a4d8c9bf14d73805c7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=97b0907439183cb86e6c05a4d8c9bf14d73805c7
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Feb 28 09:57:59 2018 +0100
ntdll: Allow loading 32-bit IL-only binaries on 64-bit.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/loader.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 6884e8d..46a7d22 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1809,18 +1809,27 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len )
/* On WoW64 setups, an image mapping can also be created for the other 32/64 CPU */
/* but it cannot necessarily be loaded as a dll, so we need some additional checks */
-static BOOL is_valid_binary( const pe_image_info_t *info )
+static BOOL is_valid_binary( HMODULE module, const pe_image_info_t *info )
{
#ifdef __i386__
return info->machine == IMAGE_FILE_MACHINE_I386;
-#elif defined(__x86_64__)
- return info->machine == IMAGE_FILE_MACHINE_AMD64 || !info->contains_code;
#elif defined(__arm__)
return info->machine == IMAGE_FILE_MACHINE_ARM ||
info->machine == IMAGE_FILE_MACHINE_THUMB ||
info->machine == IMAGE_FILE_MACHINE_ARMNT;
-#elif defined(__aarch64__)
- return info->machine == IMAGE_FILE_MACHINE_ARM64 || !info->contains_code;
+#elif defined(__x86_64__) || defined(__aarch64__) /* support 32-bit IL-only images on 64-bit */
+ const IMAGE_COR20_HEADER *cor_header;
+ DWORD size;
+
+#ifdef __x86_64__
+ if (info->machine == IMAGE_FILE_MACHINE_AMD64) return TRUE;
+#else
+ if (info->machine == IMAGE_FILE_MACHINE_ARM64) return TRUE;
+#endif
+ if (!info->contains_code) return TRUE;
+ cor_header = RtlImageDirectoryEntryToData( module, TRUE, IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR, &size );
+ if (cor_header && (cor_header->Flags & COMIMAGE_FLAGS_ILONLY)) return TRUE;
+ return FALSE;
#else
return FALSE; /* no wow64 support on other platforms */
#endif
@@ -1855,7 +1864,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
NtClose( mapping );
if ((status == STATUS_SUCCESS || status == STATUS_IMAGE_NOT_AT_BASE) &&
- !is_valid_binary( &image_info ))
+ !is_valid_binary( module, &image_info ))
{
NtUnmapViewOfSection( NtCurrentProcess(), module );
return STATUS_INVALID_IMAGE_FORMAT;
More information about the wine-cvs
mailing list