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
January 2006
----- 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
4 participants
617 discussions
Start a n
N
ew thread
Michael Kaufmann : gdi: Fixes for the isotropic mapping mode.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: 5c6301a5c948e87b714e09db4e771a3070e15b32 URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=5c6301a5c948e87b714e09d…
Author: Michael Kaufmann <hallo(a)michael-kaufmann.ch> Date: Tue Jan 31 12:56:57 2006 +0100 gdi: Fixes for the isotropic mapping mode. - Isotropic mapping mode: Adjust the viewport extension in SetWindowExtEx, handle negative extents. - Support the isotropic mapping mode in the enhanced metafile driver. - New tests. --- dlls/gdi/enhmetafile.c | 37 +++++++++++++++-- dlls/gdi/mapping.c | 24 +++++++---- dlls/gdi/tests/mapping.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 13 deletions(-) diff --git a/dlls/gdi/enhmetafile.c b/dlls/gdi/enhmetafile.c index c97e4ca..8725f9b 100644 --- a/dlls/gdi/enhmetafile.c +++ b/dlls/gdi/enhmetafile.c @@ -595,6 +595,33 @@ static void EMF_SetMapMode(HDC hdc, enum } } +/*********************************************************************** + * EMF_FixIsotropic + * + * Fix viewport extensions for isotropic mode. + */ + +static void EMF_FixIsotropic(HDC hdc, enum_emh_data *info) +{ + double xdim = fabs((double)info->vportExtX * GetDeviceCaps( hdc, HORZSIZE ) / + (GetDeviceCaps( hdc, HORZRES ) * info->wndExtX)); + double ydim = fabs((double)info->vportExtY * GetDeviceCaps( hdc, VERTSIZE ) / + (GetDeviceCaps( hdc, VERTRES ) * info->wndExtY)); + + if (xdim > ydim) + { + INT mincx = (info->vportExtX >= 0) ? 1 : -1; + info->vportExtX = floor(info->vportExtX * ydim / xdim + 0.5); + if (!info->vportExtX) info->vportExtX = mincx; + } + else + { + INT mincy = (info->vportExtY >= 0) ? 1 : -1; + info->vportExtY = floor(info->vportExtY * xdim / ydim + 0.5); + if (!info->vportExtY) info->vportExtY = mincy; + } +} + /***************************************************************************** * emr_produces_output * @@ -829,6 +856,8 @@ BOOL WINAPI PlayEnhMetaFileRecord( break; info->wndExtX = pSetWindowExtEx->szlExtent.cx; info->wndExtY = pSetWindowExtEx->szlExtent.cy; + if (info->mode == MM_ISOTROPIC) + EMF_FixIsotropic(hdc, info); TRACE("SetWindowExtEx: %d,%d\n",info->wndExtX,info->wndExtY); break; @@ -852,6 +881,8 @@ BOOL WINAPI PlayEnhMetaFileRecord( break; info->vportExtX = pSetViewportExtEx->szlExtent.cx; info->vportExtY = pSetViewportExtEx->szlExtent.cy; + if (info->mode == MM_ISOTROPIC) + EMF_FixIsotropic(hdc, info); TRACE("SetViewportExtEx: %d,%d\n",info->vportExtX,info->vportExtY); break; } @@ -1316,8 +1347,7 @@ BOOL WINAPI PlayEnhMetaFileRecord( if (info->vportExtX == 0) info->vportExtX = 1; if (info->vportExtY == 0) info->vportExtY = 1; if (info->mode == MM_ISOTROPIC) - FIXME("EMRSCALEVIEWPORTEXTEX MM_ISOTROPIC mapping\n"); - /* MAPPING_FixIsotropic( dc ); */ + EMF_FixIsotropic(hdc, info); TRACE("EMRSCALEVIEWPORTEXTEX %ld/%ld %ld/%ld\n", lpScaleViewportExtEx->xNum,lpScaleViewportExtEx->xDenom, @@ -1342,8 +1372,7 @@ BOOL WINAPI PlayEnhMetaFileRecord( if (info->wndExtX == 0) info->wndExtX = 1; if (info->wndExtY == 0) info->wndExtY = 1; if (info->mode == MM_ISOTROPIC) - FIXME("EMRSCALEWINDOWEXTEX MM_ISOTROPIC mapping\n"); - /* MAPPING_FixIsotropic( dc ); */ + EMF_FixIsotropic(hdc, info); TRACE("EMRSCALEWINDOWEXTEX %ld/%ld %ld/%ld\n", lpScaleWindowExtEx->xNum,lpScaleWindowExtEx->xDenom, diff --git a/dlls/gdi/mapping.c b/dlls/gdi/mapping.c index 507c789..7a1b947 100644 --- a/dlls/gdi/mapping.c +++ b/dlls/gdi/mapping.c @@ -33,19 +33,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdi); */ void MAPPING_FixIsotropic( DC * dc ) { - double xdim = (double)dc->vportExtX * GetDeviceCaps( dc->hSelf, HORZSIZE ) / - (GetDeviceCaps( dc->hSelf, HORZRES ) * dc->wndExtX); - double ydim = (double)dc->vportExtY * GetDeviceCaps( dc->hSelf, VERTSIZE ) / - (GetDeviceCaps( dc->hSelf, VERTRES ) * dc->wndExtY); + double xdim = fabs((double)dc->vportExtX * GetDeviceCaps( dc->hSelf, HORZSIZE ) / + (GetDeviceCaps( dc->hSelf, HORZRES ) * dc->wndExtX)); + double ydim = fabs((double)dc->vportExtY * GetDeviceCaps( dc->hSelf, VERTSIZE ) / + (GetDeviceCaps( dc->hSelf, VERTRES ) * dc->wndExtY)); + if (xdim > ydim) { - dc->vportExtX = floor(dc->vportExtX * fabs( ydim / xdim ) + 0.5); - if (!dc->vportExtX) dc->vportExtX = 1; + INT mincx = (dc->vportExtX >= 0) ? 1 : -1; + dc->vportExtX = floor(dc->vportExtX * ydim / xdim + 0.5); + if (!dc->vportExtX) dc->vportExtX = mincx; } else { - dc->vportExtY = floor(dc->vportExtY * fabs( xdim / ydim ) + 0.5); - if (!dc->vportExtY) dc->vportExtY = 1; + INT mincy = (dc->vportExtY >= 0) ? 1 : -1; + dc->vportExtY = floor(dc->vportExtY * xdim / ydim + 0.5); + if (!dc->vportExtY) dc->vportExtY = mincy; } } @@ -326,7 +329,10 @@ BOOL WINAPI SetWindowExtEx( HDC hdc, INT } dc->wndExtX = x; dc->wndExtY = y; - /* Windows fixes MM_ISOTROPIC mode only in SetViewportExtEx() */ + /* The API docs say that you should call SetWindowExtEx before + SetViewportExtEx. This advice does not imply that Windows + doesn't ensure the isotropic mapping after SetWindowExtEx! */ + if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc ); DC_UpdateXforms( dc ); done: GDI_ReleaseObj( hdc ); diff --git a/dlls/gdi/tests/mapping.c b/dlls/gdi/tests/mapping.c index a7fdda9..0dbc89a 100644 --- a/dlls/gdi/tests/mapping.c +++ b/dlls/gdi/tests/mapping.c @@ -53,7 +53,108 @@ void test_modify_world_transform(void) ReleaseDC(0, hdc); } +void test_SetWindowExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy) +{ + SIZE windowExt, viewportExt; + POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter; + + GetWindowOrgEx(hdc, &windowOrg); + GetViewportOrgEx(hdc, &viewportOrg); + + SetWindowExtEx(hdc, cx, cy, NULL); + GetWindowExtEx(hdc, &windowExt); + ok(windowExt.cx == cx && windowExt.cy == cy, + "Window extension: Expected %ldx%ld, got %ldx%ld\n", + cx, cy, windowExt.cx, windowExt.cy); + + GetViewportExtEx(hdc, &viewportExt); + ok(viewportExt.cx == expected_vp_cx && viewportExt.cy == expected_vp_cy, + "Viewport extents have not been properly adjusted: Expected %ldx%ld, got %ldx%ld\n", + expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy); + + GetWindowOrgEx(hdc, &windowOrgAfter); + ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y, + "Window origin changed from (%ld,%ld) to (%ld,%ld)\n", + windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y); + + GetViewportOrgEx(hdc, &viewportOrgAfter); + ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y, + "Viewport origin changed from (%ld,%ld) to (%ld,%ld)\n", + viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y); +} + +void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy) +{ + SIZE windowExt, windowExtAfter, viewportExt; + POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter; + + GetWindowOrgEx(hdc, &windowOrg); + GetViewportOrgEx(hdc, &viewportOrg); + GetWindowExtEx(hdc, &windowExt); + + SetViewportExtEx(hdc, cx, cy, NULL); + GetViewportExtEx(hdc, &viewportExt); + ok(viewportExt.cx == expected_vp_cx && viewportExt.cy == expected_vp_cy, + "Viewport extents have not been properly adjusted: Expected %ldx%ld, got %ldx%ld\n", + expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy); + + GetWindowExtEx(hdc, &windowExtAfter); + ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy, + "Window extension changed from %ldx%ld to %ldx%ld\n", + windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy); + + GetWindowOrgEx(hdc, &windowOrgAfter); + ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y, + "Window origin changed from (%ld,%ld) to (%ld,%ld)\n", + windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y); + + GetViewportOrgEx(hdc, &viewportOrgAfter); + ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y, + "Viewport origin changed from (%ld,%ld) to (%ld,%ld)\n", + viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y); +} + +void test_isotropic_mapping(void) +{ + SIZE win, vp; + HDC hdc = GetDC(0); + + SetMapMode(hdc, MM_ISOTROPIC); + + /* MM_ISOTROPIC is set up like MM_LOMETRIC. + Initial values after SetMapMode(): + (1 inch = 25.4 mm) + + Windows 9x: Windows NT: + Window Ext: 254 x -254 HORZSIZE*10 x VERTSIZE*10 + Viewport Ext: LOGPIXELSX x LOGPIXELSY HORZRES x -VERTRES + + To test without rounding errors, we have to use multiples of + these values! + */ + + GetWindowExtEx(hdc, &win); + GetViewportExtEx(hdc, &vp); + + test_SetViewportExt(hdc, 10 * vp.cx, 10 * vp.cy, 10 * vp.cx, 10 * vp.cy); + test_SetWindowExt(hdc, win.cx, win.cy, 10 * vp.cx, 10 * vp.cy); + test_SetWindowExt(hdc, 2 * win.cx, win.cy, 10 * vp.cx, 5 * vp.cy); + test_SetWindowExt(hdc, win.cx, win.cy, 5 * vp.cx, 5 * vp.cy); + test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy); + test_SetViewportExt(hdc, vp.cx, 2 * vp.cy, vp.cx, vp.cy); + test_SetViewportExt(hdc, 2 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy); + test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy); + test_SetWindowExt(hdc, 4 * win.cx, 2 * win.cy, 2 * vp.cx, vp.cy); + test_SetViewportExt(hdc, -2 * vp.cx, -4 * vp.cy, -2 * vp.cx, -vp.cy); + test_SetViewportExt(hdc, -2 * vp.cx, -1 * vp.cy, -2 * vp.cx, -vp.cy); + test_SetWindowExt(hdc, -4 * win.cx, -2 * win.cy, -2 * vp.cx, -vp.cy); + test_SetWindowExt(hdc, 4 * win.cx, -4 * win.cy, -vp.cx, -vp.cy); + + ReleaseDC(0, hdc); +} + START_TEST(mapping) { test_modify_world_transform(); + test_isotropic_mapping(); }
1
0
0
0
Robert Shearman : widl: Use a macro to write out FC types, along with the current offset
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: cf1ccfb7129c432316f6450f88975ef6f6e1083f URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=cf1ccfb7129c432316f6450…
Author: Robert Shearman <rob(a)codeweavers.com> Date: Tue Jan 31 12:25:54 2006 +0100 widl: Use a macro to write out FC types, along with the current offset which is useful for debugging. --- tools/widl/typegen.c | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index f6a619a..f03cef3 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -108,6 +108,14 @@ static int compare_expr(const expr_t *a, return -1; } +#define WRITE_FCTYPE(file, fctype, typestring_offset) \ + do { \ + if (file) \ + fprintf(file, "/* %2u */\n", typestring_offset); \ + print_file((file), 2, "0x%02x, /* " #fctype " */\n", RPC_##fctype); \ + } \ + while (0) + static int print_file(FILE *file, int indent, const char *format, ...) { va_list va; @@ -568,9 +576,9 @@ static size_t write_string_tfs(FILE *fil name, USHRT_MAX, array->cval - USHRT_MAX); if (type->type == RPC_FC_CHAR) - print_file(file, 2, "0x%x, /* FC_CSTRING */\n", RPC_FC_C_CSTRING); + WRITE_FCTYPE(file, FC_CSTRING, typestring_offset); else - print_file(file, 2, "0x%x, /* FC_WSTRING */\n", RPC_FC_C_WSTRING); + WRITE_FCTYPE(file, FC_WSTRING, typestring_offset); print_file(file, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD); typestring_size = 2; @@ -584,9 +592,9 @@ static size_t write_string_tfs(FILE *fil size_t typestring_size; if (type->type == RPC_FC_CHAR) - print_file(file, 2, "0x%x, /* FC_C_CSTRING */\n", RPC_FC_C_CSTRING); + WRITE_FCTYPE(file, FC_C_CSTRING, typestring_offset); else - print_file(file, 2, "0x%x, /* FC_C_WSTRING */\n", RPC_FC_C_WSTRING); + WRITE_FCTYPE(file, FC_C_WSTRING, typestring_offset); print_file(file, 2, "0x%x, /* FC_STRING_SIZED */\n", RPC_FC_STRING_SIZED); typestring_size = 2; @@ -599,9 +607,9 @@ static size_t write_string_tfs(FILE *fil size_t typestring_size; if (type->type == RPC_FC_CHAR) - print_file(file, 2, "0x%x, /* FC_C_CSTRING */\n", RPC_FC_C_CSTRING); + WRITE_FCTYPE(file, FC_C_CSTRING, typestring_offset); else - print_file(file, 2, "0x%x, /* FC_C_WSTRING */\n", RPC_FC_C_WSTRING); + WRITE_FCTYPE(file, FC_C_WSTRING, typestring_offset); print_file(file, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD); typestring_size = 2; @@ -634,7 +642,7 @@ static size_t write_array_tfs(FILE *file size_t size = type_memsize(type, 0, array); if (size < USHRT_MAX) { - print_file(file, 2, "0x%x, /* FC_SMFARRAY */\n", RPC_FC_SMFARRAY); + WRITE_FCTYPE(file, FC_SMFARRAY, typestring_offset); /* alignment */ print_file(file, 2, "0x%x, /* 0 */\n", 0); /* size */ @@ -643,7 +651,7 @@ static size_t write_array_tfs(FILE *file } else { - print_file(file, 2, "0x%x, /* FC_LGFARRAY */\n", RPC_FC_LGFARRAY); + WRITE_FCTYPE(file, FC_LGFARRAY, typestring_offset); /* alignment */ print_file(file, 2, "0x%x, /* 0 */\n", 0); /* size */ @@ -669,7 +677,7 @@ static size_t write_array_tfs(FILE *file if (total_size < USHRT_MAX) { - print_file(file, 2, "0x%x, /* FC_SMVARRAY */\n", RPC_FC_SMVARRAY); + WRITE_FCTYPE(file, FC_SMVARRAY, typestring_offset); /* alignment */ print_file(file, 2, "0x%x, /* 0 */\n", 0); /* total size */ @@ -680,7 +688,7 @@ static size_t write_array_tfs(FILE *file } else { - print_file(file, 2, "0x%x, /* FC_LGVARRAY */\n", RPC_FC_LGVARRAY); + WRITE_FCTYPE(file, FC_LGVARRAY, typestring_offset); /* alignment */ print_file(file, 2, "0x%x, /* 0 */\n", 0); /* total size */ @@ -711,7 +719,7 @@ static size_t write_array_tfs(FILE *file size_t typestring_size; size_t element_size = type_memsize(type, 0, NULL); - print_file(file, 2, "0x%x, /* FC_CARRAY */\n", RPC_FC_CARRAY); + WRITE_FCTYPE(file, FC_CARRAY, typestring_offset); /* alignment */ print_file(file, 2, "0x%x, /* 0 */\n", 0); /* element size */ @@ -735,7 +743,7 @@ static size_t write_array_tfs(FILE *file size_t typestring_size; size_t element_size = type_memsize(type, 0, NULL); - print_file(file, 2, "0x%x, /* FC_CARRAY */\n", RPC_FC_CARRAY); + WRITE_FCTYPE(file, FC_CVARRAY, typestring_offset); /* alignment */ print_file(file, 2, "0x%x, /* 0 */\n", 0); /* element size */ @@ -789,7 +797,7 @@ static size_t write_struct_tfs(FILE *fil error("structure size for parameter %s exceeds %d bytes by %d bytes\n", name, USHRT_MAX, total_size - USHRT_MAX); - print_file(file, 2, "0x%x, /* %s */\n", RPC_FC_STRUCT, "FC_STRUCT"); + WRITE_FCTYPE(file, FC_STRUCT, typestring_offset); /* alignment */ print_file(file, 2, "0x0,\n"); /* total size */ @@ -809,7 +817,7 @@ static size_t write_struct_tfs(FILE *fil error("structure size for parameter %s exceeds %d bytes by %d bytes\n", name, USHRT_MAX, total_size - USHRT_MAX); - print_file(file, 2, "0x%x, /* %s */\n", RPC_FC_CSTRUCT, "FC_CSTRUCT"); + WRITE_FCTYPE(file, FC_CSTRUCT, typestring_offset); /* alignment */ print_file(file, 2, "0x0,\n"); /* total size */ @@ -834,7 +842,7 @@ static size_t write_struct_tfs(FILE *fil error("structure size for parameter %s exceeds %d bytes by %d bytes\n", name, USHRT_MAX, total_size - USHRT_MAX); - print_file(file, 2, "0x%x, /* %s */\n", RPC_FC_CVSTRUCT, "FC_CVSTRUCT"); + WRITE_FCTYPE(file, FC_CVSTRUCT, typestring_offset); /* alignment */ print_file(file, 2, "0x0,\n"); /* total size */
1
0
0
0
Robert Shearman : widl: Pass the current type format string offset through all type
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: 2ee6f722e0573ec68fad44ee3cd315d5b6245562 URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=2ee6f722e0573ec68fad44e…
Author: Robert Shearman <rob(a)codeweavers.com> Date: Tue Jan 31 12:24:54 2006 +0100 widl: Pass the current type format string offset through all type writing functions. --- tools/widl/typegen.c | 83 +++++++++++++++++++++++++------------------------- 1 files changed, 42 insertions(+), 41 deletions(-) Diff:
http://source.winehq.org/git/?p=wine.git;a=commitdiff;h=2ee6f722e0573ec68fa…
1
0
0
0
Robert Shearman : widl: Eliminate redundant callback routines.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: a6909fa5e82cc70fc376bddbe23dad38fd027ede URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=a6909fa5e82cc70fc376bdd…
Author: Robert Shearman <rob(a)codeweavers.com> Date: Tue Jan 31 12:24:11 2006 +0100 widl: Eliminate redundant callback routines. Add a function for comparing expressions and use it to eliminate redundant callback functions. --- tools/widl/typegen.c | 83 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 71 insertions(+), 12 deletions(-) diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 6a17719..b429fa0 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -62,6 +62,52 @@ struct expr_eval_routine static size_t type_memsize(const type_t *t, int ptr_level, const expr_t *array); static size_t fields_memsize(const var_t *v); +static int compare_expr(const expr_t *a, const expr_t *b) +{ + int ret; + + if (a->type != b->type) + return a->type - b->type; + + switch (a->type) + { + case EXPR_NUM: + case EXPR_HEXNUM: + return a->u.lval - b->u.lval; + case EXPR_IDENTIFIER: + return strcmp(a->u.sval, b->u.sval); + case EXPR_COND: + ret = compare_expr(a->ref, b->ref); + if (ret != 0) + return ret; + ret = compare_expr(a->u.ext, b->u.ext); + if (ret != 0) + return ret; + return compare_expr(a->ext2, b->ext2); + case EXPR_OR: + case EXPR_AND: + case EXPR_ADD: + case EXPR_SUB: + case EXPR_MUL: + case EXPR_DIV: + case EXPR_SHL: + case EXPR_SHR: + ret = compare_expr(a->ref, b->ref); + if (ret != 0) + return ret; + return compare_expr(a->u.ext, b->u.ext); + case EXPR_NOT: + case EXPR_NEG: + case EXPR_PPTR: + case EXPR_CAST: + case EXPR_SIZEOF: + return compare_expr(a->ref, b->ref); + case EXPR_VOID: + return 0; + } + return -1; +} + static int print_file(FILE *file, int indent, const char *format, ...) { va_list va; @@ -382,21 +428,31 @@ static size_t write_conf_or_var_desc(FIL else { unsigned int callback_offset = 0; - struct list *cursor; - - LIST_FOR_EACH(cursor, &expr_eval_routines) - callback_offset++; - - if (callback_offset > USHRT_MAX) - error("Maximum number of callback routines reached\n"); if (structure) { - struct expr_eval_routine *eval = xmalloc(sizeof(*eval)); - eval->structure = structure; - eval->structure_size = fields_memsize(structure->fields); - eval->expr = expr; - list_add_tail(&expr_eval_routines, &eval->entry); + struct expr_eval_routine *eval; + int found = 0; + + LIST_FOR_EACH_ENTRY(eval, &expr_eval_routines, struct expr_eval_routine, entry) + { + if (!strcmp(eval->structure->name, structure->name) && + !compare_expr(eval->expr, expr)) + { + found = 1; + break; + } + callback_offset++; + } + + if (!found) + { + eval = xmalloc(sizeof(*eval)); + eval->structure = structure; + eval->structure_size = fields_memsize(structure->fields); + eval->expr = expr; + list_add_tail(&expr_eval_routines, &eval->entry); + } correlation_type = RPC_FC_NORMAL_CONFORMANCE; } @@ -406,6 +462,9 @@ static size_t write_conf_or_var_desc(FIL correlation_type = RPC_FC_TOP_LEVEL_CONFORMANCE; } + if (callback_offset > USHRT_MAX) + error("Maximum number of callback routines reached\n"); + print_file(file, 2, "0x%x, /* Corr desc: %s */\n", correlation_type, correlation_type == RPC_FC_TOP_LEVEL_CONFORMANCE ? "parameter" : "");
1
0
0
0
Robert Shearman : widl: Define a value for RPC_FC_WSTRING.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: 14e4a5453c1a31f51296171492729d1a21c39a73 URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=14e4a5453c1a31f51296171…
Author: Robert Shearman <rob(a)codeweavers.com> Date: Tue Jan 31 12:23:59 2006 +0100 widl: Define a value for RPC_FC_WSTRING. --- include/wine/rpcfc.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/wine/rpcfc.h b/include/wine/rpcfc.h index 090ab28..7a124d4 100644 --- a/include/wine/rpcfc.h +++ b/include/wine/rpcfc.h @@ -68,6 +68,7 @@ #define RPC_FC_C_CSTRING 0x22 #define RPC_FC_C_WSTRING 0x25 #define RPC_FC_CSTRING 0x26 +#define RPC_FC_WSTRING 0x29 #define RPC_FC_ENCAPSULATED_UNION 0x2a #define RPC_FC_NON_ENCAPSULATED_UNION 0x2b
1
0
0
0
Vitaliy Margolen : winecfg: Default for PixelShaders is disabled.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: 7b98e1f7175272d333b628e37d1c974d07b7732b URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=7b98e1f7175272d333b628e…
Author: Vitaliy Margolen <wine-patch(a)kievinfo.com> Date: Tue Jan 31 12:23:01 2006 +0100 winecfg: Default for PixelShaders is disabled. --- programs/winecfg/x11drvdlg.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/programs/winecfg/x11drvdlg.c b/programs/winecfg/x11drvdlg.c index fe1a503..73fe40c 100644 --- a/programs/winecfg/x11drvdlg.c +++ b/programs/winecfg/x11drvdlg.c @@ -177,7 +177,7 @@ static void init_dialog(HWND dialog) } HeapFree(GetProcessHeap(), 0, buf); - buf = get_reg_key(config_key, keypath("Direct3D"), "PixelShaderMode", "enabled"); + buf = get_reg_key(config_key, keypath("Direct3D"), "PixelShaderMode", "disabled"); if (!strcmp(buf, "enabled")) CheckDlgButton(dialog, IDC_D3D_PSHADER_MODE, BST_CHECKED); else
1
0
0
0
James Hawkins : setupapi: Add tests for SetupGetInfInformation.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: ac6c9410587c7b0c3ec5614ba1c8289dd525a407 URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=ac6c9410587c7b0c3ec5614…
Author: James Hawkins <truiken(a)gmail.com> Date: Tue Jan 31 12:22:48 2006 +0100 setupapi: Add tests for SetupGetInfInformation. --- dlls/setupapi/tests/Makefile.in | 1 dlls/setupapi/tests/query.c | 278 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 279 insertions(+), 0 deletions(-) create mode 100644 dlls/setupapi/tests/query.c diff --git a/dlls/setupapi/tests/Makefile.in b/dlls/setupapi/tests/Makefile.in index 517d44f..7730f68 100644 --- a/dlls/setupapi/tests/Makefile.in +++ b/dlls/setupapi/tests/Makefile.in @@ -7,6 +7,7 @@ IMPORTS = setupapi kernel32 CTESTS = \ parser.c \ + query.c \ stringtable.c @MAKE_TEST_RULES@ diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c new file mode 100644 index 0000000..71dc50e --- /dev/null +++ b/dlls/setupapi/tests/query.c @@ -0,0 +1,278 @@ +/* + * Unit tests for setupapi.dll query functions + * + * Copyright (C) 2006 James Hawkins + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <windows.h> +#include <setupapi.h> +#include "wine/test.h" + +/* function pointers */ +static HMODULE hSetupAPI; +static void (WINAPI *pSetupCloseInfFile)(HINF); +static BOOL (WINAPI *pSetupGetInfInformationA)(LPCVOID,DWORD,PSP_INF_INFORMATION,DWORD,PDWORD); +static HINF (WINAPI *pSetupOpenInfFileA)(PCSTR,PCSTR,DWORD,PUINT); +static BOOL (WINAPI *pSetupQueryInfFileInformationA)(PSP_INF_INFORMATION,UINT,PSTR,DWORD,PDWORD); + +CHAR CURR_DIR[MAX_PATH]; +CHAR WIN_DIR[MAX_PATH]; + +static void init_function_pointers(void) +{ + hSetupAPI = LoadLibraryA("setupapi.dll"); + + if (hSetupAPI) + { + pSetupCloseInfFile = (void *)GetProcAddress(hSetupAPI, "SetupCloseInfFile"); + pSetupGetInfInformationA = (void *)GetProcAddress(hSetupAPI, "SetupGetInfInformationA"); + pSetupOpenInfFileA = (void *)GetProcAddress(hSetupAPI, "SetupOpenInfFileA"); + pSetupQueryInfFileInformationA = (void *)GetProcAddress(hSetupAPI, "SetupQueryInfFileInformationA"); + } +} + +static void get_directories(void) +{ + int len; + + GetCurrentDirectoryA(MAX_PATH, CURR_DIR); + len = lstrlenA(CURR_DIR); + + if(len && (CURR_DIR[len-1] == '\\')) + CURR_DIR[len-1] = 0; + + GetWindowsDirectoryA(WIN_DIR, MAX_PATH); + len = lstrlenA(WIN_DIR); + + if (len && (WIN_DIR[len-1] == '\\')) + WIN_DIR[len-1] = 0; +} + +static void append_str(char **str, const char *data) +{ + sprintf(*str, data); + *str += strlen(*str); +} + +static void create_inf_file(LPSTR filename) +{ + char data[1024]; + char *ptr = data; + DWORD dwNumberOfBytesWritten; + HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + + append_str(&ptr, "[Version]\n"); + append_str(&ptr, "Signature=\"$Chicago$\"\n"); + append_str(&ptr, "AdvancedINF=2.5\n"); + + WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL); + CloseHandle(hf); +} + +static BOOL check_info_filename(PSP_INF_INFORMATION info, LPSTR test) +{ + LPSTR filename; + DWORD size; + BOOL ret = FALSE; + + if (!pSetupQueryInfFileInformationA(info, 0, NULL, 0, &size)) + return FALSE; + + filename = HeapAlloc(GetProcessHeap(), 0, size); + if (!filename) + return FALSE; + + pSetupQueryInfFileInformationA(info, 0, filename, size, &size); + + if (!lstrcmpiA(test, filename)) + ret = TRUE; + + HeapFree(GetProcessHeap(), 0, filename); + return ret; +} + +static PSP_INF_INFORMATION alloc_inf_info(LPSTR filename, DWORD search, PDWORD size) +{ + PSP_INF_INFORMATION info; + BOOL ret; + + ret = pSetupGetInfInformationA(filename, search, NULL, 0, size); + if (!ret) + return NULL; + + info = HeapAlloc(GetProcessHeap(), 0, *size); + return info; +} + +static void test_SetupGetInfInformation(void) +{ + PSP_INF_INFORMATION info; + CHAR inf_filename[MAX_PATH]; + CHAR inf_one[MAX_PATH], inf_two[MAX_PATH]; + DWORD size; + HINF hinf; + BOOL ret; + + lstrcpyA(inf_filename, CURR_DIR); + lstrcatA(inf_filename, "\\"); + lstrcatA(inf_filename, "test.inf"); + + /* try an invalid inf handle */ + size = 0xdeadbeef; + SetLastError(0xbeefcafe); + ret = pSetupGetInfInformationA(NULL, INFINFO_INF_SPEC_IS_HINF, NULL, 0, &size); + todo_wine + { + ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, + "Expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError()); + } + ok(size == 0xdeadbeef, "Expected size to remain unchanged\n"); + + /* try an invalid inf filename */ + size = 0xdeadbeef; + SetLastError(0xbeefcafe); + ret = pSetupGetInfInformationA(NULL, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size); + todo_wine + { + ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + } + ok(size == 0xdeadbeef, "Expected size to remain unchanged\n"); + + create_inf_file(inf_filename); + + /* try an invalid search flag */ + size = 0xdeadbeef; + SetLastError(0xbeefcafe); + ret = pSetupGetInfInformationA(inf_filename, -1, NULL, 0, &size); + todo_wine + { + ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + } + ok(size == 0xdeadbeef, "Expected size to remain unchanged\n"); + + /* try a nonexistent inf file */ + size = 0xdeadbeef; + SetLastError(0xbeefcafe); + ret = pSetupGetInfInformationA("idontexist", INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size); + todo_wine + { + ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); + } + ok(size == 0xdeadbeef, "Expected size to remain unchanged\n"); + + /* successfully open the inf file */ + size = 0xdeadbeef; + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + todo_wine + { + ok(size != 0xdeadbeef, "Expected a valid size on return\n"); + } + + /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero */ + SetLastError(0xbeefcafe); + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size); + todo_wine + { + ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + } + + info = HeapAlloc(GetProcessHeap(), 0, size); + + /* try valid ReturnBuffer but too small size */ + SetLastError(0xbeefcafe); + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, info, size - 1, &size); + todo_wine + { + ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, + "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError()); + } + + /* successfully get the inf information */ + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, info, size, &size); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + todo_wine + { + ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n"); + } + + /* try the INFINFO_INF_SPEC_IS_HINF search flag */ + hinf = pSetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL); + ret = pSetupGetInfInformationA(hinf, INFINFO_INF_SPEC_IS_HINF, info, size, &size); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + todo_wine + { + ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n"); + } + pSetupCloseInfFile(hinf); + + lstrcpyA(inf_one, WIN_DIR); + lstrcatA(inf_one, "\\inf\\"); + lstrcatA(inf_one, "test.inf"); + create_inf_file(inf_one); + + lstrcpyA(inf_two, WIN_DIR); + lstrcatA(inf_two, "\\system32\\"); + lstrcatA(inf_two, "test.inf"); + create_inf_file(inf_two); + + HeapFree(GetProcessHeap(), 0, info); + info = alloc_inf_info("test.inf", INFINFO_DEFAULT_SEARCH, &size); + + /* test the INFINFO_DEFAULT_SEARCH search flag */ + ret = pSetupGetInfInformationA("test.inf", INFINFO_DEFAULT_SEARCH, info, size, &size); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + todo_wine + { + ok(check_info_filename(info, inf_one), "Expected returned filename to be equal\n"); + } + + HeapFree(GetProcessHeap(), 0, info); + info = alloc_inf_info("test.inf", INFINFO_REVERSE_DEFAULT_SEARCH, &size); + + /* test the INFINFO_REVERSE_DEFAULT_SEARCH search flag */ + ret = pSetupGetInfInformationA("test.inf", INFINFO_REVERSE_DEFAULT_SEARCH, info, size, &size); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + todo_wine + { + ok(check_info_filename(info, inf_two), "Expected returned filename to be equal\n"); + } + + DeleteFileA(inf_filename); + DeleteFileA(inf_one); + DeleteFileA(inf_two); +} + +START_TEST(query) +{ + init_function_pointers(); + get_directories(); + + test_SetupGetInfInformation(); +}
1
0
0
0
James Hawkins : setupapi: Add definitions for the SetupGetInfInformation search flags.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: 95d17daf006196fbae5cf564e81a4dc82d4341c6 URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=95d17daf006196fbae5cf56…
Author: James Hawkins <truiken(a)gmail.com> Date: Tue Jan 31 12:22:38 2006 +0100 setupapi: Add definitions for the SetupGetInfInformation search flags. --- include/setupapi.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/include/setupapi.h b/include/setupapi.h index ce3bde0..3b8911c 100644 --- a/include/setupapi.h +++ b/include/setupapi.h @@ -684,6 +684,12 @@ DECL_WINELIB_SETUPAPI_TYPE_AW(PFILEPATHS #define IDF_NOFOREGROUND 0x00000400 #define IDF_WARNIFSKIP 0x00000800 +#define INFINFO_INF_SPEC_IS_HINF 1 +#define INFINFO_INF_NAME_IS_ABSOLUTE 2 +#define INFINFO_DEFAULT_SEARCH 3 +#define INFINFO_REVERSE_DEFAULT_SEARCH 4 +#define INFINFO_INF_PATH_LIST_SEARCH 5 + LONG WINAPI AddTagToGroupOrderList(PCWSTR lpGroupName, DWORD dwUnknown2, DWORD dwUnknown3); DWORD WINAPI CaptureAndConvertAnsiArg(PCSTR lpSrc, PWSTR *lpDst); DWORD WINAPI CaptureStringArg(PCWSTR lpSrc, PWSTR *lpDst);
1
0
0
0
Mike McCormack : kernel: Add some test cases for ReadDirectoryChangesW.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: 9e2b6687f6ec1bbda1af684571ea9a7a9b7c6223 URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=9e2b6687f6ec1bbda1af684…
Author: Mike McCormack <mike(a)codeweavers.com> Date: Tue Jan 31 12:22:24 2006 +0100 kernel: Add some test cases for ReadDirectoryChangesW. --- dlls/kernel/tests/change.c | 126 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 126 insertions(+), 0 deletions(-) diff --git a/dlls/kernel/tests/change.c b/dlls/kernel/tests/change.c index 2ad35f8..1b384ae 100644 --- a/dlls/kernel/tests/change.c +++ b/dlls/kernel/tests/change.c @@ -314,8 +314,134 @@ static void test_ffcn(void) ok( r == TRUE, "failed to remove dir\n"); } +typedef BOOL (WINAPI *fnReadDirectoryChangesW)(HANDLE,LPVOID,DWORD,BOOL,DWORD, + LPDWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE); + +static void test_readdirectorychanges(void) +{ + HANDLE hdir; + char buffer[0x1000]; + DWORD fflags, filter = 0, r; + OVERLAPPED ov; + WCHAR path[MAX_PATH], subdir[MAX_PATH]; + static const WCHAR szBoo[] = { '\\','b','o','o',0 }; + static const WCHAR szHoo[] = { '\\','h','o','o',0 }; + fnReadDirectoryChangesW pReadDirectoryChangesW; + HMODULE hkernel32; + + hkernel32 = GetModuleHandle("kernel32"); + pReadDirectoryChangesW = (fnReadDirectoryChangesW) + GetProcAddress(hkernel32, "ReadDirectoryChangesW"); + if (!pReadDirectoryChangesW) + return; + + r = GetTempPathW( MAX_PATH, path ); + ok( r != 0, "temp path failed\n"); + if (!r) + return; + + lstrcatW( path, szBoo ); + lstrcpyW( subdir, path ); + lstrcatW( subdir, szHoo ); + + RemoveDirectoryW( subdir ); + RemoveDirectoryW( path ); + + r = CreateDirectoryW(path, NULL); + ok( r == TRUE, "failed to create directory\n"); + + SetLastError(0xd0b00b00); + r = pReadDirectoryChangesW(NULL,NULL,0,FALSE,0,NULL,NULL,NULL); + ok(GetLastError()==ERROR_INVALID_PARAMETER,"last error wrong\n"); + ok(r==FALSE, "should return false\n"); + + fflags = FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED; + hdir = CreateFileW(path, GENERIC_READ|SYNCHRONIZE, FILE_SHARE_READ, NULL, + OPEN_EXISTING, fflags, NULL); + ok( hdir != INVALID_HANDLE_VALUE, "failed to open directory\n"); + + ov.hEvent = CreateEvent( NULL, 0, 0, NULL ); + + SetLastError(0xd0b00b00); + r = pReadDirectoryChangesW(hdir,NULL,0,FALSE,0,NULL,NULL,NULL); + ok(GetLastError()==ERROR_INVALID_PARAMETER,"last error wrong\n"); + ok(r==FALSE, "should return false\n"); + + SetLastError(0xd0b00b00); + r = pReadDirectoryChangesW(hdir,NULL,0,FALSE,0,NULL,&ov,NULL); + ok(GetLastError()==ERROR_INVALID_PARAMETER,"last error wrong\n"); + ok(r==FALSE, "should return false\n"); + + filter = FILE_NOTIFY_CHANGE_FILE_NAME; + filter |= FILE_NOTIFY_CHANGE_DIR_NAME; + filter |= FILE_NOTIFY_CHANGE_ATTRIBUTES; + filter |= FILE_NOTIFY_CHANGE_SIZE; + filter |= FILE_NOTIFY_CHANGE_LAST_WRITE; + filter |= FILE_NOTIFY_CHANGE_LAST_ACCESS; + filter |= FILE_NOTIFY_CHANGE_CREATION; + filter |= FILE_NOTIFY_CHANGE_SECURITY; + + SetLastError(0xd0b00b00); + r = pReadDirectoryChangesW(hdir,buffer,sizeof buffer,FALSE,-1,NULL,&ov,NULL); + ok(GetLastError()==ERROR_INVALID_PARAMETER,"last error wrong\n"); + ok(r==FALSE, "should return false\n"); + + r = pReadDirectoryChangesW(hdir,NULL,0,FALSE,filter,NULL,&ov,NULL); + ok(r==TRUE, "should return true\n"); + + r = WaitForSingleObject( ov.hEvent, 0 ); + ok( r == STATUS_TIMEOUT, "should timeout\n" ); + + r = WaitForSingleObject( hdir, 0 ); + ok( r == STATUS_TIMEOUT, "should timeout\n" ); + + r = CreateDirectoryW( subdir, NULL ); + ok( r == TRUE, "failed to create directory\n"); + + r = WaitForSingleObject( hdir, 0 ); + ok( r == STATUS_TIMEOUT, "should timeout\n" ); + + r = WaitForSingleObject( ov.hEvent, 0 ); + ok( r == WAIT_OBJECT_0, "event should be ready\n" ); + + SetLastError(0xd0b00b00); + r = pReadDirectoryChangesW(hdir,buffer,sizeof buffer,FALSE,0,NULL,NULL,NULL); + ok(GetLastError()==ERROR_INVALID_PARAMETER,"last error wrong\n"); + ok(r==FALSE, "should return false\n"); + + r = pReadDirectoryChangesW(hdir,buffer,sizeof buffer,FALSE,0,NULL,&ov,NULL); + ok(GetLastError()==ERROR_INVALID_PARAMETER,"last error wrong\n"); + ok(r==FALSE, "should return false\n"); + + filter = FILE_NOTIFY_CHANGE_SIZE; + + CloseHandle( ov.hEvent ); + ov.hEvent = NULL; + r = pReadDirectoryChangesW(hdir,NULL,0,FALSE,filter,NULL,&ov,NULL); + ok(r==TRUE, "should return true\n"); + + r = WaitForSingleObject( hdir, 0 ); + ok( r == STATUS_TIMEOUT, "should timeout\n" ); + + r = RemoveDirectoryW( subdir ); + ok( r == TRUE, "failed to remove directory\n"); + + r = WaitForSingleObject( hdir, 0 ); + ok( r == WAIT_OBJECT_0, "should be ready\n" ); + + r = WaitForSingleObject( hdir, 0 ); + ok( r == WAIT_OBJECT_0, "should be ready\n" ); + + CloseHandle(hdir); + + r = RemoveDirectoryW( path ); + ok( r == TRUE, "failed to remove directory\n"); +} + + START_TEST(change) { test_FindFirstChangeNotification(); test_ffcn(); + test_readdirectorychanges(); }
1
0
0
0
Juan Lang : crypt32: Correct X509_NAME decoding, and more stringent tests.
by Alexandre Julliard
31 Jan '06
31 Jan '06
Module: wine Branch: refs/heads/master Commit: faeac967704e1409a3a250f7838d7f33f8539385 URL:
http://source.winehq.org/git/?p=wine.git;a=commit;h=faeac967704e1409a3a250f…
Author: Juan Lang <juan(a)codeweavers.com> Date: Tue Jan 31 12:22:15 2006 +0100 crypt32: Correct X509_NAME decoding, and more stringent tests. --- dlls/crypt32/encode.c | 6 +- dlls/crypt32/tests/encode.c | 151 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 125 insertions(+), 32 deletions(-) diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c index 25f854e..e97c894 100644 --- a/dlls/crypt32/encode.c +++ b/dlls/crypt32/encode.c @@ -3554,8 +3554,11 @@ static BOOL WINAPI CRYPT_AsnDecodeRdnAtt sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, NULL, attr, pcbStructInfo, attr ? attr->pszObjId : NULL); if (attr) + { TRACE("attr->pszObjId is %p (%s)\n", attr->pszObjId, debugstr_a(attr->pszObjId)); + TRACE("attr->dwValueType is %ld\n", attr->dwValueType); + } TRACE("returning %d (%08lx)\n", ret, GetLastError()); } __EXCEPT_PAGE_FAULT @@ -3578,9 +3581,10 @@ static BOOL WINAPI CRYPT_AsnDecodeRdn(DW struct AsnArrayDescriptor arrayDesc = { ASN_CONSTRUCTOR | ASN_SETOF, CRYPT_AsnDecodeRdnAttr, sizeof(CERT_RDN_ATTR), TRUE, offsetof(CERT_RDN_ATTR, pszObjId) }; + PCERT_RDN rdn = (PCERT_RDN)pvStructInfo; ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, - pDecodePara, pvStructInfo, pcbStructInfo, NULL); + pDecodePara, pvStructInfo, pcbStructInfo, rdn ? rdn->rgRDNAttr : NULL); } __EXCEPT_PAGE_FAULT { diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c index 86f5347..3c69eb2 100644 --- a/dlls/crypt32/tests/encode.c +++ b/dlls/crypt32/tests/encode.c @@ -661,6 +661,54 @@ static const BYTE twoRDNs[] = { 0x13,0x05,0x4c,0x61,0x6e,0x67,0x00,0x30,0x11,0x06,0x03,0x55,0x04,0x03, 0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0}; +static const BYTE us[] = { 0x55, 0x53 }; +static const BYTE minnesota[] = { 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x73, 0x6f, + 0x74, 0x61 }; +static const BYTE minneapolis[] = { 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x61, 0x70, + 0x6f, 0x6c, 0x69, 0x73 }; +static const BYTE codeweavers[] = { 0x43, 0x6f, 0x64, 0x65, 0x57, 0x65, 0x61, + 0x76, 0x65, 0x72, 0x73 }; +static const BYTE wine[] = { 0x57, 0x69, 0x6e, 0x65, 0x20, 0x44, 0x65, 0x76, + 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74 }; +static const BYTE localhostAttr[] = { 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74 }; +static const BYTE aric[] = { 0x61, 0x72, 0x69, 0x63, 0x40, 0x63, 0x6f, 0x64, + 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x6f, 0x6d }; + +#define _blob_of(arr) { sizeof(arr), (LPBYTE)arr } +const CERT_RDN_ATTR rdnAttrs[] = { + { "2.5.4.6", CERT_RDN_PRINTABLE_STRING, _blob_of(us) }, + { "2.5.4.8", CERT_RDN_PRINTABLE_STRING, _blob_of(minnesota) }, + { "2.5.4.7", CERT_RDN_PRINTABLE_STRING, _blob_of(minneapolis) }, + { "2.5.4.10", CERT_RDN_PRINTABLE_STRING, _blob_of(codeweavers) }, + { "2.5.4.11", CERT_RDN_PRINTABLE_STRING, _blob_of(wine) }, + { "2.5.4.3", CERT_RDN_PRINTABLE_STRING, _blob_of(localhostAttr) }, + { "1.2.840.113549.1.9.1", CERT_RDN_IA5_STRING, _blob_of(aric) }, +}; +const CERT_RDN_ATTR decodedRdnAttrs[] = { + { "2.5.4.6", CERT_RDN_PRINTABLE_STRING, _blob_of(us) }, + { "2.5.4.3", CERT_RDN_PRINTABLE_STRING, _blob_of(localhostAttr) }, + { "2.5.4.8", CERT_RDN_PRINTABLE_STRING, _blob_of(minnesota) }, + { "2.5.4.7", CERT_RDN_PRINTABLE_STRING, _blob_of(minneapolis) }, + { "2.5.4.10", CERT_RDN_PRINTABLE_STRING, _blob_of(codeweavers) }, + { "2.5.4.11", CERT_RDN_PRINTABLE_STRING, _blob_of(wine) }, + { "1.2.840.113549.1.9.1", CERT_RDN_IA5_STRING, _blob_of(aric) }, +}; +#undef _blob_of + +static const BYTE encodedRDNAttrs[] = { +0x30,0x81,0x96,0x31,0x81,0x93,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55, +0x53,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x6c,0x6f,0x63,0x61,0x6c,0x68, +0x6f,0x73,0x74,0x30,0x10,0x06,0x03,0x55,0x04,0x08,0x13,0x09,0x4d,0x69,0x6e,0x6e, +0x65,0x73,0x6f,0x74,0x61,0x30,0x12,0x06,0x03,0x55,0x04,0x07,0x13,0x0b,0x4d,0x69, +0x6e,0x6e,0x65,0x61,0x70,0x6f,0x6c,0x69,0x73,0x30,0x12,0x06,0x03,0x55,0x04,0x0a, +0x13,0x0b,0x43,0x6f,0x64,0x65,0x57,0x65,0x61,0x76,0x65,0x72,0x73,0x30,0x17,0x06, +0x03,0x55,0x04,0x0b,0x13,0x10,0x57,0x69,0x6e,0x65,0x20,0x44,0x65,0x76,0x65,0x6c, +0x6f,0x70,0x6d,0x65,0x6e,0x74,0x30,0x21,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d, +0x01,0x09,0x01,0x16,0x14,0x61,0x72,0x69,0x63,0x40,0x63,0x6f,0x64,0x65,0x77,0x65, +0x61,0x76,0x65,0x72,0x73,0x2e,0x63,0x6f,0x6d +}; + static void test_encodeName(DWORD dwEncoding) { CERT_RDN_ATTR attrs[2]; @@ -770,6 +818,61 @@ static void test_encodeName(DWORD dwEnco LocalFree(buf); } } + /* Test a more complex name */ + rdn.cRDNAttr = sizeof(rdnAttrs) / sizeof(rdnAttrs[0]); + rdn.rgRDNAttr = (PCERT_RDN_ATTR)rdnAttrs; + info.cRDN = 1; + info.rgRDN = &rdn; + buf = NULL; + size = 0; + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (ret) + { + ok(size == sizeof(encodedRDNAttrs), "Expected size %d, got %ld\n", + sizeof(encodedRDNAttrs), size); + ok(!memcmp(buf, encodedRDNAttrs, size), "Unexpected value\n"); + LocalFree(buf); + } +} + +static void compareRDNAttrs(const CERT_RDN_ATTR *expected, + const CERT_RDN_ATTR *got) +{ + if (expected->pszObjId && strlen(expected->pszObjId)) + { + ok(got->pszObjId != NULL, "Expected OID %s, got NULL\n", + expected->pszObjId); + if (got->pszObjId) + { + ok(!strcmp(got->pszObjId, expected->pszObjId), + "Got unexpected OID %s, expected %s\n", got->pszObjId, + expected->pszObjId); + } + } + ok(got->dwValueType == expected->dwValueType, + "Expected string type %ld, got %ld\n", expected->dwValueType, + got->dwValueType); + ok(got->Value.cbData == expected->Value.cbData, + "Unexpected data size, got %ld, expected %ld\n", got->Value.cbData, + expected->Value.cbData); + if (got->Value.cbData && got->Value.pbData) + ok(!memcmp(got->Value.pbData, expected->Value.pbData, + min(got->Value.cbData, expected->Value.cbData)), "Unexpected value\n"); +} + +static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got) +{ + ok(got->cRDNAttr == expected->cRDNAttr, + "Expected %ld RDN attrs, got %ld\n", expected->cRDNAttr, got->cRDNAttr); + if (got->cRDNAttr) + { + DWORD i; + + for (i = 0; i < got->cRDNAttr; i++) + compareRDNAttrs(&expected->rgRDNAttr[i], &got->rgRDNAttr[i]); + } } static void compareNames(const CERT_NAME_INFO *expected, @@ -779,37 +882,10 @@ static void compareNames(const CERT_NAME expected->cRDN, got->cRDN); if (got->cRDN) { - ok(got->rgRDN[0].cRDNAttr == expected->rgRDN[0].cRDNAttr, - "Expected %ld RDN attrs, got %ld\n", expected->rgRDN[0].cRDNAttr, - got->rgRDN[0].cRDNAttr); - if (got->rgRDN[0].cRDNAttr) - { - if (expected->rgRDN[0].rgRDNAttr[0].pszObjId && - strlen(expected->rgRDN[0].rgRDNAttr[0].pszObjId)) - { - ok(got->rgRDN[0].rgRDNAttr[0].pszObjId != NULL, - "Expected OID %s, got NULL\n", - expected->rgRDN[0].rgRDNAttr[0].pszObjId); - if (got->rgRDN[0].rgRDNAttr[0].pszObjId) - ok(!strcmp(got->rgRDN[0].rgRDNAttr[0].pszObjId, - expected->rgRDN[0].rgRDNAttr[0].pszObjId), - "Got unexpected OID %s, expected %s\n", - got->rgRDN[0].rgRDNAttr[0].pszObjId, - expected->rgRDN[0].rgRDNAttr[0].pszObjId); - } - ok(got->rgRDN[0].rgRDNAttr[0].Value.cbData == - expected->rgRDN[0].rgRDNAttr[0].Value.cbData, - "Unexpected data size, got %ld, expected %ld\n", - got->rgRDN[0].rgRDNAttr[0].Value.cbData, - expected->rgRDN[0].rgRDNAttr[0].Value.cbData); - if (got->rgRDN[0].rgRDNAttr[0].Value.cbData && - got->rgRDN[0].rgRDNAttr[0].Value.pbData) - ok(!memcmp(got->rgRDN[0].rgRDNAttr[0].Value.pbData, - expected->rgRDN[0].rgRDNAttr[0].Value.pbData, - min(got->rgRDN[0].rgRDNAttr[0].Value.cbData, - expected->rgRDN[0].rgRDNAttr[0].Value.cbData)), - "Unexpected value\n"); - } + DWORD i; + + for (i = 0; i < got->cRDN; i++) + compareRDNs(&expected->rgRDN[i], &got->rgRDN[i]); } } @@ -899,6 +975,19 @@ static void test_decodeName(DWORD dwEnco compareNames(&info, (CERT_NAME_INFO *)buf); LocalFree(buf); } + /* And, a slightly more complicated name */ + buf = NULL; + bufSize = 0; + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs, + sizeof(encodedRDNAttrs), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (ret) + { + rdn.cRDNAttr = sizeof(decodedRdnAttrs) / sizeof(decodedRdnAttrs[0]); + rdn.rgRDNAttr = (PCERT_RDN_ATTR)decodedRdnAttrs; + compareNames(&info, (CERT_NAME_INFO *)buf); + LocalFree(buf); + } } static const BYTE emptyAltName[] = { 0x30, 0x00 };
1
0
0
0
← Newer
1
2
3
4
5
6
...
62
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
Results per page:
10
25
50
100
200