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
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
April 2014
----- 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
500 discussions
Start a n
N
ew thread
Stefan Dösinger : ddraw: SetPrivateData(..., data = NULL, ...) is not valid.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: ee57e19b40ec60aa4481ca2e313736f4f6ed5d50 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ee57e19b40ec60aa4481ca2e3…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon Apr 7 22:27:32 2014 +0200 ddraw: SetPrivateData(..., data = NULL, ...) is not valid. --- dlls/ddraw/surface.c | 6 ++++++ dlls/ddraw/tests/ddraw4.c | 9 +++++++++ dlls/ddraw/tests/ddraw7.c | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 5cfec01..5717956 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -2254,6 +2254,12 @@ static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface, TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n", iface, debugstr_guid(tag), data, size, flags); + if (!data) + { + WARN("data is NULL, returning DDERR_INVALIDPARAMS.\n"); + return DDERR_INVALIDPARAMS; + } + wined3d_mutex_lock(); hr = wined3d_private_store_set_private_data(&surface->private_store, tag, data, size, flags); wined3d_mutex_unlock(); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 716dc43..be965dc 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -6103,6 +6103,15 @@ static void test_private_data(void) hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + /* NULL pointers are not valid, but don't cause a crash. */ + hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, + sizeof(IUnknown *), DDSPD_IUNKNOWNPOINTER); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + /* DDSPD_IUNKNOWNPOINTER needs sizeof(IUnknown *) bytes of data. */ hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw, 0, DDSPD_IUNKNOWNPOINTER); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 31d552d..940d28b 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -5958,6 +5958,15 @@ static void test_private_data(void) hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + /* NULL pointers are not valid, but don't cause a crash. */ + hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, + sizeof(IUnknown *), DDSPD_IUNKNOWNPOINTER); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + /* DDSPD_IUNKNOWNPOINTER needs sizeof(IUnknown *) bytes of data. */ hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw, 0, DDSPD_IUNKNOWNPOINTER);
1
0
0
0
Stefan Dösinger : dxgi/tests: Add private data tests.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 7983d9974bcc451d1081136670bb8563bea74d8c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7983d9974bcc451d108113667…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon Apr 7 22:27:31 2014 +0200 dxgi/tests: Add private data tests. --- dlls/dxgi/tests/device.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index 84567a1..70cf3be 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -23,6 +23,12 @@ static HRESULT (WINAPI *pCreateDXGIFactory1)(REFIID iid, void **factory); +static ULONG get_refcount(IUnknown *iface) +{ + IUnknown_AddRef(iface); + return IUnknown_Release(iface); +} + static IDXGIDevice *create_device(void) { IDXGIDevice *dxgi_device; @@ -578,6 +584,142 @@ static void test_create_factory(void) IUnknown_Release(iface); } +static void test_private_data(void) +{ + ULONG refcount, expected_refcount; + IDXGIDevice *device; + HRESULT hr; + IDXGIDevice *test_object; + IUnknown *ptr; + static const DWORD data[] = {1, 2, 3, 4}; + UINT size; + static const GUID dxgi_private_data_test_guid = + { + 0xfdb37466, + 0x428f, + 0x4edf, + {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc} + }; + static const GUID dxgi_private_data_test_guid2 = + { + 0x2e5afac2, + 0x87b5, + 0x4c10, + {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b} + }; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + test_object = create_device(); + + /* SetPrivateData with a pointer of NULL has the purpose of FreePrivateData in previous + * d3d versions. A successful clear returns S_OK. A redundant clear S_FALSE. Setting a + * NULL interface is not considered a clear but as setting an interface pointer that + * happens to be NULL. */ + hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 0, NULL); + todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr); + hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL); + todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr); + + hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + size = sizeof(ptr) * 2; + ptr = (IUnknown *)0xdeadbeef; + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, &ptr); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + todo_wine ok(!ptr, "Got unexpected pointer %p.\n", ptr); + todo_wine ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size); + + refcount = get_refcount((IUnknown *)test_object); + hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, + (IUnknown *)test_object); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + expected_refcount = refcount + 1; + refcount = get_refcount((IUnknown *)test_object); + todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, + (IUnknown *)test_object); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + refcount = get_refcount((IUnknown *)test_object); + todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + + hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + expected_refcount--; + refcount = get_refcount((IUnknown *)test_object); + ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + + hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, + (IUnknown *)test_object); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + size = sizeof(data); + hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, size, data); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + refcount = get_refcount((IUnknown *)test_object); + ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL); + todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr); + + hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, + (IUnknown *)test_object); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + expected_refcount++; + size = 2 * sizeof(ptr); + ptr = NULL; + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, &ptr); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + todo_wine ok(size == sizeof(test_object), "Got unexpected size %u.\n", size); + expected_refcount++; + refcount = get_refcount((IUnknown *)test_object); + todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + if (ptr) + IUnknown_Release(ptr); + expected_refcount--; + + ptr = (IUnknown *)0xdeadbeef; + size = 1; + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size); + size = 2 * sizeof(ptr); + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size); + refcount = get_refcount((IUnknown *)test_object); + todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + + size = 1; + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, &ptr); + todo_wine ok(hr == DXGI_ERROR_MORE_DATA, "Got unexpected hr %#x.\n", hr); + todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size); + ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr); + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid2, NULL, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + size = 0xdeadbabe; + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid2, &size, &ptr); + todo_wine ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + todo_wine ok(size == 0, "Got unexpected size %u.\n", size); + ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr); + hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, NULL, &ptr); + todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr); + + refcount = IDXGIDevice_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + refcount = IDXGIDevice_Release(test_object); + ok(!refcount, "Test object has %u references left.\n", refcount); +} + START_TEST(device) { pCreateDXGIFactory1 = (void *)GetProcAddress(GetModuleHandleA("dxgi.dll"), "CreateDXGIFactory1"); @@ -589,4 +731,5 @@ START_TEST(device) test_output(); test_createswapchain(); test_create_factory(); + test_private_data(); }
1
0
0
0
Stefan Dösinger : ddraw/tests: Nvidia has an off-by-one rectangle handling bug.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 24187d5397867ffffef46a59543021f19358cce5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=24187d5397867ffffef46a595…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon Apr 7 22:27:30 2014 +0200 ddraw/tests: Nvidia has an off-by-one rectangle handling bug. --- dlls/ddraw/tests/ddraw1.c | 18 +++++++++++++++++- dlls/ddraw/tests/ddraw2.c | 18 +++++++++++++++++- dlls/ddraw/tests/ddraw4.c | 18 +++++++++++++++++- dlls/ddraw/tests/ddraw7.c | 18 +++++++++++++++++- 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 857882a..c5caff3 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -556,6 +556,21 @@ static void test_clipper_blt(void) 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, }; + /* Nvidia on Windows seems to have an off-by-one error + * when processing source rectangles. Our left = 1 and + * right = 5 input reads from x = {1, 2, 3}. x = 4 is + * read as well, but only for the edge pixels on the + * output image. The bug happens on the y axis as well, + * but we only read one row there, and all source rows + * contain the same data. This bug is not dependent on + * the presence of a clipper. */ + static const D3DCOLOR expected1_broken[] = + { + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00ff0000, 0x00ff0000, + 0x00000000, 0x00000000, 0x0000ff00, 0x00ff0000, + }; static const D3DCOLOR expected2[] = { 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, @@ -669,7 +684,8 @@ static void test_clipper_blt(void) x = 80 * ((2 * j) + 1); y = 60 * ((2 * i) + 1); color = get_surface_color(dst_surface, x, y); - ok(compare_color(color, expected1[i * 4 + j], 1), + ok(compare_color(color, expected1[i * 4 + j], 1) + || broken(compare_color(color, expected1_broken[i * 4 + j], 1)), "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color); } } diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 36845fe..921abbd 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -504,6 +504,21 @@ static void test_clipper_blt(void) 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, }; + /* Nvidia on Windows seems to have an off-by-one error + * when processing source rectangles. Our left = 1 and + * right = 5 input reads from x = {1, 2, 3}. x = 4 is + * read as well, but only for the edge pixels on the + * output image. The bug happens on the y axis as well, + * but we only read one row there, and all source rows + * contain the same data. This bug is not dependent on + * the presence of a clipper. */ + static const D3DCOLOR expected1_broken[] = + { + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00ff0000, 0x00ff0000, + 0x00000000, 0x00000000, 0x0000ff00, 0x00ff0000, + }; static const D3DCOLOR expected2[] = { 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, @@ -617,7 +632,8 @@ static void test_clipper_blt(void) x = 80 * ((2 * j) + 1); y = 60 * ((2 * i) + 1); color = get_surface_color(dst_surface, x, y); - ok(compare_color(color, expected1[i * 4 + j], 1), + ok(compare_color(color, expected1[i * 4 + j], 1) + || broken(compare_color(color, expected1_broken[i * 4 + j], 1)), "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color); } } diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index bd2cf17..716dc43 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -696,6 +696,21 @@ static void test_clipper_blt(void) 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, }; + /* Nvidia on Windows seems to have an off-by-one error + * when processing source rectangles. Our left = 1 and + * right = 5 input reads from x = {1, 2, 3}. x = 4 is + * read as well, but only for the edge pixels on the + * output image. The bug happens on the y axis as well, + * but we only read one row there, and all source rows + * contain the same data. This bug is not dependent on + * the presence of a clipper. */ + static const D3DCOLOR expected1_broken[] = + { + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00ff0000, 0x00ff0000, + 0x00000000, 0x00000000, 0x0000ff00, 0x00ff0000, + }; static const D3DCOLOR expected2[] = { 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, @@ -809,7 +824,8 @@ static void test_clipper_blt(void) x = 80 * ((2 * j) + 1); y = 60 * ((2 * i) + 1); color = get_surface_color(dst_surface, x, y); - ok(compare_color(color, expected1[i * 4 + j], 1), + ok(compare_color(color, expected1[i * 4 + j], 1) + || broken(compare_color(color, expected1_broken[i * 4 + j], 1)), "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color); } } diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 8aab791..31d552d 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -670,6 +670,21 @@ static void test_clipper_blt(void) 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff, }; + /* Nvidia on Windows seems to have an off-by-one error + * when processing source rectangles. Our left = 1 and + * right = 5 input reads from x = {1, 2, 3}. x = 4 is + * read as well, but only for the edge pixels on the + * output image. The bug happens on the y axis as well, + * but we only read one row there, and all source rows + * contain the same data. This bug is not dependent on + * the presence of a clipper. */ + static const D3DCOLOR expected1_broken[] = + { + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00ff0000, 0x00ff0000, + 0x00000000, 0x00000000, 0x0000ff00, 0x00ff0000, + }; static const D3DCOLOR expected2[] = { 0x000000ff, 0x000000ff, 0x00000000, 0x00000000, @@ -783,7 +798,8 @@ static void test_clipper_blt(void) x = 80 * ((2 * j) + 1); y = 60 * ((2 * i) + 1); color = get_surface_color(dst_surface, x, y); - ok(compare_color(color, expected1[i * 4 + j], 1), + ok(compare_color(color, expected1[i * 4 + j], 1) + || broken(compare_color(color, expected1_broken[i * 4 + j], 1)), "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color); } }
1
0
0
0
Stefan Dösinger : d3d8/tests: Test locking of mipmap textures.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 2bf09a153866300ac18a38f84be6bd75e110e5d1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2bf09a153866300ac18a38f84…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon Apr 7 22:27:29 2014 +0200 d3d8/tests: Test locking of mipmap textures. --- dlls/d3d8/tests/device.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 37621bf..8d5403c 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -6101,6 +6101,77 @@ static void test_resource_type(void) DestroyWindow(window); } +static void test_mipmap_lock(void) +{ + IDirect3DDevice8 *device; + IDirect3DSurface8 *surface, *surface2, *surface_dst, *surface_dst2; + IDirect3DTexture8 *texture, *texture_dst; + IDirect3D8 *d3d; + ULONG refcount; + HWND window; + HRESULT hr; + D3DLOCKED_RECT locked_rect; + + window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW, + 0, 0, 640, 480, NULL, NULL, NULL, NULL); + d3d = Direct3DCreate8(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d, window, window, TRUE))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D8_Release(d3d); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice8_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8, + D3DPOOL_DEFAULT, &texture_dst); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = IDirect3DTexture8_GetSurfaceLevel(texture_dst, 0, &surface_dst); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + hr = IDirect3DTexture8_GetSurfaceLevel(texture_dst, 1, &surface_dst2); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + + hr = IDirect3DDevice8_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8, + D3DPOOL_SYSTEMMEM, &texture); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &surface); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + hr = IDirect3DTexture8_GetSurfaceLevel(texture, 1, &surface2); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + + hr = IDirect3DSurface8_LockRect(surface, &locked_rect, NULL, 0); + ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr); + hr = IDirect3DSurface8_LockRect(surface2, &locked_rect, NULL, 0); + ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr); + hr = IDirect3DSurface8_UnlockRect(surface); + ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr); + + hr = IDirect3DDevice8_CopyRects(device, surface, NULL, 0, surface_dst, NULL); + ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr); + hr = IDirect3DDevice8_CopyRects(device, surface2, NULL, 0, surface_dst2, NULL); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + + /* Apparently there's no validation on the container. */ + hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)texture, + (IDirect3DBaseTexture8 *)texture_dst); + ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr); + + hr = IDirect3DSurface8_UnlockRect(surface2); + ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr); + + IDirect3DSurface8_Release(surface_dst2); + IDirect3DSurface8_Release(surface_dst); + IDirect3DSurface8_Release(surface2); + IDirect3DSurface8_Release(surface); + IDirect3DTexture8_Release(texture_dst); + IDirect3DTexture8_Release(texture); + + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + IDirect3D8_Release(d3d); + DestroyWindow(window); +} START_TEST(device) { HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" ); @@ -6184,6 +6255,7 @@ START_TEST(device) test_begin_end_state_block(); test_shader_constant_apply(); test_resource_type(); + test_mipmap_lock(); UnregisterClassA("d3d8_test_wc", GetModuleHandleA(NULL)); }
1
0
0
0
Stefan Dösinger : d3d9/tests: Test locking of mipmap textures.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 9177261a223293ee84791eb4897c75909389fe48 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9177261a223293ee84791eb48…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon Apr 7 22:27:28 2014 +0200 d3d9/tests: Test locking of mipmap textures. --- dlls/d3d9/tests/device.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 550c95e..9128292 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -7781,6 +7781,78 @@ static void test_resource_type(void) DestroyWindow(window); } +static void test_mipmap_lock(void) +{ + IDirect3DDevice9 *device; + IDirect3DSurface9 *surface, *surface2, *surface_dst, *surface_dst2; + IDirect3DTexture9 *texture, *texture_dst; + IDirect3D9 *d3d; + ULONG refcount; + HWND window; + HRESULT hr; + D3DLOCKED_RECT locked_rect; + + window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW, + 0, 0, 640, 480, NULL, NULL, NULL, NULL); + d3d = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d, window, window, TRUE))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D9_Release(d3d); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8, + D3DPOOL_DEFAULT, &texture_dst, NULL); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = IDirect3DTexture9_GetSurfaceLevel(texture_dst, 0, &surface_dst); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + hr = IDirect3DTexture9_GetSurfaceLevel(texture_dst, 1, &surface_dst2); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + + hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8, + D3DPOOL_SYSTEMMEM, &texture, NULL); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface2); + ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + + hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0); + ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr); + hr = IDirect3DSurface9_LockRect(surface2, &locked_rect, NULL, 0); + ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr); + hr = IDirect3DSurface9_UnlockRect(surface); + ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr); + + hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, surface_dst, NULL); + ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr); + hr = IDirect3DDevice9_UpdateSurface(device, surface2, NULL, surface_dst2, NULL); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + + /* Apparently there's no validation on the container. */ + hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture, + (IDirect3DBaseTexture9 *)texture_dst); + ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr); + + hr = IDirect3DSurface9_UnlockRect(surface2); + ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr); + + IDirect3DSurface9_Release(surface_dst2); + IDirect3DSurface9_Release(surface_dst); + IDirect3DSurface9_Release(surface2); + IDirect3DSurface9_Release(surface); + IDirect3DTexture9_Release(texture_dst); + IDirect3DTexture9_Release(texture); + + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + IDirect3D9_Release(d3d); + DestroyWindow(window); +} + START_TEST(device) { WNDCLASSA wc = {0}; @@ -7870,6 +7942,7 @@ START_TEST(device) test_shader_constant_apply(); test_vdecl_apply(); test_resource_type(); + test_mipmap_lock(); UnregisterClassA("d3d9_test_wc", GetModuleHandleA(NULL)); }
1
0
0
0
Sebastian Lackner : kernel32: Forward RtlInstallFunctionTableCallback to ntdll.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 7ba43b2fd1b7e62e12018f65056907e1303d18a3 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7ba43b2fd1b7e62e12018f650…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Sat Apr 5 02:01:38 2014 +0200 kernel32: Forward RtlInstallFunctionTableCallback to ntdll. --- dlls/kernel32/kernel32.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index f3e5c67..a6c6b29 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -1042,6 +1042,7 @@ @ stdcall -arch=x86_64 RtlCompareMemory(ptr ptr long) ntdll.RtlCompareMemory @ cdecl -arch=arm,x86_64 RtlDeleteFunctionTable(ptr) ntdll.RtlDeleteFunctionTable @ stdcall RtlFillMemory(ptr long long) ntdll.RtlFillMemory +@ cdecl -arch=x86_64 RtlInstallFunctionTableCallback(long long long ptr ptr ptr) ntdll.RtlInstallFunctionTableCallback @ stdcall -arch=arm,x86_64 RtlLookupFunctionEntry(long ptr ptr) ntdll.RtlLookupFunctionEntry @ stdcall RtlMoveMemory(ptr ptr long) ntdll.RtlMoveMemory @ stdcall -arch=x86_64,arm RtlPcToFileHeader(ptr ptr) ntdll.RtlPcToFileHeader
1
0
0
0
Sebastian Lackner : ntdll/tests: Add tests for dynamic unwind table.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 7821be356d4c3df1e532427d8241396725e974b1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7821be356d4c3df1e532427d8…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Mon Apr 7 01:14:20 2014 +0200 ntdll/tests: Add tests for dynamic unwind table. --- dlls/ntdll/tests/exception.c | 136 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index b4cbaf5..817a19c 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -51,6 +51,13 @@ static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, static NTSTATUS (WINAPI *pNtSetInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); +#if defined(__x86_64__) +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*); +#endif + #ifdef __i386__ #ifndef __WINE_WINTRNL_H @@ -1447,6 +1454,122 @@ static void test_virtual_unwind(void) call_virtual_unwind( i, &tests[i] ); } +static RUNTIME_FUNCTION* CALLBACK dynamic_unwind_callback( DWORD64 pc, PVOID context ) +{ + static const int code_offset = 1024; + static RUNTIME_FUNCTION runtime_func; + (*(DWORD *)context)++; + + runtime_func.BeginAddress = code_offset + 16; + runtime_func.EndAddress = code_offset + 32; + runtime_func.UnwindData = 0; + return &runtime_func; +} + +static void test_dynamic_unwind(void) +{ + static const int code_offset = 1024; + char buf[sizeof(RUNTIME_FUNCTION) + 4]; + RUNTIME_FUNCTION *runtime_func, *func; + ULONG_PTR table, base; + DWORD count; + + /* Test RtlAddFunctionTable with aligned RUNTIME_FUNCTION pointer */ + runtime_func = (RUNTIME_FUNCTION *)buf; + runtime_func->BeginAddress = code_offset; + runtime_func->EndAddress = code_offset + 16; + runtime_func->UnwindData = 0; + ok( pRtlAddFunctionTable( runtime_func, 1, (ULONG_PTR)code_mem ), + "RtlAddFunctionTable failed for runtime_func = %p (aligned)\n", runtime_func ); + + /* Lookup function outside of any function table */ + base = 0xdeadbeef; + func = pRtlLookupFunctionEntry( (ULONG_PTR)code_mem + code_offset + 16, &base, NULL ); + ok( func == NULL, + "RtlLookupFunctionEntry returned unexpected function, expected: NULL, got: %p\n", func ); + ok( base == 0xdeadbeef, + "RtlLookupFunctionEntry modified base address, expected: 0xdeadbeef, got: %lx\n", base ); + + /* Test with pointer inside of our function */ + base = 0xdeadbeef; + func = pRtlLookupFunctionEntry( (ULONG_PTR)code_mem + code_offset + 8, &base, NULL ); + ok( func == runtime_func, + "RtlLookupFunctionEntry didn't return expected function, expected: %p, got: %p\n", runtime_func, func ); + ok( base == (ULONG_PTR)code_mem, + "RtlLookupFunctionEntry returned invalid base, expected: %lx, got: %lx\n", (ULONG_PTR)code_mem, base ); + + /* Test RtlDeleteFunctionTable */ + ok( pRtlDeleteFunctionTable( runtime_func ), + "RtlDeleteFunctionTable failed for runtime_func = %p (aligned)\n", runtime_func ); + ok( !pRtlDeleteFunctionTable( runtime_func ), + "RtlDeleteFunctionTable returned success for nonexistent table runtime_func = %p\n", runtime_func ); + + /* Unaligned RUNTIME_FUNCTION pointer */ + runtime_func = (RUNTIME_FUNCTION *)((ULONG_PTR)buf | 0x3); + runtime_func->BeginAddress = code_offset; + runtime_func->EndAddress = code_offset + 16; + runtime_func->UnwindData = 0; + ok( pRtlAddFunctionTable( runtime_func, 1, (ULONG_PTR)code_mem ), + "RtlAddFunctionTable failed for runtime_func = %p (unaligned)\n", runtime_func ); + ok( pRtlDeleteFunctionTable( runtime_func ), + "RtlDeleteFunctionTable failed for runtime_func = %p (unaligned)\n", runtime_func ); + + /* Attempt to insert the same entry twice */ + runtime_func = (RUNTIME_FUNCTION *)buf; + runtime_func->BeginAddress = code_offset; + runtime_func->EndAddress = code_offset + 16; + runtime_func->UnwindData = 0; + ok( pRtlAddFunctionTable( runtime_func, 1, (ULONG_PTR)code_mem ), + "RtlAddFunctionTable failed for runtime_func = %p (first attempt)\n", runtime_func ); + ok( pRtlAddFunctionTable( runtime_func, 1, (ULONG_PTR)code_mem ), + "RtlAddFunctionTable failed for runtime_func = %p (second attempt)\n", runtime_func ); + ok( pRtlDeleteFunctionTable( runtime_func ), + "RtlDeleteFunctionTable failed for runtime_func = %p (first attempt)\n", runtime_func ); + ok( pRtlDeleteFunctionTable( runtime_func ), + "RtlDeleteFunctionTable failed for runtime_func = %p (second attempt)\n", runtime_func ); + ok( !pRtlDeleteFunctionTable( runtime_func ), + "RtlDeleteFunctionTable returned success for nonexistent table runtime_func = %p\n", runtime_func ); + + /* Test RtlInstallFunctionTableCallback with both low bits unset */ + table = (ULONG_PTR)code_mem; + ok( !pRtlInstallFunctionTableCallback( table, (ULONG_PTR)code_mem, code_offset + 32, &dynamic_unwind_callback, (PVOID*)&count, NULL ), + "RtlInstallFunctionTableCallback returned success for table = %lx\n", table ); + + /* Test RtlInstallFunctionTableCallback with both low bits set */ + table = (ULONG_PTR)code_mem | 0x3; + ok( pRtlInstallFunctionTableCallback( table, (ULONG_PTR)code_mem, code_offset + 32, &dynamic_unwind_callback, (PVOID*)&count, NULL ), + "RtlInstallFunctionTableCallback failed for table = %lx\n", table ); + + /* Lookup function outside of any function table */ + count = 0; + base = 0xdeadbeef; + func = pRtlLookupFunctionEntry( (ULONG_PTR)code_mem + code_offset + 32, &base, NULL ); + ok( func == NULL, + "RtlLookupFunctionEntry returned unexpected function, expected: NULL, got: %p\n", func ); + ok( base == 0xdeadbeef, + "RtlLookupFunctionEntry modified base address, expected: 0xdeadbeef, got: %lx\n", base ); + ok( !count, + "RtlLookupFunctionEntry issued %d unexpected calls to dynamic_unwind_callback\n", count ); + + /* Test with pointer inside of our function */ + count = 0; + base = 0xdeadbeef; + func = pRtlLookupFunctionEntry( (ULONG_PTR)code_mem + code_offset + 24, &base, NULL ); + ok( func != NULL && func->BeginAddress == code_offset + 16 && func->EndAddress == code_offset + 32, + "RtlLookupFunctionEntry didn't return expected function, got: %p\n", func ); + ok( base == (ULONG_PTR)code_mem, + "RtlLookupFunctionEntry returned invalid base, expected: %lx, got: %lx\n", (ULONG_PTR)code_mem, base ); + ok( count == 1, + "RtlLookupFunctionEntry issued %d calls to dynamic_unwind_callback, expected: 1\n", count ); + + /* Clean up again */ + ok( pRtlDeleteFunctionTable( (PRUNTIME_FUNCTION)table ), + "RtlDeleteFunctionTable failed for table = %p\n", (PVOID)table ); + ok( !pRtlDeleteFunctionTable( (PRUNTIME_FUNCTION)table ), + "RtlDeleteFunctionTable returned success for nonexistent table = %p\n", (PVOID)table ); + +} + #endif /* __x86_64__ */ START_TEST(exception) @@ -1534,9 +1657,22 @@ START_TEST(exception) test_dpe_exceptions(); #elif defined(__x86_64__) + pRtlAddFunctionTable = (void *)GetProcAddress( hntdll, + "RtlAddFunctionTable" ); + pRtlDeleteFunctionTable = (void *)GetProcAddress( hntdll, + "RtlDeleteFunctionTable" ); + pRtlInstallFunctionTableCallback = (void *)GetProcAddress( hntdll, + "RtlInstallFunctionTableCallback" ); + pRtlLookupFunctionEntry = (void *)GetProcAddress( hntdll, + "RtlLookupFunctionEntry" ); test_virtual_unwind(); + if (pRtlAddFunctionTable && pRtlDeleteFunctionTable && pRtlInstallFunctionTableCallback && pRtlLookupFunctionEntry) + test_dynamic_unwind(); + else + skip( "Dynamic unwind functions not found\n" ); + #endif VirtualFree(code_mem, 0, MEM_FREE);
1
0
0
0
Sebastian Lackner : ntdll: Implement RtlInstallFunctionTableCallback on x86_64.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 4d8edf7612a62e1d2234f310b060e03e920f540c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4d8edf7612a62e1d2234f310b…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Mon Apr 7 00:41:30 2014 +0200 ntdll: Implement RtlInstallFunctionTableCallback on x86_64. --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_x86_64.c | 48 +++++++++++++++++++++++++++++++++++++++++++- include/winnt.h | 3 +++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 0dd75a2..5bac269 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -689,6 +689,7 @@ # @ stub RtlInitializeStackTraceDataBase @ stub RtlInsertElementGenericTable # @ stub RtlInsertElementGenericTableAvl +@ cdecl -arch=x86_64 RtlInstallFunctionTableCallback(long long long ptr ptr wstr) @ stdcall RtlInt64ToUnicodeString(int64 long ptr) @ stdcall RtlIntegerToChar(long long long ptr) @ stdcall RtlIntegerToUnicodeString(long long ptr) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 8b4c0ee..dbef828 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -287,6 +287,10 @@ struct dynamic_unwind_entry /* lookup table */ RUNTIME_FUNCTION *table; DWORD table_size; + + /* user defined callback */ + PGET_RUNTIME_FUNCTION_CALLBACK callback; + PVOID context; }; static struct list dynamic_unwind_list = LIST_INIT(dynamic_unwind_list); @@ -1979,7 +1983,12 @@ static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MO if (pc >= entry->base && pc < entry->base + entry->size) { *base = entry->base; - func = find_function_info( pc, (HMODULE)entry->base, entry->table, entry->table_size ); + + /* use callback or lookup in function table */ + if (entry->callback) + func = entry->callback( pc, entry->context ); + else + func = find_function_info( pc, (HMODULE)entry->base, entry->table, entry->table_size ); break; } } @@ -2585,6 +2594,43 @@ BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, DWORD64 entry->size = table[count - 1].EndAddress; entry->table = table; entry->table_size = count * sizeof(RUNTIME_FUNCTION); + entry->callback = NULL; + entry->context = NULL; + + RtlEnterCriticalSection( &dynamic_unwind_section ); + list_add_tail( &dynamic_unwind_list, &entry->entry ); + RtlLeaveCriticalSection( &dynamic_unwind_section ); + + return TRUE; +} + + +/********************************************************************** + * RtlInstallFunctionTableCallback (NTDLL.@) + */ +BOOLEAN CDECL RtlInstallFunctionTableCallback( DWORD64 table, DWORD64 base, DWORD length, + PGET_RUNTIME_FUNCTION_CALLBACK callback, PVOID context, PCWSTR dll ) +{ + struct dynamic_unwind_entry *entry; + + TRACE( "%lx %lx %d %p %p %s\n", table, base, length, callback, context, wine_dbgstr_w(dll) ); + + /* NOTE: Windows doesn't check if the provided callback is a NULL pointer */ + + /* both low-order bits must be set */ + if ((table & 0x3) != 0x3) + return FALSE; + + entry = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*entry) ); + if (!entry) + return FALSE; + + entry->base = base; + entry->size = length; + entry->table = (RUNTIME_FUNCTION *)table; + entry->table_size = 0; + entry->callback = callback; + entry->context = context; RtlEnterCriticalSection( &dynamic_unwind_section ); list_add_tail( &dynamic_unwind_list, &entry->entry ); diff --git a/include/winnt.h b/include/winnt.h index 93fd70a..3f33c6b 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -1193,8 +1193,11 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS } DUMMYUNIONNAME2; } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS; +typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64,PVOID); + BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD64); BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*); +BOOLEAN CDECL RtlInstallFunctionTableCallback(DWORD64,DWORD64,DWORD,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR); PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD64,DWORD64*,UNWIND_HISTORY_TABLE*); PVOID WINAPI RtlVirtualUnwind(ULONG,ULONG64,ULONG64,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG64*,KNONVOLATILE_CONTEXT_POINTERS*);
1
0
0
0
Sebastian Lackner : ntdll: Implement RtlAddFunctionTable / RtlDeleteFunctionTable for x86_64.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: 98307b22fba5c0d757be15b9f355b29e97ab1d5c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=98307b22fba5c0d757be15b9f…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Mon Apr 7 00:22:07 2014 +0200 ntdll: Implement RtlAddFunctionTable / RtlDeleteFunctionTable for x86_64. --- dlls/ntdll/signal_x86_64.c | 84 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 0e72092..8b4c0ee 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -56,6 +56,7 @@ #include "winternl.h" #include "wine/library.h" #include "wine/exception.h" +#include "wine/list.h" #include "ntdll_misc.h" #include "wine/debug.h" @@ -271,6 +272,33 @@ typedef int (*wine_signal_handler)(unsigned int sig); static wine_signal_handler handlers[256]; +/*********************************************************************** + * Dynamic unwind table + */ + +struct dynamic_unwind_entry +{ + struct list entry; + + /* memory region which matches this entry */ + DWORD64 base; + DWORD size; + + /* lookup table */ + RUNTIME_FUNCTION *table; + DWORD table_size; +}; + +static struct list dynamic_unwind_list = LIST_INIT(dynamic_unwind_list); + +static RTL_CRITICAL_SECTION dynamic_unwind_section; +static RTL_CRITICAL_SECTION_DEBUG dynamic_unwind_debug = +{ + 0, 0, &dynamic_unwind_section, + { &dynamic_unwind_debug.ProcessLocksList, &dynamic_unwind_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": dynamic_unwind_section") } +}; +static RTL_CRITICAL_SECTION dynamic_unwind_section = { &dynamic_unwind_debug, -1, 0, 0, 0, 0 }; /*********************************************************************** * Definitions for Win32 unwind tables @@ -1927,6 +1955,7 @@ static RUNTIME_FUNCTION *find_function_info( ULONG64 pc, HMODULE module, static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MODULE **module ) { RUNTIME_FUNCTION *func = NULL; + struct dynamic_unwind_entry *entry; ULONG size; /* PE module or wine module */ @@ -1941,8 +1970,22 @@ static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MO } } else + { *module = NULL; + RtlEnterCriticalSection( &dynamic_unwind_section ); + LIST_FOR_EACH_ENTRY( entry, &dynamic_unwind_list, struct dynamic_unwind_entry, entry ) + { + if (pc >= entry->base && pc < entry->base + entry->size) + { + *base = entry->base; + func = find_function_info( pc, (HMODULE)entry->base, entry->table, entry->table_size ); + break; + } + } + RtlLeaveCriticalSection( &dynamic_unwind_section ); + } + return func; } @@ -2528,7 +2571,25 @@ void signal_init_process(void) */ BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, DWORD64 addr ) { - FIXME( "%p %u %lx: stub\n", table, count, addr ); + struct dynamic_unwind_entry *entry; + + TRACE( "%p %u %lx\n", table, count, addr ); + + /* NOTE: Windows doesn't check if table is aligned or a NULL pointer */ + + entry = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*entry) ); + if (!entry) + return FALSE; + + entry->base = addr; + entry->size = table[count - 1].EndAddress; + entry->table = table; + entry->table_size = count * sizeof(RUNTIME_FUNCTION); + + RtlEnterCriticalSection( &dynamic_unwind_section ); + list_add_tail( &dynamic_unwind_list, &entry->entry ); + RtlLeaveCriticalSection( &dynamic_unwind_section ); + return TRUE; } @@ -2538,7 +2599,26 @@ BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, DWORD64 */ BOOLEAN CDECL RtlDeleteFunctionTable( RUNTIME_FUNCTION *table ) { - FIXME( "%p: stub\n", table ); + struct dynamic_unwind_entry *entry, *to_free = NULL; + + TRACE( "%p\n", table ); + + RtlEnterCriticalSection( &dynamic_unwind_section ); + LIST_FOR_EACH_ENTRY( entry, &dynamic_unwind_list, struct dynamic_unwind_entry, entry ) + { + if (entry->table == table) + { + to_free = entry; + list_remove( &entry->entry ); + break; + } + } + RtlLeaveCriticalSection( &dynamic_unwind_section ); + + if (!to_free) + return FALSE; + + RtlFreeHeap( GetProcessHeap(), 0, to_free ); return TRUE; }
1
0
0
0
Sebastian Lackner : ntdll: Unify exception function lookup on x86_64.
by Alexandre Julliard
08 Apr '14
08 Apr '14
Module: wine Branch: master Commit: a71d1e389f7fffb66b93de3a9a9bbb568337623a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a71d1e389f7fffb66b93de3a9…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Fri Apr 4 10:11:56 2014 +0200 ntdll: Unify exception function lookup on x86_64. --- dlls/ntdll/signal_x86_64.c | 100 ++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index b28cb99..0e72092 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -1921,6 +1921,30 @@ static RUNTIME_FUNCTION *find_function_info( ULONG64 pc, HMODULE module, return NULL; } +/********************************************************************** + * lookup_function_info + */ +static RUNTIME_FUNCTION *lookup_function_info( ULONG64 pc, ULONG64 *base, LDR_MODULE **module ) +{ + RUNTIME_FUNCTION *func = NULL; + ULONG size; + + /* PE module or wine module */ + if (!LdrFindEntryForAddress( (void *)pc, module )) + { + *base = (ULONG64)(*module)->BaseAddress; + if ((func = RtlImageDirectoryEntryToData( (*module)->BaseAddress, TRUE, + IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size ))) + { + /* lookup in function table */ + func = find_function_info( pc, (*module)->BaseAddress, func, size ); + } + } + else + *module = NULL; + + return func; +} /********************************************************************** * call_handler @@ -2002,7 +2026,6 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex DISPATCHER_CONTEXT dispatch; CONTEXT context, new_context; LDR_MODULE *module; - DWORD size; NTSTATUS status; context = *orig_context; @@ -2016,31 +2039,17 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex /* FIXME: should use the history table to make things faster */ - module = NULL; dispatch.ImageBase = 0; /* first look for PE exception information */ - if (!LdrFindEntryForAddress( (void *)context.Rip, &module )) + if ((dispatch.FunctionEntry = lookup_function_info( context.Rip, &dispatch.ImageBase, &module ))) { - RUNTIME_FUNCTION *dir; - - dispatch.ImageBase = (ULONG64)module->BaseAddress; - if ((dir = RtlImageDirectoryEntryToData( module->BaseAddress, TRUE, - IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size ))) - { - if ((dispatch.FunctionEntry = find_function_info( context.Rip, module->BaseAddress, - dir, size ))) - { - dispatch.LanguageHandler = RtlVirtualUnwind( UNW_FLAG_EHANDLER, dispatch.ImageBase, - context.Rip, dispatch.FunctionEntry, - &new_context, &dispatch.HandlerData, - &dispatch.EstablisherFrame, NULL ); - goto unwind_done; - } - } - else if (!(module->Flags & LDR_WINE_INTERNAL)) - WARN( "exception data not found in %s\n", debugstr_w(module->BaseDllName.Buffer) ); + dispatch.LanguageHandler = RtlVirtualUnwind( UNW_FLAG_EHANDLER, dispatch.ImageBase, + context.Rip, dispatch.FunctionEntry, + &new_context, &dispatch.HandlerData, + &dispatch.EstablisherFrame, NULL ); + goto unwind_done; } /* then look for host system exception information */ @@ -2064,6 +2073,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex goto unwind_done; } } + else WARN( "exception data not found in %s\n", debugstr_w(module->BaseDllName.Buffer) ); /* no exception information, treat as a leaf function */ @@ -2540,23 +2550,18 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG64 pc, ULONG64 *base, UNWI { LDR_MODULE *module; RUNTIME_FUNCTION *func; - ULONG size; /* FIXME: should use the history table to make things faster */ - if (LdrFindEntryForAddress( (void *)pc, &module )) + func = lookup_function_info( pc, base, &module ); + if (!func) { - WARN( "module not found for %lx\n", pc ); - return NULL; - } - if (!(func = RtlImageDirectoryEntryToData( module->BaseAddress, TRUE, - IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size ))) - { - WARN( "no exception table found in module %p pc %lx\n", module->BaseAddress, pc ); - return NULL; + if (module) + WARN( "no exception table found in module %p pc %lx\n", module->BaseAddress, pc ); + else + WARN( "module not found for %lx\n", pc ); } - func = find_function_info( pc, module->BaseAddress, func, size ); - if (func) *base = (ULONG64)module->BaseAddress; + return func; } @@ -2916,7 +2921,7 @@ void WINAPI RtlUnwindEx( PVOID end_frame, PVOID target_ip, EXCEPTION_RECORD *rec CONTEXT new_context; LDR_MODULE *module; NTSTATUS status; - DWORD i, size; + DWORD i; RtlCaptureContext( context ); new_context = *context; @@ -2956,32 +2961,18 @@ void WINAPI RtlUnwindEx( PVOID end_frame, PVOID target_ip, EXCEPTION_RECORD *rec { /* FIXME: should use the history table to make things faster */ - module = NULL; dispatch.ImageBase = 0; dispatch.ScopeIndex = 0; /* FIXME */ /* first look for PE exception information */ - if (!LdrFindEntryForAddress( (void *)context->Rip, &module )) + if ((dispatch.FunctionEntry = lookup_function_info( context->Rip, &dispatch.ImageBase, &module ))) { - RUNTIME_FUNCTION *dir; - - dispatch.ImageBase = (ULONG64)module->BaseAddress; - if ((dir = RtlImageDirectoryEntryToData( module->BaseAddress, TRUE, - IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size ))) - { - if ((dispatch.FunctionEntry = find_function_info( context->Rip, module->BaseAddress, - dir, size ))) - { - dispatch.LanguageHandler = RtlVirtualUnwind( UNW_FLAG_UHANDLER, dispatch.ImageBase, - context->Rip, dispatch.FunctionEntry, - &new_context, &dispatch.HandlerData, - &dispatch.EstablisherFrame, NULL ); - goto unwind_done; - } - } - else if (!(module->Flags & LDR_WINE_INTERNAL)) - WARN( "exception data not found in %s\n", debugstr_w(module->BaseDllName.Buffer) ); + dispatch.LanguageHandler = RtlVirtualUnwind( UNW_FLAG_UHANDLER, dispatch.ImageBase, + context->Rip, dispatch.FunctionEntry, + &new_context, &dispatch.HandlerData, + &dispatch.EstablisherFrame, NULL ); + goto unwind_done; } /* then look for host system exception information */ @@ -3005,6 +2996,7 @@ void WINAPI RtlUnwindEx( PVOID end_frame, PVOID target_ip, EXCEPTION_RECORD *rec goto unwind_done; } } + else WARN( "exception data not found in %s\n", debugstr_w(module->BaseDllName.Buffer) ); /* no exception information, treat as a leaf function */
1
0
0
0
← Newer
1
...
33
34
35
36
37
38
39
...
50
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
Results per page:
10
25
50
100
200