ReactOS.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
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
List overview
Download
Ros-diffs
November 2016
----- 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
ros-diffs@reactos.org
15 participants
317 discussions
Start a n
N
ew thread
[akhaldi] 73270: [GDIPLUS] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:35:44 2016 New Revision: 73270 URL:
http://svn.reactos.org/svn/reactos?rev=73270&view=rev
Log: [GDIPLUS] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/reactos/dll/win32/gdiplus/brush.c trunk/reactos/dll/win32/gdiplus/gdiplus.spec trunk/reactos/dll/win32/gdiplus/gdiplus_private.h trunk/reactos/dll/win32/gdiplus/graphics.c trunk/reactos/dll/win32/gdiplus/graphicspath.c trunk/reactos/dll/win32/gdiplus/image.c trunk/reactos/dll/win32/gdiplus/imageattributes.c trunk/reactos/dll/win32/gdiplus/matrix.c trunk/reactos/dll/win32/gdiplus/metafile.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/gdiplus/brush.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/brush.c?…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/brush.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/brush.c [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -441,25 +441,42 @@ { GpStatus stat; LinearGradientMode mode; - REAL width, height, exofs, eyofs; + REAL exofs, eyofs; REAL sin_angle, cos_angle, sin_cos_angle; TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable, wrap, line); - sin_angle = sinf(deg2rad(angle)); - cos_angle = cosf(deg2rad(angle)); + if (!rect || !rect->Width || !rect->Height) + return InvalidParameter; + + angle = fmodf(angle, 360); + if (angle < 0) + angle += 360; + + if (isAngleScalable) + { + float add_angle = 0; + + while(angle >= 90) { + angle -= 180; + add_angle += M_PI; + } + + if (angle != 90 && angle != -90) + angle = atan((rect->Width / rect->Height) * tan(deg2rad(angle))); + else + angle = deg2rad(angle); + angle += add_angle; + } + else + { + angle = deg2rad(angle); + } + + sin_angle = sinf(angle); + cos_angle = cosf(angle); sin_cos_angle = sin_angle * cos_angle; - - if (isAngleScalable) - { - width = height = 1.0; - } - else - { - width = rect->Width; - height = rect->Height; - } if (sin_cos_angle >= 0) mode = LinearGradientModeForwardDiagonal; @@ -472,19 +489,13 @@ { if (sin_cos_angle >= 0) { - exofs = width * sin_cos_angle + height * cos_angle * cos_angle; - eyofs = width * sin_angle * sin_angle + height * sin_cos_angle; + exofs = rect->Height * sin_cos_angle + rect->Width * cos_angle * cos_angle; + eyofs = rect->Height * sin_angle * sin_angle + rect->Width * sin_cos_angle; } else { - exofs = width * sin_angle * sin_angle + height * sin_cos_angle; - eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle; - } - - if (isAngleScalable) - { - exofs = exofs * rect->Width; - eyofs = eyofs * rect->Height; + exofs = rect->Width * sin_angle * sin_angle + rect->Height * sin_cos_angle; + eyofs = -rect->Width * sin_cos_angle + rect->Height * sin_angle * sin_angle; } if (sin_angle >= 0) Modified: trunk/reactos/dll/win32/gdiplus/gdiplus.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/gdiplus.…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/gdiplus.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/gdiplus.spec [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -615,11 +615,11 @@ 615 stub GdipGetEffectParameterSize 616 stub GdipGetEffectParameters 617 stdcall GdipSetEffectParameters(ptr ptr long) -618 stub GdipInitializePalette +618 stdcall GdipInitializePalette(ptr long long long ptr) 619 stdcall GdipBitmapCreateApplyEffect(ptr long ptr ptr ptr ptr long ptr ptr) 620 stdcall GdipBitmapApplyEffect(ptr ptr ptr long ptr ptr) -621 stub GdipBitmapGetHistogram -622 stub GdipBitmapGetHistogramSize +621 stdcall GdipBitmapGetHistogram(ptr long long ptr ptr ptr ptr) +622 stdcall GdipBitmapGetHistogramSize(long ptr) 623 stdcall GdipBitmapConvertFormat(ptr long long long ptr float) 624 stdcall GdipImageSetAbort(ptr ptr) 625 stub GdipGraphicsSetAbort Modified: trunk/reactos/dll/win32/gdiplus/gdiplus_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/gdiplus_…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/gdiplus_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/gdiplus_private.h [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -89,6 +89,9 @@ extern REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi) DECLSPEC_HIDDEN; extern REAL units_scale(GpUnit from, GpUnit to, REAL dpi) DECLSPEC_HIDDEN; +extern GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space, + GpCoordinateSpace src_space, GpMatrix *matrix) DECLSPEC_HIDDEN; + extern GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics) DECLSPEC_HIDDEN; extern GpStatus METAFILE_GetGraphicsContext(GpMetafile* metafile, GpGraphics **result) DECLSPEC_HIDDEN; @@ -97,9 +100,21 @@ extern GpStatus METAFILE_GraphicsClear(GpMetafile* metafile, ARGB color) DECLSPEC_HIDDEN; extern GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush, GDIPCONST GpRectF* rects, INT count) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_SetClipRect(GpMetafile* metafile, + REAL x, REAL y, REAL width, REAL height, CombineMode mode) DECLSPEC_HIDDEN; extern GpStatus METAFILE_SetPageTransform(GpMetafile* metafile, GpUnit unit, REAL scale) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_SetWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* transform) DECLSPEC_HIDDEN; extern GpStatus METAFILE_ScaleWorldTransform(GpMetafile* metafile, REAL sx, REAL sy, MatrixOrder order) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_MultiplyWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* matrix, MatrixOrder order) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_RotateWorldTransform(GpMetafile* metafile, REAL angle, MatrixOrder order) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_TranslateWorldTransform(GpMetafile* metafile, REAL dx, REAL dy, MatrixOrder order) DECLSPEC_HIDDEN; extern GpStatus METAFILE_ResetWorldTransform(GpMetafile* metafile) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_BeginContainer(GpMetafile* metafile, GDIPCONST GpRectF *dstrect, + GDIPCONST GpRectF *srcrect, GpUnit unit, DWORD StackIndex) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_BeginContainerNoParams(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_EndContainer(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_SaveGraphics(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_RestoreGraphics(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN; extern GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile) DECLSPEC_HIDDEN; extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, @@ -367,10 +382,13 @@ GpRectF src_rect; HANDLETABLE *handle_table; int handle_count; + XFORM gdiworldtransform; GpMatrix *world_transform; GpUnit page_unit; REAL page_scale; GpRegion *base_clip; /* clip region in device space for all metafile output */ + GpRegion *clip; /* clip region within the metafile */ + struct list containers; }; struct GpBitmap{ Modified: trunk/reactos/dll/win32/gdiplus/graphics.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/graphics…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/graphics.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/graphics.c [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -47,9 +47,6 @@ GDIPCONST GpBrush *brush, GDIPCONST PointF *positions, INT flags, GDIPCONST GpMatrix *matrix); -static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space, - GpCoordinateSpace src_space, GpMatrix *matrix); - /* Converts from gdiplus path point type to gdi path point type. */ static BYTE convert_path_point_type(BYTE type) { @@ -1920,9 +1917,15 @@ return result; } +typedef enum GraphicsContainerType { + BEGIN_CONTAINER, + SAVE_GRAPHICS +} GraphicsContainerType; + typedef struct _GraphicsContainerItem { struct list entry; GraphicsContainer contid; + GraphicsContainerType type; SmoothingMode smoothing; CompositingQuality compqual; @@ -1939,7 +1942,7 @@ } GraphicsContainerItem; static GpStatus init_container(GraphicsContainerItem** container, - GDIPCONST GpGraphics* graphics){ + GDIPCONST GpGraphics* graphics, GraphicsContainerType type){ GpStatus sts; *container = heap_alloc_zero(sizeof(GraphicsContainerItem)); @@ -1947,6 +1950,7 @@ return OutOfMemory; (*container)->contid = graphics->contid + 1; + (*container)->type = type; (*container)->smoothing = graphics->smoothing; (*container)->compqual = graphics->compqual; @@ -3075,6 +3079,8 @@ HDC hdc; BOOL temp_hdc = FALSE, temp_bitmap = FALSE; HBITMAP hbitmap, old_hbm=NULL; + HRGN hrgn; + INT save_state; if (!(bitmap->format == PixelFormat16bppRGB555 || bitmap->format == PixelFormat24bppRGB || @@ -3135,6 +3141,16 @@ old_hbm = SelectObject(hdc, hbitmap); } + save_state = SaveDC(graphics->hdc); + + stat = get_clip_hrgn(graphics, &hrgn); + + if (stat == Ok && hrgn) + { + ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND); + DeleteObject(hrgn); + } + if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) { gdi_alpha_blend(graphics, pti[0].x, pti[0].y, pti[1].x - pti[0].x, pti[2].y - pti[0].y, @@ -3146,6 +3162,8 @@ hdc, srcx, srcy, srcwidth, srcheight, SRCCOPY); } + RestoreDC(graphics->hdc, save_state); + if (temp_hdc) { SelectObject(hdc, old_hbm); @@ -3284,6 +3302,12 @@ TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x1, y1, x2, y2); + if (!pen) + return InvalidParameter; + + if (pen->unit == UnitPixel && pen->width <= 0.0) + return Ok; + pt[0].X = x1; pt[0].Y = y1; pt[1].X = x2; @@ -3347,26 +3371,12 @@ return retval; } -GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path) +GpStatus GDI32_GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path) { INT save_state; GpStatus retval; HRGN hrgn=NULL; - TRACE("(%p, %p, %p)\n", graphics, pen, path); - - if(!pen || !graphics) - return InvalidParameter; - - if(graphics->busy) - return ObjectBusy; - - if (!graphics->hdc) - { - FIXME("graphics object has no HDC\n"); - return Ok; - } - save_state = prepare_dc(graphics, pen); retval = get_clip_hrgn(graphics, &hrgn); @@ -3383,6 +3393,398 @@ end: restore_dc(graphics, save_state); DeleteObject(hrgn); + + return retval; +} + +GpStatus SOFTWARE_GdipDrawThinPath(GpGraphics *graphics, GpPen *pen, GpPath *path) +{ + GpStatus stat; + GpPath* flat_path; + GpMatrix* transform; + GpRectF gp_bound_rect; + GpRect gp_output_area; + RECT output_area; + INT output_height, output_width; + DWORD *output_bits, *brush_bits=NULL; + int i; + static const BYTE static_dash_pattern[] = {1,1,1,0,1,0,1,0}; + const BYTE *dash_pattern; + INT dash_pattern_size; + BYTE *dyn_dash_pattern = NULL; + + stat = GdipClonePath(path, &flat_path); + + if (stat != Ok) + return stat; + + stat = GdipCreateMatrix(&transform); + + if (stat == Ok) + { + stat = get_graphics_transform(graphics, CoordinateSpaceDevice, + CoordinateSpaceWorld, transform); + + if (stat == Ok) + stat = GdipFlattenPath(flat_path, transform, 1.0); + + GdipDeleteMatrix(transform); + } + + /* estimate the output size in pixels, can be larger than necessary */ + if (stat == Ok) + { + output_area.left = floorf(flat_path->pathdata.Points[0].X); + output_area.right = ceilf(flat_path->pathdata.Points[0].X); + output_area.top = floorf(flat_path->pathdata.Points[0].Y); + output_area.bottom = ceilf(flat_path->pathdata.Points[0].Y); + + for (i=1; i<flat_path->pathdata.Count; i++) + { + REAL x, y; + x = flat_path->pathdata.Points[i].X; + y = flat_path->pathdata.Points[i].Y; + + if (floorf(x) < output_area.left) output_area.left = floorf(x); + if (floorf(y) < output_area.top) output_area.top = floorf(y); + if (ceilf(x) > output_area.right) output_area.right = ceilf(x); + if (ceilf(y) > output_area.bottom) output_area.bottom = ceilf(y); + } + + stat = get_graphics_bounds(graphics, &gp_bound_rect); + } + + if (stat == Ok) + { + output_area.left = max(output_area.left, floorf(gp_bound_rect.X)); + output_area.top = max(output_area.top, floorf(gp_bound_rect.Y)); + output_area.right = min(output_area.right, ceilf(gp_bound_rect.X + gp_bound_rect.Width)); + output_area.bottom = min(output_area.bottom, ceilf(gp_bound_rect.Y + gp_bound_rect.Height)); + + output_width = output_area.right - output_area.left + 1; + output_height = output_area.bottom - output_area.top + 1; + + if (output_width <= 0 || output_height <= 0) + { + GdipDeletePath(flat_path); + return Ok; + } + + gp_output_area.X = output_area.left; + gp_output_area.Y = output_area.top; + gp_output_area.Width = output_width; + gp_output_area.Height = output_height; + + output_bits = heap_alloc_zero(output_width * output_height * sizeof(DWORD)); + if (!output_bits) + stat = OutOfMemory; + } + + if (stat == Ok) + { + if (pen->brush->bt != BrushTypeSolidColor) + { + /* allocate and draw brush output */ + brush_bits = heap_alloc_zero(output_width * output_height * sizeof(DWORD)); + + if (brush_bits) + { + stat = brush_fill_pixels(graphics, pen->brush, brush_bits, + &gp_output_area, output_width); + } + else + stat = OutOfMemory; + } + + if (stat == Ok) + { + /* convert dash pattern to bool array */ + switch (pen->dash) + { + case DashStyleCustom: + { + dash_pattern_size = 0; + + for (i=0; i < pen->numdashes; i++) + dash_pattern_size += gdip_round(pen->dashes[i]); + + if (dash_pattern_size != 0) + { + dash_pattern = dyn_dash_pattern = heap_alloc(dash_pattern_size); + + if (dyn_dash_pattern) + { + int j=0; + for (i=0; i < pen->numdashes; i++) + { + int k; + for (k=0; k < gdip_round(pen->dashes[i]); k++) + dyn_dash_pattern[j++] = (i&1)^1; + } + } + else + stat = OutOfMemory; + + break; + } + /* else fall through */ + } + case DashStyleSolid: + default: + dash_pattern = static_dash_pattern; + dash_pattern_size = 1; + break; + case DashStyleDash: + dash_pattern = static_dash_pattern; + dash_pattern_size = 4; + break; + case DashStyleDot: + dash_pattern = &static_dash_pattern[4]; + dash_pattern_size = 2; + break; + case DashStyleDashDot: + dash_pattern = static_dash_pattern; + dash_pattern_size = 6; + break; + case DashStyleDashDotDot: + dash_pattern = static_dash_pattern; + dash_pattern_size = 8; + break; + } + } + + if (stat == Ok) + { + /* trace path */ + GpPointF subpath_start = flat_path->pathdata.Points[0]; + INT prev_x = INT_MAX, prev_y = INT_MAX; + int dash_pos = dash_pattern_size - 1; + + for (i=0; i < flat_path->pathdata.Count; i++) + { + BYTE type, type2; + GpPointF start_point, end_point; + GpPoint start_pointi, end_pointi; + + type = flat_path->pathdata.Types[i]; + if (i+1 < flat_path->pathdata.Count) + type2 = flat_path->pathdata.Types[i+1]; + else + type2 = PathPointTypeStart; + + start_point = flat_path->pathdata.Points[i]; + + if ((type & PathPointTypePathTypeMask) == PathPointTypeStart) + subpath_start = start_point; + + if ((type & PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath) + end_point = subpath_start; + else if ((type2 & PathPointTypePathTypeMask) == PathPointTypeStart) + continue; + else + end_point = flat_path->pathdata.Points[i+1]; + + start_pointi.X = floorf(start_point.X); + start_pointi.Y = floorf(start_point.Y); + end_pointi.X = floorf(end_point.X); + end_pointi.Y = floorf(end_point.Y); + + /* draw line segment */ + if (abs(start_pointi.Y - end_pointi.Y) > abs(start_pointi.X - end_pointi.X)) + { + INT x, y, start_y, end_y, step; + + if (start_pointi.Y < end_pointi.Y) + { + step = 1; + start_y = ceilf(start_point.Y) - output_area.top; + end_y = end_pointi.Y - output_area.top; + } + else + { + step = -1; + start_y = start_point.Y - output_area.top; + end_y = ceilf(end_point.Y) - output_area.top; + } + + for (y=start_y; y != (end_y+step); y+=step) + { + x = gdip_round( start_point.X + + (end_point.X - start_point.X) * (y + output_area.top - start_point.Y) / (end_point.Y - start_point.Y) ) + - output_area.left; + + if (x == prev_x && y == prev_y) + continue; + + prev_x = x; + prev_y = y; + dash_pos = (dash_pos + 1 == dash_pattern_size) ? 0 : dash_pos + 1; + + if (!dash_pattern[dash_pos]) + continue; + + if (x < 0 || x >= output_width || y < 0 || y >= output_height) + continue; + + if (brush_bits) + output_bits[x + y*output_width] = brush_bits[x + y*output_width]; + else + output_bits[x + y*output_width] = ((GpSolidFill*)pen->brush)->color; + } + } + else + { + INT x, y, start_x, end_x, step; + + if (start_pointi.X < end_pointi.X) + { + step = 1; + start_x = ceilf(start_point.X) - output_area.left; + end_x = end_pointi.X - output_area.left; + } + else + { + step = -1; + start_x = start_point.X - output_area.left; + end_x = ceilf(end_point.X) - output_area.left; + } + + for (x=start_x; x != (end_x+step); x+=step) + { + y = gdip_round( start_point.Y + + (end_point.Y - start_point.Y) * (x + output_area.left - start_point.X) / (end_point.X - start_point.X) ) + - output_area.top; + + if (x == prev_x && y == prev_y) + continue; + + prev_x = x; + prev_y = y; + dash_pos = (dash_pos + 1 == dash_pattern_size) ? 0 : dash_pos + 1; + + if (!dash_pattern[dash_pos]) + continue; + + if (x < 0 || x >= output_width || y < 0 || y >= output_height) + continue; + + if (brush_bits) + output_bits[x + y*output_width] = brush_bits[x + y*output_width]; + else + output_bits[x + y*output_width] = ((GpSolidFill*)pen->brush)->color; + } + } + } + } + + /* draw output image */ + if (stat == Ok) + { + stat = alpha_blend_pixels(graphics, output_area.left, output_area.top, + (BYTE*)output_bits, output_width, output_height, output_width * 4, + PixelFormat32bppARGB); + } + + heap_free(brush_bits); + heap_free(dyn_dash_pattern); + heap_free(output_bits); + } + + GdipDeletePath(flat_path); + + return stat; +} + +GpStatus SOFTWARE_GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path) +{ + GpStatus stat; + GpPath *wide_path; + GpMatrix *transform=NULL; + + /* Check if the final pen thickness in pixels is too thin. */ + if (pen->unit == UnitPixel) + { + if (pen->width < 1.415) + return SOFTWARE_GdipDrawThinPath(graphics, pen, path); + } + else + { + GpPointF points[3] = {{0,0}, {1,0}, {0,1}}; + + points[1].X = pen->width; + points[2].Y = pen->width; + + stat = GdipTransformPoints(graphics, CoordinateSpaceDevice, + CoordinateSpaceWorld, points, 3); + + if (stat != Ok) + return stat; + + if (((points[1].X-points[0].X)*(points[1].X-points[0].X) + + (points[1].Y-points[0].Y)*(points[1].Y-points[0].Y) < 2.0001) && + ((points[2].X-points[0].X)*(points[2].X-points[0].X) + + (points[2].Y-points[0].Y)*(points[2].Y-points[0].Y) < 2.0001)) + return SOFTWARE_GdipDrawThinPath(graphics, pen, path); + } + + stat = GdipClonePath(path, &wide_path); + + if (stat != Ok) + return stat; + + if (pen->unit == UnitPixel) + { + /* We have to transform this to device coordinates to get the widths right. */ + stat = GdipCreateMatrix(&transform); + + if (stat == Ok) + stat = get_graphics_transform(graphics, CoordinateSpaceDevice, + CoordinateSpaceWorld, transform); + } + + if (stat == Ok) + stat = GdipWidenPath(wide_path, pen, transform, 1.0); + + if (pen->unit == UnitPixel) + { + /* Transform the path back to world coordinates */ + if (stat == Ok) + stat = GdipInvertMatrix(transform); + + if (stat == Ok) + stat = GdipTransformPath(wide_path, transform); + } + + /* Actually draw the path */ + if (stat == Ok) + stat = GdipFillPath(graphics, pen->brush, wide_path); + + GdipDeleteMatrix(transform); + + GdipDeletePath(wide_path); + + return stat; +} + +GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path) +{ + GpStatus retval; + + TRACE("(%p, %p, %p)\n", graphics, pen, path); + + if(!pen || !graphics) + return InvalidParameter; + + if(graphics->busy) + return ObjectBusy; + + if (path->pathdata.Count == 0) + return Ok; + + if (!graphics->hdc) + retval = SOFTWARE_GdipDrawPath(graphics, pen, path); + else + retval = GDI32_GdipDrawPath(graphics, pen, path); return retval; } @@ -3934,6 +4336,23 @@ ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND); + DeleteObject(hrgn); + + hrgn = NULL; + status = get_clip_hrgn(graphics, &hrgn); + + if (status != Ok) + { + RestoreDC(graphics->hdc, save_state); + return status; + } + + if (hrgn) + { + ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND); + DeleteObject(hrgn); + } + if (GetClipBox(graphics->hdc, &rc) != NULLREGION) { BeginPath(graphics->hdc); @@ -3945,7 +4364,6 @@ RestoreDC(graphics->hdc, save_state); - DeleteObject(hrgn); return Ok; } @@ -5128,14 +5546,11 @@ return GdipSetMatrixElements(&graphics->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); } -GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state) -{ - return GdipEndContainer(graphics, state); -} - GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle, GpMatrixOrder order) { + GpStatus stat; + TRACE("(%p, %.2f, %d)\n", graphics, angle, order); if(!graphics) @@ -5144,45 +5559,119 @@ if(graphics->busy) return ObjectBusy; + if (graphics->image && graphics->image->type == ImageTypeMetafile) { + stat = METAFILE_RotateWorldTransform((GpMetafile*)graphics->image, angle, order); + + if (stat != Ok) + return stat; + } + return GdipRotateMatrix(&graphics->worldtrans, angle, order); } +static GpStatus begin_container(GpGraphics *graphics, + GraphicsContainerType type, GraphicsContainer *state) +{ + GraphicsContainerItem *container; + GpStatus sts; + + if(!graphics || !state) + return InvalidParameter; + + sts = init_container(&container, graphics, type); + if(sts != Ok) + return sts; + + list_add_head(&graphics->containers, &container->entry); + *state = graphics->contid = container->contid; + + if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (type == BEGIN_CONTAINER) + METAFILE_BeginContainerNoParams((GpMetafile*)graphics->image, container->contid); + else + METAFILE_SaveGraphics((GpMetafile*)graphics->image, container->contid); + } + + return Ok; +} + GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state) { - return GdipBeginContainer2(graphics, state); + TRACE("(%p, %p)\n", graphics, state); + return begin_container(graphics, SAVE_GRAPHICS, state); } GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics, GraphicsContainer *state) { + TRACE("(%p, %p)\n", graphics, state); + return begin_container(graphics, BEGIN_CONTAINER, state); +} + +GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state) +{ GraphicsContainerItem *container; - GpStatus sts; - - TRACE("(%p, %p)\n", graphics, state); - - if(!graphics || !state) - return InvalidParameter; - - sts = init_container(&container, graphics); - if(sts != Ok) - return sts; + GpMatrix transform; + GpStatus stat; + GpRectF scaled_srcrect; + REAL scale_x, scale_y; + + TRACE("(%p, %s, %s, %d, %p)\n", graphics, debugstr_rectf(dstrect), debugstr_rectf(srcrect), unit, state); + + if(!graphics || !dstrect || !srcrect || unit < UnitPixel || unit > UnitMillimeter || !state) + return InvalidParameter; + + stat = init_container(&container, graphics, BEGIN_CONTAINER); + if(stat != Ok) + return stat; list_add_head(&graphics->containers, &container->entry); *state = graphics->contid = container->contid; + scale_x = units_to_pixels(1.0, unit, graphics->xres); + scale_y = units_to_pixels(1.0, unit, graphics->yres); + + scaled_srcrect.X = scale_x * srcrect->X; + scaled_srcrect.Y = scale_y * srcrect->Y; + scaled_srcrect.Width = scale_x * srcrect->Width; + scaled_srcrect.Height = scale_y * srcrect->Height; + + transform.matrix[0] = dstrect->Width / scaled_srcrect.Width; + transform.matrix[1] = 0.0; + transform.matrix[2] = 0.0; + transform.matrix[3] = dstrect->Height / scaled_srcrect.Height; + transform.matrix[4] = dstrect->X - scaled_srcrect.X; + transform.matrix[5] = dstrect->Y - scaled_srcrect.Y; + + GdipMultiplyMatrix(&graphics->worldtrans, &transform, MatrixOrderPrepend); + + if (graphics->image && graphics->image->type == ImageTypeMetafile) { + METAFILE_BeginContainer((GpMetafile*)graphics->image, dstrect, srcrect, unit, container->contid); + } + return Ok; } -GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state) -{ - FIXME("(%p, %p, %p, %d, %p): stub\n", graphics, dstrect, srcrect, unit, state); - return NotImplemented; -} - GpStatus WINGDIPAPI GdipBeginContainerI(GpGraphics *graphics, GDIPCONST GpRect *dstrect, GDIPCONST GpRect *srcrect, GpUnit unit, GraphicsContainer *state) { - FIXME("(%p, %p, %p, %d, %p): stub\n", graphics, dstrect, srcrect, unit, state); - return NotImplemented; + GpRectF dstrectf, srcrectf; + + TRACE("(%p, %p, %p, %d, %p)\n", graphics, dstrect, srcrect, unit, state); + + if (!dstrect || !srcrect) + return InvalidParameter; + + dstrectf.X = dstrect->X; + dstrectf.Y = dstrect->Y; + dstrectf.Width = dstrect->Width; + dstrectf.Height = dstrect->Height; + + srcrectf.X = srcrect->X; + srcrectf.Y = srcrect->Y; + srcrectf.Width = srcrect->Width; + srcrectf.Height = srcrect->Height; + + return GdipBeginContainer(graphics, &dstrectf, &srcrectf, unit, state); } GpStatus WINGDIPAPI GdipComment(GpGraphics *graphics, UINT sizeData, GDIPCONST BYTE *data) @@ -5191,18 +5680,17 @@ return NotImplemented; } -GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state) +static GpStatus end_container(GpGraphics *graphics, GraphicsContainerType type, + GraphicsContainer state) { GpStatus sts; GraphicsContainerItem *container, *container2; - TRACE("(%p, %x)\n", graphics, state); - if(!graphics) return InvalidParameter; LIST_FOR_EACH_ENTRY(container, &graphics->containers, GraphicsContainerItem, entry){ - if(container->contid == state) + if(container->contid == state && container->type == type) break; } @@ -5225,7 +5713,26 @@ list_remove(&container->entry); delete_container(container); + if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (type == BEGIN_CONTAINER) + METAFILE_EndContainer((GpMetafile*)graphics->image, state); + else + METAFILE_RestoreGraphics((GpMetafile*)graphics->image, state); + } + return Ok; +} + +GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state) +{ + TRACE("(%p, %x)\n", graphics, state); + return end_container(graphics, BEGIN_CONTAINER, state); +} + +GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state) +{ + TRACE("(%p, %x)\n", graphics, state); + return end_container(graphics, SAVE_GRAPHICS, state); } GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, @@ -5459,6 +5966,8 @@ GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix) { + GpStatus stat; + TRACE("(%p, %p)\n", graphics, matrix); if(!graphics || !matrix) @@ -5471,6 +5980,13 @@ matrix->matrix[0], matrix->matrix[1], matrix->matrix[2], matrix->matrix[3], matrix->matrix[4], matrix->matrix[5]); + if (graphics->image && graphics->image->type == ImageTypeMetafile) { + stat = METAFILE_SetWorldTransform((GpMetafile*)graphics->image, matrix); + + if (stat != Ok) + return stat; + } + graphics->worldtrans = *matrix; return Ok; @@ -5479,6 +5995,8 @@ GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx, REAL dy, GpMatrixOrder order) { + GpStatus stat; + TRACE("(%p, %.2f, %.2f, %d)\n", graphics, dx, dy, order); if(!graphics) @@ -5486,6 +6004,13 @@ if(graphics->busy) return ObjectBusy; + + if (graphics->image && graphics->image->type == ImageTypeMetafile) { + stat = METAFILE_TranslateWorldTransform((GpMetafile*)graphics->image, dx, dy, order); + + if (stat != Ok) + return stat; + } return GdipTranslateMatrix(&graphics->worldtrans, dx, dy, order); } @@ -5561,6 +6086,13 @@ if(graphics->busy) return ObjectBusy; + + if (graphics->image && graphics->image->type == ImageTypeMetafile) + { + status = METAFILE_SetClipRect((GpMetafile*)graphics->image, x, y, width, height, mode); + if (status != Ok) + return status; + } rect.X = x; rect.Y = y; @@ -5628,8 +6160,8 @@ GpStatus WINGDIPAPI GdipDrawPolygon(GpGraphics *graphics,GpPen *pen,GDIPCONST GpPointF *points, INT count) { - INT save_state; - POINT *pti; + GpStatus status; + GpPath* path; TRACE("(%p, %p, %d)\n", graphics, points, count); @@ -5639,24 +6171,16 @@ if(graphics->busy) return ObjectBusy; - if (!graphics->hdc) - { - FIXME("graphics object has no HDC\n"); - return Ok; - } - - pti = heap_alloc_zero(sizeof(POINT) * count); - - save_state = prepare_dc(graphics, pen); - SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH)); - - transform_and_round_points(graphics, pti, (GpPointF*)points, count); - Polygon(graphics->hdc, pti, count); - - restore_dc(graphics, save_state); - heap_free(pti); - - return Ok; + status = GdipCreatePath(FillModeAlternate, &path); + if (status != Ok) return status; + + status = GdipAddPathPolygon(path, points, count); + if (status == Ok) + status = GdipDrawPath(graphics, pen, path); + + GdipDeletePath(path); + + return status; } GpStatus WINGDIPAPI GdipDrawPolygonI(GpGraphics *graphics,GpPen *pen,GDIPCONST GpPoint *points, @@ -5723,6 +6247,13 @@ if(graphics->busy) return ObjectBusy; + + if (graphics->image && graphics->image->type == ImageTypeMetafile) { + ret = METAFILE_MultiplyWorldTransform((GpMetafile*)graphics->image, matrix, order); + + if (ret != Ok) + return ret; + } m = graphics->worldtrans; @@ -5896,7 +6427,7 @@ return Ok; } -static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space, +GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space, GpCoordinateSpace src_space, GpMatrix *matrix) { GpStatus stat = Ok; @@ -6176,6 +6707,8 @@ GpPointF pt; HFONT hfont; UINT eto_flags=0; + GpStatus status; + HRGN hrgn; if (flags & unsupported_flags) FIXME("Ignoring flags %x\n", flags & unsupported_flags); @@ -6186,6 +6719,14 @@ save_state = SaveDC(graphics->hdc); SetBkMode(graphics->hdc, TRANSPARENT); SetTextColor(graphics->hdc, get_gdi_brush_color(brush)); + + status = get_clip_hrgn(graphics, &hrgn); + + if (status == Ok && hrgn) + { + ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND); + DeleteObject(hrgn); + } pt = positions[0]; GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, &pt, 1); Modified: trunk/reactos/dll/win32/gdiplus/graphicspath.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/graphics…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/graphicspath.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/graphicspath.c [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -1567,17 +1567,49 @@ GpStatus WINGDIPAPI GdipIsOutlineVisiblePathPoint(GpPath* path, REAL x, REAL y, GpPen *pen, GpGraphics *graphics, BOOL *result) { - static int calls; + GpStatus stat; + GpPath *wide_path; + GpMatrix *transform = NULL; TRACE("(%p,%0.2f,%0.2f,%p,%p,%p)\n", path, x, y, pen, graphics, result); if(!path || !pen) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); - - return NotImplemented; + stat = GdipClonePath(path, &wide_path); + + if (stat != Ok) + return stat; + + if (pen->unit == UnitPixel && graphics != NULL) + { + stat = GdipCreateMatrix(&transform); + + if (stat == Ok) + stat = get_graphics_transform(graphics, CoordinateSpaceDevice, + CoordinateSpaceWorld, transform); + } + + if (stat == Ok) + stat = GdipWidenPath(wide_path, pen, transform, 1.0); + + if (pen->unit == UnitPixel && graphics != NULL) + { + if (stat == Ok) + stat = GdipInvertMatrix(transform); + + if (stat == Ok) + stat = GdipTransformPath(wide_path, transform); + } + + if (stat == Ok) + stat = GdipIsVisiblePathPoint(wide_path, x, y, graphics, result); + + GdipDeleteMatrix(transform); + + GdipDeletePath(wide_path); + + return stat; } GpStatus WINGDIPAPI GdipIsVisiblePathPointI(GpPath* path, INT x, INT y, GpGraphics *graphics, BOOL *result) @@ -1874,7 +1906,7 @@ int i; path_list_node_t *prev_point; - if (end <= start+1) + if (end <= start) return; /* left outline */ Modified: trunk/reactos/dll/win32/gdiplus/image.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/image.c?…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/image.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/image.c [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -26,6 +26,7 @@ HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory**); #define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24) +#define WMF_PLACEABLE_KEY 0x9ac6cdd7 static const struct { @@ -2138,6 +2139,10 @@ srcRect->Height = (REAL) ((GpBitmap*)image)->height; *srcUnit = UnitPixel; } + else{ + WARN("GpImage with no image data\n"); + return InvalidParameter; + } TRACE("returning (%f, %f) (%f, %f) unit type %d\n", srcRect->X, srcRect->Y, srcRect->Width, srcRect->Height, *srcUnit); @@ -2160,6 +2165,10 @@ else if(image->type == ImageTypeBitmap){ *height = ((GpBitmap*)image)->height; *width = ((GpBitmap*)image)->width; + } + else{ + WARN("GpImage with no image data\n"); + return InvalidParameter; } TRACE("returning (%f, %f)\n", *height, *width); @@ -2215,6 +2224,11 @@ *height = units_to_pixels(((GpMetafile*)image)->bounds.Height, ((GpMetafile*)image)->unit, image->yres); else if(image->type == ImageTypeBitmap) *height = ((GpBitmap*)image)->height; + else + { + WARN("GpImage with no image data\n"); + return InvalidParameter; + } TRACE("returning %d\n", *height); @@ -2313,6 +2327,11 @@ *width = units_to_pixels(((GpMetafile*)image)->bounds.Width, ((GpMetafile*)image)->unit, image->xres); else if(image->type == ImageTypeBitmap) *width = ((GpBitmap*)image)->width; + else + { + WARN("GpImage with no image data\n"); + return InvalidParameter; + } TRACE("returning %d\n", *width); @@ -3981,29 +4000,25 @@ static GpStatus load_wmf(IStream *stream, GpMetafile **metafile) { - GpStatus status = GenericError; + WmfPlaceableFileHeader pfh; + BOOL is_placeable = FALSE; + LARGE_INTEGER seek; + GpStatus status; + METAHEADER mh; + HMETAFILE hmf; HRESULT hr; UINT size; - LARGE_INTEGER pos; - WmfPlaceableFileHeader pfh; - BOOL is_placeable = FALSE; - METAHEADER mh; - HMETAFILE hmf; void *buf; - - pos.QuadPart = 0; - IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); hr = IStream_Read(stream, &mh, sizeof(mh), &size); if (hr != S_OK || size != sizeof(mh)) return GenericError; - if (mh.mtType == 0xcdd7 && mh.mtHeaderSize == 0x9ac6) - { - is_placeable = TRUE; - - pos.QuadPart = 0; - IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); + if (((WmfPlaceableFileHeader *)&mh)->Key == WMF_PLACEABLE_KEY) + { + seek.QuadPart = 0; + hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL); + if (FAILED(hr)) return hresult_to_status(hr); hr = IStream_Read(stream, &pfh, sizeof(pfh), &size); if (hr != S_OK || size != sizeof(pfh)) @@ -4012,82 +4027,112 @@ hr = IStream_Read(stream, &mh, sizeof(mh), &size); if (hr != S_OK || size != sizeof(mh)) return GenericError; - } - - pos.QuadPart = is_placeable ? sizeof(pfh) : 0; - IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); + + is_placeable = TRUE; + } + + seek.QuadPart = is_placeable ? sizeof(pfh) : 0; + hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL); + if (FAILED(hr)) return hresult_to_status(hr); buf = heap_alloc(mh.mtSize * 2); if (!buf) return OutOfMemory; hr = IStream_Read(stream, buf, mh.mtSize * 2, &size); - if (hr == S_OK && size == mh.mtSize * 2) - { - hmf = SetMetaFileBitsEx(mh.mtSize * 2, buf); - if (hmf) - { - status = GdipCreateMetafileFromWmf(hmf, TRUE, is_placeable ? &pfh : NULL, metafile); - if (status != Ok) - DeleteMetaFile(hmf); - } - } - + if (hr != S_OK || size != mh.mtSize * 2) + { + heap_free(buf); + return GenericError; + } + + hmf = SetMetaFileBitsEx(mh.mtSize * 2, buf); heap_free(buf); + if (!hmf) + return GenericError; + + status = GdipCreateMetafileFromWmf(hmf, TRUE, is_placeable ? &pfh : NULL, metafile); + if (status != Ok) + DeleteMetaFile(hmf); return status; } +static GpStatus decode_image_wmf(IStream *stream, GpImage **image) +{ + GpMetafile *metafile; + GpStatus status; + + TRACE("%p %p\n", stream, image); + + if (!stream || !image) + return InvalidParameter; + + status = load_wmf(stream, &metafile); + if (status != Ok) + { + TRACE("Could not load metafile\n"); + return status; + } + + *image = (GpImage *)metafile; + TRACE("<-- %p\n", *image); + + return Ok; +} + static GpStatus load_emf(IStream *stream, GpMetafile **metafile) { - GpStatus status = GenericError; + LARGE_INTEGER seek; + ENHMETAHEADER emh; + HENHMETAFILE hemf; + GpStatus status; HRESULT hr; UINT size; - LARGE_INTEGER pos; - ENHMETAHEADER emh; - HENHMETAFILE hemf; void *buf; - - pos.QuadPart = 0; - IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); hr = IStream_Read(stream, &emh, sizeof(emh), &size); if (hr != S_OK || size != sizeof(emh) || emh.dSignature != ENHMETA_SIGNATURE) return GenericError; - pos.QuadPart = 0; - IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); + seek.QuadPart = 0; + hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL); + if (FAILED(hr)) return hresult_to_status(hr); buf = heap_alloc(emh.nBytes); if (!buf) return OutOfMemory; hr = IStream_Read(stream, buf, emh.nBytes, &size); - if (hr == S_OK && size == emh.nBytes) - { - hemf = SetEnhMetaFileBits(emh.nBytes, buf); - if (hemf) - { - status = GdipCreateMetafileFromEmf(hemf, FALSE, metafile); - if (status != Ok) - DeleteEnhMetaFile(hemf); - } - } - + if (hr != S_OK || size != emh.nBytes) + { + heap_free(buf); + return GenericError; + } + + hemf = SetEnhMetaFileBits(emh.nBytes, buf); heap_free(buf); + if (!hemf) + return GenericError; + + status = GdipCreateMetafileFromEmf(hemf, TRUE, metafile); + if (status != Ok) + DeleteEnhMetaFile(hemf); return status; } -static GpStatus decode_image_metafile(IStream *stream, GpImage **image) +static GpStatus decode_image_emf(IStream *stream, GpImage **image) { GpMetafile *metafile; + GpStatus status; TRACE("%p %p\n", stream, image); - if(!stream || !image) - return InvalidParameter; - - if (load_emf(stream, &metafile) != Ok && load_wmf(stream, &metafile) != Ok) + if (!stream || !image) + return InvalidParameter; + + status = load_emf(stream, &metafile); + if (status != Ok) { TRACE("Could not load metafile\n"); - return GenericError; + return status; } *image = (GpImage *)metafile; @@ -4487,7 +4532,7 @@ static GpStatus encode_image_gif(GpImage *image, IStream* stream, GDIPCONST CLSID* clsid, GDIPCONST EncoderParameters* params) { - return encode_image_wic(image, stream, &CLSID_WICGifEncoder, params); + return encode_image_wic(image, stream, &GUID_ContainerFormatGif, params); } /***************************************************************************** @@ -4500,7 +4545,7 @@ encode_image_func encode_image; int i; - TRACE("%p %p %p %p\n", image, stream, clsid, params); + TRACE("%p %p %s %p\n", image, stream, wine_dbgstr_guid(clsid), params); if(!image || !stream) return InvalidParameter; @@ -4748,7 +4793,7 @@ /* SigMask */ emf_sig_mask, }, NULL, - decode_image_metafile, + decode_image_emf, NULL }, { @@ -4768,7 +4813,7 @@ /* SigMask */ wmf_sig_mask, }, NULL, - decode_image_metafile, + decode_image_wmf, NULL }, { @@ -5348,8 +5393,15 @@ */ GpStatus WINGDIPAPI GdipImageSetAbort(GpImage *image, GdiplusAbort *pabort) { - FIXME("(%p, %p): stub\n", image, pabort); - return NotImplemented; + TRACE("(%p, %p)\n", image, pabort); + + if (!image) + return InvalidParameter; + + if (pabort) + FIXME("Abort callback is not supported.\n"); + + return Ok; } /***************************************************************************** @@ -5361,3 +5413,248 @@ FIXME("(%p, 0x%08x, %d, %d, %p, %f): stub\n", bitmap, format, dithertype, palettetype, palette, alphathreshold); return NotImplemented; } + +static void set_histogram_point_argb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + ch0[ color >> 24 ]++; + ch1[(color >> 16) & 0xff]++; + ch2[(color >> 8) & 0xff]++; + ch3[ color & 0xff]++; +} + +static void set_histogram_point_pargb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + BYTE alpha = color >> 24; + + ch0[alpha]++; + ch1[(((color >> 16) & 0xff) * alpha) / 0xff]++; + ch2[(((color >> 8) & 0xff) * alpha) / 0xff]++; + ch3[(( color & 0xff) * alpha) / 0xff]++; +} + +static void set_histogram_point_rgb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + ch0[(color >> 16) & 0xff]++; + ch1[(color >> 8) & 0xff]++; + ch2[ color & 0xff]++; +} + +static void set_histogram_point_gray(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + ch0[(76 * ((color >> 16) & 0xff) + 150 * ((color >> 8) & 0xff) + 29 * (color & 0xff)) / 0xff]++; +} + +static void set_histogram_point_b(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + ch0[color & 0xff]++; +} + +static void set_histogram_point_g(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + ch0[(color >> 8) & 0xff]++; +} + +static void set_histogram_point_r(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + ch0[(color >> 16) & 0xff]++; +} + +static void set_histogram_point_a(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + ch0[(color >> 24) & 0xff]++; +} + +/***************************************************************************** + * GdipBitmapGetHistogram [GDIPLUS.@] + */ +GpStatus WINGDIPAPI GdipBitmapGetHistogram(GpBitmap *bitmap, HistogramFormat format, UINT num_of_entries, + UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) +{ + static void (* const set_histogram_point[])(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) = + { + set_histogram_point_argb, + set_histogram_point_pargb, + set_histogram_point_rgb, + set_histogram_point_gray, + set_histogram_point_b, + set_histogram_point_g, + set_histogram_point_r, + set_histogram_point_a, + }; + UINT width, height, x, y; + + TRACE("(%p, %d, %u, %p, %p, %p, %p)\n", bitmap, format, num_of_entries, + ch0, ch1, ch2, ch3); + + if (!bitmap || num_of_entries != 256) + return InvalidParameter; + + /* Make sure passed channel pointers match requested format */ + switch (format) + { + case HistogramFormatARGB: + case HistogramFormatPARGB: + if (!ch0 || !ch1 || !ch2 || !ch3) + return InvalidParameter; + memset(ch0, 0, num_of_entries * sizeof(UINT)); + memset(ch1, 0, num_of_entries * sizeof(UINT)); + memset(ch2, 0, num_of_entries * sizeof(UINT)); + memset(ch3, 0, num_of_entries * sizeof(UINT)); + break; + case HistogramFormatRGB: + if (!ch0 || !ch1 || !ch2 || ch3) + return InvalidParameter; + memset(ch0, 0, num_of_entries * sizeof(UINT)); + memset(ch1, 0, num_of_entries * sizeof(UINT)); + memset(ch2, 0, num_of_entries * sizeof(UINT)); + break; + case HistogramFormatGray: + case HistogramFormatB: + case HistogramFormatG: + case HistogramFormatR: + case HistogramFormatA: + if (!ch0 || ch1 || ch2 || ch3) + return InvalidParameter; + memset(ch0, 0, num_of_entries * sizeof(UINT)); + break; + default: + WARN("Invalid histogram format requested, %d\n", format); + return InvalidParameter; + } + + GdipGetImageWidth(&bitmap->image, &width); + GdipGetImageHeight(&bitmap->image, &height); + + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + { + ARGB color; + + GdipBitmapGetPixel(bitmap, x, y, &color); + set_histogram_point[format](color, ch0, ch1, ch2, ch3); + } + + return Ok; +} + +/***************************************************************************** + * GdipBitmapGetHistogramSize [GDIPLUS.@] + */ +GpStatus WINGDIPAPI GdipBitmapGetHistogramSize(HistogramFormat format, UINT *num_of_entries) +{ + TRACE("(%d, %p)\n", format, num_of_entries); + + if (!num_of_entries) + return InvalidParameter; + + *num_of_entries = 256; + return Ok; +} + +static GpStatus create_optimal_palette(ColorPalette *palette, INT desired, + BOOL transparent, GpBitmap *bitmap) +{ + GpStatus status; + BitmapData data; + HRESULT hr; + IWICImagingFactory *factory; + IWICPalette *wic_palette; + + if (!bitmap) return InvalidParameter; + if (palette->Count < desired) return GenericError; + + status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, PixelFormat24bppRGB, &data); + if (status != Ok) return status; + + hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory); + if (hr != S_OK) + { + GdipBitmapUnlockBits(bitmap, &data); + return hresult_to_status(hr); + } + + hr = IWICImagingFactory_CreatePalette(factory, &wic_palette); + if (hr == S_OK) + { + IWICBitmap *bitmap; + + /* PixelFormat24bppRGB actually stores the bitmap bits as BGR. */ + hr = IWICImagingFactory_CreateBitmapFromMemory(factory, data.Width, data.Height, + &GUID_WICPixelFormat24bppBGR, data.Stride, data.Stride * data.Width, data.Scan0, &bitmap); + if (hr == S_OK) + { + hr = IWICPalette_InitializeFromBitmap(wic_palette, (IWICBitmapSource *)bitmap, desired, transparent); + if (hr == S_OK) + { + palette->Flags = 0; + IWICPalette_GetColorCount(wic_palette, &palette->Count); + IWICPalette_GetColors(wic_palette, palette->Count, palette->Entries, &palette->Count); + } + + IWICBitmap_Release(bitmap); + } + + IWICPalette_Release(wic_palette); + } + + IWICImagingFactory_Release(factory); + GdipBitmapUnlockBits(bitmap, &data); + + return hresult_to_status(hr); +} + +/***************************************************************************** + * GdipInitializePalette [GDIPLUS.@] + */ +GpStatus WINGDIPAPI GdipInitializePalette(ColorPalette *palette, + PaletteType type, INT desired, BOOL transparent, GpBitmap *bitmap) +{ + TRACE("(%p,%d,%d,%d,%p)\n", palette, type, desired, transparent, bitmap); + + if (!palette) return InvalidParameter; + + switch (type) + { + case PaletteTypeCustom: + return Ok; + + case PaletteTypeOptimal: + return create_optimal_palette(palette, desired, transparent, bitmap); + + /* WIC palette type enumeration matches these gdiplus enums */ + case PaletteTypeFixedBW: + case PaletteTypeFixedHalftone8: + case PaletteTypeFixedHalftone27: + case PaletteTypeFixedHalftone64: + case PaletteTypeFixedHalftone125: + case PaletteTypeFixedHalftone216: + case PaletteTypeFixedHalftone252: + case PaletteTypeFixedHalftone256: + { + ColorPalette *wic_palette; + GpStatus status = Ok; + + wic_palette = get_palette(NULL, type); + if (!wic_palette) return OutOfMemory; + + if (palette->Count >= wic_palette->Count) + { + palette->Flags = wic_palette->Flags; + palette->Count = wic_palette->Count; + memcpy(palette->Entries, wic_palette->Entries, wic_palette->Count * sizeof(wic_palette->Entries[0])); + } + else + status = GenericError; + + heap_free(wic_palette); + + return status; + } + + default: + FIXME("unknown palette type %d\n", type); + break; + } + + return InvalidParameter; +} Modified: trunk/reactos/dll/win32/gdiplus/imageattributes.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/imageatt…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/imageattributes.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/imageattributes.c [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -21,17 +21,51 @@ GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr, GpImageAttributes **cloneImageattr) { - GpStatus stat; + GpStatus stat = Ok; + struct color_remap_table remap_tables[ColorAdjustTypeCount] = {{0}}; + int i; TRACE("(%p, %p)\n", imageattr, cloneImageattr); if(!imageattr || !cloneImageattr) return InvalidParameter; - stat = GdipCreateImageAttributes(cloneImageattr); + for (i=0; i<ColorAdjustTypeCount; i++) + { + if (imageattr->colorremaptables[i].enabled) + { + remap_tables[i].enabled = TRUE; + remap_tables[i].mapsize = imageattr->colorremaptables[i].mapsize; + remap_tables[i].colormap = heap_alloc(sizeof(ColorMap) * remap_tables[i].mapsize); + + if (remap_tables[i].colormap) + { + memcpy(remap_tables[i].colormap, imageattr->colorremaptables[i].colormap, + sizeof(ColorMap) * remap_tables[i].mapsize); + } + else + { + stat = OutOfMemory; + break; + } + } + } if (stat == Ok) + stat = GdipCreateImageAttributes(cloneImageattr); + + if (stat == Ok) + { **cloneImageattr = *imageattr; + + memcpy((*cloneImageattr)->colorremaptables, remap_tables, sizeof(remap_tables)); + } + + if (stat != Ok) + { + for (i=0; i<ColorAdjustTypeCount; i++) + heap_free(remap_tables[i].colormap); + } return stat; } Modified: trunk/reactos/dll/win32/gdiplus/matrix.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/matrix.c…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/matrix.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/matrix.c [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -484,23 +484,17 @@ GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix *matrix, BOOL *result) { - GpMatrix *e; - GpStatus ret; - BOOL isIdentity; + static const GpMatrix identity = + { + { 1.0, 0.0, + 0.0, 1.0, + 0.0, 0.0 } + }; TRACE("(%p, %p)\n", matrix, result); if(!matrix || !result) return InvalidParameter; - ret = GdipCreateMatrix(&e); - if(ret != Ok) return ret; - - ret = GdipIsMatrixEqual(matrix, e, &isIdentity); - if(ret == Ok) - *result = isIdentity; - - heap_free(e); - - return ret; -} + return GdipIsMatrixEqual(matrix, &identity, result); +} Modified: trunk/reactos/dll/win32/gdiplus/metafile.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdiplus/metafile…
============================================================================== --- trunk/reactos/dll/win32/gdiplus/metafile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdiplus/metafile.c [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -48,6 +48,12 @@ DWORD Count; } EmfPlusFillRects; +typedef struct EmfPlusSetClipRect +{ + EmfPlusRecordHeader Header; + GpRectF ClipRect; +} EmfPlusSetClipRect; + typedef struct EmfPlusSetPageTransform { EmfPlusRecordHeader Header; @@ -62,12 +68,69 @@ SHORT Height; } EmfPlusRect; +typedef struct EmfPlusSetWorldTransform +{ + EmfPlusRecordHeader Header; + REAL MatrixData[6]; +} EmfPlusSetWorldTransform; + typedef struct EmfPlusScaleWorldTransform { EmfPlusRecordHeader Header; REAL Sx; REAL Sy; } EmfPlusScaleWorldTransform; + +typedef struct EmfPlusMultiplyWorldTransform +{ + EmfPlusRecordHeader Header; + REAL MatrixData[6]; +} EmfPlusMultiplyWorldTransform; + +typedef struct EmfPlusRotateWorldTransform +{ + EmfPlusRecordHeader Header; + REAL Angle; +} EmfPlusRotateWorldTransform; + +typedef struct EmfPlusTranslateWorldTransform +{ + EmfPlusRecordHeader Header; + REAL dx; + REAL dy; +} EmfPlusTranslateWorldTransform; + +typedef struct EmfPlusBeginContainer +{ + EmfPlusRecordHeader Header; + GpRectF DestRect; + GpRectF SrcRect; + DWORD StackIndex; +} EmfPlusBeginContainer; + +typedef struct EmfPlusContainerRecord +{ + EmfPlusRecordHeader Header; + DWORD StackIndex; +} EmfPlusContainerRecord; + +enum container_type +{ + BEGIN_CONTAINER, + SAVE_GRAPHICS +}; + +typedef struct container +{ + struct list entry; + DWORD id; + enum container_type type; + GraphicsContainer state; + GpMatrix world_transform; + GpUnit page_unit; + REAL page_scale; + GpRegion *clip; +} container; static GpStatus METAFILE_AllocateRecord(GpMetafile *metafile, DWORD size, void **result) { @@ -260,6 +323,7 @@ (*metafile)->comment_data_size = 0; (*metafile)->comment_data_length = 0; (*metafile)->hemf = NULL; + list_init(&(*metafile)->containers); if (!frameRect) { @@ -516,6 +580,32 @@ return Ok; } +GpStatus METAFILE_SetClipRect(GpMetafile* metafile, REAL x, REAL y, REAL width, REAL height, CombineMode mode) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusSetClipRect *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusSetClipRect), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeSetClipRect; + record->Header.Flags = (mode & 0xf) << 8; + record->ClipRect.X = x; + record->ClipRect.Y = y; + record->ClipRect.Width = width; + record->ClipRect.Height = height; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + GpStatus METAFILE_SetPageTransform(GpMetafile* metafile, GpUnit unit, REAL scale) { if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) @@ -539,6 +629,29 @@ return Ok; } +GpStatus METAFILE_SetWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* transform) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusSetWorldTransform *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusSetWorldTransform), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeSetWorldTransform; + record->Header.Flags = 0; + memcpy(record->MatrixData, transform->matrix, sizeof(record->MatrixData)); + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + GpStatus METAFILE_ScaleWorldTransform(GpMetafile* metafile, REAL sx, REAL sy, MatrixOrder order) { if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) @@ -553,9 +666,79 @@ return stat; record->Header.Type = EmfPlusRecordTypeScaleWorldTransform; - record->Header.Flags = (order == MatrixOrderAppend ? 4 : 0); + record->Header.Flags = (order == MatrixOrderAppend ? 0x2000 : 0); record->Sx = sx; record->Sy = sy; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_MultiplyWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* matrix, MatrixOrder order) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusMultiplyWorldTransform *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusMultiplyWorldTransform), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeMultiplyWorldTransform; + record->Header.Flags = (order == MatrixOrderAppend ? 0x2000 : 0); + memcpy(record->MatrixData, matrix->matrix, sizeof(record->MatrixData)); + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_RotateWorldTransform(GpMetafile* metafile, REAL angle, MatrixOrder order) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusRotateWorldTransform *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusRotateWorldTransform), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeRotateWorldTransform; + record->Header.Flags = (order == MatrixOrderAppend ? 0x2000 : 0); + record->Angle = angle; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_TranslateWorldTransform(GpMetafile* metafile, REAL dx, REAL dy, MatrixOrder order) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusTranslateWorldTransform *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusTranslateWorldTransform), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeTranslateWorldTransform; + record->Header.Flags = (order == MatrixOrderAppend ? 0x2000 : 0); + record->dx = dx; + record->dy = dy; METAFILE_WriteRecords(metafile); } @@ -578,6 +761,122 @@ record->Type = EmfPlusRecordTypeResetWorldTransform; record->Flags = 0; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_BeginContainer(GpMetafile* metafile, GDIPCONST GpRectF *dstrect, + GDIPCONST GpRectF *srcrect, GpUnit unit, DWORD StackIndex) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusBeginContainer *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, sizeof(*record), (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeBeginContainer; + record->Header.Flags = unit & 0xff; + record->DestRect = *dstrect; + record->SrcRect = *srcrect; + record->StackIndex = StackIndex; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_BeginContainerNoParams(GpMetafile* metafile, DWORD StackIndex) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusContainerRecord *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusContainerRecord), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeBeginContainerNoParams; + record->Header.Flags = 0; + record->StackIndex = StackIndex; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_EndContainer(GpMetafile* metafile, DWORD StackIndex) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusContainerRecord *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusContainerRecord), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeEndContainer; + record->Header.Flags = 0; + record->StackIndex = StackIndex; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_SaveGraphics(GpMetafile* metafile, DWORD StackIndex) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusContainerRecord *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusContainerRecord), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeSave; + record->Header.Flags = 0; + record->StackIndex = StackIndex; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + +GpStatus METAFILE_RestoreGraphics(GpMetafile* metafile, DWORD StackIndex) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusContainerRecord *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusContainerRecord), + (void**)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeRestore; + record->Header.Flags = 0; + record->StackIndex = StackIndex; METAFILE_WriteRecords(metafile); } @@ -719,6 +1018,36 @@ return Ok; } +static void METAFILE_GetFinalGdiTransform(const GpMetafile *metafile, XFORM *result) +{ + const GpRectF *rect; + const GpPointF *pt; + + /* This transforms metafile device space to output points. */ + rect = &metafile->src_rect; + pt = metafile->playback_points; + result->eM11 = (pt[1].X - pt[0].X) / rect->Width; + result->eM21 = (pt[2].X - pt[0].X) / rect->Height; + result->eDx = pt[0].X - result->eM11 * rect->X - result->eM21 * rect->Y; + result->eM12 = (pt[1].Y - pt[0].Y) / rect->Width; + result->eM22 = (pt[2].Y - pt[0].Y) / rect->Height; + result->eDy = pt[0].Y - result->eM12 * rect->X - result->eM22 * rect->Y; +} + +static GpStatus METAFILE_PlaybackUpdateGdiTransform(GpMetafile *metafile) +{ + XFORM combined, final; + + METAFILE_GetFinalGdiTransform(metafile, &final); + + CombineTransform(&combined, &metafile->gdiworldtransform, &final); + + SetGraphicsMode(metafile->playback_dc, GM_ADVANCED); + SetWorldTransform(metafile->playback_dc, &combined); + + return Ok; +} + static GpStatus METAFILE_PlaybackGetDC(GpMetafile *metafile) { GpStatus stat = Ok; @@ -727,20 +1056,10 @@ if (stat == Ok) { - /* The result of GdipGetDC always expects device co-ordinates, but the - * device co-ordinates of the source metafile do not correspond to - * device co-ordinates of the destination. Therefore, we set up the DC - * so that the metafile's bounds map to the destination points where we - * are drawing this metafile. */ - SetMapMode(metafile->playback_dc, MM_ANISOTROPIC); - - SetWindowOrgEx(metafile->playback_dc, metafile->bounds.X, metafile->bounds.Y, NULL); - SetWindowExtEx(metafile->playback_dc, metafile->bounds.Width, metafile->bounds.Height, NULL); - - SetViewportOrgEx(metafile->playback_dc, metafile->playback_points[0].X, metafile->playback_points[0].Y, NULL); - SetViewportExtEx(metafile->playback_dc, - metafile->playback_points[1].X - metafile->playback_points[0].X, - metafile->playback_points[2].Y - metafile->playback_points[0].Y, NULL); + static const XFORM identity = {1, 0, 0, 1, 0, 0}; + + metafile->gdiworldtransform = identity; + METAFILE_PlaybackUpdateGdiTransform(metafile); } return stat; @@ -757,7 +1076,11 @@ static GpStatus METAFILE_PlaybackUpdateClip(GpMetafile *metafile) { - return GdipCombineRegionRegion(metafile->playback_graphics->clip, metafile->base_clip, CombineModeReplace); + GpStatus stat; + stat = GdipCombineRegionRegion(metafile->playback_graphics->clip, metafile->base_clip, CombineModeReplace); + if (stat == Ok) + stat = GdipCombineRegionRegion(metafile->playback_graphics->clip, metafile->clip, CombineModeIntersect); + return stat; } static GpStatus METAFILE_PlaybackUpdateWorldTransform(GpMetafile *metafile) @@ -805,6 +1128,53 @@ if (metafile->playback_dc) { ENHMETARECORD *record; + + switch (recordType) + { + case EMR_SETMAPMODE: + case EMR_SAVEDC: + case EMR_RESTOREDC: + case EMR_SETWINDOWORGEX: + case EMR_SETWINDOWEXTEX: + case EMR_SETVIEWPORTORGEX: + case EMR_SETVIEWPORTEXTEX: + case EMR_SCALEVIEWPORTEXTEX: + case EMR_SCALEWINDOWEXTEX: + case EMR_MODIFYWORLDTRANSFORM: + FIXME("not implemented for record type %x\n", recordType); + break; + case EMR_SETWORLDTRANSFORM: + { + const XFORM* xform = (void*)data; + real_metafile->gdiworldtransform = *xform; + METAFILE_PlaybackUpdateGdiTransform(real_metafile); + break; + } + case EMR_EXTSELECTCLIPRGN: + { + DWORD rgndatasize = *(DWORD*)data; + DWORD mode = *(DWORD*)(data + 4); + const RGNDATA *rgndata = (const RGNDATA*)(data + 8); + HRGN hrgn = NULL; + + if (dataSize > 8) + { + XFORM final; + + METAFILE_GetFinalGdiTransform(metafile, &final); + + hrgn = ExtCreateRegion(&final, rgndatasize, rgndata); + } + + ExtSelectClipRgn(metafile->playback_dc, hrgn, mode); + + DeleteObject(hrgn); + + return Ok; + } + default: + break; + } record = heap_alloc_zero(dataSize + 8); @@ -909,6 +1279,32 @@ return stat; } + case EmfPlusRecordTypeSetClipRect: + { + EmfPlusSetClipRect *record = (EmfPlusSetClipRect*)header; + CombineMode mode = (CombineMode)((flags >> 8) & 0xf); + GpRegion *region; + GpMatrix world_to_device; + + if (dataSize + sizeof(EmfPlusRecordHeader) < sizeof(*record)) + return InvalidParameter; + + stat = GdipCreateRegionRect(&record->ClipRect, ®ion); + + if (stat == Ok) + { + get_graphics_transform(real_metafile->playback_graphics, + CoordinateSpaceDevice, CoordinateSpaceWorld, &world_to_device); + + GdipTransformRegion(region, &world_to_device); + + GdipCombineRegionRegion(real_metafile->clip, region, mode); + + GdipDeleteRegion(region); + } + + return METAFILE_PlaybackUpdateClip(real_metafile); + } case EmfPlusRecordTypeSetPageTransform: { EmfPlusSetPageTransform *record = (EmfPlusSetPageTransform*)header; @@ -922,10 +1318,21 @@ return METAFILE_PlaybackUpdateWorldTransform(real_metafile); } + case EmfPlusRecordTypeSetWorldTransform: + { + EmfPlusSetWorldTransform *record = (EmfPlusSetWorldTransform*)header; + + if (dataSize + sizeof(EmfPlusRecordHeader) < sizeof(EmfPlusSetWorldTransform)) + return InvalidParameter; + + memcpy(real_metafile->world_transform->matrix, record->MatrixData, sizeof(record->MatrixData)); + + return METAFILE_PlaybackUpdateWorldTransform(real_metafile); + } case EmfPlusRecordTypeScaleWorldTransform: { EmfPlusScaleWorldTransform *record = (EmfPlusScaleWorldTransform*)header; - MatrixOrder order = (flags & 0x4) ? MatrixOrderAppend : MatrixOrderPrepend; + MatrixOrder order = (flags & 0x2000) ? MatrixOrderAppend : MatrixOrderPrepend; if (dataSize + sizeof(EmfPlusRecordHeader) < sizeof(EmfPlusScaleWorldTransform)) return InvalidParameter; @@ -934,11 +1341,199 @@ return METAFILE_PlaybackUpdateWorldTransform(real_metafile); } + case EmfPlusRecordTypeMultiplyWorldTransform: + { + EmfPlusMultiplyWorldTransform *record = (EmfPlusMultiplyWorldTransform*)header; + MatrixOrder order = (flags & 0x2000) ? MatrixOrderAppend : MatrixOrderPrepend; + GpMatrix matrix; + + if (dataSize + sizeof(EmfPlusRecordHeader) < sizeof(EmfPlusMultiplyWorldTransform)) + return InvalidParameter; + + memcpy(matrix.matrix, record->MatrixData, sizeof(matrix.matrix)); + + GdipMultiplyMatrix(real_metafile->world_transform, &matrix, order); + + return METAFILE_PlaybackUpdateWorldTransform(real_metafile); + } + case EmfPlusRecordTypeRotateWorldTransform: + { + EmfPlusRotateWorldTransform *record = (EmfPlusRotateWorldTransform*)header; + MatrixOrder order = (flags & 0x2000) ? MatrixOrderAppend : MatrixOrderPrepend; + + if (dataSize + sizeof(EmfPlusRecordHeader) < sizeof(EmfPlusRotateWorldTransform)) + return InvalidParameter; + + GdipRotateMatrix(real_metafile->world_transform, record->Angle, order); + + return METAFILE_PlaybackUpdateWorldTransform(real_metafile); + } + case EmfPlusRecordTypeTranslateWorldTransform: + { + EmfPlusTranslateWorldTransform *record = (EmfPlusTranslateWorldTransform*)header; + MatrixOrder order = (flags & 0x2000) ? MatrixOrderAppend : MatrixOrderPrepend; + + if (dataSize + sizeof(EmfPlusRecordHeader) < sizeof(EmfPlusTranslateWorldTransform)) + return InvalidParameter; + + GdipTranslateMatrix(real_metafile->world_transform, record->dx, record->dy, order); + + return METAFILE_PlaybackUpdateWorldTransform(real_metafile); + } case EmfPlusRecordTypeResetWorldTransform: { GdipSetMatrixElements(real_metafile->world_transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); return METAFILE_PlaybackUpdateWorldTransform(real_metafile); + } + case EmfPlusRecordTypeBeginContainer: + { + EmfPlusBeginContainer *record = (EmfPlusBeginContainer*)header; + container* cont; + GpUnit unit; + REAL scale_x, scale_y; + GpRectF scaled_srcrect; + GpMatrix transform; + + cont = heap_alloc_zero(sizeof(*cont)); + if (!cont) + return OutOfMemory; + + stat = GdipCloneRegion(metafile->clip, &cont->clip); + if (stat != Ok) + { + heap_free(cont); + return stat; + } + + stat = GdipBeginContainer2(metafile->playback_graphics, &cont->state); + + if (stat != Ok) + { + GdipDeleteRegion(cont->clip); + heap_free(cont); + return stat; + } + + cont->id = record->StackIndex; + cont->type = BEGIN_CONTAINER; + cont->world_transform = *metafile->world_transform; + cont->page_unit = metafile->page_unit; + cont->page_scale = metafile->page_scale; + list_add_head(&real_metafile->containers, &cont->entry); + + unit = record->Header.Flags & 0xff; + + scale_x = units_to_pixels(1.0, unit, metafile->image.xres); + scale_y = units_to_pixels(1.0, unit, metafile->image.yres); + + scaled_srcrect.X = scale_x * record->SrcRect.X; + scaled_srcrect.Y = scale_y * record->SrcRect.Y; + scaled_srcrect.Width = scale_x * record->SrcRect.Width; + scaled_srcrect.Height = scale_y * record->SrcRect.Height; + + transform.matrix[0] = record->DestRect.Width / scaled_srcrect.Width; + transform.matrix[1] = 0.0; + transform.matrix[2] = 0.0; + transform.matrix[3] = record->DestRect.Height / scaled_srcrect.Height; + transform.matrix[4] = record->DestRect.X - scaled_srcrect.X; + transform.matrix[5] = record->DestRect.Y - scaled_srcrect.Y; + + GdipMultiplyMatrix(real_metafile->world_transform, &transform, MatrixOrderPrepend); + + return METAFILE_PlaybackUpdateWorldTransform(real_metafile); + } + case EmfPlusRecordTypeBeginContainerNoParams: + case EmfPlusRecordTypeSave: + { + EmfPlusContainerRecord *record = (EmfPlusContainerRecord*)header; + container* cont; + + cont = heap_alloc_zero(sizeof(*cont)); + if (!cont) + return OutOfMemory; + + stat = GdipCloneRegion(metafile->clip, &cont->clip); + if (stat != Ok) + { + heap_free(cont); + return stat; + } + + if (recordType == EmfPlusRecordTypeBeginContainerNoParams) + stat = GdipBeginContainer2(metafile->playback_graphics, &cont->state); + else + stat = GdipSaveGraphics(metafile->playback_graphics, &cont->state); + + if (stat != Ok) + { + GdipDeleteRegion(cont->clip); + heap_free(cont); + return stat; + } + + cont->id = record->StackIndex; + if (recordType == EmfPlusRecordTypeBeginContainerNoParams) + cont->type = BEGIN_CONTAINER; + else + cont->type = SAVE_GRAPHICS; + cont->world_transform = *metafile->world_transform; + cont->page_unit = metafile->page_unit; + cont->page_scale = metafile->page_scale; + list_add_head(&real_metafile->containers, &cont->entry); + + break; + } + case EmfPlusRecordTypeEndContainer: + case EmfPlusRecordTypeRestore: + { + EmfPlusContainerRecord *record = (EmfPlusContainerRecord*)header; + container* cont; + enum container_type type; + BOOL found=FALSE; + + if (recordType == EmfPlusRecordTypeEndContainer) + type = BEGIN_CONTAINER; + else + type = SAVE_GRAPHICS; + + LIST_FOR_EACH_ENTRY(cont, &real_metafile->containers, container, entry) + { + if (cont->id == record->StackIndex && cont->type == type) + { + found = TRUE; + break; + } + } + + if (found) + { + container* cont2; + + /* pop any newer items on the stack */ + while ((cont2 = LIST_ENTRY(list_head(&real_metafile->containers), container, entry)) != cont) + { + list_remove(&cont2->entry); + GdipDeleteRegion(cont2->clip); + heap_free(cont2); + } + + if (type == BEGIN_CONTAINER) + GdipEndContainer(real_metafile->playback_graphics, cont->state); + else + GdipRestoreGraphics(real_metafile->playback_graphics, cont->state); + + *real_metafile->world_transform = cont->world_transform; + real_metafile->page_unit = cont->page_unit; + real_metafile->page_scale = cont->page_scale; + GdipCombineRegionRegion(real_metafile->clip, cont->clip, CombineModeReplace); + + list_remove(&cont->entry); + GdipDeleteRegion(cont->clip); + heap_free(cont); + } + + break; } default: FIXME("Not implemented for record type %x\n", recordType); @@ -1063,6 +1658,9 @@ if (stat == Ok) stat = GdipGetClip(graphics, real_metafile->base_clip); + + if (stat == Ok) + stat = GdipCreateRegion(&real_metafile->clip); if (stat == Ok) stat = GdipCreatePath(FillModeAlternate, &dst_path); @@ -1118,6 +1716,17 @@ GdipDeleteRegion(real_metafile->base_clip); real_metafile->base_clip = NULL; + GdipDeleteRegion(real_metafile->clip); + real_metafile->clip = NULL; + + while (list_head(&real_metafile->containers)) + { + container* cont = LIST_ENTRY(list_head(&real_metafile->containers), container, entry); + list_remove(&cont->entry); + GdipDeleteRegion(cont->clip); + heap_free(cont); + } + GdipEndContainer(graphics, state); } @@ -1199,17 +1808,22 @@ if(!metafile || !header) return InvalidParameter; - if (!metafile->hemf) - return InvalidParameter; - - status = GdipGetMetafileHeaderFromEmf(metafile->hemf, header); - if (status != Ok) return status; + if (metafile->hemf) + { + status = GdipGetMetafileHeaderFromEmf(metafile->hemf, header); + if (status != Ok) return status; + } + else + { + memset(header, 0, sizeof(*header)); + header->Version = 0xdbc01002; + } header->Type = metafile->metafile_type; header->DpiX = metafile->image.xres; header->DpiY = metafile->image.yres; - header->Width = metafile->bounds.Width; - header->Height = metafile->bounds.Height; + header->Width = gdip_round(metafile->bounds.Width); + header->Height = gdip_round(metafile->bounds.Height); return Ok; } @@ -1390,6 +2004,7 @@ (*metafile)->metafile_type = header.Type; (*metafile)->hemf = hemf; (*metafile)->preserve_hemf = !delete; + list_init(&(*metafile)->containers); TRACE("<-- %p\n", *metafile); Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 22:35:44 2016 @@ -68,7 +68,7 @@ reactos/dll/win32/faultrep # Synced to WineStaging-1.9.11 reactos/dll/win32/fontsub # Synced to WineStaging-1.9.13 reactos/dll/win32/fusion # Synced to WineStaging-1.9.23 -reactos/dll/win32/gdiplus # Synced to WineStaging-1.9.16 +reactos/dll/win32/gdiplus # Synced to WineStaging-1.9.23 reactos/dll/win32/hhctrl.ocx # Synced to WineStaging-1.9.16 reactos/dll/win32/hlink # Synced to WineStaging-1.9.16 reactos/dll/win32/hnetcfg # Synced to WineStaging-1.9.16
8 years, 1 month
1
0
0
0
[akhaldi] 73269: [PSDK] Update gdipluscolormatrix.h, gdiplusenums.h and gdiplusflat.h CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:31:42 2016 New Revision: 73269 URL:
http://svn.reactos.org/svn/reactos?rev=73269&view=rev
Log: [PSDK] Update gdipluscolormatrix.h, gdiplusenums.h and gdiplusflat.h CORE-12409 Modified: trunk/reactos/sdk/include/psdk/gdipluscolormatrix.h trunk/reactos/sdk/include/psdk/gdiplusenums.h trunk/reactos/sdk/include/psdk/gdiplusflat.h Modified: trunk/reactos/sdk/include/psdk/gdipluscolormatrix.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/gdiplusco…
============================================================================== --- trunk/reactos/sdk/include/psdk/gdipluscolormatrix.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/gdipluscolormatrix.h [iso-8859-1] Thu Nov 17 22:31:42 2016 @@ -48,10 +48,23 @@ Color newColor; }; +enum HistogramFormat +{ + HistogramFormatARGB, + HistogramFormatPARGB, + HistogramFormatRGB, + HistogramFormatGray, + HistogramFormatB, + HistogramFormatG, + HistogramFormatR, + HistogramFormatA, +}; + #ifndef __cplusplus typedef enum ColorAdjustType ColorAdjustType; typedef enum ColorMatrixFlags ColorMatrixFlags; +typedef enum HistogramFormat HistogramFormat; typedef struct ColorMatrix ColorMatrix; typedef struct ColorMap ColorMap; Modified: trunk/reactos/sdk/include/psdk/gdiplusenums.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/gdiplusen…
============================================================================== --- trunk/reactos/sdk/include/psdk/gdiplusenums.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/gdiplusenums.h [iso-8859-1] Thu Nov 17 22:31:42 2016 @@ -47,7 +47,7 @@ DriverStringOptionsCmapLookup = 1, DriverStringOptionsVertical = 2, DriverStringOptionsRealizedAdvance = 4, - DriverStringOptionsLimitSubpixel = 4 + DriverStringOptionsLimitSubpixel = 8 }; enum FillMode Modified: trunk/reactos/sdk/include/psdk/gdiplusflat.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/gdiplusfl…
============================================================================== --- trunk/reactos/sdk/include/psdk/gdiplusflat.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/gdiplusflat.h [iso-8859-1] Thu Nov 17 22:31:42 2016 @@ -41,6 +41,8 @@ /* Bitmap */ GpStatus WINGDIPAPI GdipBitmapApplyEffect(GpBitmap*,CGpEffect*,RECT*,BOOL,VOID**,INT*); GpStatus WINGDIPAPI GdipBitmapCreateApplyEffect(GpBitmap**,INT,CGpEffect*,RECT*,RECT*,GpBitmap**,BOOL,VOID**,INT*); +GpStatus WINGDIPAPI GdipBitmapGetHistogram(GpBitmap*,HistogramFormat,UINT,UINT*,UINT*,UINT*,UINT*); +GpStatus WINGDIPAPI GdipBitmapGetHistogramSize(HistogramFormat,UINT*); GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap*,INT,INT,ARGB*); GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap*,GDIPCONST GpRect*,UINT, PixelFormat,BitmapData*); @@ -262,6 +264,7 @@ GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics*,ARGB); GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics*,GpRectF*); GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics*,GpRect*); +GpStatus WINGDIPAPI GdipInitializePalette(ColorPalette*,PaletteType,INT,BOOL,GpBitmap*); GpStatus WINGDIPAPI GdipIsClipEmpty(GpGraphics*, BOOL*); GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics*,REAL,REAL,BOOL*); GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics*,INT,INT,BOOL*);
8 years, 1 month
1
0
0
0
[akhaldi] 73268: [FUSION_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:28:40 2016 New Revision: 73268 URL:
http://svn.reactos.org/svn/reactos?rev=73268&view=rev
Log: [FUSION_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/rostests/winetests/fusion/asmenum.c trunk/rostests/winetests/fusion/asmname.c Modified: trunk/rostests/winetests/fusion/asmenum.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/fusion/asmenum.…
============================================================================== --- trunk/rostests/winetests/fusion/asmenum.c [iso-8859-1] (original) +++ trunk/rostests/winetests/fusion/asmenum.c [iso-8859-1] Thu Nov 17 22:28:40 2016 @@ -41,7 +41,7 @@ IUnknown *pUnkReserved, IAssemblyName *pName, DWORD dwFlags, LPVOID pvReserved); -static HRESULT (WINAPI *pCreateAssemblyNameObject)(LPASSEMBLYNAME *ppAssemblyNameObj, +static HRESULT (WINAPI *pCreateAssemblyNameObject)(IAssemblyName **ppAssemblyNameObj, LPCWSTR szAssemblyName, DWORD dwFlags, LPVOID pvReserved); static HRESULT (WINAPI *pGetCachePath)(ASM_CACHE_FLAGS dwCacheFlags, Modified: trunk/rostests/winetests/fusion/asmname.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/fusion/asmname.…
============================================================================== --- trunk/rostests/winetests/fusion/asmname.c [iso-8859-1] (original) +++ trunk/rostests/winetests/fusion/asmname.c [iso-8859-1] Thu Nov 17 22:28:40 2016 @@ -44,7 +44,7 @@ if (lstrcmpA(string1, aString) != 0) \ ok(0, "Expected \"%s\", got \"%s\"\n", aString, string1); -static HRESULT (WINAPI *pCreateAssemblyNameObject)(LPASSEMBLYNAME *ppAssemblyNameObj, +static HRESULT (WINAPI *pCreateAssemblyNameObject)(IAssemblyName **ppAssemblyNameObj, LPCWSTR szAssemblyName, DWORD dwFlags, LPVOID pvReserved); static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR szDllName, LPCWSTR szVersion,
8 years, 1 month
1
0
0
0
[akhaldi] 73267: [FUSION] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:27:46 2016 New Revision: 73267 URL:
http://svn.reactos.org/svn/reactos?rev=73267&view=rev
Log: [FUSION] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/reactos/dll/win32/fusion/asmname.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/fusion/asmname.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/fusion/asmname.c…
============================================================================== --- trunk/reactos/dll/win32/fusion/asmname.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/fusion/asmname.c [iso-8859-1] Thu Nov 17 22:27:46 2016 @@ -712,7 +712,7 @@ /****************************************************************** * CreateAssemblyNameObject (FUSION.@) */ -HRESULT WINAPI CreateAssemblyNameObject(LPASSEMBLYNAME *ppAssemblyNameObj, +HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj, LPCWSTR szAssemblyName, DWORD dwFlags, LPVOID pvReserved) { Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 22:27:46 2016 @@ -67,7 +67,7 @@ reactos/dll/win32/dciman32 # Synced to WineStaging-1.9.11 reactos/dll/win32/faultrep # Synced to WineStaging-1.9.11 reactos/dll/win32/fontsub # Synced to WineStaging-1.9.13 -reactos/dll/win32/fusion # Synced to WineStaging-1.9.11 +reactos/dll/win32/fusion # Synced to WineStaging-1.9.23 reactos/dll/win32/gdiplus # Synced to WineStaging-1.9.16 reactos/dll/win32/hhctrl.ocx # Synced to WineStaging-1.9.16 reactos/dll/win32/hlink # Synced to WineStaging-1.9.16
8 years, 1 month
1
0
0
0
[akhaldi] 73266: [CABINET] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:26:11 2016 New Revision: 73266 URL:
http://svn.reactos.org/svn/reactos?rev=73266&view=rev
Log: [CABINET] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/reactos/dll/win32/cabinet/fdi.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/cabinet/fdi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cabinet/fdi.c?re…
============================================================================== --- trunk/reactos/dll/win32/cabinet/fdi.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/cabinet/fdi.c [iso-8859-1] Thu Nov 17 22:26:11 2016 @@ -2629,6 +2629,7 @@ fdin.date = file->date; fdin.time = file->time; fdin.attribs = file->attribs; + fdin.iFolder = file->index; if ((filehf = ((*pfnfdin)(fdintCOPY_FILE, &fdin))) == -1) { set_error( fdi, FDIERROR_USER_ABORT, 0 ); filehf = 0; @@ -2754,6 +2755,7 @@ fdin.date = file->date; fdin.time = file->time; fdin.attribs = file->attribs; /* FIXME: filter _A_EXEC? */ + fdin.iFolder = file->index; ((*pfnfdin)(fdintCLOSE_FILE_INFO, &fdin)); filehf = 0; Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 22:26:11 2016 @@ -51,7 +51,7 @@ reactos/dll/win32/avifil32 # Synced to WineStaging-1.9.23 reactos/dll/win32/bcrypt # Synced to WineStaging-1.9.23 reactos/dll/win32/browseui # Out of sync -reactos/dll/win32/cabinet # Synced to WineStaging-1.9.16 +reactos/dll/win32/cabinet # Synced to WineStaging-1.9.23 reactos/dll/win32/clusapi # Synced to WineStaging-1.9.11 reactos/dll/win32/comcat # Synced to WineStaging-1.9.11 reactos/dll/win32/comctl32 # Synced to WineStaging-1.9.16
8 years, 1 month
1
0
0
0
[akhaldi] 73265: [CMD_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:23:43 2016 New Revision: 73265 URL:
http://svn.reactos.org/svn/reactos?rev=73265&view=rev
Log: [CMD_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/rostests/winetests/cmd/test_builtins.cmd trunk/rostests/winetests/cmd/test_builtins.cmd.exp Modified: trunk/rostests/winetests/cmd/test_builtins.cmd URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/cmd/test_builti…
============================================================================== --- trunk/rostests/winetests/cmd/test_builtins.cmd [iso-8859-1] (original) +++ trunk/rostests/winetests/cmd/test_builtins.cmd [iso-8859-1] Thu Nov 17 22:23:43 2016 @@ -836,6 +836,17 @@ if "1" GEQ "10" (echo 1 GEQ "10") else echo foo if '1' GEQ "10" (echo '1' GEQ "10") else echo foo if "10" GEQ "10" (echo "10" GEQ "10") +echo --- unconditional ampersand after if one line +if "0"=="0" echo 1 & echo 2 & echo 3 else echo 4 +echo --- +echo x & if "0"=="1" echo 1 & echo 2 +echo --- +echo x & if "0"=="1" echo 1 & echo 2 & echo 3 +echo --- +echo x & if "0"=="1" (echo 1 & echo 2 & echo 3) +echo --- +echo x & if "0"=="1" echo 1 & echo 2 & echo 3 else echo 4 +echo --- goto :endIfCompOpsSubroutines rem IF subroutines helpers Modified: trunk/rostests/winetests/cmd/test_builtins.cmd.exp URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/cmd/test_builti…
============================================================================== --- trunk/rostests/winetests/cmd/test_builtins.cmd.exp [iso-8859-1] (original) +++ trunk/rostests/winetests/cmd/test_builtins.cmd.exp [iso-8859-1] Thu Nov 17 22:23:43 2016 @@ -645,6 +645,19 @@ foo '1' GEQ "10" "10" GEQ "10" +--- unconditional ampersand after if one line +1@space@ +2@space@ +3 else echo 4 +--- +x@space@ +--- +x@space@ +--- +x@space@ +--- +x@space@ +--- ------------ Testing for ------------ --- plain FOR A @@ -1045,8 +1058,8 @@ @todo_wine@bar@or_broken@baz read-only files are moveable file moved in subdirectory -@todo_wine@moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op! -@todo_wine@ErrorLevel: 0@or_broken@ErrorLevel: 1 +moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op! +ErrorLevel: 0@or_broken@ErrorLevel: 1 --- directory move simple directory move succeeded moving a directory to itself gives error; errlevel 1
8 years, 1 month
1
0
0
0
[cfinck] 73264: [LOCALSPL_APITEST] Add a test for fpGetPrintProcessorDirectory, the actual worker function inside localspl.dll at the end of the call chain. With that final test, we should have eno...
by cfinck@svn.reactos.org
Author: cfinck Date: Thu Nov 17 22:23:28 2016 New Revision: 73264 URL:
http://svn.reactos.org/svn/reactos?rev=73264&view=rev
Log: [LOCALSPL_APITEST] Add a test for fpGetPrintProcessorDirectory, the actual worker function inside localspl.dll at the end of the call chain. With that final test, we should have enough information to implement 100% compatible versions of GetPrintProcessorDirectoryA/W and fpGetPrintProcessorDirectory. [WINSPOOL_APITEST] Initialize some more variables with bogus values to verify that they have actually changed. Next step for CORE-12399 Added: trunk/rostests/apitests/localspl/dll/fpGetPrintProcessorDirectory.c (with props) Modified: trunk/rostests/apitests/localspl/dll/CMakeLists.txt trunk/rostests/apitests/localspl/dll/main.c trunk/rostests/apitests/localspl/testlist.c trunk/rostests/apitests/localspl/tests.c trunk/rostests/apitests/winspool/GetPrintProcessorDirectory.c Modified: trunk/rostests/apitests/localspl/dll/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/localspl/dll/CMa…
============================================================================== --- trunk/rostests/apitests/localspl/dll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/localspl/dll/CMakeLists.txt [iso-8859-1] Thu Nov 17 22:23:28 2016 @@ -3,6 +3,7 @@ list(APPEND SOURCE fpEnumPrinters.c + fpGetPrintProcessorDirectory.c main.c) add_library(localspl_apitest.dll SHARED ${SOURCE}) Added: trunk/rostests/apitests/localspl/dll/fpGetPrintProcessorDirectory.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/localspl/dll/fpG…
============================================================================== --- trunk/rostests/apitests/localspl/dll/fpGetPrintProcessorDirectory.c (added) +++ trunk/rostests/apitests/localspl/dll/fpGetPrintProcessorDirectory.c [iso-8859-1] Thu Nov 17 22:23:28 2016 @@ -0,0 +1,90 @@ +/* + * PROJECT: ReactOS Local Spooler API Tests Injected DLL + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Tests for fpGetPrintProcessorDirectory + * COPYRIGHT: Copyright 2016 Colin Finck <colin(a)reactos.org> + */ + +#include <apitest.h> + +#define WIN32_NO_STATUS +#include <windef.h> +#include <winbase.h> +#include <wingdi.h> +#include <winreg.h> +#include <winspool.h> +#include <winsplp.h> + +#include "../localspl_apitest.h" +#include <spoolss.h> + +extern BOOL GetLocalsplFuncs(LPPRINTPROVIDOR pp); + +START_TEST(fpGetPrintProcessorDirectory) +{ + DWORD cbNeeded; + DWORD cbTemp; + DWORD dwReturned; + PRINTPROVIDOR pp; + PWSTR pwszBuffer; + + if (!GetLocalsplFuncs(&pp)) + return; + + // In contrast to GetPrintProcessorDirectoryW, fpGetPrintProcessorDirectory needs an environment and doesn't just accept NULL. + SetLastError(0xDEADBEEF); + ok(!pp.fpGetPrintProcessorDirectory(NULL, NULL, 0, NULL, 0, NULL), "fpGetPrintProcessorDirectory returns TRUE!\n"); + ok(GetLastError() == ERROR_INVALID_ENVIRONMENT, "fpGetPrintProcessorDirectory returns error %lu!\n", GetLastError()); + + // Try with an invalid environment as well. + SetLastError(0xDEADBEEF); + ok(!pp.fpGetPrintProcessorDirectory(NULL, L"invalid", 0, NULL, 0, NULL), "fpGetPrintProcessorDirectory returns TRUE!\n"); + ok(GetLastError() == ERROR_INVALID_ENVIRONMENT, "fpGetPrintProcessorDirectory returns error %lu!\n", GetLastError()); + + // Now provide a valid environment and prove that it is checked case-insensitively. + // In contrast to GetPrintProcessorDirectoryW, the level isn't the next thing checked here, but fpGetPrintProcessorDirectory + // already tries to access the non-supplied pcbNeeded variable. + _SEH2_TRY + { + dwReturned = 0; + pp.fpGetPrintProcessorDirectory(NULL, L"wIndows nt x86", 0, NULL, 0, NULL); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + dwReturned = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + ok(dwReturned == EXCEPTION_ACCESS_VIOLATION, "dwReturned is %lu!\n", dwReturned); + + // fpGetPrintProcessorDirectory doesn't care about the supplied level at all. Prove this here. + // With no buffer given, this needs to fail with ERROR_INSUFFICIENT_BUFFER. + SetLastError(0xDEADBEEF); + cbNeeded = 0; + ok(!pp.fpGetPrintProcessorDirectory(NULL, L"wIndows nt x86", 1337, NULL, 0, &cbNeeded), "fpGetPrintProcessorDirectory returns TRUE!\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "fpGetPrintProcessorDirectory returns error %lu!\n", GetLastError()); + ok(cbNeeded > 0, "cbNeeded is %lu!\n", cbNeeded); + + // Now provide the demanded size, but no buffer. + // Unlike GetPrintProcessorDirectoryW, fpGetPrintProcessorDirectory doesn't check for this case and tries to access the buffer. + _SEH2_TRY + { + dwReturned = 0; + pp.fpGetPrintProcessorDirectory(NULL, L"wIndows nt x86", 1, NULL, cbNeeded, &cbTemp); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + dwReturned = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + ok(dwReturned == EXCEPTION_ACCESS_VIOLATION, "dwReturned is %lu!\n", dwReturned); + + // Finally use the function as intended and aim for success! + // We only check success by the boolean return value though. GetLastError doesn't return anything meaningful here. + pwszBuffer = DllAllocSplMem(cbNeeded); + SetLastError(0xDEADBEEF); + ok(pp.fpGetPrintProcessorDirectory(NULL, L"wIndows nt x86", 1, (PBYTE)pwszBuffer, cbNeeded, &cbTemp), "fpGetPrintProcessorDirectory returns FALSE!\n"); + ok(wcslen(pwszBuffer) == cbNeeded / sizeof(WCHAR) - 1, "fpGetPrintProcessorDirectory string is %Iu characters long, but %lu characters expected!\n", wcslen(pwszBuffer), cbNeeded / sizeof(WCHAR) - 1); + DllFreeSplMem(pwszBuffer); +} Propchange: trunk/rostests/apitests/localspl/dll/fpGetPrintProcessorDirectory.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/localspl/dll/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/localspl/dll/mai…
============================================================================== --- trunk/rostests/apitests/localspl/dll/main.c [iso-8859-1] (original) +++ trunk/rostests/apitests/localspl/dll/main.c [iso-8859-1] Thu Nov 17 22:23:28 2016 @@ -2,7 +2,7 @@ * PROJECT: ReactOS Local Spooler API Tests Injected DLL * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation * PURPOSE: Main functions - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2016 Colin Finck <colin(a)reactos.org> */ #define __ROS_LONG64__ @@ -26,11 +26,12 @@ // Test list extern void func_fpEnumPrinters(void); +extern void func_fpGetPrintProcessorDirectory(void); const struct test winetest_testlist[] = { { "fpEnumPrinters", func_fpEnumPrinters }, - + { "fpGetPrintProcessorDirectory", func_fpGetPrintProcessorDirectory }, { 0, 0 } }; Modified: trunk/rostests/apitests/localspl/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/localspl/testlis…
============================================================================== --- trunk/rostests/apitests/localspl/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/localspl/testlist.c [iso-8859-1] Thu Nov 17 22:23:28 2016 @@ -2,7 +2,7 @@ * PROJECT: ReactOS Local Spooler API Tests * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation * PURPOSE: Test list - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2016 Colin Finck <colin(a)reactos.org> */ #define __ROS_LONG64__ @@ -11,11 +11,13 @@ #include <apitest.h> extern void func_fpEnumPrinters(void); +extern void func_fpGetPrintProcessorDirectory(void); extern void func_service(void); const struct test winetest_testlist[] = { { "fpEnumPrinters", func_fpEnumPrinters }, + { "fpGetPrintProcessorDirectory", func_fpGetPrintProcessorDirectory }, { "service", func_service }, { 0, 0 } Modified: trunk/rostests/apitests/localspl/tests.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/localspl/tests.c…
============================================================================== --- trunk/rostests/apitests/localspl/tests.c [iso-8859-1] (original) +++ trunk/rostests/apitests/localspl/tests.c [iso-8859-1] Thu Nov 17 22:23:28 2016 @@ -212,3 +212,8 @@ { _RunRemoteTest("fpEnumPrinters"); } + +START_TEST(fpGetPrintProcessorDirectory) +{ + _RunRemoteTest("fpGetPrintProcessorDirectory"); +} Modified: trunk/rostests/apitests/winspool/GetPrintProcessorDirectory.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/winspool/GetPrin…
============================================================================== --- trunk/rostests/apitests/winspool/GetPrintProcessorDirectory.c [iso-8859-1] (original) +++ trunk/rostests/apitests/winspool/GetPrintProcessorDirectory.c [iso-8859-1] Thu Nov 17 22:23:28 2016 @@ -31,6 +31,7 @@ // Try with an invalid environment as well. SetLastError(0xDEADBEEF); + cbNeeded = 0xDEADBEEF; ok(!GetPrintProcessorDirectoryA(NULL, "invalid", 1, NULL, 0, &cbNeeded), "GetPrintProcessorDirectoryA returns TRUE!\n"); ok(GetLastError() == ERROR_INVALID_ENVIRONMENT, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError()); ok(cbNeeded == 0, "cbNeeded is %lu!\n", cbNeeded); @@ -38,18 +39,21 @@ // Now get the required buffer size by supplying pcbNeeded. This needs to fail with ERROR_INSUFFICIENT_BUFFER. // Note for GetPrintProcessorDirectoryA: cbNeeded will be the same as for GetPrintProcessorDirectoryW, even though the ANSI string only needs half of it! SetLastError(0xDEADBEEF); + cbNeeded = 0; ok(!GetPrintProcessorDirectoryA(NULL, NULL, 1, NULL, 0, &cbNeeded), "GetPrintProcessorDirectoryA returns TRUE!\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError()); ok(cbNeeded > 0, "cbNeeded is 0!\n"); // Now provide the demanded size, but no buffer. SetLastError(0xDEADBEEF); + cbTemp = 0xDEADBEEF; ok(!GetPrintProcessorDirectoryA(NULL, NULL, 1, NULL, cbNeeded, &cbTemp), "GetPrintProcessorDirectoryA returns TRUE!\n"); ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError()); ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp); // Same error has to occur with a size too small. SetLastError(0xDEADBEEF); + cbTemp = 0xDEADBEEF; ok(!GetPrintProcessorDirectoryA(NULL, NULL, 1, NULL, 1, &cbTemp), "GetPrintProcessorDirectoryA returns TRUE!\n"); ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError()); ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp); @@ -83,24 +87,28 @@ // Try with an invalid environment as well. SetLastError(0xDEADBEEF); + cbNeeded = 0xDEADBEEF; ok(!GetPrintProcessorDirectoryW(NULL, L"invalid", 1, NULL, 0, &cbNeeded), "GetPrintProcessorDirectoryW returns TRUE!\n"); ok(GetLastError() == ERROR_INVALID_ENVIRONMENT, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError()); ok(cbNeeded == 0, "cbNeeded is %lu!\n", cbNeeded); // Now get the required buffer size by supplying pcbNeeded. This needs to fail with ERROR_INSUFFICIENT_BUFFER. SetLastError(0xDEADBEEF); + cbNeeded = 0; ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, 0, &cbNeeded), "GetPrintProcessorDirectoryW returns TRUE!\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError()); ok(cbNeeded > 0, "cbNeeded is 0!\n"); // Now provide the demanded size, but no buffer. SetLastError(0xDEADBEEF); + cbTemp = 0xDEADBEEF; ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, cbNeeded, &cbTemp), "GetPrintProcessorDirectoryW returns TRUE!\n"); ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError()); ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp); // Same error has to occur with a size too small. SetLastError(0xDEADBEEF); + cbTemp = 0xDEADBEEF; ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, 1, &cbTemp), "GetPrintProcessorDirectoryW returns TRUE!\n"); ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError()); ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp);
8 years, 1 month
1
0
0
0
[akhaldi] 73263: [BCRYPT_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:22:21 2016 New Revision: 73263 URL:
http://svn.reactos.org/svn/reactos?rev=73263&view=rev
Log: [BCRYPT_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/rostests/winetests/bcrypt/CMakeLists.txt trunk/rostests/winetests/bcrypt/bcrypt.c Modified: trunk/rostests/winetests/bcrypt/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/bcrypt/CMakeLis…
============================================================================== --- trunk/rostests/winetests/bcrypt/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/bcrypt/CMakeLists.txt [iso-8859-1] Thu Nov 17 22:22:21 2016 @@ -1,5 +1,6 @@ +remove_definitions(-D_WIN32_WINNT=0x502) add_executable(bcrypt_winetest bcrypt.c testlist.c) set_module_type(bcrypt_winetest win32cui) -add_importlibs(bcrypt_winetest bcrypt user32 msvcrt kernel32) +add_importlibs(bcrypt_winetest bcrypt advapi32 user32 msvcrt kernel32) add_cd_file(TARGET bcrypt_winetest DESTINATION reactos/bin FOR all) Modified: trunk/rostests/winetests/bcrypt/bcrypt.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/bcrypt/bcrypt.c…
============================================================================== --- trunk/rostests/winetests/bcrypt/bcrypt.c [iso-8859-1] (original) +++ trunk/rostests/winetests/bcrypt/bcrypt.c [iso-8859-1] Thu Nov 17 22:22:21 2016 @@ -26,6 +26,9 @@ #include "wine/test.h" +static NTSTATUS (WINAPI *pBCryptHash)( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG secretlen, + UCHAR *input, ULONG inputlen, UCHAR *output, ULONG outputlen ); + static void test_BCryptGenRandom(void) { NTSTATUS ret; @@ -58,11 +61,45 @@ static void test_BCryptGetFipsAlgorithmMode(void) { - NTSTATUS ret; + static const WCHAR policyKeyVistaW[] = { + 'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'L','s','a','\\', + 'F','I','P','S','A','l','g','o','r','i','t','h','m','P','o','l','i','c','y',0}; + static const WCHAR policyValueVistaW[] = {'E','n','a','b','l','e','d',0}; + static const WCHAR policyKeyXPW[] = { + 'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'L','s','a',0}; + static const WCHAR policyValueXPW[] = { + 'F','I','P','S','A','l','g','o','r','i','t','h','m','P','o','l','i','c','y',0}; + BOOLEAN expected; BOOLEAN enabled; + DWORD value, count[2] = {sizeof(value), sizeof(value)}; + NTSTATUS ret; + + if (!RegGetValueW(HKEY_LOCAL_MACHINE, policyKeyVistaW, policyValueVistaW, + RRF_RT_REG_DWORD, NULL, &value, &count[0])) + { + expected = !!value; + } + else if (!RegGetValueW(HKEY_LOCAL_MACHINE, policyKeyXPW, policyValueXPW, + RRF_RT_REG_DWORD, NULL, &value, &count[1])) + { + expected = !!value; + } + else + { + expected = FALSE; +todo_wine + ok(0, "Neither XP or Vista key is present\n"); + } ret = BCryptGetFipsAlgorithmMode(&enabled); ok(ret == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%x\n", ret); + ok(enabled == expected, "expected result %d, got %d\n", expected, enabled); ret = BCryptGetFipsAlgorithmMode(NULL); ok(ret == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got 0x%x\n", ret); @@ -115,9 +152,10 @@ static void test_sha1(void) { static const char expected[] = "961fa64958818f767707072755d7018dcd278e94"; + static const char expected_hmac[] = "2472cf65d0e090618d769d3e46f0d9446cf212da"; BCRYPT_ALG_HANDLE alg; BCRYPT_HASH_HANDLE hash; - UCHAR buf[512], sha1[20]; + UCHAR buf[512], buf_hmac[1024], sha1[20], sha1_hmac[20]; ULONG size, len; char str[41]; NTSTATUS ret; @@ -165,6 +203,9 @@ ok(ret == STATUS_SUCCESS, "got %08x\n", ret); ok(hash != NULL, "hash not set\n"); + ret = BCryptHashData(hash, NULL, 0, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); @@ -182,15 +223,46 @@ ret = BCryptCloseAlgorithmProvider(alg, 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA1_ALGORITHM, MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + hash = NULL; + len = sizeof(buf_hmac); + ret = BCryptCreateHash(alg, &hash, buf_hmac, len, (UCHAR *)"key", sizeof("key"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(hash != NULL, "hash not set\n"); + + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + test_hash_length(hash, 20); + test_alg_name(hash, "SHA1"); + + memset(sha1_hmac, 0, sizeof(sha1_hmac)); + ret = BCryptFinishHash(hash, sha1_hmac, sizeof(sha1_hmac), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( sha1_hmac, sizeof(sha1_hmac), str ); + ok(!strcmp(str, expected_hmac), "got %s\n", str); + + ret = BCryptDestroyHash(hash); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); } static void test_sha256(void) { static const char expected[] = "ceb73749c899693706ede1e30c9929b3fd5dd926163831c2fb8bd41e6efb1126"; + static const char expected_hmac[] = + "34c1aa473a4468a91d06e7cdbc75bc4f93b830ccfc2a47ffd74e8e6ed29e4c72"; BCRYPT_ALG_HANDLE alg; BCRYPT_HASH_HANDLE hash; - UCHAR buf[512], sha256[32]; + UCHAR buf[512], buf_hmac[1024], sha256[32], sha256_hmac[32]; ULONG size, len; char str[65]; NTSTATUS ret; @@ -238,6 +310,9 @@ ok(ret == STATUS_SUCCESS, "got %08x\n", ret); ok(hash != NULL, "hash not set\n"); + ret = BCryptHashData(hash, NULL, 0, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); @@ -255,15 +330,46 @@ ret = BCryptCloseAlgorithmProvider(alg, 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA256_ALGORITHM, MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + hash = NULL; + len = sizeof(buf_hmac); + ret = BCryptCreateHash(alg, &hash, buf_hmac, len, (UCHAR *)"key", sizeof("key"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(hash != NULL, "hash not set\n"); + + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + test_hash_length(hash, 32); + test_alg_name(hash, "SHA256"); + + memset(sha256_hmac, 0, sizeof(sha256_hmac)); + ret = BCryptFinishHash(hash, sha256_hmac, sizeof(sha256_hmac), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( sha256_hmac, sizeof(sha256_hmac), str ); + ok(!strcmp(str, expected_hmac), "got %s\n", str); + + ret = BCryptDestroyHash(hash); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); } static void test_sha384(void) { static const char expected[] = "62b21e90c9022b101671ba1f808f8631a8149f0f12904055839a35c1ca78ae5363eed1e743a692d70e0504b0cfd12ef9"; + static const char expected_hmac[] = + "4b3e6d6ff2da121790ab7e7b9247583e3a7eed2db5bd4dabc680303b1608f37dfdc836d96a704c03283bc05b4f6c5eb8"; BCRYPT_ALG_HANDLE alg; BCRYPT_HASH_HANDLE hash; - UCHAR buf[512], sha384[48]; + UCHAR buf[512], buf_hmac[1024], sha384[48], sha384_hmac[48]; ULONG size, len; char str[97]; NTSTATUS ret; @@ -311,6 +417,9 @@ ok(ret == STATUS_SUCCESS, "got %08x\n", ret); ok(hash != NULL, "hash not set\n"); + ret = BCryptHashData(hash, NULL, 0, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); @@ -322,6 +431,35 @@ ok(ret == STATUS_SUCCESS, "got %08x\n", ret); format_hash( sha384, sizeof(sha384), str ); ok(!strcmp(str, expected), "got %s\n", str); + + ret = BCryptDestroyHash(hash); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA384_ALGORITHM, MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + hash = NULL; + len = sizeof(buf_hmac); + ret = BCryptCreateHash(alg, &hash, buf_hmac, len, (UCHAR *)"key", sizeof("key"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(hash != NULL, "hash not set\n"); + + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + test_hash_length(hash, 48); + test_alg_name(hash, "SHA384"); + + memset(sha384_hmac, 0, sizeof(sha384_hmac)); + ret = BCryptFinishHash(hash, sha384_hmac, sizeof(sha384_hmac), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( sha384_hmac, sizeof(sha384_hmac), str ); + ok(!strcmp(str, expected_hmac), "got %s\n", str); ret = BCryptDestroyHash(hash); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); @@ -335,9 +473,12 @@ static const char expected[] = "d55ced17163bf5386f2cd9ff21d6fd7fe576a915065c24744d09cfae4ec84ee1e" "f6ef11bfbc5acce3639bab725b50a1fe2c204f8c820d6d7db0df0ecbc49c5ca"; + static const char expected_hmac[] = + "415fb6b10018ca03b38a1b1399c42ac0be5e8aceddb9a73103f5e543bf2d888f2" + "eecf91373941f9315dd730a77937fa92444450fbece86f409d9cb5ec48c6513"; BCRYPT_ALG_HANDLE alg; BCRYPT_HASH_HANDLE hash; - UCHAR buf[512], sha512[64]; + UCHAR buf[512], buf_hmac[1024], sha512[64], sha512_hmac[64]; ULONG size, len; char str[129]; NTSTATUS ret; @@ -385,6 +526,9 @@ ok(ret == STATUS_SUCCESS, "got %08x\n", ret); ok(hash != NULL, "hash not set\n"); + ret = BCryptHashData(hash, NULL, 0, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); @@ -402,14 +546,235 @@ ret = BCryptCloseAlgorithmProvider(alg, 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret); -} + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA512_ALGORITHM, MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + hash = NULL; + len = sizeof(buf_hmac); + ret = BCryptCreateHash(alg, &hash, buf_hmac, len, (UCHAR *)"key", sizeof("key"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(hash != NULL, "hash not set\n"); + + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + test_hash_length(hash, 64); + test_alg_name(hash, "SHA512"); + + memset(sha512_hmac, 0, sizeof(sha512_hmac)); + ret = BCryptFinishHash(hash, sha512_hmac, sizeof(sha512_hmac), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( sha512_hmac, sizeof(sha512_hmac), str ); + ok(!strcmp(str, expected_hmac), "got %s\n", str); + + ret = BCryptDestroyHash(hash); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + +} + +static void test_md5(void) +{ + static const char expected[] = + "e2a3e68d23ce348b8f68b3079de3d4c9"; + static const char expected_hmac[] = + "7bda029b93fa8d817fcc9e13d6bdf092"; + BCRYPT_ALG_HANDLE alg; + BCRYPT_HASH_HANDLE hash; + UCHAR buf[512], buf_hmac[1024], md5[16], md5_hmac[16]; + ULONG size, len; + char str[65]; + NTSTATUS ret; + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_MD5_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + len = size = 0xdeadbeef; + ret = BCryptGetProperty(NULL, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0); + ok(ret == STATUS_INVALID_HANDLE, "got %08x\n", ret); + + len = size = 0xdeadbeef; + ret = BCryptGetProperty(alg, NULL, (UCHAR *)&len, sizeof(len), &size, 0); + ok(ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret); + + len = size = 0xdeadbeef; + ret = BCryptGetProperty(alg, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), NULL, 0); + ok(ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret); + + len = size = 0xdeadbeef; + ret = BCryptGetProperty(alg, BCRYPT_OBJECT_LENGTH, NULL, sizeof(len), &size, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(size == sizeof(len), "got %u\n", size); + + len = size = 0xdeadbeef; + ret = BCryptGetProperty(alg, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, 0, &size, 0); + ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret); + ok(len == 0xdeadbeef, "got %u\n", len); + ok(size == sizeof(len), "got %u\n", size); + + len = size = 0xdeadbeef; + ret = BCryptGetProperty(alg, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len , sizeof(len), &size, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(len != 0xdeadbeef, "len not set\n"); + ok(size == sizeof(len), "got %u\n", size); + + test_hash_length(alg, 16); + test_alg_name(alg, "MD5"); + + hash = NULL; + len = sizeof(buf); + ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(hash != NULL, "hash not set\n"); + + ret = BCryptHashData(hash, NULL, 0, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + test_hash_length(hash, 16); + test_alg_name(hash, "MD5"); + + memset(md5, 0, sizeof(md5)); + ret = BCryptFinishHash(hash, md5, sizeof(md5), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( md5, sizeof(md5), str ); + ok(!strcmp(str, expected), "got %s\n", str); + + ret = BCryptDestroyHash(hash); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_MD5_ALGORITHM, MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + hash = NULL; + len = sizeof(buf_hmac); + ret = BCryptCreateHash(alg, &hash, buf_hmac, len, (UCHAR *)"key", sizeof("key"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(hash != NULL, "hash not set\n"); + + ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + test_hash_length(hash, 16); + test_alg_name(hash, "MD5"); + + memset(md5_hmac, 0, sizeof(md5_hmac)); + ret = BCryptFinishHash(hash, md5_hmac, sizeof(md5_hmac), 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( md5_hmac, sizeof(md5_hmac), str ); + ok(!strcmp(str, expected_hmac), "got %s\n", str); + + ret = BCryptDestroyHash(hash); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); +} + +static void test_BcryptHash(void) +{ + static const char expected[] = + "e2a3e68d23ce348b8f68b3079de3d4c9"; + static const char expected_hmac[] = + "7bda029b93fa8d817fcc9e13d6bdf092"; + BCRYPT_ALG_HANDLE alg; + UCHAR md5[16], md5_hmac[16]; + char str[65]; + NTSTATUS ret; + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_MD5_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + test_hash_length(alg, 16); + test_alg_name(alg, "MD5"); + + memset(md5, 0, sizeof(md5)); + ret = pBCryptHash(alg, NULL, 0, (UCHAR *)"test", sizeof("test"), md5, sizeof(md5)); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( md5, sizeof(md5), str ); + ok(!strcmp(str, expected), "got %s\n", str); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + + alg = NULL; + memset(md5_hmac, 0, sizeof(md5_hmac)); + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_MD5_ALGORITHM, MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + ret = pBCryptHash(alg, (UCHAR *)"key", sizeof("key"), (UCHAR *)"test", sizeof("test"), md5_hmac, sizeof(md5_hmac)); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + format_hash( md5_hmac, sizeof(md5_hmac), str ); + ok(!strcmp(str, expected_hmac), "got %s\n", str); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); +} + +static void test_rng(void) +{ + BCRYPT_ALG_HANDLE alg; + ULONG size, len; + UCHAR buf[16]; + NTSTATUS ret; + + alg = NULL; + ret = BCryptOpenAlgorithmProvider(&alg, BCRYPT_RNG_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(alg != NULL, "alg not set\n"); + + len = size = 0xdeadbeef; + ret = BCryptGetProperty(alg, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0); + ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret); + + test_alg_name(alg, "RNG"); + + memset(buf, 0, 16); + ret = BCryptGenRandom(alg, buf, 8, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(memcmp(buf, buf + 8, 8), "got zeroes\n"); + + ret = BCryptCloseAlgorithmProvider(alg, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); +} + START_TEST(bcrypt) { + HMODULE module; + + module = GetModuleHandleA( "bcrypt.dll" ); + test_BCryptGenRandom(); test_BCryptGetFipsAlgorithmMode(); test_sha1(); test_sha256(); test_sha384(); test_sha512(); -} + test_md5(); + test_rng(); + + pBCryptHash = (void *)GetProcAddress( module, "BCryptHash" ); + + if (pBCryptHash) + test_BcryptHash(); + else + win_skip("BCryptHash is not available\n"); +}
8 years, 1 month
1
0
0
0
[akhaldi] 73262: [BOOTDATA] Add FIPSAlgorithmPolicy registry value for bcrypt tests.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:21:35 2016 New Revision: 73262 URL:
http://svn.reactos.org/svn/reactos?rev=73262&view=rev
Log: [BOOTDATA] Add FIPSAlgorithmPolicy registry value for bcrypt tests. Modified: trunk/reactos/boot/bootdata/hivesys.inf Modified: trunk/reactos/boot/bootdata/hivesys.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys.inf?…
============================================================================== --- trunk/reactos/boot/bootdata/hivesys.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivesys.inf [iso-8859-1] Thu Nov 17 22:21:35 2016 @@ -817,6 +817,7 @@ ; Lsa HKLM,"SYSTEM\CurrentControlSet\Control\Lsa","Authentication Packages",0x00010000,"msv1_0" +HKLM,"SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy","Enabled",0x00010001,0 ; Network HKLM,"SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}",,0x00000000,"Network Adapters"
8 years, 1 month
1
0
0
0
[akhaldi] 73261: [BCRYPT] Sync with Wine Staging 1.9.23. The mbedtls code paths are brought to you by Peter Hater. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 22:13:28 2016 New Revision: 73261 URL:
http://svn.reactos.org/svn/reactos?rev=73261&view=rev
Log: [BCRYPT] Sync with Wine Staging 1.9.23. The mbedtls code paths are brought to you by Peter Hater. CORE-12409 Modified: trunk/reactos/dll/win32/bcrypt/bcrypt.spec trunk/reactos/dll/win32/bcrypt/bcrypt_main.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/bcrypt/bcrypt.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/bcrypt/bcrypt.sp…
============================================================================== --- trunk/reactos/dll/win32/bcrypt/bcrypt.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/bcrypt/bcrypt.spec [iso-8859-1] Thu Nov 17 22:13:28 2016 @@ -29,6 +29,7 @@ @ stub BCryptGenerateSymmetricKey @ stdcall BCryptGetFipsAlgorithmMode(ptr) @ stdcall BCryptGetProperty(ptr wstr ptr long ptr long) +@ stdcall BCryptHash(ptr ptr long ptr long ptr long) @ stdcall BCryptHashData(ptr ptr long long) @ stub BCryptImportKey @ stub BCryptImportKeyPair Modified: trunk/reactos/dll/win32/bcrypt/bcrypt_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/bcrypt/bcrypt_ma…
============================================================================== --- trunk/reactos/dll/win32/bcrypt/bcrypt_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/bcrypt/bcrypt_main.c [iso-8859-1] Thu Nov 17 22:13:28 2016 @@ -32,6 +32,8 @@ #include <wine/library.h> #ifdef SONAME_LIBMBEDTLS +#include <mbedtls/md.h> +#include <mbedtls/md5.h> #include <mbedtls/sha1.h> #include <mbedtls/sha256.h> #include <mbedtls/sha512.h> @@ -53,6 +55,9 @@ MAKE_FUNCPTR(gnutls_hash); MAKE_FUNCPTR(gnutls_hash_deinit); MAKE_FUNCPTR(gnutls_hash_init); +MAKE_FUNCPTR(gnutls_hmac); +MAKE_FUNCPTR(gnutls_hmac_deinit); +MAKE_FUNCPTR(gnutls_hmac_init); MAKE_FUNCPTR(gnutls_perror); #undef MAKE_FUNCPTR @@ -85,6 +90,9 @@ LOAD_FUNCPTR(gnutls_hash); LOAD_FUNCPTR(gnutls_hash_deinit); LOAD_FUNCPTR(gnutls_hash_init); + LOAD_FUNCPTR(gnutls_hmac); + LOAD_FUNCPTR(gnutls_hmac_deinit); + LOAD_FUNCPTR(gnutls_hmac_init); LOAD_FUNCPTR(gnutls_perror) #undef LOAD_FUNCPTR @@ -120,6 +128,17 @@ void *libmbedtls_handle; #define MAKE_FUNCPTR(f) static typeof(f) * p##f +MAKE_FUNCPTR(mbedtls_md_init); +MAKE_FUNCPTR(mbedtls_md_setup); +MAKE_FUNCPTR(mbedtls_md_update); +MAKE_FUNCPTR(mbedtls_md_hmac_starts); +MAKE_FUNCPTR(mbedtls_md_hmac_finish); +MAKE_FUNCPTR(mbedtls_md_free); +MAKE_FUNCPTR(mbedtls_md5_init); +MAKE_FUNCPTR(mbedtls_md5_starts); +MAKE_FUNCPTR(mbedtls_md5_update); +MAKE_FUNCPTR(mbedtls_md5_finish); +MAKE_FUNCPTR(mbedtls_md5_free); MAKE_FUNCPTR(mbedtls_sha1_init); MAKE_FUNCPTR(mbedtls_sha1_starts); MAKE_FUNCPTR(mbedtls_sha1_update); @@ -137,6 +156,17 @@ MAKE_FUNCPTR(mbedtls_sha512_free); #undef MAKE_FUNCPTR +#define mbedtls_md_init pmbedtls_md_init +#define mbedtls_md_setup pmbedtls_md_setup +#define mbedtls_md_update pmbedtls_md_update +#define mbedtls_md_hmac_starts pmbedtls_md_hmac_starts +#define mbedtls_md_hmac_finish pmbedtls_md_hmac_finish +#define mbedtls_md_free pmbedtls_md_free +#define mbedtls_md5_init pmbedtls_md5_init +#define mbedtls_md5_starts pmbedtls_md5_starts +#define mbedtls_md5_update pmbedtls_md5_update +#define mbedtls_md5_finish pmbedtls_md5_finish +#define mbedtls_md5_free pmbedtls_md5_free #define mbedtls_sha1_init pmbedtls_sha1_init #define mbedtls_sha1_starts pmbedtls_sha1_starts #define mbedtls_sha1_update pmbedtls_sha1_update @@ -168,6 +198,17 @@ goto fail; \ } + LOAD_FUNCPTR(mbedtls_md_init) + LOAD_FUNCPTR(mbedtls_md_setup) + LOAD_FUNCPTR(mbedtls_md_update) + LOAD_FUNCPTR(mbedtls_md_hmac_starts) + LOAD_FUNCPTR(mbedtls_md_hmac_finish) + LOAD_FUNCPTR(mbedtls_md_free); + LOAD_FUNCPTR(mbedtls_md5_init) + LOAD_FUNCPTR(mbedtls_md5_starts) + LOAD_FUNCPTR(mbedtls_md5_update) + LOAD_FUNCPTR(mbedtls_md5_finish) + LOAD_FUNCPTR(mbedtls_md5_free); LOAD_FUNCPTR(mbedtls_sha1_init) LOAD_FUNCPTR(mbedtls_sha1_starts) LOAD_FUNCPTR(mbedtls_sha1_update) @@ -211,10 +252,48 @@ return STATUS_NOT_IMPLEMENTED; } -NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE algorithm, UCHAR *buffer, ULONG count, ULONG flags) +#define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0') +#define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H') +struct object +{ + ULONG magic; +}; + +enum alg_id +{ + ALG_ID_MD5, + ALG_ID_RNG, + ALG_ID_SHA1, + ALG_ID_SHA256, + ALG_ID_SHA384, + ALG_ID_SHA512 +}; + +static const struct { + ULONG hash_length; + const WCHAR *alg_name; +} alg_props[] = { + /* ALG_ID_MD5 */ { 16, BCRYPT_MD5_ALGORITHM }, + /* ALG_ID_RNG */ { 0, BCRYPT_RNG_ALGORITHM }, + /* ALG_ID_SHA1 */ { 20, BCRYPT_SHA1_ALGORITHM }, + /* ALG_ID_SHA256 */ { 32, BCRYPT_SHA256_ALGORITHM }, + /* ALG_ID_SHA384 */ { 48, BCRYPT_SHA384_ALGORITHM }, + /* ALG_ID_SHA512 */ { 64, BCRYPT_SHA512_ALGORITHM } +}; + +struct algorithm +{ + struct object hdr; + enum alg_id id; + BOOL hmac; +}; + +NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG count, ULONG flags) { const DWORD supported_flags = BCRYPT_USE_SYSTEM_PREFERRED_RNG; - TRACE("%p, %p, %u, %08x - semi-stub\n", algorithm, buffer, count, flags); + struct algorithm *algorithm = handle; + + TRACE("%p, %p, %u, %08x - semi-stub\n", handle, buffer, count, flags); if (!algorithm) { @@ -224,6 +303,9 @@ if (!(flags & BCRYPT_USE_SYSTEM_PREFERRED_RNG)) return STATUS_INVALID_HANDLE; } + else if (algorithm->hdr.magic != MAGIC_ALG || algorithm->id != ALG_ID_RNG) + return STATUS_INVALID_HANDLE; + if (!buffer) return STATUS_INVALID_PARAMETER; @@ -237,7 +319,7 @@ if (!count) return STATUS_SUCCESS; - if (flags & BCRYPT_USE_SYSTEM_PREFERRED_RNG) + if (algorithm || (flags & BCRYPT_USE_SYSTEM_PREFERRED_RNG)) { if (RtlGenRandom(buffer, count)) return STATUS_SUCCESS; @@ -247,52 +329,25 @@ return STATUS_NOT_IMPLEMENTED; } -#define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0') -#define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H') -struct object -{ - ULONG magic; -}; - -enum alg_id -{ - ALG_ID_SHA1, - ALG_ID_SHA256, - ALG_ID_SHA384, - ALG_ID_SHA512 -}; - -static const struct { - ULONG hash_length; - const WCHAR *alg_name; -} alg_props[] = { - /* ALG_ID_SHA1 */ { 20, BCRYPT_SHA1_ALGORITHM }, - /* ALG_ID_SHA256 */ { 32, BCRYPT_SHA256_ALGORITHM }, - /* ALG_ID_SHA384 */ { 48, BCRYPT_SHA384_ALGORITHM }, - /* ALG_ID_SHA512 */ { 64, BCRYPT_SHA512_ALGORITHM } -}; - -struct algorithm -{ - struct object hdr; - enum alg_id id; -}; - NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR id, LPCWSTR implementation, DWORD flags ) { struct algorithm *alg; enum alg_id alg_id; + const DWORD supported_flags = BCRYPT_ALG_HANDLE_HMAC_FLAG; + TRACE( "%p, %s, %s, %08x\n", handle, wine_dbgstr_w(id), wine_dbgstr_w(implementation), flags ); if (!handle || !id) return STATUS_INVALID_PARAMETER; - if (flags) - { - FIXME( "unimplemented flags %08x\n", flags ); + if (flags & ~supported_flags) + { + FIXME( "unsupported flags %08x\n", flags & ~supported_flags); return STATUS_NOT_IMPLEMENTED; } if (!strcmpW( id, BCRYPT_SHA1_ALGORITHM )) alg_id = ALG_ID_SHA1; + else if (!strcmpW( id, BCRYPT_MD5_ALGORITHM )) alg_id = ALG_ID_MD5; + else if (!strcmpW( id, BCRYPT_RNG_ALGORITHM )) alg_id = ALG_ID_RNG; else if (!strcmpW( id, BCRYPT_SHA256_ALGORITHM )) alg_id = ALG_ID_SHA256; else if (!strcmpW( id, BCRYPT_SHA384_ALGORITHM )) alg_id = ALG_ID_SHA384; else if (!strcmpW( id, BCRYPT_SHA512_ALGORITHM )) alg_id = ALG_ID_SHA512; @@ -310,6 +365,7 @@ if (!(alg = HeapAlloc( GetProcessHeap(), 0, sizeof(*alg) ))) return STATUS_NO_MEMORY; alg->hdr.magic = MAGIC_ALG; alg->id = alg_id; + alg->hmac = flags & BCRYPT_ALG_HANDLE_HMAC_FLAG; *handle = alg; return STATUS_SUCCESS; @@ -342,11 +398,14 @@ { struct object hdr; enum alg_id alg_id; + BOOL hmac; union { + CC_MD5_CTX md5_ctx; CC_SHA1_CTX sha1_ctx; CC_SHA256_CTX sha256_ctx; CC_SHA512_CTX sha512_ctx; + CCHmacContext hmac_ctx; } u; }; @@ -354,6 +413,10 @@ { switch (hash->alg_id) { + case ALG_ID_MD5: + CC_MD5_Init( &hash->u.md5_ctx ); + break; + case ALG_ID_SHA1: CC_SHA1_Init( &hash->u.sha1_ctx ); break; @@ -377,10 +440,49 @@ return STATUS_SUCCESS; } +static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size ) +{ + CCHmacAlgorithm cc_algorithm; + switch (hash->alg_id) + { + case ALG_ID_MD5: + cc_algorithm = kCCHmacAlgMD5; + break; + + case ALG_ID_SHA1: + cc_algorithm = kCCHmacAlgSHA1; + break; + + case ALG_ID_SHA256: + cc_algorithm = kCCHmacAlgSHA256; + break; + + case ALG_ID_SHA384: + cc_algorithm = kCCHmacAlgSHA384; + break; + + case ALG_ID_SHA512: + cc_algorithm = kCCHmacAlgSHA512; + break; + + default: + ERR( "unhandled id %u\n", hash->alg_id ); + return STATUS_NOT_IMPLEMENTED; + } + + CCHmacInit( &hash->u.hmac_ctx, cc_algorithm, key, key_size ); + return STATUS_SUCCESS; +} + + static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size ) { switch (hash->alg_id) { + case ALG_ID_MD5: + CC_MD5_Update( &hash->u.md5_ctx, input, size ); + break; + case ALG_ID_SHA1: CC_SHA1_Update( &hash->u.sha1_ctx, input, size ); break; @@ -404,10 +506,20 @@ return STATUS_SUCCESS; } +static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size ) +{ + CCHmacUpdate( &hash->u.hmac_ctx, input, size ); + return STATUS_SUCCESS; +} + static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size ) { switch (hash->alg_id) { + case ALG_ID_MD5: + CC_MD5_Final( output, &hash->u.md5_ctx ); + break; + case ALG_ID_SHA1: CC_SHA1_Final( output, &hash->u.sha1_ctx ); break; @@ -430,12 +542,24 @@ } return STATUS_SUCCESS; } + +static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size ) +{ + CCHmacFinal( &hash->u.hmac_ctx, output ); + + return STATUS_SUCCESS; +} #elif defined(HAVE_GNUTLS_HASH) struct hash { struct object hdr; enum alg_id alg_id; - gnutls_hash_hd_t handle; + BOOL hmac; + union + { + gnutls_hash_hd_t hash_handle; + gnutls_hmac_hd_t hmac_handle; + } u; }; static NTSTATUS hash_init( struct hash *hash ) @@ -446,6 +570,9 @@ switch (hash->alg_id) { + case ALG_ID_MD5: + alg = GNUTLS_DIG_MD5; + break; case ALG_ID_SHA1: alg = GNUTLS_DIG_SHA1; break; @@ -467,31 +594,82 @@ return STATUS_NOT_IMPLEMENTED; } - if (pgnutls_hash_init( &hash->handle, alg )) return STATUS_INTERNAL_ERROR; + if (pgnutls_hash_init( &hash->u.hash_handle, alg )) return STATUS_INTERNAL_ERROR; + return STATUS_SUCCESS; +} + +static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size ) +{ + gnutls_mac_algorithm_t alg; + + if (!libgnutls_handle) return STATUS_INTERNAL_ERROR; + + switch (hash->alg_id) + { + case ALG_ID_MD5: + alg = GNUTLS_MAC_MD5; + break; + case ALG_ID_SHA1: + alg = GNUTLS_MAC_SHA1; + break; + + case ALG_ID_SHA256: + alg = GNUTLS_MAC_SHA256; + break; + + case ALG_ID_SHA384: + alg = GNUTLS_MAC_SHA384; + break; + + case ALG_ID_SHA512: + alg = GNUTLS_MAC_SHA512; + break; + + default: + ERR( "unhandled id %u\n", hash->alg_id ); + return STATUS_NOT_IMPLEMENTED; + } + + if (pgnutls_hmac_init( &hash->u.hmac_handle, alg, key, key_size )) return STATUS_INTERNAL_ERROR; return STATUS_SUCCESS; } static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size ) { - if (pgnutls_hash( hash->handle, input, size )) return STATUS_INTERNAL_ERROR; + if (pgnutls_hash( hash->u.hash_handle, input, size )) return STATUS_INTERNAL_ERROR; + return STATUS_SUCCESS; +} + +static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size ) +{ + if (pgnutls_hmac( hash->u.hmac_handle, input, size )) return STATUS_INTERNAL_ERROR; return STATUS_SUCCESS; } static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size ) { - pgnutls_hash_deinit( hash->handle, output ); + pgnutls_hash_deinit( hash->u.hash_handle, output ); + return STATUS_SUCCESS; +} + +static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size ) +{ + pgnutls_hmac_deinit( hash->u.hmac_handle, output ); return STATUS_SUCCESS; } #elif defined(SONAME_LIBMBEDTLS) struct hash { - struct object hdr; - enum alg_id alg_id; + struct object hdr; + BOOL hmac; + enum alg_id alg_id; union { + mbedtls_md5_context md5_ctx; mbedtls_sha1_context sha1_ctx; mbedtls_sha256_context sha256_ctx; mbedtls_sha512_context sha512_ctx; + mbedtls_md_context_t hmac_ctx; } u; }; @@ -502,6 +680,11 @@ #endif switch (hash->alg_id) { + case ALG_ID_MD5: + mbedtls_md5_init(&hash->u.md5_ctx); + mbedtls_md5_starts(&hash->u.md5_ctx); + break; + case ALG_ID_SHA1: mbedtls_sha1_init(&hash->u.sha1_ctx); mbedtls_sha1_starts(&hash->u.sha1_ctx); @@ -526,6 +709,58 @@ return STATUS_SUCCESS; } +static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size ) +{ + const mbedtls_md_info_t *md_info; + mbedtls_md_type_t md_type; + int ret; +#ifndef __REACTOS__ + if (!libmbedtls_handle) return STATUS_INTERNAL_ERROR; +#endif + mbedtls_md_init(&hash->u.hmac_ctx); + switch (hash->alg_id) + { + case ALG_ID_MD5: + md_type = MBEDTLS_MD_MD5; + break; + + case ALG_ID_SHA1: + md_type = MBEDTLS_MD_SHA1; + break; + + case ALG_ID_SHA256: + md_type = MBEDTLS_MD_SHA256; + break; + + case ALG_ID_SHA384: + md_type = MBEDTLS_MD_SHA384; + break; + + case ALG_ID_SHA512: + md_type = MBEDTLS_MD_SHA512; + break; + + default: + ERR("unhandled id %u\n", hash->alg_id); + return STATUS_NOT_IMPLEMENTED; + } + if ((md_info = mbedtls_md_info_from_type(md_type)) == NULL) + { + mbedtls_md_free(&hash->u.hmac_ctx); + return STATUS_INTERNAL_ERROR; + } + + if ((ret = mbedtls_md_setup(&hash->u.hmac_ctx, md_info, 1)) != 0) + { + mbedtls_md_free(&hash->u.hmac_ctx); + return STATUS_INTERNAL_ERROR; + } + + mbedtls_md_hmac_starts(&hash->u.hmac_ctx, key, key_size); + + return STATUS_SUCCESS; +} + static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size ) { #ifndef __REACTOS__ @@ -533,6 +768,10 @@ #endif switch (hash->alg_id) { + case ALG_ID_MD5: + mbedtls_md5_update(&hash->u.md5_ctx, input, size); + break; + case ALG_ID_SHA1: mbedtls_sha1_update(&hash->u.sha1_ctx, input, size); break; @@ -550,6 +789,16 @@ ERR( "unhandled id %u\n", hash->alg_id ); return STATUS_NOT_IMPLEMENTED; } + + return STATUS_SUCCESS; +} + +static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size ) +{ +#ifndef __REACTOS__ + if (!libmbedtls_handle) return STATUS_INTERNAL_ERROR; +#endif + mbedtls_md_update(&hash->u.hmac_ctx, input, size); return STATUS_SUCCESS; } @@ -561,6 +810,11 @@ #endif switch (hash->alg_id) { + case ALG_ID_MD5: + mbedtls_md5_finish(&hash->u.md5_ctx, output); + mbedtls_md5_free(&hash->u.md5_ctx); + break; + case ALG_ID_SHA1: mbedtls_sha1_finish(&hash->u.sha1_ctx, output); mbedtls_sha1_free(&hash->u.sha1_ctx); @@ -584,32 +838,20 @@ return STATUS_SUCCESS; } -#else -struct hash -{ - struct object hdr; - enum alg_id alg_id; -}; - -static NTSTATUS hash_init( struct hash *hash ) -{ - ERR( "support for hashes not available at build time\n" ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size ) -{ - ERR( "support for hashes not available at build time\n" ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size ) -{ - ERR( "support for hashes not available at build time\n" ); - return STATUS_NOT_IMPLEMENTED; -} + +static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size ) +{ +#ifndef __REACTOS__ + if (!libmbedtls_handle) return STATUS_INTERNAL_ERROR; #endif - + mbedtls_md_hmac_finish(&hash->u.hmac_ctx, output); + mbedtls_md_free(&hash->u.hmac_ctx); + + return STATUS_SUCCESS; +} +#endif + +#define OBJECT_LENGTH_MD5 274 #define OBJECT_LENGTH_SHA1 278 #define OBJECT_LENGTH_SHA256 286 #define OBJECT_LENGTH_SHA384 382 @@ -651,6 +893,20 @@ switch (id) { + case ALG_ID_MD5: + if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH )) + { + value = OBJECT_LENGTH_MD5; + break; + } + FIXME( "unsupported md5 algorithm property %s\n", debugstr_w(prop) ); + return STATUS_NOT_IMPLEMENTED; + + case ALG_ID_RNG: + if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH )) return STATUS_NOT_SUPPORTED; + FIXME( "unsupported rng algorithm property %s\n", debugstr_w(prop) ); + return STATUS_NOT_IMPLEMENTED; + case ALG_ID_SHA1: if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH )) { @@ -761,7 +1017,18 @@ if (!(hash = HeapAlloc( GetProcessHeap(), 0, sizeof(*hash) ))) return STATUS_NO_MEMORY; hash->hdr.magic = MAGIC_HASH; hash->alg_id = alg->id; - if ((status = hash_init( hash )) != STATUS_SUCCESS) + hash->hmac = alg->hmac; + + if (hash->hmac) + { + status = hmac_init( hash, secret, secretlen ); + } + else + { + status = hash_init( hash ); + } + + if (status != STATUS_SUCCESS) { HeapFree( GetProcessHeap(), 0, hash ); return status; @@ -789,9 +1056,16 @@ TRACE( "%p, %p, %u, %08x\n", handle, input, size, flags ); if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE; - if (!input) return STATUS_INVALID_PARAMETER; - - return hash_update( hash, input, size ); + if (!input) return STATUS_SUCCESS; + + if (hash->hmac) + { + return hmac_update( hash, input, size ); + } + else + { + return hash_update( hash, input, size ); + } } NTSTATUS WINAPI BCryptFinishHash( BCRYPT_HASH_HANDLE handle, UCHAR *output, ULONG size, ULONG flags ) @@ -803,7 +1077,46 @@ if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE; if (!output) return STATUS_INVALID_PARAMETER; - return hash_finish( hash, output, size ); + if (hash->hmac) + { + return hmac_finish( hash, output, size ); + } + else + { + return hash_finish( hash, output, size ); + } +} + +NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG secretlen, + UCHAR *input, ULONG inputlen, UCHAR *output, ULONG outputlen ) +{ + NTSTATUS status; + BCRYPT_HASH_HANDLE handle; + + TRACE( "%p, %p, %u, %p, %u, %p, %u\n", algorithm, secret, secretlen, + input, inputlen, output, outputlen ); + + status = BCryptCreateHash( algorithm, &handle, NULL, 0, secret, secretlen, 0); + if (status != STATUS_SUCCESS) + { + return status; + } + + status = BCryptHashData( handle, input, inputlen, 0 ); + if (status != STATUS_SUCCESS) + { + BCryptDestroyHash( handle ); + return status; + } + + status = BCryptFinishHash( handle, output, outputlen, 0 ); + if (status != STATUS_SUCCESS) + { + BCryptDestroyHash( handle ); + return status; + } + + return BCryptDestroyHash( handle ); } BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 22:13:28 2016 @@ -49,7 +49,7 @@ reactos/dll/win32/atl80 # Synced to WineStaging-1.9.11 reactos/dll/win32/atl100 # Synced to WineStaging-1.9.11 reactos/dll/win32/avifil32 # Synced to WineStaging-1.9.23 -reactos/dll/win32/bcrypt # Synced to WineStaging-1.9.4 +reactos/dll/win32/bcrypt # Synced to WineStaging-1.9.23 reactos/dll/win32/browseui # Out of sync reactos/dll/win32/cabinet # Synced to WineStaging-1.9.16 reactos/dll/win32/clusapi # Synced to WineStaging-1.9.11
8 years, 1 month
1
0
0
0
← Newer
1
...
12
13
14
15
16
17
18
...
32
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
Results per page:
10
25
50
100
200