[GDI] Fix metafile crashes and null driver issues.

Patch by Jérôme Gardou modified by me.
CORE-14023 : Fix SetWorldTransform for metafiles #137
Includes CORE-12832 and CORE-13627.
This commit is contained in:
James Tabor 2017-11-26 14:48:06 -06:00
parent 53d3f00b2b
commit e1e79f248b
5 changed files with 26 additions and 10 deletions

View file

@ -633,6 +633,7 @@ typedef enum _DCFUNC
DCFUNC_SetViewportOrgEx, DCFUNC_SetViewportOrgEx,
DCFUNC_SetWindowExtEx, DCFUNC_SetWindowExtEx,
DCFUNC_SetWindowOrgEx, DCFUNC_SetWindowOrgEx,
DCFUNC_SetWorldTransform,
DCFUNC_StretchBlt, DCFUNC_StretchBlt,
DCFUNC_StrokeAndFillPath, DCFUNC_StrokeAndFillPath,
DCFUNC_StrokePath, DCFUNC_StrokePath,

View file

@ -318,7 +318,14 @@ ModifyWorldTransform(
if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE) if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE)
return FALSE; return FALSE;
HANDLE_METADC(BOOL, ModifyWorldTransform, FALSE, hdc, pxform, dwMode); if (dwMode == MWT_SET)
{
HANDLE_METADC(BOOL, SetWorldTransform, FALSE, hdc, pxform);
}
else
{
HANDLE_METADC(BOOL, ModifyWorldTransform, FALSE, hdc, pxform, dwMode);
}
/* Get the DC attribute */ /* Get the DC attribute */
pdcattr = GdiGetDcAttr(hdc); pdcattr = GdiGetDcAttr(hdc);

View file

@ -546,7 +546,6 @@ static void EMF_Update_MF_Xform(HDC hdc, const enum_emh_data *info)
if (!SetWorldTransform(hdc, &final_trans)) if (!SetWorldTransform(hdc, &final_trans))
{ {
__debugbreak();
ERR("World transform failed!\n"); ERR("World transform failed!\n");
} }
} }

View file

@ -180,10 +180,10 @@ HGDIOBJ WINAPI GdiFixUpHandle(HGDIOBJ hGdiObj);
extern void push_dc_driver_ros(PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs); extern void push_dc_driver_ros(PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs);
#define push_dc_driver push_dc_driver_ros #define push_dc_driver push_dc_driver_ros
#if 0
BOOL WINAPI SetWorldTransformForMetafile(HDC hdc, const XFORM *pxform); BOOL WINAPI SetWorldTransformForMetafile(HDC hdc, const XFORM *pxform);
#define SetWorldTransform SetWorldTransformForMetafile #define SetWorldTransform SetWorldTransformForMetafile
#endif
#ifdef _M_ARM #ifdef _M_ARM
#define DbgRaiseAssertionFailure() __emit(0xdefc) #define DbgRaiseAssertionFailure() __emit(0xdefc)
#else #else

View file

@ -42,6 +42,10 @@ static INT NULL_ExtSelectClipRgn(PHYSDEV dev, HRGN hrgn, INT iMode) { return 1
static INT NULL_IntersectClipRect(PHYSDEV dev, INT left, INT top, INT right, INT bottom) { return 1; } static INT NULL_IntersectClipRect(PHYSDEV dev, INT left, INT top, INT right, INT bottom) { return 1; }
static INT NULL_OffsetClipRgn(PHYSDEV dev, INT x, INT y) { return SIMPLEREGION; } static INT NULL_OffsetClipRgn(PHYSDEV dev, INT x, INT y) { return SIMPLEREGION; }
static INT NULL_ExcludeClipRect(PHYSDEV dev, INT left, INT top, INT right, INT bottom) { return 1; } static INT NULL_ExcludeClipRect(PHYSDEV dev, INT left, INT top, INT right, INT bottom) { return 1; }
static BOOL NULL_ExtTextOutW(PHYSDEV dev, INT x, INT y, UINT fuOptions, const RECT *lprc, LPCWSTR lpString, UINT cwc, const INT *lpDx) { return TRUE; }
static BOOL NULL_ModifyWorldTransform( PHYSDEV dev, const XFORM* xform, DWORD mode ) { return TRUE; }
static BOOL NULL_SetWorldTransform( PHYSDEV dev, const XFORM* xform ) { return TRUE; }
static BOOL NULL_PolyPolyline(PHYSDEV dev, const POINT *pt, const DWORD *lpt, DWORD cw) { return TRUE; }
static const struct gdi_dc_funcs DummyPhysDevFuncs = static const struct gdi_dc_funcs DummyPhysDevFuncs =
{ {
@ -73,7 +77,7 @@ static const struct gdi_dc_funcs DummyPhysDevFuncs =
(PVOID)NULL_Unused, //INT (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID); (PVOID)NULL_Unused, //INT (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
(PVOID)NULL_Unused, //BOOL (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT); (PVOID)NULL_Unused, //BOOL (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
NULL_ExtSelectClipRgn, //INT (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT); NULL_ExtSelectClipRgn, //INT (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
(PVOID)NULL_Unused, //BOOL (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*); NULL_ExtTextOutW, //BOOL (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
nulldrv_FillPath, //BOOL (*pFillPath)(PHYSDEV); nulldrv_FillPath, //BOOL (*pFillPath)(PHYSDEV);
(PVOID)NULL_Unused, //BOOL (*pFillRgn)(PHYSDEV,HRGN,HBRUSH); (PVOID)NULL_Unused, //BOOL (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
nulldrv_FlattenPath, //BOOL (*pFlattenPath)(PHYSDEV); nulldrv_FlattenPath, //BOOL (*pFlattenPath)(PHYSDEV);
@ -108,7 +112,7 @@ static const struct gdi_dc_funcs DummyPhysDevFuncs =
NULL_IntersectClipRect, //INT (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT); NULL_IntersectClipRect, //INT (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
(PVOID)NULL_Unused, //BOOL (*pInvertRgn)(PHYSDEV,HRGN); (PVOID)NULL_Unused, //BOOL (*pInvertRgn)(PHYSDEV,HRGN);
(PVOID)NULL_Unused, //BOOL (*pLineTo)(PHYSDEV,INT,INT); (PVOID)NULL_Unused, //BOOL (*pLineTo)(PHYSDEV,INT,INT);
(PVOID)NULL_Unused, //BOOL (*pModifyWorldTransform)(PHYSDEV,const XFORM*,DWORD); NULL_ModifyWorldTransform, //BOOL (*pModifyWorldTransform)(PHYSDEV,const XFORM*,DWORD);
(PVOID)NULL_Unused, //BOOL (*pMoveTo)(PHYSDEV,INT,INT); (PVOID)NULL_Unused, //BOOL (*pMoveTo)(PHYSDEV,INT,INT);
NULL_OffsetClipRgn, //INT (*pOffsetClipRgn)(PHYSDEV,INT,INT); NULL_OffsetClipRgn, //INT (*pOffsetClipRgn)(PHYSDEV,INT,INT);
(PVOID)NULL_Unused, //BOOL (*pOffsetViewportOrgEx)(PHYSDEV,INT,INT,POINT*); (PVOID)NULL_Unused, //BOOL (*pOffsetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
@ -120,7 +124,7 @@ static const struct gdi_dc_funcs DummyPhysDevFuncs =
(PVOID)NULL_Unused, //BOOL (*pPolyBezierTo)(PHYSDEV,const POINT*,DWORD); (PVOID)NULL_Unused, //BOOL (*pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
(PVOID)NULL_Unused, //BOOL (*pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD); (PVOID)NULL_Unused, //BOOL (*pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
(PVOID)NULL_Unused, //BOOL (*pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT); (PVOID)NULL_Unused, //BOOL (*pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
(PVOID)NULL_Unused, //BOOL (*pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD); NULL_PolyPolyline, //BOOL (*pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
(PVOID)NULL_Unused, //BOOL (*pPolygon)(PHYSDEV,const POINT*,INT); (PVOID)NULL_Unused, //BOOL (*pPolygon)(PHYSDEV,const POINT*,INT);
(PVOID)NULL_Unused, //BOOL (*pPolyline)(PHYSDEV,const POINT*,INT); (PVOID)NULL_Unused, //BOOL (*pPolyline)(PHYSDEV,const POINT*,INT);
(PVOID)NULL_Unused, //BOOL (*pPolylineTo)(PHYSDEV,const POINT*,INT); (PVOID)NULL_Unused, //BOOL (*pPolylineTo)(PHYSDEV,const POINT*,INT);
@ -165,7 +169,7 @@ static const struct gdi_dc_funcs DummyPhysDevFuncs =
NULL_SetViewportOrgEx, //BOOL (*pSetViewportOrgEx)(PHYSDEV,INT,INT,POINT*); NULL_SetViewportOrgEx, //BOOL (*pSetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
NULL_SetWindowExtEx, //BOOL (*pSetWindowExtEx)(PHYSDEV,INT,INT,SIZE*); NULL_SetWindowExtEx, //BOOL (*pSetWindowExtEx)(PHYSDEV,INT,INT,SIZE*);
NULL_SetWindowOrgEx, //BOOL (*pSetWindowOrgEx)(PHYSDEV,INT,INT,POINT*); NULL_SetWindowOrgEx, //BOOL (*pSetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
(PVOID)NULL_Unused, //BOOL (*pSetWorldTransform)(PHYSDEV,const XFORM*); NULL_SetWorldTransform, //BOOL (*pSetWorldTransform)(PHYSDEV,const XFORM*);
(PVOID)NULL_Unused, //INT (*pStartDoc)(PHYSDEV,const DOCINFOW*); (PVOID)NULL_Unused, //INT (*pStartDoc)(PHYSDEV,const DOCINFOW*);
(PVOID)NULL_Unused, //INT (*pStartPage)(PHYSDEV); (PVOID)NULL_Unused, //INT (*pStartPage)(PHYSDEV);
(PVOID)NULL_Unused, //BOOL (*pStretchBlt)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,DWORD); (PVOID)NULL_Unused, //BOOL (*pStretchBlt)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,DWORD);
@ -534,7 +538,7 @@ DeleteColorSpace(
{ {
return NtGdiDeleteColorSpace(hcs); return NtGdiDeleteColorSpace(hcs);
} }
#if 0
BOOL BOOL
WINAPI WINAPI
SetWorldTransformForMetafile( SetWorldTransformForMetafile(
@ -561,7 +565,7 @@ SetWorldTransformForMetafile(
return SetWorldTransform(hdc, pxform); return SetWorldTransform(hdc, pxform);
} }
#endif
void void
__cdecl __cdecl
_assert ( _assert (
@ -1044,6 +1048,11 @@ DRIVER_Dispatch(
_va_arg_n(argptr, INT, 0), // X _va_arg_n(argptr, INT, 0), // X
_va_arg_n(argptr, INT, 1), // Y _va_arg_n(argptr, INT, 1), // Y
_va_arg_n(argptr, LPPOINT, 2)); // lpPoint _va_arg_n(argptr, LPPOINT, 2)); // lpPoint
case DCFUNC_SetWorldTransform:
return physdev->funcs->pSetWorldTransform(physdev,
va_arg(argptr, const XFORM*));
case DCFUNC_StretchBlt: case DCFUNC_StretchBlt:
return DRIVER_StretchBlt(physdev, return DRIVER_StretchBlt(physdev,
physdev->hdc, physdev->hdc,