winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
August 2016
----- 2025 -----
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
777 discussions
Start a n
N
ew thread
Józef Kucia : user32/tests: Add more tests for setting window styles.
by Alexandre Julliard
18 Aug '16
18 Aug '16
Module: wine Branch: master Commit: 412b8dcafb53616b61796511951740c792f37b78 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=412b8dcafb53616b617965119…
Author: Józef Kucia <jkucia(a)codeweavers.com> Date: Wed Aug 17 13:56:08 2016 +0200 user32/tests: Add more tests for setting window styles. Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/tests/win.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 00885d9..f7ed6d5 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -6265,6 +6265,103 @@ static void test_SetWindowLong(void) } } +static LRESULT WINAPI check_style_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + const STYLESTRUCT *expected = (STYLESTRUCT *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + const STYLESTRUCT *got = (STYLESTRUCT *)lParam; + + if (message == WM_STYLECHANGING && wParam == GWL_STYLE) + { + ok(got->styleOld == expected[0].styleOld, "expected old style %#x, got %#x\n", + expected[0].styleOld, got->styleOld); + ok(got->styleNew == expected[0].styleNew, "expected new style %#x, got %#x\n", + expected[0].styleNew, got->styleNew); + } + else if (message == WM_STYLECHANGED && wParam == GWL_STYLE) + { + ok(got->styleOld == expected[1].styleOld, "expected old style %#x, got %#x\n", + expected[1].styleOld, got->styleOld); + todo_wine_if(expected[0].styleOld & WS_MINIMIZE) + ok(got->styleNew == expected[1].styleNew, "expected new style %#x, got %#x\n", + expected[1].styleNew, got->styleNew); + } + + return DefWindowProcA(hwnd, message, wParam, lParam); +} + +static void test_set_window_style(void) +{ + LONG expected_style, new_style, old_style; + STYLESTRUCT expected_stylestruct[2]; + unsigned int i; + WNDCLASSA cls; + HWND hwnd; + + static const struct + { + LONG creation_style; + LONG style; + } + tests[] = + { + { WS_MINIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, + WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX }, + { WS_MINIMIZE | WS_CLIPSIBLINGS | WS_CAPTION, + WS_CLIPSIBLINGS | WS_CAPTION }, + { WS_MAXIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, + WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX }, + { WS_MAXIMIZE | WS_CLIPSIBLINGS | WS_CAPTION, + WS_CLIPSIBLINGS | WS_CAPTION }, + { WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, + WS_MINIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX }, + { WS_CLIPSIBLINGS | WS_CAPTION, + WS_MINIMIZE | WS_CLIPSIBLINGS | WS_CAPTION }, + { WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, + WS_MAXIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX }, + { WS_CLIPSIBLINGS | WS_CAPTION, + WS_MAXIMIZE | WS_CLIPSIBLINGS | WS_CAPTION }, + }; + + memset(&cls, 0, sizeof(cls)); + cls.lpfnWndProc = check_style_wnd_proc; + cls.hInstance = GetModuleHandleA(0); + cls.lpszClassName = "TestSetWindowStylesClass"; + ok(RegisterClassA(&cls), "RegisterClass failed\n"); + + for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + { + BOOL todo = FALSE; + expected_style = tests[i].style; + if ((tests[i].creation_style & WS_MINIMIZE) && !(tests[i].style & WS_MINIMIZE)) + { + todo = TRUE; + expected_style |= WS_MINIMIZE; + } + + expected_stylestruct[0].styleOld = tests[i].creation_style; + expected_stylestruct[0].styleNew = tests[i].style; + expected_stylestruct[1].styleOld = tests[i].creation_style; + expected_stylestruct[1].styleNew = expected_style; + + hwnd = CreateWindowA(cls.lpszClassName, "Test set styles", + tests[i].creation_style, 100, 100, 200, 200, 0, 0, 0, NULL); + ok(hwnd != 0, "CreateWindow failed\n"); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)&expected_stylestruct); + + old_style = SetWindowLongA(hwnd, GWL_STYLE, tests[i].style); + ok(old_style == tests[i].creation_style, "expected old style %#x, got %#x\n", + tests[i].creation_style, old_style); + new_style = GetWindowLongA(hwnd, GWL_STYLE); + todo_wine_if(todo) ok(new_style == expected_style, "expected new style %#x, got %#x\n", + expected_style, new_style); + + SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0); + DestroyWindow(hwnd); + } + + UnregisterClassA(cls.lpszClassName, cls.hInstance); +} + static void test_ShowWindow(void) { HWND hwnd; @@ -9355,6 +9452,7 @@ START_TEST(win) test_redrawnow(); test_csparentdc(); test_SetWindowLong(); + test_set_window_style(); test_ShowWindow(); test_gettext(); test_GetUpdateRect();
1
0
0
0
Piotr Caban : ntdll: Pass updated context inside dispatch.ContextRecord in call_stack_handlers.
by Alexandre Julliard
18 Aug '16
18 Aug '16
Module: wine Branch: master Commit: 4af2012729b7ad656fe240838697eeb2ce5c924e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4af2012729b7ad656fe240838…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 17 12:48:24 2016 +0200 ntdll: Pass updated context inside dispatch.ContextRecord in call_stack_handlers. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_x86_64.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 5633e0b..f5ecf80 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -2312,7 +2312,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex EXCEPTION_REGISTRATION_RECORD *teb_frame = NtCurrentTeb()->Tib.ExceptionList; UNWIND_HISTORY_TABLE table; DISPATCHER_CONTEXT dispatch; - CONTEXT context, new_context; + CONTEXT context; LDR_MODULE *module; NTSTATUS status; @@ -2322,8 +2322,6 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex dispatch.HistoryTable = &table; for (;;) { - new_context = context; - /* FIXME: should use the history table to make things faster */ dispatch.ImageBase = 0; @@ -2332,11 +2330,11 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex /* first look for PE exception information */ - if ((dispatch.FunctionEntry = lookup_function_info( context.Rip, &dispatch.ImageBase, &module ))) + if ((dispatch.FunctionEntry = lookup_function_info( dispatch.ControlPc, &dispatch.ImageBase, &module ))) { dispatch.LanguageHandler = RtlVirtualUnwind( UNW_FLAG_EHANDLER, dispatch.ImageBase, - context.Rip, dispatch.FunctionEntry, - &new_context, &dispatch.HandlerData, + dispatch.ControlPc, dispatch.FunctionEntry, + &context, &dispatch.HandlerData, &dispatch.EstablisherFrame, NULL ); goto unwind_done; } @@ -2347,11 +2345,11 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex { BOOL got_info = FALSE; struct dwarf_eh_bases bases; - const struct dwarf_fde *fde = _Unwind_Find_FDE( (void *)(context.Rip - 1), &bases ); + const struct dwarf_fde *fde = _Unwind_Find_FDE( (void *)(dispatch.ControlPc - 1), &bases ); if (fde) { - status = dwarf_virtual_unwind( context.Rip, &dispatch.EstablisherFrame, &new_context, + status = dwarf_virtual_unwind( dispatch.ControlPc, &dispatch.EstablisherFrame, &context, fde, &bases, &dispatch.LanguageHandler, &dispatch.HandlerData ); if (status != STATUS_SUCCESS) return status; got_info = TRUE; @@ -2359,7 +2357,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex #ifdef HAVE_LIBUNWIND_H else { - status = libunwind_virtual_unwind( context.Rip, &got_info, &dispatch.EstablisherFrame, &new_context, + status = libunwind_virtual_unwind( dispatch.ControlPc, &got_info, &dispatch.EstablisherFrame, &context, &dispatch.LanguageHandler, &dispatch.HandlerData ); if (status != STATUS_SUCCESS) return status; } @@ -2378,11 +2376,9 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex } else WARN( "exception data not found in %s\n", debugstr_w(module->BaseDllName.Buffer) ); - /* no exception information, treat as a leaf function */ - - new_context.Rip = *(ULONG64 *)context.Rsp; - new_context.Rsp = context.Rsp + sizeof(ULONG64); - dispatch.EstablisherFrame = new_context.Rsp; + context.Rip = *(ULONG64 *)context.Rsp; + context.Rsp = context.Rsp + sizeof(ULONG64); + dispatch.EstablisherFrame = context.Rsp; dispatch.LanguageHandler = NULL; unwind_done: @@ -2426,10 +2422,10 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex } } /* hack: call wine handlers registered in the tib list */ - else while ((ULONG64)teb_frame < new_context.Rsp) + else while ((ULONG64)teb_frame < context.Rsp) { TRACE( "found wine frame %p rsp %lx handler %p\n", - teb_frame, new_context.Rsp, teb_frame->Handler ); + teb_frame, context.Rsp, teb_frame->Handler ); dispatch.EstablisherFrame = (ULONG64)teb_frame; switch (call_teb_handler( rec, orig_context, &dispatch, teb_frame )) { @@ -2459,8 +2455,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex teb_frame = teb_frame->Prev; } - if (new_context.Rsp == (ULONG64)NtCurrentTeb()->Tib.StackBase) break; - context = new_context; + if (context.Rsp == (ULONG64)NtCurrentTeb()->Tib.StackBase) break; } return STATUS_UNHANDLED_EXCEPTION; }
1
0
0
0
Piotr Caban : ntdll: Print fixme message in case of nested exception.
by Alexandre Julliard
18 Aug '16
18 Aug '16
Module: wine Branch: master Commit: 10fa7c6e45da1921d941cf03782751e498a9a690 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=10fa7c6e45da1921d941cf037…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 17 12:48:17 2016 +0200 ntdll: Print fixme message in case of nested exception. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_x86_64.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 062a40c..5633e0b 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -2250,6 +2250,15 @@ static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MO return func; } +static DWORD nested_exception_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame, + CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher ) +{ + if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) return ExceptionContinueSearch; + + /* FIXME */ + return ExceptionNestedException; +} + /********************************************************************** * call_handler * @@ -2258,12 +2267,18 @@ static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MO */ static DWORD call_handler( EXCEPTION_RECORD *rec, CONTEXT *context, DISPATCHER_CONTEXT *dispatch ) { + EXCEPTION_REGISTRATION_RECORD frame; DWORD res; + frame.Handler = nested_exception_handler; + __wine_push_frame( &frame ); + TRACE( "calling handler %p (rec=%p, frame=0x%lx context=%p, dispatch=%p)\n", dispatch->LanguageHandler, rec, dispatch->EstablisherFrame, dispatch->ContextRecord, dispatch ); res = dispatch->LanguageHandler( rec, dispatch->EstablisherFrame, context, dispatch ); TRACE( "handler at %p returned %u\n", dispatch->LanguageHandler, res ); + + __wine_pop_frame( &frame ); return res; } @@ -2392,7 +2407,9 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex *orig_context = *dispatch.ContextRecord; return STATUS_SUCCESS; case ExceptionContinueSearch: + break; case ExceptionNestedException: + FIXME( "nested exception\n" ); break; case ExceptionCollidedUnwind: { ULONG64 frame; @@ -2421,7 +2438,9 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex *orig_context = *dispatch.ContextRecord; return STATUS_SUCCESS; case ExceptionContinueSearch: + break; case ExceptionNestedException: + FIXME( "nested exception\n" ); break; case ExceptionCollidedUnwind: { ULONG64 frame;
1
0
0
0
Piotr Caban : ntdll: Add support for exceptions inside termination handlers in __C_specific_handler.
by Alexandre Julliard
18 Aug '16
18 Aug '16
Module: wine Branch: master Commit: b23de3cd4a2c0ab0fd3f54369a2786e008c79539 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b23de3cd4a2c0ab0fd3f54369…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 17 12:48:13 2016 +0200 ntdll: Add support for exceptions inside termination handlers in __C_specific_handler. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_x86_64.c | 16 ++++----- dlls/ntdll/tests/exception.c | 83 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 8 deletions(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index e50c8ed..062a40c 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -3787,7 +3787,6 @@ void WINAPI _local_unwind( void *frame, void *target_ip ) RtlUnwindEx( frame, target_ip, NULL, NULL, &context, NULL ); } - /******************************************************************* * __C_specific_handler (NTDLL.@) */ @@ -3804,10 +3803,10 @@ EXCEPTION_DISPOSITION WINAPI __C_specific_handler( EXCEPTION_RECORD *rec, if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) { - for (i = 0; i < table->Count; i++) + for (i = dispatch->ScopeIndex; i < table->Count; i++) { - if (context->Rip >= dispatch->ImageBase + table->ScopeRecord[i].BeginAddress && - context->Rip < dispatch->ImageBase + table->ScopeRecord[i].EndAddress) + if (dispatch->ControlPc >= dispatch->ImageBase + table->ScopeRecord[i].BeginAddress && + dispatch->ControlPc < dispatch->ImageBase + table->ScopeRecord[i].EndAddress) { TERMINATION_HANDLER handler; @@ -3821,6 +3820,7 @@ EXCEPTION_DISPOSITION WINAPI __C_specific_handler( EXCEPTION_RECORD *rec, } handler = (TERMINATION_HANDLER)(dispatch->ImageBase + table->ScopeRecord[i].HandlerAddress); + dispatch->ScopeIndex = i+1; TRACE( "calling __finally %p frame %lx\n", handler, frame ); handler( 1, frame ); @@ -3829,10 +3829,10 @@ EXCEPTION_DISPOSITION WINAPI __C_specific_handler( EXCEPTION_RECORD *rec, return ExceptionContinueSearch; } - for (i = 0; i < table->Count; i++) + for (i = dispatch->ScopeIndex; i < table->Count; i++) { - if (context->Rip >= dispatch->ImageBase + table->ScopeRecord[i].BeginAddress && - context->Rip < dispatch->ImageBase + table->ScopeRecord[i].EndAddress) + if (dispatch->ControlPc >= dispatch->ImageBase + table->ScopeRecord[i].BeginAddress && + dispatch->ControlPc < dispatch->ImageBase + table->ScopeRecord[i].EndAddress) { if (!table->ScopeRecord[i].JumpTarget) continue; if (table->ScopeRecord[i].HandlerAddress != EXCEPTION_EXECUTE_HANDLER) @@ -3856,7 +3856,7 @@ EXCEPTION_DISPOSITION WINAPI __C_specific_handler( EXCEPTION_RECORD *rec, } TRACE( "unwinding to target %lx\n", dispatch->ImageBase + table->ScopeRecord[i].JumpTarget ); RtlUnwindEx( (void *)frame, (char *)dispatch->ImageBase + table->ScopeRecord[i].JumpTarget, - rec, 0, context, dispatch->HistoryTable ); + rec, 0, dispatch->ContextRecord, dispatch->HistoryTable ); } } return ExceptionContinueSearch; diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index a086436..f1bfee6 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -53,10 +53,37 @@ static NTSTATUS (WINAPI *pNtSetInformationProcess)(HANDLE, PROCESSINFOCLASS, PV static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); #if defined(__x86_64__) +typedef struct +{ + ULONG Count; + struct + { + ULONG BeginAddress; + ULONG EndAddress; + ULONG HandlerAddress; + ULONG JumpTarget; + } ScopeRecord[1]; +} SCOPE_TABLE; + +typedef struct +{ + ULONG64 ControlPc; + ULONG64 ImageBase; + PRUNTIME_FUNCTION FunctionEntry; + ULONG64 EstablisherFrame; + ULONG64 TargetIp; + PCONTEXT ContextRecord; + void* /*PEXCEPTION_ROUTINE*/ LanguageHandler; + PVOID HandlerData; + PUNWIND_HISTORY_TABLE HistoryTable; + ULONG ScopeIndex; +} DISPATCHER_CONTEXT; + static BOOLEAN (CDECL *pRtlAddFunctionTable)(RUNTIME_FUNCTION*, DWORD, DWORD64); static BOOLEAN (CDECL *pRtlDeleteFunctionTable)(RUNTIME_FUNCTION*); static BOOLEAN (CDECL *pRtlInstallFunctionTableCallback)(DWORD64, DWORD64, DWORD, PGET_RUNTIME_FUNCTION_CALLBACK, PVOID, PCWSTR); static PRUNTIME_FUNCTION (WINAPI *pRtlLookupFunctionEntry)(ULONG64, ULONG64*, UNWIND_HISTORY_TABLE*); +static EXCEPTION_DISPOSITION (WINAPI *p__C_specific_handler)(EXCEPTION_RECORD*, ULONG64, CONTEXT*, DISPATCHER_CONTEXT*); #endif #ifdef __i386__ @@ -1747,6 +1774,59 @@ static void test_dynamic_unwind(void) } +static int termination_handler_called; +static void WINAPI termination_handler(ULONG flags, ULONG64 frame) +{ + termination_handler_called++; + + ok(flags == 1 || broken(flags == 0x401), "flags = %x\n", flags); + ok(frame == 0x1234, "frame = %p\n", (void*)frame); +} + +static void test___C_specific_handler(void) +{ + DISPATCHER_CONTEXT dispatch; + EXCEPTION_RECORD rec; + CONTEXT context; + ULONG64 frame; + EXCEPTION_DISPOSITION ret; + SCOPE_TABLE scope_table; + + if (!p__C_specific_handler) + { + win_skip("__C_specific_handler not available\n"); + return; + } + + memset(&rec, 0, sizeof(rec)); + rec.ExceptionFlags = 2; /* EH_UNWINDING */ + frame = 0x1234; + memset(&dispatch, 0, sizeof(dispatch)); + dispatch.ImageBase = (ULONG_PTR)GetModuleHandleA(NULL); + dispatch.ControlPc = dispatch.ImageBase + 0x200; + dispatch.HandlerData = &scope_table; + dispatch.ContextRecord = &context; + scope_table.Count = 1; + scope_table.ScopeRecord[0].BeginAddress = 0x200; + scope_table.ScopeRecord[0].EndAddress = 0x400; + scope_table.ScopeRecord[0].HandlerAddress = (ULONG_PTR)termination_handler-dispatch.ImageBase; + scope_table.ScopeRecord[0].JumpTarget = 0; + memset(&context, 0, sizeof(context)); + + termination_handler_called = 0; + ret = p__C_specific_handler(&rec, frame, &context, &dispatch); + ok(ret == ExceptionContinueSearch, "__C_specific_handler returned %x\n", ret); + ok(termination_handler_called == 1, "termination_handler_called = %d\n", + termination_handler_called); + ok(dispatch.ScopeIndex == 1, "dispatch.ScopeIndex = %d\n", dispatch.ScopeIndex); + + ret = p__C_specific_handler(&rec, frame, &context, &dispatch); + ok(ret == ExceptionContinueSearch, "__C_specific_handler returned %x\n", ret); + ok(termination_handler_called == 1, "termination_handler_called = %d\n", + termination_handler_called); + ok(dispatch.ScopeIndex == 1, "dispatch.ScopeIndex = %d\n", dispatch.ScopeIndex); +} + #endif /* __x86_64__ */ #if defined(__i386__) || defined(__x86_64__) @@ -2267,6 +2347,8 @@ START_TEST(exception) "RtlInstallFunctionTableCallback" ); pRtlLookupFunctionEntry = (void *)GetProcAddress( hntdll, "RtlLookupFunctionEntry" ); + p__C_specific_handler = (void *)GetProcAddress( hntdll, + "__C_specific_handler" ); test_debug_registers(); test_outputdebugstring(1, FALSE); @@ -2275,6 +2357,7 @@ START_TEST(exception) test_breakpoint(1); test_vectored_continue_handler(); test_virtual_unwind(); + test___C_specific_handler(); if (pRtlAddFunctionTable && pRtlDeleteFunctionTable && pRtlInstallFunctionTableCallback && pRtlLookupFunctionEntry) test_dynamic_unwind();
1
0
0
0
Piotr Caban : ntdll: Call exception handler with correct context.
by Alexandre Julliard
18 Aug '16
18 Aug '16
Module: wine Branch: master Commit: 7c060d0061596c4370c4ccaa26c74b779783f14b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7c060d0061596c4370c4ccaa2…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 17 12:48:10 2016 +0200 ntdll: Call exception handler with correct context. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_x86_64.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index e54f162..e50c8ed 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -2256,13 +2256,13 @@ static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MO * Call a single exception handler. * FIXME: Handle nested exceptions. */ -static DWORD call_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch ) +static DWORD call_handler( EXCEPTION_RECORD *rec, CONTEXT *context, DISPATCHER_CONTEXT *dispatch ) { DWORD res; TRACE( "calling handler %p (rec=%p, frame=0x%lx context=%p, dispatch=%p)\n", dispatch->LanguageHandler, rec, dispatch->EstablisherFrame, dispatch->ContextRecord, dispatch ); - res = dispatch->LanguageHandler( rec, dispatch->EstablisherFrame, dispatch->ContextRecord, dispatch ); + res = dispatch->LanguageHandler( rec, dispatch->EstablisherFrame, context, dispatch ); TRACE( "handler at %p returned %u\n", dispatch->LanguageHandler, res ); return res; } @@ -2274,14 +2274,14 @@ static DWORD call_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch ) * Call a single exception handler from the TEB chain. * FIXME: Handle nested exceptions. */ -static DWORD call_teb_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch, +static DWORD call_teb_handler( EXCEPTION_RECORD *rec, CONTEXT *context, DISPATCHER_CONTEXT *dispatch, EXCEPTION_REGISTRATION_RECORD *teb_frame ) { DWORD res; TRACE( "calling TEB handler %p (rec=%p, frame=%p context=%p, dispatch=%p)\n", teb_frame->Handler, rec, teb_frame, dispatch->ContextRecord, dispatch ); - res = teb_frame->Handler( rec, teb_frame, dispatch->ContextRecord, (EXCEPTION_REGISTRATION_RECORD**)dispatch ); + res = teb_frame->Handler( rec, teb_frame, context, (EXCEPTION_REGISTRATION_RECORD**)dispatch ); TRACE( "handler at %p returned %u\n", teb_frame->Handler, res ); return res; } @@ -2385,7 +2385,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex if (dispatch.LanguageHandler) { - switch (call_handler( rec, &dispatch )) + switch (call_handler( rec, orig_context, &dispatch )) { case ExceptionContinueExecution: if (rec->ExceptionFlags & EH_NONCONTINUABLE) return STATUS_NONCONTINUABLE_EXCEPTION; @@ -2414,8 +2414,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex TRACE( "found wine frame %p rsp %lx handler %p\n", teb_frame, new_context.Rsp, teb_frame->Handler ); dispatch.EstablisherFrame = (ULONG64)teb_frame; - context = *orig_context; - switch (call_teb_handler( rec, &dispatch, teb_frame )) + switch (call_teb_handler( rec, orig_context, &dispatch, teb_frame )) { case ExceptionContinueExecution: if (rec->ExceptionFlags & EH_NONCONTINUABLE) return STATUS_NONCONTINUABLE_EXCEPTION;
1
0
0
0
Piotr Caban : ntdll: Add support for ExceptionCollidedUnwind return from exception handler.
by Alexandre Julliard
18 Aug '16
18 Aug '16
Module: wine Branch: master Commit: abebb8141264ee5e1b701f4e28f5275426ed0a0d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=abebb8141264ee5e1b701f4e2…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 17 12:48:05 2016 +0200 ntdll: Add support for ExceptionCollidedUnwind return from exception handler. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_x86_64.c | 99 +++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 79ca846..e54f162 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -2256,31 +2256,15 @@ static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MO * Call a single exception handler. * FIXME: Handle nested exceptions. */ -static NTSTATUS call_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch, CONTEXT *orig_context ) +static DWORD call_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch ) { DWORD res; - dispatch->ControlPc = dispatch->ContextRecord->Rip; - TRACE( "calling handler %p (rec=%p, frame=0x%lx context=%p, dispatch=%p)\n", dispatch->LanguageHandler, rec, dispatch->EstablisherFrame, dispatch->ContextRecord, dispatch ); res = dispatch->LanguageHandler( rec, dispatch->EstablisherFrame, dispatch->ContextRecord, dispatch ); TRACE( "handler at %p returned %u\n", dispatch->LanguageHandler, res ); - - switch (res) - { - case ExceptionContinueExecution: - if (rec->ExceptionFlags & EH_NONCONTINUABLE) return STATUS_NONCONTINUABLE_EXCEPTION; - *orig_context = *dispatch->ContextRecord; - return STATUS_SUCCESS; - case ExceptionContinueSearch: - break; - case ExceptionNestedException: - break; - default: - return STATUS_INVALID_DISPOSITION; - } - return STATUS_UNHANDLED_EXCEPTION; + return res; } @@ -2290,31 +2274,16 @@ static NTSTATUS call_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatc * Call a single exception handler from the TEB chain. * FIXME: Handle nested exceptions. */ -static NTSTATUS call_teb_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch, - EXCEPTION_REGISTRATION_RECORD *teb_frame, CONTEXT *orig_context ) +static DWORD call_teb_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch, + EXCEPTION_REGISTRATION_RECORD *teb_frame ) { - EXCEPTION_REGISTRATION_RECORD *dispatcher; DWORD res; - TRACE( "calling TEB handler %p (rec=%p, frame=%p context=%p, dispatcher=%p)\n", - teb_frame->Handler, rec, teb_frame, dispatch->ContextRecord, &dispatcher ); - res = teb_frame->Handler( rec, teb_frame, dispatch->ContextRecord, &dispatcher ); + TRACE( "calling TEB handler %p (rec=%p, frame=%p context=%p, dispatch=%p)\n", + teb_frame->Handler, rec, teb_frame, dispatch->ContextRecord, dispatch ); + res = teb_frame->Handler( rec, teb_frame, dispatch->ContextRecord, (EXCEPTION_REGISTRATION_RECORD**)dispatch ); TRACE( "handler at %p returned %u\n", teb_frame->Handler, res ); - - switch (res) - { - case ExceptionContinueExecution: - if (rec->ExceptionFlags & EH_NONCONTINUABLE) return STATUS_NONCONTINUABLE_EXCEPTION; - *orig_context = *dispatch->ContextRecord; - return STATUS_SUCCESS; - case ExceptionContinueSearch: - break; - case ExceptionNestedException: - break; - default: - return STATUS_INVALID_DISPOSITION; - } - return STATUS_UNHANDLED_EXCEPTION; + return res; } @@ -2336,7 +2305,6 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex dispatch.TargetIp = 0; dispatch.ContextRecord = &context; dispatch.HistoryTable = &table; - dispatch.ScopeIndex = 0; /* FIXME */ for (;;) { new_context = context; @@ -2344,6 +2312,8 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex /* FIXME: should use the history table to make things faster */ dispatch.ImageBase = 0; + dispatch.ControlPc = context.Rip; + dispatch.ScopeIndex = 0; /* first look for PE exception information */ @@ -2415,8 +2385,28 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex if (dispatch.LanguageHandler) { - status = call_handler( rec, &dispatch, orig_context ); - if (status != STATUS_UNHANDLED_EXCEPTION) return status; + switch (call_handler( rec, &dispatch )) + { + case ExceptionContinueExecution: + if (rec->ExceptionFlags & EH_NONCONTINUABLE) return STATUS_NONCONTINUABLE_EXCEPTION; + *orig_context = *dispatch.ContextRecord; + return STATUS_SUCCESS; + case ExceptionContinueSearch: + case ExceptionNestedException: + break; + case ExceptionCollidedUnwind: { + ULONG64 frame; + + context = *dispatch.ContextRecord; + dispatch.ContextRecord = &context; + RtlVirtualUnwind( UNW_FLAG_NHANDLER, dispatch.ImageBase, + dispatch.ControlPc, dispatch.FunctionEntry, + &context, NULL, &frame, NULL ); + goto unwind_done; + } + default: + return STATUS_INVALID_DISPOSITION; + } } /* hack: call wine handlers registered in the tib list */ else while ((ULONG64)teb_frame < new_context.Rsp) @@ -2425,8 +2415,29 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex teb_frame, new_context.Rsp, teb_frame->Handler ); dispatch.EstablisherFrame = (ULONG64)teb_frame; context = *orig_context; - status = call_teb_handler( rec, &dispatch, teb_frame, orig_context ); - if (status != STATUS_UNHANDLED_EXCEPTION) return status; + switch (call_teb_handler( rec, &dispatch, teb_frame )) + { + case ExceptionContinueExecution: + if (rec->ExceptionFlags & EH_NONCONTINUABLE) return STATUS_NONCONTINUABLE_EXCEPTION; + *orig_context = *dispatch.ContextRecord; + return STATUS_SUCCESS; + case ExceptionContinueSearch: + case ExceptionNestedException: + break; + case ExceptionCollidedUnwind: { + ULONG64 frame; + + context = *dispatch.ContextRecord; + dispatch.ContextRecord = &context; + RtlVirtualUnwind( UNW_FLAG_NHANDLER, dispatch.ImageBase, + dispatch.ControlPc, dispatch.FunctionEntry, + &context, NULL, &frame, NULL ); + teb_frame = teb_frame->Prev; + goto unwind_done; + } + default: + return STATUS_INVALID_DISPOSITION; + } teb_frame = teb_frame->Prev; }
1
0
0
0
Piotr Caban : ntdll: Add support for collided unwinds.
by Alexandre Julliard
18 Aug '16
18 Aug '16
Module: wine Branch: master Commit: 66567dbdf183d8a08453a3efb2fd87527ec0d9de URL:
http://source.winehq.org/git/wine.git/?a=commit;h=66567dbdf183d8a08453a3efb…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 17 12:48:00 2016 +0200 ntdll: Add support for collided unwinds. Based on work by Alexandre Julliard. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_x86_64.c | 90 +++++++++++++++++++++++++++++++++++++--------- include/wine/exception.h | 1 + 2 files changed, 75 insertions(+), 16 deletions(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 4c88536..79ca846 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -3376,35 +3376,69 @@ PVOID WINAPI RtlVirtualUnwind( ULONG type, ULONG64 base, ULONG64 pc, return (char *)base + handler_data->handler; } +struct unwind_exception_frame +{ + EXCEPTION_REGISTRATION_RECORD frame; + DISPATCHER_CONTEXT *dispatch; +}; + +/********************************************************************** + * unwind_exception_handler + * + * Handler for exceptions happening while calling an unwind handler. + */ +static DWORD unwind_exception_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame, + CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher ) +{ + struct unwind_exception_frame *unwind_frame = (struct unwind_exception_frame *)frame; + DISPATCHER_CONTEXT *dispatch = (DISPATCHER_CONTEXT *)dispatcher; + + /* copy the original dispatcher into the current one, except for the TargetIp */ + dispatch->ControlPc = unwind_frame->dispatch->ControlPc; + dispatch->ImageBase = unwind_frame->dispatch->ImageBase; + dispatch->FunctionEntry = unwind_frame->dispatch->FunctionEntry; + dispatch->EstablisherFrame = unwind_frame->dispatch->EstablisherFrame; + dispatch->ContextRecord = unwind_frame->dispatch->ContextRecord; + dispatch->LanguageHandler = unwind_frame->dispatch->LanguageHandler; + dispatch->HandlerData = unwind_frame->dispatch->HandlerData; + dispatch->HistoryTable = unwind_frame->dispatch->HistoryTable; + dispatch->ScopeIndex = unwind_frame->dispatch->ScopeIndex; + TRACE( "detected collided unwind\n" ); + return ExceptionCollidedUnwind; +} /********************************************************************** * call_unwind_handler * * Call a single unwind handler. - * FIXME: Handle nested exceptions. */ -static void call_unwind_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch ) +static DWORD call_unwind_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch ) { + struct unwind_exception_frame frame; DWORD res; - dispatch->ControlPc = dispatch->ContextRecord->Rip; + frame.frame.Handler = unwind_exception_handler; + frame.dispatch = dispatch; + __wine_push_frame( &frame.frame ); TRACE( "calling handler %p (rec=%p, frame=0x%lx context=%p, dispatch=%p)\n", dispatch->LanguageHandler, rec, dispatch->EstablisherFrame, dispatch->ContextRecord, dispatch ); res = dispatch->LanguageHandler( rec, dispatch->EstablisherFrame, dispatch->ContextRecord, dispatch ); TRACE( "handler %p returned %x\n", dispatch->LanguageHandler, res ); + __wine_pop_frame( &frame.frame ); + switch (res) { case ExceptionContinueSearch: - break; case ExceptionCollidedUnwind: - FIXME( "ExceptionCollidedUnwind not supported yet\n" ); break; default: raise_status( STATUS_INVALID_DISPOSITION, rec ); break; } + + return res; } @@ -3412,30 +3446,28 @@ static void call_unwind_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *disp * call_teb_unwind_handler * * Call a single unwind handler from the TEB chain. - * FIXME: Handle nested exceptions. */ -static void call_teb_unwind_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch, +static DWORD call_teb_unwind_handler( EXCEPTION_RECORD *rec, DISPATCHER_CONTEXT *dispatch, EXCEPTION_REGISTRATION_RECORD *teb_frame ) { - EXCEPTION_REGISTRATION_RECORD *dispatcher; DWORD res; - TRACE( "calling TEB handler %p (rec=%p, frame=%p context=%p, dispatcher=%p)\n", - teb_frame->Handler, rec, teb_frame, dispatch->ContextRecord, &dispatcher ); - res = teb_frame->Handler( rec, teb_frame, dispatch->ContextRecord, &dispatcher ); + TRACE( "calling TEB handler %p (rec=%p, frame=%p context=%p, dispatch=%p)\n", + teb_frame->Handler, rec, teb_frame, dispatch->ContextRecord, dispatch ); + res = teb_frame->Handler( rec, teb_frame, dispatch->ContextRecord, (EXCEPTION_REGISTRATION_RECORD**)dispatch ); TRACE( "handler at %p returned %u\n", teb_frame->Handler, res ); switch (res) { case ExceptionContinueSearch: - break; case ExceptionCollidedUnwind: - FIXME( "ExceptionCollidedUnwind not supported yet\n" ); break; default: raise_status( STATUS_INVALID_DISPOSITION, rec ); break; } + + return res; } @@ -3588,7 +3620,8 @@ void WINAPI RtlUnwindEx( PVOID end_frame, PVOID target_ip, EXCEPTION_RECORD *rec /* FIXME: should use the history table to make things faster */ dispatch.ImageBase = 0; - dispatch.ScopeIndex = 0; /* FIXME */ + dispatch.ScopeIndex = 0; + dispatch.ControlPc = context->Rip; /* first look for PE exception information */ @@ -3674,7 +3707,19 @@ void WINAPI RtlUnwindEx( PVOID end_frame, PVOID target_ip, EXCEPTION_RECORD *rec raise_status( STATUS_INVALID_UNWIND_TARGET, rec ); } if (dispatch.EstablisherFrame == (ULONG64)end_frame) rec->ExceptionFlags |= EH_TARGET_UNWIND; - call_unwind_handler( rec, &dispatch ); + if (call_unwind_handler( rec, &dispatch ) == ExceptionCollidedUnwind) + { + ULONG64 frame; + + *context = new_context = *dispatch.ContextRecord; + dispatch.ContextRecord = context; + RtlVirtualUnwind( UNW_FLAG_NHANDLER, dispatch.ImageBase, + dispatch.ControlPc, dispatch.FunctionEntry, + &new_context, NULL, &frame, NULL ); + rec->ExceptionFlags |= EH_COLLIDED_UNWIND; + goto unwind_done; + } + rec->ExceptionFlags &= ~EH_COLLIDED_UNWIND; } else /* hack: call builtin handlers registered in the tib list */ { @@ -3683,7 +3728,20 @@ void WINAPI RtlUnwindEx( PVOID end_frame, PVOID target_ip, EXCEPTION_RECORD *rec { TRACE( "found builtin frame %p handler %p\n", teb_frame, teb_frame->Handler ); dispatch.EstablisherFrame = (ULONG64)teb_frame; - call_teb_unwind_handler( rec, &dispatch, teb_frame ); + if (call_teb_unwind_handler( rec, &dispatch, teb_frame ) == ExceptionCollidedUnwind) + { + ULONG64 frame; + + teb_frame = __wine_pop_frame( teb_frame ); + + *context = new_context = *dispatch.ContextRecord; + dispatch.ContextRecord = context; + RtlVirtualUnwind( UNW_FLAG_NHANDLER, dispatch.ImageBase, + dispatch.ControlPc, dispatch.FunctionEntry, + &new_context, NULL, &frame, NULL ); + rec->ExceptionFlags |= EH_COLLIDED_UNWIND; + goto unwind_done; + } teb_frame = __wine_pop_frame( teb_frame ); } if ((ULONG64)teb_frame == (ULONG64)end_frame && (ULONG64)end_frame < new_context.Rsp) break; diff --git a/include/wine/exception.h b/include/wine/exception.h index 8b807c1..f275568 100644 --- a/include/wine/exception.h +++ b/include/wine/exception.h @@ -253,6 +253,7 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_get_frame(void) #define EH_STACK_INVALID 0x08 #define EH_NESTED_CALL 0x10 #define EH_TARGET_UNWIND 0x20 +#define EH_COLLIDED_UNWIND 0x40 /* Wine-specific exceptions codes */
1
0
0
0
Huw Davies : ntdll/tests: Dump the handle table on failure.
by Alexandre Julliard
17 Aug '16
17 Aug '16
Module: wine Branch: master Commit: cf22192b288dfc84991390684bcba6c3d75f6793 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=cf22192b288dfc84991390684…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Aug 17 13:45:18 2016 +0100 ntdll/tests: Dump the handle table on failure. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Sebastian Lackner <sebastian(a)fds-team.de> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/tests/info.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 19c7d66..ea1f3ef 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -521,7 +521,11 @@ static void test_query_handle(void) for (i = 0, found = FALSE; i < shi->Count && !found; i++) found = (shi->Handle[i].OwnerPid == GetCurrentProcessId()) && ((HANDLE)(ULONG_PTR)shi->Handle[i].HandleValue == EventHandle); - ok( found, "Expected to find event handle in handle list\n" ); + ok( found, "Expected to find event handle %p (pid %x) in handle list\n", EventHandle, GetCurrentProcessId() ); + + if (!found) + for (i = 0; i < shi->Count; i++) + trace( "%d: handle %x pid %x\n", i, shi->Handle[i].HandleValue, shi->Handle[i].OwnerPid ); CloseHandle(EventHandle);
1
0
0
0
John Sheu : kernel32/tests: Add thread tests for fiber-local storage.
by Alexandre Julliard
17 Aug '16
17 Aug '16
Module: wine Branch: master Commit: 4e8f43f42307e74ec4e093eb83cb345dd6507ac0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4e8f43f42307e74ec4e093eb8…
Author: John Sheu <sheu(a)google.com> Date: Tue Aug 2 15:55:44 2016 -0700 kernel32/tests: Add thread tests for fiber-local storage. Signed-off-by: John Sheu <sheu(a)google.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/thread.c | 225 ++++++++++++++++++++++++++++--------------- 1 file changed, 148 insertions(+), 77 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=4e8f43f42307e74ec4e09…
1
0
0
0
John Sheu : kernel32/tests: Add loader tests for fiber-local storage.
by Alexandre Julliard
17 Aug '16
17 Aug '16
Module: wine Branch: master Commit: ab11a5ae455400c4476fe4043a34aca6f56c307c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ab11a5ae455400c4476fe4043…
Author: John Sheu <sheu(a)google.com> Date: Tue Aug 2 15:55:43 2016 -0700 kernel32/tests: Add loader tests for fiber-local storage. Signed-off-by: John Sheu <sheu(a)google.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/loader.c | 111 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index 28449ac..4f72c3e 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c @@ -70,6 +70,10 @@ static PVOID (WINAPI *pResolveDelayLoadedAPI)(PVOID, PCIMAGE_DELAYLOAD_DESCRI PDELAYLOAD_FAILURE_DLL_CALLBACK, PVOID, PIMAGE_THUNK_DATA ThunkAddress,ULONG); static PVOID (WINAPI *pRtlImageDirectoryEntryToData)(HMODULE,BOOL,WORD,ULONG *); +static DWORD (WINAPI *pFlsAlloc)(PFLS_CALLBACK_FUNCTION); +static BOOL (WINAPI *pFlsSetValue)(DWORD, PVOID); +static PVOID (WINAPI *pFlsGetValue)(DWORD); +static BOOL (WINAPI *pFlsFree)(DWORD); static PVOID RVAToAddr(DWORD_PTR rva, HMODULE module) { @@ -1476,6 +1480,7 @@ static HANDLE attached_thread[MAX_COUNT]; static DWORD attached_thread_count; HANDLE stop_event, event, mutex, semaphore, loader_lock_event, peb_lock_event, heap_lock_event, ack_event; static int test_dll_phase, inside_loader_lock, inside_peb_lock, inside_heap_lock; +static LONG fls_callback_count; static DWORD WINAPI mutex_thread_proc(void *param) { @@ -1558,9 +1563,18 @@ static DWORD WINAPI noop_thread_proc(void *param) return 195; } +static VOID WINAPI fls_callback(PVOID lpFlsData) +{ + ok(lpFlsData == (void*) 0x31415, "lpFlsData is %p, expected %p\n", lpFlsData, (void*) 0x31415); + InterlockedIncrement(&fls_callback_count); +} + static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param) { static LONG noop_thread_started; + static DWORD fls_index = FLS_OUT_OF_INDEXES; + static int fls_count = 0; + static int thread_detach_count = 0; DWORD ret; ok(!inside_loader_lock, "inside_loader_lock should not be set\n"); @@ -1574,6 +1588,23 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param) ret = pRtlDllShutdownInProgress(); ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret); + /* Set up the FLS slot, if FLS is available */ + if (pFlsGetValue) + { + void* value; + BOOL bret; + ret = pFlsAlloc(&fls_callback); + ok(ret != FLS_OUT_OF_INDEXES, "FlsAlloc returned %d\n", ret); + fls_index = ret; + SetLastError(0xdeadbeef); + value = pFlsGetValue(fls_index); + ok(!value, "FlsGetValue returned %p, expected NULL\n", value); + ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError()); + bret = pFlsSetValue(fls_index, (void*) 0x31415); + ok(bret, "FlsSetValue failed\n"); + fls_count++; + } + break; case DLL_PROCESS_DETACH: { @@ -1627,6 +1658,43 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param) ok(!ret || broken(ret) /* before Vista */, "RtlDllShutdownInProgress returned %d\n", ret); } + /* In the case that the process is terminating, FLS slots should still be accessible, but + * the callback should be already run for this thread and the contents already NULL. + * Note that this is broken for Win2k3, which runs the callbacks *after* the DLL entry + * point has already run. + */ + if (param && pFlsGetValue) + { + void* value; + SetLastError(0xdeadbeef); + value = pFlsGetValue(fls_index); + todo_wine + { + ok(broken(value == (void*) 0x31415) || /* Win2k3 */ + value == NULL, "FlsGetValue returned %p, expected NULL\n", value); + } + ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError()); + todo_wine + { + ok(broken(fls_callback_count == thread_detach_count) || /* Win2k3 */ + fls_callback_count == thread_detach_count + 1, + "wrong FLS callback count %d, expected %d\n", fls_callback_count, thread_detach_count + 1); + } + } + if (pFlsFree) + { + BOOL ret; + /* Call FlsFree now and run the remaining callbacks from uncleanly terminated threads */ + ret = pFlsFree(fls_index); + ok(ret, "FlsFree failed with error %u\n", GetLastError()); + fls_index = FLS_OUT_OF_INDEXES; + todo_wine + { + ok(fls_callback_count == fls_count, + "wrong FLS callback count %d, expected %d\n", fls_callback_count, fls_count); + } + } + ok(attached_thread_count >= 2, "attached thread count should be >= 2\n"); for (i = 0; i < attached_thread_count; i++) @@ -1797,9 +1865,26 @@ todo_wine 0, TRUE, DUPLICATE_SAME_ACCESS); attached_thread_count++; } + + /* Make sure the FLS slot is empty, if FLS is available */ + if (pFlsGetValue) + { + void* value; + BOOL ret; + SetLastError(0xdeadbeef); + value = pFlsGetValue(fls_index); + ok(!value, "FlsGetValue returned %p, expected NULL\n", value); + todo_wine + ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError()); + ret = pFlsSetValue(fls_index, (void*) 0x31415); + ok(ret, "FlsSetValue failed\n"); + fls_count++; + } + break; case DLL_THREAD_DETACH: trace("dll: %p, DLL_THREAD_DETACH, %p\n", hinst, param); + thread_detach_count++; ret = pRtlDllShutdownInProgress(); /* win7 doesn't allow creating a thread during process shutdown but @@ -1811,6 +1896,23 @@ todo_wine else ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret); + /* FLS data should already be destroyed, if FLS is available. + * Note that this is broken for Win2k3, which runs the callbacks *after* the DLL entry + * point has already run. + */ + if (pFlsGetValue && fls_index != FLS_OUT_OF_INDEXES) + { + void* value; + SetLastError(0xdeadbeef); + value = pFlsGetValue(fls_index); + todo_wine + { + ok(broken(value == (void*) 0x31415) || /* Win2k3 */ + !value, "FlsGetValue returned %p, expected NULL\n", value); + } + ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError()); + } + break; default: trace("dll: %p, %d, %p\n", hinst, reason, param); @@ -2909,10 +3011,11 @@ START_TEST(loader) { int argc; char **argv; - HANDLE ntdll, mapping; + HANDLE ntdll, mapping, kernel32; SYSTEM_INFO si; ntdll = GetModuleHandleA("ntdll.dll"); + kernel32 = GetModuleHandleA("kernel32.dll"); pNtCreateSection = (void *)GetProcAddress(ntdll, "NtCreateSection"); pNtQuerySection = (void *)GetProcAddress(ntdll, "NtQuerySection"); pNtMapViewOfSection = (void *)GetProcAddress(ntdll, "NtMapViewOfSection"); @@ -2929,7 +3032,11 @@ START_TEST(loader) pRtlAcquirePebLock = (void *)GetProcAddress(ntdll, "RtlAcquirePebLock"); pRtlReleasePebLock = (void *)GetProcAddress(ntdll, "RtlReleasePebLock"); pRtlImageDirectoryEntryToData = (void *)GetProcAddress(ntdll, "RtlImageDirectoryEntryToData"); - pResolveDelayLoadedAPI = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "ResolveDelayLoadedAPI"); + pFlsAlloc = (void *)GetProcAddress(kernel32, "FlsAlloc"); + pFlsSetValue = (void *)GetProcAddress(kernel32, "FlsSetValue"); + pFlsGetValue = (void *)GetProcAddress(kernel32, "FlsGetValue"); + pFlsFree = (void *)GetProcAddress(kernel32, "FlsFree"); + pResolveDelayLoadedAPI = (void *)GetProcAddress(kernel32, "ResolveDelayLoadedAPI"); GetSystemInfo( &si ); page_size = si.dwPageSize;
1
0
0
0
← Newer
1
...
32
33
34
35
36
37
38
...
78
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Results per page:
10
25
50
100
200