Skip to content
Permalink
Browse files

[WIN32SS][NTGDI] Strictly check in XFORMOBJ_iSetXform (#1676)

Check if the determinant of the given transformation matrix is non-zero. If zero, the function returns DDI_ERROR without change. CORE-15554
  • Loading branch information...
katahiromz committed Jun 24, 2019
1 parent ede3fdd commit bf06c94e15c47e549e824a1f82e672d40b150bc6
Showing with 44 additions and 16 deletions.
  1. +44 −16 win32ss/gdi/ntgdi/xformobj.c
@@ -104,12 +104,9 @@ HintFromAccel(ULONG flAccel)
/** Internal functions ********************************************************/

ULONG
NTAPI
XFORMOBJ_UpdateAccel(
IN OUT XFORMOBJ *pxo)
FASTCALL
MX_UpdateAccel(IN OUT PMATRIX pmx)
{
PMATRIX pmx = XFORMOBJ_pmx(pxo);

/* Copy Dx and Dy to FIX format */
pmx->fxDx = FLOATOBJ_GetFix(&pmx->efDx);
pmx->fxDy = FLOATOBJ_GetFix(&pmx->efDy);
@@ -143,31 +140,62 @@ XFORMOBJ_UpdateAccel(
return HintFromAccel(pmx->flAccel);
}

ULONG
NTAPI
XFORMOBJ_UpdateAccel(
IN OUT XFORMOBJ *pxo)
{
PMATRIX pmx = XFORMOBJ_pmx(pxo);

return MX_UpdateAccel(pmx);
}


ULONG
NTAPI
XFORMOBJ_iSetXform(
IN OUT XFORMOBJ *pxo,
IN const XFORML *pxform)
{
PMATRIX pmx = XFORMOBJ_pmx(pxo);
PMATRIX pmx;
MATRIX mxTemp;
ULONG Hint;

/* Check parameters */
if (!pxo || !pxform) return DDI_ERROR;

/* Check if the xform is valid */
if ((pxform->eM11 == 0) || (pxform->eM22 == 0)) return DDI_ERROR;

/* Copy members */
FLOATOBJ_SetFloat(&pmx->efM11, pxform->eM11);
FLOATOBJ_SetFloat(&pmx->efM12, pxform->eM12);
FLOATOBJ_SetFloat(&pmx->efM21, pxform->eM21);
FLOATOBJ_SetFloat(&pmx->efM22, pxform->eM22);
FLOATOBJ_SetFloat(&pmx->efDx, pxform->eDx);
FLOATOBJ_SetFloat(&pmx->efDy, pxform->eDy);
FLOATOBJ_SetFloat(&mxTemp.efM11, pxform->eM11);
FLOATOBJ_SetFloat(&mxTemp.efM12, pxform->eM12);
FLOATOBJ_SetFloat(&mxTemp.efM21, pxform->eM21);
FLOATOBJ_SetFloat(&mxTemp.efM22, pxform->eM22);
FLOATOBJ_SetFloat(&mxTemp.efDx, pxform->eDx);
FLOATOBJ_SetFloat(&mxTemp.efDy, pxform->eDy);

/* Update accelerators and return complexity */
return XFORMOBJ_UpdateAccel(pxo);
Hint = MX_UpdateAccel(&mxTemp);

/* Check whether det = (M11 * M22 - M12 * M21) is non-zero */
if (Hint == GX_SCALE)
{
if (FLOATOBJ_Equal0(&mxTemp.efM11) || FLOATOBJ_Equal0(&mxTemp.efM22))
{
return DDI_ERROR;
}
}
else if (Hint == GX_GENERAL)
{
if (!MX_IsInvertible(&mxTemp))
{
return DDI_ERROR;
}
}

/* Store */
pmx = XFORMOBJ_pmx(pxo);
*pmx = mxTemp;

return Hint;
}


0 comments on commit bf06c94

Please sign in to comment.
You can’t perform that action at this time.