Added patch to implement mscoree._CorValidateImage for mono runtime.

This commit is contained in:
Sebastian Lackner 2015-04-02 03:42:09 +02:00
parent 3b9b44454b
commit 7a76ebf786
5 changed files with 126 additions and 1 deletions

View File

@ -38,7 +38,7 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
===================================
**Bugfixes and features included in the next upcoming release [13]:**
**Bugfixes and features included in the next upcoming release [14]:**
* Add stub fltmgr.sys (filter manager driver) ([Wine Bug #23583](https://bugs.winehq.org/show_bug.cgi?id=23583))
* Add stubs for Power[Set|Clear]Request
@ -49,6 +49,7 @@ Included bug fixes and improvements
* Fix device paths in HKLM\SYSTEM\MountedDevices ([Wine Bug #38235](https://bugs.winehq.org/show_bug.cgi?id=38235))
* Fix handling of ANSI NTLM credentials ([Wine Bug #37063](https://bugs.winehq.org/show_bug.cgi?id=37063))
* Implement empty enumerator for IWiaDevMgr::EnumDeviceInfo ([Wine Bug #27775](https://bugs.winehq.org/show_bug.cgi?id=27775))
* Implement mscoree._CorValidateImage for mono runtime
* Return correct device type for cd devices without medium
* Show unmounted devices in winecfg and allow changing the unix path
* Software support for Environmental Audio Extensions (EAX)

1
debian/changelog vendored
View File

@ -15,6 +15,7 @@ wine-staging (1.7.40) UNRELEASED; urgency=low
* Added patch to show unmounted devices in winecfg and allow changing the unix path.
* Added patch for support of 8bpp grayscale TIFF images with 8bpp alpha channel (replaces previous stub).
* Added patch to implement support for linux priority levels (by Joakim Hernberg, various modifications by Sebastian Lackner).
* Added patch to implement mscoree._CorValidateImage for mono runtime.
* Removed patch to fix regression causing black screen on startup (accepted upstream).
* Removed patch to fix edge cases in TOOLTIPS_GetTipText (fixed upstream).
* Removed patch for IConnectionPoint/INetworkListManagerEvents stub interface (accepted upstream).

View File

@ -0,0 +1,106 @@
From 813e87c2f979a552a0573abfd6afcfcec8584edf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 2 Apr 2015 02:38:29 +0200
Subject: mscoree: Implement _CorValidateImage.
---
dlls/mscoree/mscoree_main.c | 71 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 69 insertions(+), 2 deletions(-)
diff --git a/dlls/mscoree/mscoree_main.c b/dlls/mscoree/mscoree_main.c
index 8b46fd5..6e02c79 100644
--- a/dlls/mscoree/mscoree_main.c
+++ b/dlls/mscoree/mscoree_main.c
@@ -21,11 +21,14 @@
#include <stdarg.h>
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#define COBJMACROS
#include "wine/unicode.h"
#include "wine/library.h"
#include "windef.h"
#include "winbase.h"
+#include "winternl.h"
#include "winuser.h"
#include "winnls.h"
#include "winreg.h"
@@ -259,8 +262,72 @@ VOID WINAPI _CorImageUnloading(PVOID imageBase)
HRESULT WINAPI _CorValidateImage(PVOID* imageBase, LPCWSTR imageName)
{
- TRACE("(%p, %s): stub\n", imageBase, debugstr_w(imageName));
- return E_FAIL;
+ IMAGE_COR20_HEADER *cliheader;
+ IMAGE_NT_HEADERS *nt;
+ ULONG size;
+
+ TRACE("(%p, %s)\n", imageBase, debugstr_w(imageName));
+
+ if (!imageBase)
+ return E_INVALIDARG;
+
+ nt = RtlImageNtHeader(*imageBase);
+ if (!nt) return STATUS_INVALID_IMAGE_FORMAT;
+
+ cliheader = RtlImageDirectoryEntryToData(*imageBase, TRUE, IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR, &size);
+ if (!cliheader || size < sizeof(*cliheader))
+ return STATUS_INVALID_IMAGE_FORMAT;
+
+#ifdef __x86_64__
+ if (cliheader->Flags & COMIMAGE_FLAGS_32BITREQUIRED)
+ return STATUS_INVALID_IMAGE_FORMAT;
+
+ if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
+ {
+ /* Clear out the entrypoint if nonzero */
+ if ((cliheader->Flags & COMIMAGE_FLAGS_ILONLY) && nt->OptionalHeader.AddressOfEntryPoint)
+ {
+ DWORD *entry = &nt->OptionalHeader.AddressOfEntryPoint;
+ DWORD old_protect;
+
+ if (!VirtualProtect(entry, sizeof(*entry), PAGE_READWRITE, &old_protect))
+ return E_UNEXPECTED;
+ *entry = 0;
+ if (!VirtualProtect(entry, sizeof(*entry), old_protect, &old_protect))
+ return E_UNEXPECTED;
+ }
+
+ return STATUS_SUCCESS;
+ }
+
+ if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
+ {
+ if (!(cliheader->Flags & COMIMAGE_FLAGS_ILONLY))
+ return STATUS_INVALID_IMAGE_FORMAT;
+
+ FIXME("conversion of IMAGE_NT_HEADERS32 -> IMAGE_NT_HEADERS64 header not implemented\n");
+ return STATUS_NOT_IMPLEMENTED;
+ }
+
+#else
+ if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
+ {
+ DWORD *entry = &nt->OptionalHeader.AddressOfEntryPoint;
+ DWORD old_protect;
+
+ if (!VirtualProtect(entry, sizeof(*entry), PAGE_READWRITE, &old_protect))
+ return E_UNEXPECTED;
+ *entry = (nt->FileHeader.Characteristics & IMAGE_FILE_DLL) ?
+ ((DWORD)&_CorDllMain - (DWORD)*imageBase) : (DWORD)&_CorExeMain - (DWORD)*imageBase;
+ if (!VirtualProtect(entry, sizeof(*entry), old_protect, &old_protect))
+ return E_UNEXPECTED;
+
+ return STATUS_SUCCESS;
+ }
+
+#endif
+
+ return STATUS_INVALID_IMAGE_FORMAT;
}
HRESULT WINAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
--
2.3.3

View File

@ -0,0 +1 @@
Fixes: Implement mscoree._CorValidateImage for mono runtime

View File

@ -127,6 +127,7 @@ patch_enable_all ()
enable_makedep_PARENTSPEC="$1"
enable_mmdevapi_AEV_Stubs="$1"
enable_mountmgr_DosDevices="$1"
enable_mscoree_CorValidateImage="$1"
enable_msctf_DllCanUnloadNow="$1"
enable_msvcp90_basic_string_wchar_dtor="$1"
enable_msvcrt_atof_strtod="$1"
@ -447,6 +448,9 @@ patch_enable ()
mountmgr-DosDevices)
enable_mountmgr_DosDevices="$2"
;;
mscoree-CorValidateImage)
enable_mscoree_CorValidateImage="$2"
;;
msctf-DllCanUnloadNow)
enable_msctf_DllCanUnloadNow="$2"
;;
@ -2918,6 +2922,18 @@ if test "$enable_mountmgr_DosDevices" -eq 1; then
) >> "$patchlist"
fi
# Patchset mscoree-CorValidateImage
# |
# | Modified files:
# | * dlls/mscoree/mscoree_main.c
# |
if test "$enable_mscoree_CorValidateImage" -eq 1; then
patch_apply mscoree-CorValidateImage/0001-mscoree-Implement-_CorValidateImage.patch
(
echo '+ { "Michael Müller", "mscoree: Implement _CorValidateImage.", 1 },';
) >> "$patchlist"
fi
# Patchset msctf-DllCanUnloadNow
# |
# | This patchset fixes the following Wine bugs: