From a8ed1e17c2abd6acbe134877de9b55a54f68e78d Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 18 Aug 2016 19:14:01 +0200 Subject: [PATCH] Rebase against 60f8b516e2a6233eaee8ae58cd2eccce998dd81f. [ntdll-x86_64_Builtin_Frames] Temporarily disable patchset to improve handling of builtin frames for x86_64 when switching stack. This needs additional work to be compatible with the recent collided unwind upstream changes. --- ...ption-if-invalid-handle-is-passed-to.patch | 24 +++++++++---------- ...gString-should-throw-the-exception-a.patch | 20 ++++++++-------- .../ntdll-x86_64_Builtin_Frames/definition | 1 + patches/patchinstall.sh | 18 +------------- 4 files changed, 24 insertions(+), 39 deletions(-) diff --git a/patches/ntdll-Exception/0001-ntdll-Throw-exception-if-invalid-handle-is-passed-to.patch b/patches/ntdll-Exception/0001-ntdll-Throw-exception-if-invalid-handle-is-passed-to.patch index 12ecb9c7..aa68412d 100644 --- a/patches/ntdll-Exception/0001-ntdll-Throw-exception-if-invalid-handle-is-passed-to.patch +++ b/patches/ntdll-Exception/0001-ntdll-Throw-exception-if-invalid-handle-is-passed-to.patch @@ -1,4 +1,4 @@ -From d6ce4357c4a5600f33e24df046e9a24fcfb71bf2 Mon Sep 17 00:00:00 2001 +From cd82af4ce885a2541e75c4adb3527197eb940569 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 28 Sep 2014 22:42:46 +0200 Subject: ntdll: Throw exception if invalid handle is passed to NtClose and @@ -62,18 +62,18 @@ index 1279f2b..35c3672 100644 } diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c -index 64f3dff..56940c3 100644 +index f1bfee6..3e22bed 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c -@@ -52,6 +52,7 @@ static NTSTATUS (WINAPI *pNtTerminateProcess)(HANDLE handle, LONG exit_code); +@@ -51,6 +51,7 @@ static NTSTATUS (WINAPI *pNtTerminateProcess)(HANDLE handle, LONG exit_code); static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG); static NTSTATUS (WINAPI *pNtSetInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); +static NTSTATUS (WINAPI *pNtClose)(HANDLE); #if defined(__x86_64__) - static BOOLEAN (CDECL *pRtlAddFunctionTable)(RUNTIME_FUNCTION*, DWORD, DWORD64); -@@ -963,6 +964,16 @@ static void test_debugger(void) + typedef struct +@@ -989,6 +990,16 @@ static void test_debugger(void) if (stage == 10) continuestatus = DBG_EXCEPTION_NOT_HANDLED; } @@ -90,7 +90,7 @@ index 64f3dff..56940c3 100644 else ok(FALSE, "unexpected stage %x\n", stage); -@@ -2115,6 +2126,53 @@ static void test_breakpoint(DWORD numexc) +@@ -2194,6 +2205,53 @@ static void test_breakpoint(DWORD numexc) pRtlRemoveVectoredExceptionHandler(vectored_handler); } @@ -144,7 +144,7 @@ index 64f3dff..56940c3 100644 static void test_vectored_continue_handler(void) { PVOID handler1, handler2; -@@ -2167,6 +2225,7 @@ START_TEST(exception) +@@ -2245,6 +2303,7 @@ START_TEST(exception) pNtGetContextThread = (void *)GetProcAddress( hntdll, "NtGetContextThread" ); pNtSetContextThread = (void *)GetProcAddress( hntdll, "NtSetContextThread" ); pNtReadVirtualMemory = (void *)GetProcAddress( hntdll, "NtReadVirtualMemory" ); @@ -152,7 +152,7 @@ index 64f3dff..56940c3 100644 pRtlUnwind = (void *)GetProcAddress( hntdll, "RtlUnwind" ); pRtlRaiseException = (void *)GetProcAddress( hntdll, "RtlRaiseException" ); pNtTerminateProcess = (void *)GetProcAddress( hntdll, "NtTerminateProcess" ); -@@ -2242,6 +2301,10 @@ START_TEST(exception) +@@ -2315,6 +2374,10 @@ START_TEST(exception) test_breakpoint(0); test_stage = 10; test_breakpoint(1); @@ -163,7 +163,7 @@ index 64f3dff..56940c3 100644 } else skip( "RtlRaiseException not found\n" ); -@@ -2258,6 +2321,7 @@ START_TEST(exception) +@@ -2331,6 +2394,7 @@ START_TEST(exception) test_ripevent(1); test_debug_service(1); test_breakpoint(1); @@ -171,14 +171,14 @@ index 64f3dff..56940c3 100644 test_vectored_continue_handler(); test_debugger(); test_simd_exceptions(); -@@ -2280,6 +2344,7 @@ START_TEST(exception) +@@ -2355,6 +2419,7 @@ START_TEST(exception) test_ripevent(1); test_debug_service(1); test_breakpoint(1); + test_closehandle(0); test_vectored_continue_handler(); test_virtual_unwind(); - + test___C_specific_handler(); -- -2.7.0 +2.9.0 diff --git a/patches/ntdll-Exception/0002-ntdll-OutputDebugString-should-throw-the-exception-a.patch b/patches/ntdll-Exception/0002-ntdll-OutputDebugString-should-throw-the-exception-a.patch index b4eb4e43..e1a86103 100644 --- a/patches/ntdll-Exception/0002-ntdll-OutputDebugString-should-throw-the-exception-a.patch +++ b/patches/ntdll-Exception/0002-ntdll-OutputDebugString-should-throw-the-exception-a.patch @@ -1,4 +1,4 @@ -From 6ee41ac52713ab965e458f4c86793d49980ebb21 Mon Sep 17 00:00:00 2001 +From bdc7f21350a4dd7bc639bc6be69243bb6dd5dbf5 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 28 Sep 2014 23:39:51 +0200 Subject: ntdll: OutputDebugString should throw the exception a second time, if @@ -10,7 +10,7 @@ Subject: ntdll: OutputDebugString should throw the exception a second time, if 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/debugger.c b/dlls/kernel32/debugger.c -index d4d66b2..981661b 100644 +index a277f93..2fb9c73 100644 --- a/dlls/kernel32/debugger.c +++ b/dlls/kernel32/debugger.c @@ -277,6 +277,23 @@ void WINAPI OutputDebugStringA( LPCSTR str ) @@ -38,10 +38,10 @@ index d4d66b2..981661b 100644 if (!mutex_inited) { diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c -index 56940c3..71f5985 100644 +index 3e22bed..3dab0bd 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c -@@ -1824,7 +1824,7 @@ static LONG CALLBACK outputdebugstring_vectored_handler(EXCEPTION_POINTERS *Exce +@@ -1903,7 +1903,7 @@ static LONG CALLBACK outputdebugstring_vectored_handler(EXCEPTION_POINTERS *Exce return EXCEPTION_CONTINUE_SEARCH; } @@ -50,7 +50,7 @@ index 56940c3..71f5985 100644 { PVOID vectored_handler; -@@ -1840,7 +1840,6 @@ static void test_outputdebugstring(DWORD numexc, BOOL todo) +@@ -1919,7 +1919,6 @@ static void test_outputdebugstring(DWORD numexc, BOOL todo) outputdebugstring_exceptions = 0; OutputDebugStringA("Hello World"); @@ -58,7 +58,7 @@ index 56940c3..71f5985 100644 ok(outputdebugstring_exceptions == numexc, "OutputDebugStringA generated %d exceptions, expected %d\n", outputdebugstring_exceptions, numexc); -@@ -2286,9 +2285,9 @@ START_TEST(exception) +@@ -2359,9 +2358,9 @@ START_TEST(exception) run_rtlraiseexception_test(EXCEPTION_BREAKPOINT); run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE); test_stage = 3; @@ -70,7 +70,7 @@ index 56940c3..71f5985 100644 test_stage = 5; test_ripevent(0); test_stage = 6; -@@ -2317,7 +2316,7 @@ START_TEST(exception) +@@ -2390,7 +2389,7 @@ START_TEST(exception) test_exceptions(); test_rtlraiseexception(); test_debug_registers(); @@ -79,8 +79,8 @@ index 56940c3..71f5985 100644 test_ripevent(1); test_debug_service(1); test_breakpoint(1); -@@ -2340,7 +2339,7 @@ START_TEST(exception) - "RtlLookupFunctionEntry" ); +@@ -2415,7 +2414,7 @@ START_TEST(exception) + "__C_specific_handler" ); test_debug_registers(); - test_outputdebugstring(1, FALSE); @@ -89,5 +89,5 @@ index 56940c3..71f5985 100644 test_debug_service(1); test_breakpoint(1); -- -2.7.0 +2.9.0 diff --git a/patches/ntdll-x86_64_Builtin_Frames/definition b/patches/ntdll-x86_64_Builtin_Frames/definition index a01f1f3e..47e3130a 100644 --- a/patches/ntdll-x86_64_Builtin_Frames/definition +++ b/patches/ntdll-x86_64_Builtin_Frames/definition @@ -1 +1,2 @@ Fixes: Improve handling of builtin frames for x86_64 when switching stacks +Disabled: true diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 092bed87..65ea639d 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "51021faaef8312c35e9772873ad588c194c5c709" + echo "60f8b516e2a6233eaee8ae58cd2eccce998dd81f" } # Show version information @@ -244,7 +244,6 @@ patch_enable_all () enable_ntdll_WriteWatches="$1" enable_ntdll_Zero_mod_name="$1" enable_ntdll_call_thread_func_wrapper="$1" - enable_ntdll_x86_64_Builtin_Frames="$1" enable_ntoskrnl_DriverTest="$1" enable_ntoskrnl_Stubs="$1" enable_nvapi_Stub_DLL="$1" @@ -904,9 +903,6 @@ patch_enable () ntdll-call_thread_func_wrapper) enable_ntdll_call_thread_func_wrapper="$2" ;; - ntdll-x86_64_Builtin_Frames) - enable_ntdll_x86_64_Builtin_Frames="$2" - ;; ntoskrnl-DriverTest) enable_ntoskrnl_DriverTest="$2" ;; @@ -5328,18 +5324,6 @@ if test "$enable_ntdll_call_thread_func_wrapper" -eq 1; then ) >> "$patchlist" fi -# Patchset ntdll-x86_64_Builtin_Frames -# | -# | Modified files: -# | * dlls/ntdll/signal_x86_64.c -# | -if test "$enable_ntdll_x86_64_Builtin_Frames" -eq 1; then - patch_apply ntdll-x86_64_Builtin_Frames/0001-ntdll-Improve-handling-of-builtin-frames-for-x86_64-.patch - ( - echo '+ { "Sebastian Lackner", "ntdll: Improve handling of builtin frames for x86_64 when switching stacks.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntoskrnl-DriverTest # | # | Modified files: