Removed remaining patches for ATL thunk improvements (accepted upstream).

This commit is contained in:
Sebastian Lackner 2014-10-15 19:10:59 +02:00
parent 71db25dc7d
commit 5a35178f86
6 changed files with 2 additions and 205 deletions

View File

@ -35,12 +35,10 @@ Wine. All those differences are also documented on the
Included bugfixes and improvements
==================================
**Bugfixes and features included in the next upcoming release [6]:**
**Bugfixes and features included in the next upcoming release [4]:**
* ATL thunk check shouldn't trigger page fault ([Wine Bug #19296](http://bugs.winehq.org/show_bug.cgi?id=19296))
* Anno 1602 installer depends on Windows 98 behavior of SHFileOperationW
* FEAR 1 installer expects basic_string_wchar_dtor to return NULL ([Wine Bug #37358](http://bugs.winehq.org/show_bug.cgi?id=37358))
* Fix issue with ATL thunks in combination with guard pages ([Wine Bug #34479](http://bugs.winehq.org/show_bug.cgi?id=34479))
* Support for UTF7 encoding/decoding ([Wine Bug #27388](http://bugs.winehq.org/show_bug.cgi?id=27388))
* Wine ignores IDF_CHECKFIRST flag in SetupPromptForDisk ([Wine Bug #20465](http://bugs.winehq.org/show_bug.cgi?id=20465))

2
debian/changelog vendored
View File

@ -7,8 +7,8 @@ wine-compholio (1.7.29) UNRELEASED; urgency=low
* Removed patch to fix issues with drag image in ImageLists (accepted upstream).
* Removed patch to set ldr.EntryPoint for main executable (accepted upstream).
* Removed patch to implement stubs for [Get|Set]SystemFileCacheSize (accepted upstream).
* Removed patches for ATL thunk patches (accepted upstream).
* Partially removed patches for WRITECOPY memory protection (accepted upstream).
* Partially removed patches for ATL thunk patches (accepted upstream).
-- Sebastian Lackner <sebastian@fds-team.de> Mon, 06 Oct 2014 01:02:37 +0200
wine-compholio (1.7.28) unstable; urgency=low

View File

@ -39,7 +39,6 @@ PATCHLIST := \
kernel32-UTF7_Support.ok \
libs-Unicode_Collation.ok \
msvcp90-basic_string_wchar_dtor.ok \
ntdll-ATL_Thunk.ok \
ntdll-DOS_Attributes.ok \
ntdll-Dynamic_DST.ok \
ntdll-Exception.ok \
@ -540,26 +539,6 @@ msvcp90-basic_string_wchar_dtor.ok:
echo '+ { "msvcp90-basic_string_wchar_dtor", "Michael Müller", "basic_string_wchar_dtor needs to return NULL." },'; \
) > msvcp90-basic_string_wchar_dtor.ok
# Patchset ntdll-ATL_Thunk
# |
# | Included patches:
# | * Fix several issues with execute permissions in guard page / write watch handling. [rev 2, by Sebastian Lackner]
# |
# | This patchset fixes the following Wine bugs:
# | * [#19296] ATL thunk check shouldn't trigger page fault
# | * [#34479] Fix issue with ATL thunks in combination with guard pages
# |
# | Modified files:
# | * dlls/kernel32/tests/virtual.c, dlls/ntdll/signal_i386.c
# |
.INTERMEDIATE: ntdll-ATL_Thunk.ok
ntdll-ATL_Thunk.ok:
$(call APPLY_FILE,ntdll-ATL_Thunk/0001-kernel32-tests-Add-test-to-show-incorrect-behaviour-.patch)
$(call APPLY_FILE,ntdll-ATL_Thunk/0002-ntdll-Try-to-not-raise-exceptions-when-checking-for-.patch)
@( \
echo '+ { "ntdll-ATL_Thunk", "Sebastian Lackner", "Fix several issues with execute permissions in guard page / write watch handling. [rev 2]" },'; \
) > ntdll-ATL_Thunk.ok
# Patchset ntdll-DOS_Attributes
# |
# | Included patches:

View File

@ -1,127 +0,0 @@
From 0055b9ee3688aaec1bdfccb89c867c2f62d61146 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 11 Oct 2014 00:35:02 +0200
Subject: kernel32/tests: Add test to show incorrect behaviour in ATL thunk
handler.
---
dlls/kernel32/tests/virtual.c | 71 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 65 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 434d880..7ecd54d 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -35,7 +35,7 @@
#define NUM_THREADS 4
#define MAPPING_SIZE 0x100000
-static HINSTANCE hkernel32;
+static HINSTANCE hkernel32, hntdll;
static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD);
static BOOL (WINAPI *pVirtualFreeEx)(HANDLE, LPVOID, SIZE_T, DWORD);
static UINT (WINAPI *pGetWriteWatch)(DWORD,LPVOID,SIZE_T,LPVOID*,ULONG_PTR*,ULONG*);
@@ -44,6 +44,8 @@ static NTSTATUS (WINAPI *pNtAreMappedFilesTheSame)(PVOID,PVOID);
static NTSTATUS (WINAPI *pNtMapViewOfSection)(HANDLE, HANDLE, PVOID *, ULONG, SIZE_T, const LARGE_INTEGER *, SIZE_T *, ULONG, ULONG, ULONG);
static DWORD (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID);
static struct _TEB * (WINAPI *pNtCurrentTeb)(void);
+static PVOID (WINAPI *pRtlAddVectoredExceptionHandler)(ULONG, PVECTORED_EXCEPTION_HANDLER);
+static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID);
/* ############################### */
@@ -1843,6 +1845,31 @@ static DWORD execute_fault_seh_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR
return ExceptionContinueExecution;
}
+static LONG CALLBACK execute_fault_vec_handler( EXCEPTION_POINTERS *ExceptionInfo )
+{
+ PEXCEPTION_RECORD rec = ExceptionInfo->ExceptionRecord;
+ DWORD old_prot;
+ BOOL success;
+
+ trace( "exception: %08x flags:%x addr:%p\n",
+ rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
+
+ ok( rec->NumberParameters == 2, "NumberParameters is %d instead of 2\n", rec->NumberParameters );
+ ok( rec->ExceptionCode == STATUS_ACCESS_VIOLATION,
+ "ExceptionCode is %08x instead of STATUS_ACCESS_VIOLATION\n", rec->ExceptionCode );
+
+ num_execute_fault_calls++;
+
+ if (rec->ExceptionInformation[0] == EXCEPTION_READ_FAULT)
+ return EXCEPTION_CONTINUE_SEARCH;
+
+ success = VirtualProtect( (void *)rec->ExceptionInformation[1], 16, PAGE_EXECUTE_READWRITE, &old_prot );
+ ok( success, "VirtualProtect failed %u\n", GetLastError() );
+ ok( old_prot == PAGE_NOACCESS, "wrong old prot %x\n", old_prot );
+
+ return EXCEPTION_CONTINUE_EXECUTION;
+}
+
static inline DWORD send_message_excpt( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
EXCEPTION_REGISTRATION_RECORD frame;
@@ -2021,6 +2048,35 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+ /* The following test shows that on Windows, even a vectored exception handler cannot intercept
+ * internal exceptions thrown by the ATL thunk emulation layer. */
+
+
+ if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && !(dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
+ {
+ if (pRtlAddVectoredExceptionHandler && pRtlRemoveVectoredExceptionHandler)
+ {
+ PVOID vectored_handler;
+
+ success = VirtualProtect( base, size, PAGE_NOACCESS, &old_prot );
+ ok( success, "VirtualProtect failed %u\n", GetLastError() );
+
+ vectored_handler = pRtlAddVectoredExceptionHandler( TRUE, &execute_fault_vec_handler );
+ ok(vectored_handler != 0, "RtlAddVectoredExceptionHandler failed\n");
+
+ num_execute_fault_calls = 0;
+ ret = SendMessageA( hWnd, WM_USER, 0, 0 );
+
+ pRtlRemoveVectoredExceptionHandler(vectored_handler);
+
+ ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
+ todo_wine
+ ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+ }
+ else
+ win_skip("RtlAddVectoredExceptionHandler or RtlRemoveVectoredExceptionHandler or RtlRaiseException not found\n");
+ }
+
/* Restore the JMP instruction, set to executable, and then destroy the Window */
memcpy( base, code_jmp, sizeof(code_jmp) );
@@ -3265,15 +3321,18 @@ START_TEST(virtual)
}
hkernel32 = GetModuleHandleA("kernel32.dll");
+ hntdll = GetModuleHandleA("ntdll.dll");
+
pVirtualAllocEx = (void *) GetProcAddress(hkernel32, "VirtualAllocEx");
pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx");
pGetWriteWatch = (void *) GetProcAddress(hkernel32, "GetWriteWatch");
pResetWriteWatch = (void *) GetProcAddress(hkernel32, "ResetWriteWatch");
- pNtAreMappedFilesTheSame = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"),
- "NtAreMappedFilesTheSame" );
- pNtMapViewOfSection = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtMapViewOfSection");
- pNtUnmapViewOfSection = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtUnmapViewOfSection");
- pNtCurrentTeb = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"), "NtCurrentTeb" );
+ pNtAreMappedFilesTheSame = (void *)GetProcAddress( hntdll, "NtAreMappedFilesTheSame" );
+ pNtMapViewOfSection = (void *)GetProcAddress( hntdll, "NtMapViewOfSection" );
+ pNtUnmapViewOfSection = (void *)GetProcAddress( hntdll, "NtUnmapViewOfSection" );
+ pNtCurrentTeb = (void *)GetProcAddress( hntdll, "NtCurrentTeb" );
+ pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlAddVectoredExceptionHandler" );
+ pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlRemoveVectoredExceptionHandler" );
test_shared_memory(FALSE);
test_shared_memory_ro(FALSE, FILE_MAP_READ|FILE_MAP_WRITE);
--
2.1.2

View File

@ -1,48 +0,0 @@
From 280ec71a219496224a2269c23480e6b1b0af3cb6 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 11 Oct 2014 02:04:27 +0200
Subject: ntdll: Try to not raise exceptions when checking for ATL thunks.
Original patch by Markus Amsler.
---
dlls/kernel32/tests/virtual.c | 1 -
dlls/ntdll/signal_i386.c | 7 +++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 7ecd54d..6d05eef 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -2070,7 +2070,6 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
pRtlRemoveVectoredExceptionHandler(vectored_handler);
ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
- todo_wine
ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
}
else
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 7f01554..48212ba 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -1633,10 +1633,17 @@ struct atl_thunk
static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context )
{
const struct atl_thunk *thunk = (const struct atl_thunk *)rec->ExceptionInformation[1];
+ MEMORY_BASIC_INFORMATION mbi;
+ NTSTATUS status;
BOOL ret = FALSE;
if (!virtual_is_valid_code_address( thunk, sizeof(*thunk) )) return FALSE;
+ /* Try to avoid exceptions, to not confuse debuggers / vectored handlers. */
+ status = NtQueryVirtualMemory( NtCurrentProcess(), thunk, 0, &mbi, sizeof(mbi), NULL );
+ if (status != STATUS_SUCCESS || (mbi.Protect & PAGE_NOACCESS))
+ return FALSE;
+
__TRY
{
if (thunk->movl == 0x042444c7 && thunk->jmp == 0xe9)
--
2.1.2

View File

@ -1,5 +0,0 @@
Author: Sebastian Lackner
Subject: Fix several issues with execute permissions in guard page / write watch handling.
Revision: 2
Fixes: [19296] ATL thunk check shouldn't trigger page fault
Fixes: [34479] Fix issue with ATL thunks in combination with guard pages