winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2020
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1016 discussions
Start a n
N
ew thread
Jeff Smith : gdiplus: Reuse point when calling GdipAddPathLine on open figure.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: f54bf06a2a593825e228db0e2a316df66d233af8 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f54bf06a2a593825e228db0e…
Author: Jeff Smith <whydoubt(a)gmail.com> Date: Wed Apr 15 15:07:09 2020 -0500 gdiplus: Reuse point when calling GdipAddPathLine on open figure. Signed-off-by: Jeff Smith <whydoubt(a)gmail.com> Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/graphicspath.c | 24 ++++++------------------ dlls/gdiplus/tests/graphicspath.c | 5 ++++- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 2729455567..083b79b932 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -717,31 +717,19 @@ GpStatus WINGDIPAPI GdipAddPathLine2I(GpPath *path, GDIPCONST GpPoint *points, I */ GpStatus WINGDIPAPI GdipAddPathLine(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2) { - INT old_count; + PointF points[2]; TRACE("(%p, %.2f, %.2f, %.2f, %.2f)\n", path, x1, y1, x2, y2); if(!path) return InvalidParameter; - if(!lengthen_path(path, 2)) - return OutOfMemory; - - old_count = path->pathdata.Count; - - path->pathdata.Points[old_count].X = x1; - path->pathdata.Points[old_count].Y = y1; - path->pathdata.Points[old_count + 1].X = x2; - path->pathdata.Points[old_count + 1].Y = y2; - - path->pathdata.Types[old_count] = - (path->newfigure ? PathPointTypeStart : PathPointTypeLine); - path->pathdata.Types[old_count + 1] = PathPointTypeLine; - - path->newfigure = FALSE; - path->pathdata.Count += 2; + points[0].X = x1; + points[0].Y = y1; + points[1].X = x2; + points[1].Y = y2; - return Ok; + return extend_current_figure(path, points, 2, PathPointTypeLine); } /************************************************************************* diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index d19c7836fb..1af53762e4 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -722,7 +722,8 @@ static path_test_t linei_path[] = { {15.00, 15.00, PathPointTypeLine, 0, 0}, /*9*/ {26.00, 28.00, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*10*/ {35.00, 35.00, PathPointTypeStart, 0, 0}, /*11*/ - {36.00, 38.00, PathPointTypeLine, 0, 0} /*12*/ + {36.00, 38.00, PathPointTypeLine, 0, 0}, /*12*/ + {39.00, 40.00, PathPointTypeLine, 0, 0} /*13*/ }; static void test_linei(void) @@ -739,6 +740,8 @@ static void test_linei(void) GdipClosePathFigure(path); status = GdipAddPathLineI(path, 35.0, 35.0, 36.0, 38.0); expect(Ok, status); + status = GdipAddPathLineI(path, 36, 38, 39, 40); + expect(Ok, status); ok_path(path, linei_path, ARRAY_SIZE(linei_path), FALSE);
1
0
0
0
Jeff Smith : gdiplus: Reuse point when calling GdipAddPathBeziers on open figure.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: a7e6cb4a257540e01aca1d160ca10890eaca9ceb URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a7e6cb4a257540e01aca1d16…
Author: Jeff Smith <whydoubt(a)gmail.com> Date: Wed Apr 15 15:07:08 2020 -0500 gdiplus: Reuse point when calling GdipAddPathBeziers on open figure. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=48877
Signed-off-by: Jeff Smith <whydoubt(a)gmail.com> Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/graphicspath.c | 20 +------------------- dlls/gdiplus/tests/graphicspath.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 547f172d98..2729455567 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -322,30 +322,12 @@ GpStatus WINGDIPAPI GdipAddPathBezierI(GpPath *path, INT x1, INT y1, INT x2, GpStatus WINGDIPAPI GdipAddPathBeziers(GpPath *path, GDIPCONST GpPointF *points, INT count) { - INT i, old_count; - TRACE("(%p, %p, %d)\n", path, points, count); if(!path || !points || ((count - 1) % 3)) return InvalidParameter; - if(!lengthen_path(path, count)) - return OutOfMemory; - - old_count = path->pathdata.Count; - - for(i = 0; i < count; i++){ - path->pathdata.Points[old_count + i].X = points[i].X; - path->pathdata.Points[old_count + i].Y = points[i].Y; - path->pathdata.Types[old_count + i] = PathPointTypeBezier; - } - - path->pathdata.Types[old_count] = - (path->newfigure ? PathPointTypeStart : PathPointTypeLine); - path->newfigure = FALSE; - path->pathdata.Count += count; - - return Ok; + return extend_current_figure(path, points, count, PathPointTypeBezier); } GpStatus WINGDIPAPI GdipAddPathBeziersI(GpPath *path, GDIPCONST GpPoint *points, diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index d85cf68dfc..d19c7836fb 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -365,6 +365,28 @@ static void test_bezier(void) GdipDeletePath(path); } +static void test_beziers(void) +{ + GpStatus status; + GpPath* path; + PointF bezier_points1[] = {{10.0,10.0}, {20.0,10.0}, {20.0,20.0}, {30.0,20.0}}; + PointF bezier_points2[] = {{30.0,20.0}, {40.0,20.0}, {40.0,30.0}, {50.0,30.0}}; + PointF bezier_points3[] = {{50.0,10.0}, {60.0,10.0}, {60.0,20.0}, {70.0,20.0}}; + + GdipCreatePath(FillModeAlternate, &path); + + status = GdipAddPathBeziers(path, bezier_points1, 4); + expect(Ok, status); + status = GdipAddPathBeziers(path, bezier_points2, 4); + expect(Ok, status); + status = GdipAddPathBeziers(path, bezier_points3, 4); + expect(Ok, status); + + ok_path(path, bezier_path, ARRAY_SIZE(bezier_path), FALSE); + + GdipDeletePath(path); +} + static path_test_t arc_path[] = { {600.0, 450.0, PathPointTypeStart, 0, 0}, /*0*/ {600.0, 643.3, PathPointTypeBezier, 0, 0}, /*1*/ @@ -1818,6 +1840,7 @@ START_TEST(graphicspath) test_createpath2(); test_line2(); test_bezier(); + test_beziers(); test_arc(); test_worldbounds(); test_pathpath();
1
0
0
0
Jeff Smith : gdiplus: Reuse point when calling GdipAddPathBezier on open figure.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: 1a3a8a00165b0debdcb458b3680de61163a71a84 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=1a3a8a00165b0debdcb458b3…
Author: Jeff Smith <whydoubt(a)gmail.com> Date: Wed Apr 15 15:07:07 2020 -0500 gdiplus: Reuse point when calling GdipAddPathBezier on open figure. Signed-off-by: Jeff Smith <whydoubt(a)gmail.com> Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/graphicspath.c | 80 +++++++++++++++++++++++++++------------ dlls/gdiplus/tests/graphicspath.c | 34 +++++++++++++++++ 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 4d5a73588f..547f172d98 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -166,6 +166,52 @@ static BOOL flatten_bezier(path_list_node_t *start, REAL x2, REAL y2, REAL x3, R return TRUE; } +/* GdipAddPath* helper + * + * Several GdipAddPath functions are expected to add onto an open figure. + * So if the first point being added is an exact match to the last point + * of the existing line, that point should not be added. + * + * Parameters: + * path : path to which points should be added + * points : array of points to add + * count : number of points to add (at least 1) + * type : type of the points being added + * + * Return value: + * OutOfMemory : out of memory, could not lengthen path + * Ok : success + */ +static GpStatus extend_current_figure(GpPath *path, GDIPCONST PointF *points, INT count, BYTE type) +{ + INT insert_index = path->pathdata.Count; + BYTE first_point_type = (path->newfigure ? PathPointTypeStart : PathPointTypeLine); + + if(!path->newfigure && + path->pathdata.Points[insert_index-1].X == points[0].X && + path->pathdata.Points[insert_index-1].Y == points[0].Y) + { + points++; + count--; + first_point_type = type; + } + + if(!count) + return Ok; + + if(!lengthen_path(path, count)) + return OutOfMemory; + + memcpy(path->pathdata.Points + insert_index, points, sizeof(GpPointF)*count); + path->pathdata.Types[insert_index] = first_point_type; + memset(path->pathdata.Types + insert_index + 1, type, count - 1); + + path->newfigure = FALSE; + path->pathdata.Count += count; + + return Ok; +} + /******************************************************************************* * GdipAddPathArc [GDIPLUS.1] * @@ -243,7 +289,7 @@ GpStatus WINGDIPAPI GdipAddPathArcI(GpPath *path, INT x1, INT y1, INT x2, GpStatus WINGDIPAPI GdipAddPathBezier(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2, REAL x3, REAL y3, REAL x4, REAL y4) { - INT old_count; + PointF points[4]; TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n", path, x1, y1, x2, y2, x3, y3, x4, y4); @@ -251,30 +297,16 @@ GpStatus WINGDIPAPI GdipAddPathBezier(GpPath *path, REAL x1, REAL y1, REAL x2, if(!path) return InvalidParameter; - if(!lengthen_path(path, 4)) - return OutOfMemory; - - old_count = path->pathdata.Count; + points[0].X = x1; + points[0].Y = y1; + points[1].X = x2; + points[1].Y = y2; + points[2].X = x3; + points[2].Y = y3; + points[3].X = x4; + points[3].Y = y4; - path->pathdata.Points[old_count].X = x1; - path->pathdata.Points[old_count].Y = y1; - path->pathdata.Points[old_count + 1].X = x2; - path->pathdata.Points[old_count + 1].Y = y2; - path->pathdata.Points[old_count + 2].X = x3; - path->pathdata.Points[old_count + 2].Y = y3; - path->pathdata.Points[old_count + 3].X = x4; - path->pathdata.Points[old_count + 3].Y = y4; - - path->pathdata.Types[old_count] = - (path->newfigure ? PathPointTypeStart : PathPointTypeLine); - path->pathdata.Types[old_count + 1] = PathPointTypeBezier; - path->pathdata.Types[old_count + 2] = PathPointTypeBezier; - path->pathdata.Types[old_count + 3] = PathPointTypeBezier; - - path->newfigure = FALSE; - path->pathdata.Count += 4; - - return Ok; + return extend_current_figure(path, points, 4, PathPointTypeBezier); } GpStatus WINGDIPAPI GdipAddPathBezierI(GpPath *path, INT x1, INT y1, INT x2, diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 7670a6c41f..d85cf68dfc 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -332,6 +332,39 @@ static void test_line2(void) GdipDeletePath(path); } +static path_test_t bezier_path[] = { + {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/ + {20.0, 10.0, PathPointTypeBezier, 0, 0}, /*1*/ + {20.0, 20.0, PathPointTypeBezier, 0, 0}, /*2*/ + {30.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/ + {40.0, 20.0, PathPointTypeBezier, 0, 0}, /*4*/ + {40.0, 30.0, PathPointTypeBezier, 0, 0}, /*5*/ + {50.0, 30.0, PathPointTypeBezier, 0, 0}, /*6*/ + {50.0, 10.0, PathPointTypeLine, 0, 0}, /*7*/ + {60.0, 10.0, PathPointTypeBezier, 0, 0}, /*8*/ + {60.0, 20.0, PathPointTypeBezier, 0, 0}, /*9*/ + {70.0, 20.0, PathPointTypeBezier, 0, 0} /*10*/ + }; + +static void test_bezier(void) +{ + GpStatus status; + GpPath* path; + + GdipCreatePath(FillModeAlternate, &path); + + status = GdipAddPathBezier(path, 10.0, 10.0, 20.0, 10.0, 20.0, 20.0, 30.0, 20.0); + expect(Ok, status); + status = GdipAddPathBezier(path, 30.0, 20.0, 40.0, 20.0, 40.0, 30.0, 50.0, 30.0); + expect(Ok, status); + status = GdipAddPathBezier(path, 50.0, 10.0, 60.0, 10.0, 60.0, 20.0, 70.0, 20.0); + expect(Ok, status); + + ok_path(path, bezier_path, ARRAY_SIZE(bezier_path), FALSE); + + GdipDeletePath(path); +} + static path_test_t arc_path[] = { {600.0, 450.0, PathPointTypeStart, 0, 0}, /*0*/ {600.0, 643.3, PathPointTypeBezier, 0, 0}, /*1*/ @@ -1784,6 +1817,7 @@ START_TEST(graphicspath) test_getpathdata(); test_createpath2(); test_line2(); + test_bezier(); test_arc(); test_worldbounds(); test_pathpath();
1
0
0
0
Alexandre Julliard : kernel32: Move GetNamedPipeHandleStateW() implementation to kernelbase.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: 99027aeaee22b72e5cbd62f83d26f2b2d973dd57 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=99027aeaee22b72e5cbd62f8…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 16 15:34:59 2020 +0200 kernel32: Move GetNamedPipeHandleStateW() implementation to kernelbase. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/kernel32.spec | 4 +-- dlls/kernel32/sync.c | 60 ----------------------------------------- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/sync.c | 38 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 63 deletions(-) diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index a5550dd359..01bfdd37f1 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -731,8 +731,8 @@ # @ stub GetNamedPipeClientComputerNameW @ stdcall GetNamedPipeClientProcessId(long ptr) @ stdcall GetNamedPipeClientSessionId(long ptr) -@ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr str long) -@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long) +@ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr ptr long) +@ stdcall -import GetNamedPipeHandleStateW(long ptr ptr ptr ptr ptr long) @ stdcall -import GetNamedPipeInfo(long ptr ptr ptr ptr) @ stdcall GetNamedPipeServerProcessId(long ptr) @ stdcall GetNamedPipeServerSessionId(long ptr) diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c index 48f9fca20a..7a7a37b4a2 100644 --- a/dlls/kernel32/sync.c +++ b/dlls/kernel32/sync.c @@ -42,7 +42,6 @@ #include "ddk/wdm.h" #include "wine/asm.h" -#include "wine/library.h" #include "wine/unicode.h" #include "kernel_private.h" @@ -630,65 +629,6 @@ BOOL WINAPI GetNamedPipeHandleStateA( return ret; } -/*********************************************************************** - * GetNamedPipeHandleStateW (KERNEL32.@) - */ -BOOL WINAPI GetNamedPipeHandleStateW( - HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances, - LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout, - LPWSTR lpUsername, DWORD nUsernameMaxSize) -{ - IO_STATUS_BLOCK iosb; - NTSTATUS status; - - FIXME("%p %p %p %p %p %p %d: semi-stub\n", hNamedPipe, lpState, lpCurInstances, - lpMaxCollectionCount, lpCollectDataTimeout, lpUsername, nUsernameMaxSize); - - if (lpMaxCollectionCount) - *lpMaxCollectionCount = 0; - - if (lpCollectDataTimeout) - *lpCollectDataTimeout = 0; - - if (lpUsername && nUsernameMaxSize) - { - const char *username = wine_get_user_name(); - int len = MultiByteToWideChar(CP_UNIXCP, 0, username, -1, lpUsername, nUsernameMaxSize); - if (!len) *lpUsername = 0; - } - - if (lpState) - { - FILE_PIPE_INFORMATION fpi; - status = NtQueryInformationFile(hNamedPipe, &iosb, &fpi, sizeof(fpi), - FilePipeInformation); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return FALSE; - } - - *lpState = (fpi.ReadMode ? PIPE_READMODE_MESSAGE : PIPE_READMODE_BYTE) | - (fpi.CompletionMode ? PIPE_NOWAIT : PIPE_WAIT); - } - - if (lpCurInstances) - { - FILE_PIPE_LOCAL_INFORMATION fpli; - status = NtQueryInformationFile(hNamedPipe, &iosb, &fpli, sizeof(fpli), - FilePipeLocalInformation); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return FALSE; - } - - *lpCurInstances = fpli.CurrentInstances; - } - - return TRUE; -} - /*********************************************************************** * CallNamedPipeA (KERNEL32.@) */ diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index 9aa0613ea5..631e5c02c7 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -570,7 +570,7 @@ @ stub GetNamedLocaleHashNode @ stub GetNamedPipeAttribute @ stub GetNamedPipeClientComputerNameW -@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long) kernel32.GetNamedPipeHandleStateW +@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr ptr long) @ stdcall GetNamedPipeInfo(long ptr ptr ptr ptr) @ stdcall GetNativeSystemInfo(ptr) # @ stub GetNextFgPolicyRefreshInfoInternal diff --git a/dlls/kernelbase/sync.c b/dlls/kernelbase/sync.c index 441b47ffb0..c0db4679e9 100644 --- a/dlls/kernelbase/sync.c +++ b/dlls/kernelbase/sync.c @@ -1201,6 +1201,44 @@ BOOL WINAPI DECLSPEC_HOTPATCH DisconnectNamedPipe( HANDLE pipe ) } +/*********************************************************************** + * GetNamedPipeHandleStateW (kernelbase.@) + */ +BOOL WINAPI DECLSPEC_HOTPATCH GetNamedPipeHandleStateW( HANDLE pipe, DWORD *state, DWORD *instances, + DWORD *max_count, DWORD *timeout, + WCHAR *user, DWORD size ) +{ + IO_STATUS_BLOCK io; + + FIXME( "%p %p %p %p %p %p %d: semi-stub\n", pipe, state, instances, max_count, timeout, user, size ); + + if (max_count) *max_count = 0; + if (timeout) *timeout = 0; + if (user && size && !GetEnvironmentVariableW( L"WINEUSERNAME", user, size )) user[0] = 0; + + if (state) + { + FILE_PIPE_INFORMATION info; + + if (!set_ntstatus( NtQueryInformationFile( pipe, &io, &info, sizeof(info), FilePipeInformation ))) + return FALSE; + + *state = (info.ReadMode ? PIPE_READMODE_MESSAGE : PIPE_READMODE_BYTE) | + (info.CompletionMode ? PIPE_NOWAIT : PIPE_WAIT); + } + if (instances) + { + FILE_PIPE_LOCAL_INFORMATION info; + + if (!set_ntstatus( NtQueryInformationFile( pipe, &io, &info, sizeof(info), + FilePipeLocalInformation))) + return FALSE; + *instances = info.CurrentInstances; + } + return TRUE; +} + + /*********************************************************************** * GetNamedPipeInfo (kernelbase.@) */
1
0
0
0
Alexandre Julliard : advapi32: Use WINEUSERNAME variable to implement GetUserNameA/W.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: f8fb43aaba499c6d0da05b0ee3a09c349a753cf8 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f8fb43aaba499c6d0da05b0e…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 16 15:15:21 2020 +0200 advapi32: Use WINEUSERNAME variable to implement GetUserNameA/W. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/advapi32/advapi.c | 79 +++++++++----------------------------------------- 1 file changed, 14 insertions(+), 65 deletions(-) diff --git a/dlls/advapi32/advapi.c b/dlls/advapi32/advapi.c index 433c25820d..cfd79e02af 100644 --- a/dlls/advapi32/advapi.c +++ b/dlls/advapi32/advapi.c @@ -32,7 +32,6 @@ #include "wincred.h" #include "wct.h" -#include "wine/library.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -42,81 +41,31 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); /****************************************************************************** * GetUserNameA [ADVAPI32.@] - * - * Get the current user name. - * - * PARAMS - * lpszName [O] Destination for the user name. - * lpSize [I/O] Size of lpszName. - * - * RETURNS - * Success: The length of the user name, including terminating NUL. - * Failure: ERROR_MORE_DATA if *lpSize is too small. */ -BOOL WINAPI -GetUserNameA( LPSTR lpszName, LPDWORD lpSize ) +BOOL WINAPI GetUserNameA( LPSTR name, LPDWORD size ) { - WCHAR *buffer; + DWORD len = GetEnvironmentVariableA( "WINEUSERNAME", name, *size ); BOOL ret; - DWORD sizeW = *lpSize; - - if (!(buffer = heap_alloc( sizeW * sizeof(WCHAR) ))) - { - SetLastError( ERROR_NOT_ENOUGH_MEMORY ); - return FALSE; - } - ret = GetUserNameW( buffer, &sizeW ); - if (ret) - *lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL ); - else - *lpSize = sizeW; - - heap_free( buffer ); + if (!len) return FALSE; + if ((ret = (len < *size))) len++; + *size = len; return ret; } /****************************************************************************** * GetUserNameW [ADVAPI32.@] - * - * See GetUserNameA. */ -BOOL WINAPI -GetUserNameW( LPWSTR lpszName, LPDWORD lpSize ) +BOOL WINAPI GetUserNameW( LPWSTR name, LPDWORD size ) { - const char *name = wine_get_user_name(); - DWORD i, len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 ); - LPWSTR backslash; - - if (len > *lpSize) - { - SetLastError( ERROR_INSUFFICIENT_BUFFER ); - *lpSize = len; - return FALSE; - } - - *lpSize = len; - MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len ); - - /* Word uses the user name to create named mutexes and file mappings, - * and backslashes in the name cause the creation to fail. - * Also, Windows doesn't return the domain name in the user name even when - * joined to a domain. A Unix box joined to a domain using winbindd will - * contain the domain name in the username. So we need to cut this off. - * FIXME: Only replaces forward and backslashes for now, should get the - * winbind separator char from winbindd and replace that. - */ - for (i = 0; lpszName[i]; i++) - if (lpszName[i] == '/') lpszName[i] = '\\'; - - backslash = strrchrW(lpszName, '\\'); - if (backslash == NULL) - return TRUE; - - len = lstrlenW(backslash); - memmove(lpszName, backslash + 1, len * sizeof(WCHAR)); - *lpSize = len; - return TRUE; + static const WCHAR wineusernameW[] = {'W','I','N','E','U','S','E','R','N','A','M','E',0}; + DWORD len = GetEnvironmentVariableW( wineusernameW, name, *size ); + BOOL ret; + + if (!len) return FALSE; + if ((ret = (len < *size))) len++; + *size = len; + return ret; } /******************************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Export Unix user name in WINEUSERNAME variable.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: 52bf0fbd4792130af8a847856b264b99e7177d18 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=52bf0fbd4792130af8a84785…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 16 15:15:07 2020 +0200 ntdll: Export Unix user name in WINEUSERNAME variable. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/env.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c index b37649764c..b15a425556 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -377,15 +377,16 @@ static void set_wow64_environment( WCHAR **env ) static const WCHAR winehomedirW[] = {'W','I','N','E','H','O','M','E','D','I','R',0}; static const WCHAR winedatadirW[] = {'W','I','N','E','D','A','T','A','D','I','R',0}; static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0}; + static const WCHAR wineusernameW[] = {'W','I','N','E','U','S','E','R','N','A','M','E',0}; static const WCHAR wineconfigdirW[] = {'W','I','N','E','C','O','N','F','I','G','D','I','R',0}; - WCHAR buf[64]; + WCHAR buf[256]; UNICODE_STRING arch_strW = { sizeof(archW) - sizeof(WCHAR), sizeof(archW), archW }; UNICODE_STRING arch6432_strW = { sizeof(arch6432W) - sizeof(WCHAR), sizeof(arch6432W), arch6432W }; UNICODE_STRING valW = { 0, sizeof(buf), buf }; OBJECT_ATTRIBUTES attr; UNICODE_STRING nameW; - const char *path; + const char *p, *name; WCHAR *val; HANDLE hkey; DWORD i; @@ -396,14 +397,22 @@ static void set_wow64_environment( WCHAR **env ) set_wine_path_variable( env, winehomedirW, getenv("HOME") ); set_wine_path_variable( env, winebuilddirW, wine_get_build_dir() ); set_wine_path_variable( env, wineconfigdirW, wine_get_config_dir() ); - for (i = 0; (path = wine_dll_enum_load_path( i )); i++) + for (i = 0; (p = wine_dll_enum_load_path( i )); i++) { NTDLL_swprintf( buf, winedlldirW, i ); - set_wine_path_variable( env, buf, path ); + set_wine_path_variable( env, buf, p ); } NTDLL_swprintf( buf, winedlldirW, i ); set_wine_path_variable( env, buf, NULL ); + /* set user name */ + + name = wine_get_user_name(); + if ((p = strrchr( name, '/' ))) name = p + 1; + if ((p = strrchr( name, '\\' ))) name = p + 1; + ntdll_umbstowcs( name, strlen(name) + 1, buf, ARRAY_SIZE(buf) ); + set_env_var( env, wineusernameW, buf ); + /* set the PROCESSOR_ARCHITECTURE variable */ if (!RtlQueryEnvironmentVariable_U( *env, &arch6432_strW, &valW ))
1
0
0
0
Alexandre Julliard : ntdll: Execute .so constructors during module initialization.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: 081c8e1c73bb8d79a060da7816b5c429180b35b7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=081c8e1c73bb8d79a060da78…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 16 12:22:24 2020 +0200 ntdll: Execute .so constructors during module initialization. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/loader.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index c32292d453..0568be63ad 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -24,6 +24,9 @@ #include <assert.h> #include <stdarg.h> +#ifdef HAVE_LINK_H +# include <link.h> +#endif #ifdef HAVE_SYS_MMAN_H # include <sys/mman.h> #endif @@ -1306,6 +1309,42 @@ static void call_tls_callbacks( HMODULE module, UINT reason ) } +/************************************************************************* + * call_constructors + */ +static void call_constructors( WINE_MODREF *wm ) +{ +#ifdef HAVE_DLINFO + extern char **__wine_main_environ; + struct link_map *map; + void (*init_func)(int, char **, char **) = NULL; + void (**init_array)(int, char **, char **) = NULL; + ULONG_PTR i, init_arraysz = 0; + + if (dlinfo( wm->so_handle, RTLD_DI_LINKMAP, &map ) == -1) return; + while (map->l_ld->d_tag) + { + switch (map->l_ld->d_tag) + { + case 0x60009990: init_array = (void *)((char *)map->l_addr + map->l_ld->d_un.d_val); break; + case 0x60009991: init_arraysz = map->l_ld->d_un.d_val; break; + case 0x60009992: init_func = (void *)((char *)map->l_addr + map->l_ld->d_un.d_val); break; + } + map->l_ld++; + } + + TRACE( "%s: got init_func %p init_array %p %lu\n", debugstr_us( &wm->ldr.BaseDllName ), + init_func, init_array, init_arraysz ); + + if (init_func) init_func( __wine_main_argc, __wine_main_argv, __wine_main_environ ); + + if (init_array) + for (i = 0; i < init_arraysz / sizeof(*init_array); i++) + init_array[i]( __wine_main_argc, __wine_main_argv, __wine_main_environ ); +#endif +} + + /************************************************************************* * MODULE_InitDLL */ @@ -1321,6 +1360,7 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved if (wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) return STATUS_SUCCESS; if (wm->ldr.TlsIndex != -1) call_tls_callbacks( wm->ldr.BaseAddress, reason ); + if (wm->so_handle && reason == DLL_PROCESS_ATTACH) call_constructors( wm ); if (!entry) return STATUS_SUCCESS; if (TRACE_ON(relay)) @@ -3979,6 +4019,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, void **entry, ULONG_PTR unknow } attach_implicitly_loaded_dlls( context ); virtual_release_address_space(); + if (wm->so_handle) call_constructors( wm ); if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie ); } else
1
0
0
0
Alexandre Julliard : configure: Add check for dlinfo().
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: 3154cda6bda9f8b43ea17304caecc5ecf46d8793 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=3154cda6bda9f8b43ea17304…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 16 12:22:10 2020 +0200 configure: Add check for dlinfo(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- configure | 9 +++++---- configure.ac | 2 +- include/config.h.in | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/configure b/configure index b41f1c797f..87cd2906e6 100755 --- a/configure +++ b/configure @@ -17864,12 +17864,13 @@ fi ac_wine_check_funcs_save_LIBS="$LIBS" LIBS="$LIBS $DL_LIBS" -for ac_func in dladdr +for ac_func in dladdr dlinfo do : - ac_fn_c_check_func "$LINENO" "dladdr" "ac_cv_func_dladdr" -if test "x$ac_cv_func_dladdr" = xyes; then : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define HAVE_DLADDR 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi diff --git a/configure.ac b/configure.ac index 241ea82d83..d5c67e3879 100644 --- a/configure.ac +++ b/configure.ac @@ -2182,7 +2182,7 @@ CFLAGS="$ac_save_CFLAGS" dnl Check for -ldl AC_SEARCH_LIBS(dlopen, dl) -WINE_CHECK_LIB_FUNCS(dladdr,[$DL_LIBS]) +WINE_CHECK_LIB_FUNCS(dladdr dlinfo,[$DL_LIBS]) dnl Check for -lpoll for Mac OS X/Darwin if test "$ac_cv_func_poll" = no diff --git a/include/config.h.in b/include/config.h.in index 8cbf8db09a..24a037a50e 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -110,6 +110,9 @@ /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H +/* Define to 1 if you have the `dlinfo' function. */ +#undef HAVE_DLINFO + /* Define to 1 if you have the <EGL/egl.h> header file. */ #undef HAVE_EGL_EGL_H
1
0
0
0
Alexandre Julliard : winegcc: Fixup constructors after building a module.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: c30d30d328408a9031477e084377f8d7eef11e74 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c30d30d328408a9031477e08…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 16 12:21:48 2020 +0200 winegcc: Fixup constructors after building a module. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/winegcc/winegcc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index b2a4f9189e..0682e9aa9a 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -936,6 +936,16 @@ static strarray *get_winebuild_args(struct options *opts) return spec_args; } +static void fixup_constructors( struct options *opts, const char *file ) +{ + strarray *args = get_winebuild_args( opts ); + + strarray_add( args, "--fixup-ctors" ); + strarray_add( args, file ); + spawn( opts->prefix, args, 0 ); + strarray_free( args ); +} + static void make_wine_builtin( struct options *opts, const char *file ) { strarray *args = get_winebuild_args( opts ); @@ -1354,8 +1364,6 @@ static void build(struct options* opts) spawn(opts->prefix, link_args, 0); strarray_free (link_args); - if (is_pe && opts->wine_builtin) make_wine_builtin( opts, output_path ); - /* set the base address with prelink if linker support is not present */ if (opts->prelink && !opts->target) { @@ -1371,6 +1379,9 @@ static void build(struct options* opts) } } + if (!is_pe && !opts->shared) fixup_constructors( opts, output_path ); + if (is_pe && opts->wine_builtin) make_wine_builtin( opts, output_path ); + /* create the loader script */ if (generate_app_loader) create_file(output_file, 0755, app_loader_template, strmake("%s.so", output_name));
1
0
0
0
Alexandre Julliard : winebuild: Add --fixup-ctors option to allow intercepting constructors in .so files.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: 6c4046fef1fb4a78cfb649de34af7770ffe05024 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6c4046fef1fb4a78cfb649de…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 16 12:21:23 2020 +0200 winebuild: Add --fixup-ctors option to allow intercepting constructors in .so files. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/winebuild/build.h | 1 + tools/winebuild/main.c | 13 +++- tools/winebuild/spec32.c | 159 +++++++++++++++++++++++++++++++++++++++ tools/winebuild/winebuild.man.in | 14 +++- 4 files changed, 182 insertions(+), 5 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 65493ec37f..b30785b74a 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -321,6 +321,7 @@ extern void output_fake_module16( DLLSPEC *spec16 ); extern void output_res_o_file( DLLSPEC *spec ); extern void output_asm_relays16(void); extern void make_builtin_files( char *argv[] ); +extern void fixup_constructors( char *argv[] ); extern void add_16bit_exports( DLLSPEC *spec32, DLLSPEC *spec16 ); extern int parse_spec_file( FILE *file, DLLSPEC *spec ); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index db8587c3bd..d973a4e973 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -115,6 +115,7 @@ enum exec_mode_values MODE_IMPLIB, MODE_STATICLIB, MODE_BUILTIN, + MODE_FIXUP_CTORS, MODE_RESOURCES }; @@ -301,8 +302,9 @@ static const char usage_str[] = " --exe Build an executable from object files\n" " --implib Build an import library\n" " --staticlib Build a static library\n" -" --builtin Mark a library as a Wine builtin\n" " --resources Build a .o or .res file for the resource files\n\n" +" --builtin Mark a library as a Wine builtin\n" +" --fixup-ctors Fixup the constructors data after the module has been built\n" "The mode options are mutually exclusive; you must specify one and only one.\n\n"; enum long_options_values @@ -316,6 +318,7 @@ enum long_options_values LONG_OPT_CCCMD, LONG_OPT_EXTERNAL_SYMS, LONG_OPT_FAKE_MODULE, + LONG_OPT_FIXUP_CTORS, LONG_OPT_LARGE_ADDRESS_AWARE, LONG_OPT_LDCMD, LONG_OPT_NMCMD, @@ -341,6 +344,7 @@ static const struct option long_options[] = { "cc-cmd", 1, 0, LONG_OPT_CCCMD }, { "external-symbols", 0, 0, LONG_OPT_EXTERNAL_SYMS }, { "fake-module", 0, 0, LONG_OPT_FAKE_MODULE }, + { "fixup-ctors", 0, 0, LONG_OPT_FIXUP_CTORS }, { "large-address-aware", 0, 0, LONG_OPT_LARGE_ADDRESS_AWARE }, { "ld-cmd", 1, 0, LONG_OPT_LDCMD }, { "nm-cmd", 1, 0, LONG_OPT_NMCMD }, @@ -511,6 +515,9 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec ) case LONG_OPT_BUILTIN: set_exec_mode( MODE_BUILTIN ); break; + case LONG_OPT_FIXUP_CTORS: + set_exec_mode( MODE_FIXUP_CTORS ); + break; case LONG_OPT_ASCMD: as_command = strarray_fromstring( optarg, " " ); break; @@ -701,6 +708,10 @@ int main(int argc, char **argv) if (!argv[0]) fatal_error( "missing file argument for --builtin option\n" ); make_builtin_files( argv ); break; + case MODE_FIXUP_CTORS: + if (!argv[0]) fatal_error( "missing file argument for --fixup-ctors option\n" ); + fixup_constructors( argv ); + break; case MODE_RESOURCES: load_resources( argv, spec ); output_res_o_file( spec ); diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 631a467a5e..6e6f502e99 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -1095,3 +1095,162 @@ void make_builtin_files( char *argv[] ) close( fd ); } } + +static void fixup_elf32( const char *name, int fd, void *header, size_t header_size ) +{ + struct + { + unsigned char e_ident[16]; + unsigned short e_type; + unsigned short e_machine; + unsigned int e_version; + unsigned int e_entry; + unsigned int e_phoff; + unsigned int e_shoff; + unsigned int e_flags; + unsigned short e_ehsize; + unsigned short e_phentsize; + unsigned short e_phnum; + unsigned short e_shentsize; + unsigned short e_shnum; + unsigned short e_shstrndx; + } *elf = header; + struct + { + unsigned int p_type; + unsigned int p_offset; + unsigned int p_vaddr; + unsigned int p_paddr; + unsigned int p_filesz; + unsigned int p_memsz; + unsigned int p_flags; + unsigned int p_align; + } *phdr; + struct + { + unsigned int d_tag; + unsigned int d_val; + } *dyn; + + unsigned int i, size; + + if (header_size < sizeof(*elf)) return; + if (elf->e_ident[6] != 1 /* EV_CURRENT */) return; + + size = elf->e_phnum * elf->e_phentsize; + phdr = xmalloc( size ); + lseek( fd, elf->e_phoff, SEEK_SET ); + if (read( fd, phdr, size ) != size) return; + + for (i = 0; i < elf->e_phnum; i++) + { + if (phdr->p_type == 2 /* PT_DYNAMIC */ ) break; + phdr = (void *)((char *)phdr + elf->e_phentsize); + } + if (i == elf->e_phnum) return; + + dyn = xmalloc( phdr->p_filesz ); + lseek( fd, phdr->p_offset, SEEK_SET ); + if (read( fd, dyn, phdr->p_filesz ) != phdr->p_filesz) return; + for (i = 0; i < phdr->p_filesz / sizeof(*dyn) && dyn[i].d_tag; i++) + { + switch (dyn[i].d_tag) + { + case 25: dyn[i].d_tag = 0x60009990; break; /* DT_INIT_ARRAY */ + case 27: dyn[i].d_tag = 0x60009991; break; /* DT_INIT_ARRAYSZ */ + case 12: dyn[i].d_tag = 0x60009992; break; /* DT_INIT */ + } + } + lseek( fd, phdr->p_offset, SEEK_SET ); + write( fd, dyn, phdr->p_filesz ); +} + +static void fixup_elf64( const char *name, int fd, void *header, size_t header_size ) +{ + struct + { + unsigned char e_ident[16]; + unsigned short e_type; + unsigned short e_machine; + unsigned int e_version; + unsigned __int64 e_entry; + unsigned __int64 e_phoff; + unsigned __int64 e_shoff; + unsigned int e_flags; + unsigned short e_ehsize; + unsigned short e_phentsize; + unsigned short e_phnum; + unsigned short e_shentsize; + unsigned short e_shnum; + unsigned short e_shstrndx; + } *elf = header; + struct + { + unsigned int p_type; + unsigned int p_flags; + unsigned __int64 p_offset; + unsigned __int64 p_vaddr; + unsigned __int64 p_paddr; + unsigned __int64 p_filesz; + unsigned __int64 p_memsz; + unsigned __int64 p_align; + } *phdr; + struct + { + unsigned __int64 d_tag; + unsigned __int64 d_val; + } *dyn; + + unsigned int i, size; + + if (header_size < sizeof(*elf)) return; + if (elf->e_ident[6] != 1 /* EV_CURRENT */) return; + + size = elf->e_phnum * elf->e_phentsize; + phdr = xmalloc( size ); + lseek( fd, elf->e_phoff, SEEK_SET ); + if (read( fd, phdr, size ) != size) return; + + for (i = 0; i < elf->e_phnum; i++) + { + if (phdr->p_type == 2 /* PT_DYNAMIC */ ) break; + phdr = (void *)((char *)phdr + elf->e_phentsize); + } + if (i == elf->e_phnum) return; + + dyn = xmalloc( phdr->p_filesz ); + lseek( fd, phdr->p_offset, SEEK_SET ); + if (read( fd, dyn, phdr->p_filesz ) != phdr->p_filesz) return; + for (i = 0; i < phdr->p_filesz / sizeof(*dyn) && dyn[i].d_tag; i++) + { + switch (dyn[i].d_tag) + { + case 25: dyn[i].d_tag = 0x60009990; break; /* DT_INIT_ARRAY */ + case 27: dyn[i].d_tag = 0x60009991; break; /* DT_INIT_ARRAYSZ */ + case 12: dyn[i].d_tag = 0x60009992; break; /* DT_INIT */ + } + } + lseek( fd, phdr->p_offset, SEEK_SET ); + write( fd, dyn, phdr->p_filesz ); +} + +/******************************************************************* + * fixup_constructors + */ +void fixup_constructors( char *argv[] ) +{ + int i, fd, size; + unsigned int header[64]; + + for (i = 0; argv[i]; i++) + { + if ((fd = open( argv[i], O_RDWR | O_BINARY )) == -1) fatal_perror( "Cannot open %s", argv[i] ); + size = read( fd, &header, sizeof(header) ); + if (size > 5) + { + if (!memcmp( header, "\177ELF\001", 5 )) fixup_elf32( argv[i], fd, header, size ); + else if (!memcmp( header, "\177ELF\002", 5 )) fixup_elf64( argv[i], fd, header, size ); + } + close( fd ); + } +} diff --git a/tools/winebuild/winebuild.man.in b/tools/winebuild/winebuild.man.in index 29a17484ad..9c91c1a504 100644 --- a/tools/winebuild/winebuild.man.in +++ b/tools/winebuild/winebuild.man.in @@ -54,16 +54,22 @@ in .delay.a, a delayed import library is built. .BI \--staticlib Build a .a static library from object files. .TP -.BI \--builtin -Mark a PE module as a Wine builtin module, by adding the "Wine builtin -DLL" signature string after the DOS header. -.TP .B \--resources Generate a .o file containing all the input resources. This is useful when building with a PE compiler, since the PE binutils cannot handle multiple resource files as input. For a standard Unix build, the resource files are automatically included when building the spec file, so there's no need for an intermediate .o file. +.TP +.BI \--builtin +Mark a PE module as a Wine builtin module, by adding the "Wine builtin +DLL" signature string after the DOS header. +.TP +.BI \--fixup-ctors +Fixup constructors after a module has been built. This should be done +on the final .so module if its code contains constructors, to ensure +that Wine has a chance to initialize the module before the +constructors are executed. .SH OPTIONS .TP .BI \--as-cmd= as-command
1
0
0
0
← Newer
1
...
55
56
57
58
59
60
61
...
102
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Results per page:
10
25
50
100
200