mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 14:51:00 +00:00
[WIN32K]
Make sure a region is reasonably initialized, before potentially passing it to the cleanup function, when failing to create a handle. svn path=/trunk/; revision=66614
This commit is contained in:
parent
d09753a207
commit
6dcd051d62
1 changed files with 72 additions and 54 deletions
|
@ -2187,13 +2187,6 @@ REGION_AllocRgnWithHandle(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GDIOBJ_hInsertObject(&pReg->BaseObject, GDI_OBJ_HMGR_POWNED))
|
|
||||||
{
|
|
||||||
DPRINT1("Could not insert palette into handle table.\n");
|
|
||||||
GDIOBJ_vFreeObject(&pReg->BaseObject);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//hReg = pReg->BaseObject.hHmgr;
|
//hReg = pReg->BaseObject.hHmgr;
|
||||||
|
|
||||||
if ((nReg == 0) || (nReg == 1))
|
if ((nReg == 0) || (nReg == 1))
|
||||||
|
@ -2221,6 +2214,19 @@ REGION_AllocRgnWithHandle(
|
||||||
pReg->rdh.nRgnSize = nReg * sizeof(RECT);
|
pReg->rdh.nRgnSize = nReg * sizeof(RECT);
|
||||||
pReg->prgnattr = &pReg->rgnattr;
|
pReg->prgnattr = &pReg->rgnattr;
|
||||||
|
|
||||||
|
/* Initialize the region attribute */
|
||||||
|
pReg->rgnattr.AttrFlags = 0;
|
||||||
|
pReg->rgnattr.iComplexity = SIMPLEREGION;
|
||||||
|
pReg->rgnattr.Rect = pReg->rdh.rcBound;
|
||||||
|
|
||||||
|
/* Finally insert the region into the handle table */
|
||||||
|
if (!GDIOBJ_hInsertObject(&pReg->BaseObject, GDI_OBJ_HMGR_POWNED))
|
||||||
|
{
|
||||||
|
DPRINT1("Could not insert palette into handle table.\n");
|
||||||
|
GDIOBJ_vFreeObject(&pReg->BaseObject);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return pReg;
|
return pReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2232,6 +2238,8 @@ REGION_bAllocRgnAttr(
|
||||||
PPROCESSINFO ppi;
|
PPROCESSINFO ppi;
|
||||||
PRGN_ATTR prgnattr;
|
PRGN_ATTR prgnattr;
|
||||||
|
|
||||||
|
NT_ASSERT(prgn->prgnattr == &prgn->rgnattr);
|
||||||
|
|
||||||
ppi = PsGetCurrentProcessWin32Process();
|
ppi = PsGetCurrentProcessWin32Process();
|
||||||
ASSERT(ppi);
|
ASSERT(ppi);
|
||||||
|
|
||||||
|
@ -2242,6 +2250,9 @@ REGION_bAllocRgnAttr(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy the current region attribute */
|
||||||
|
*prgnattr = prgn->rgnattr;
|
||||||
|
|
||||||
/* Set the object attribute in the handle table */
|
/* Set the object attribute in the handle table */
|
||||||
prgn->prgnattr = prgnattr;
|
prgn->prgnattr = prgnattr;
|
||||||
GDIOBJ_vSetObjectAttr(&prgn->BaseObject, prgnattr);
|
GDIOBJ_vSetObjectAttr(&prgn->BaseObject, prgnattr);
|
||||||
|
@ -3928,105 +3939,112 @@ NtGdiGetRgnBox(
|
||||||
INT
|
INT
|
||||||
APIENTRY
|
APIENTRY
|
||||||
NtGdiOffsetRgn(
|
NtGdiOffsetRgn(
|
||||||
HRGN hRgn,
|
_In_ HRGN hrgn,
|
||||||
INT XOffset,
|
_In_ INT cx,
|
||||||
INT YOffset)
|
_In_ INT cy)
|
||||||
{
|
{
|
||||||
PREGION rgn;
|
PREGION prgn;
|
||||||
INT ret;
|
INT iResult;
|
||||||
|
|
||||||
DPRINT("NtGdiOffsetRgn: hRgn %p Xoffs %d Yoffs %d rgn %p\n", hRgn, XOffset, YOffset, rgn );
|
DPRINT("NtGdiOffsetRgn: hrgn %p cx %d cy %d\n", hrgn, cx, cy);
|
||||||
|
|
||||||
rgn = REGION_LockRgn(hRgn);
|
/* Lock the region */
|
||||||
if (rgn == NULL)
|
prgn = REGION_LockRgn(hrgn);
|
||||||
|
if (prgn == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("NtGdiOffsetRgn: hRgn error\n");
|
DPRINT1("NtGdiOffsetRgn: failed to lock region %p\n", hrgn);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!REGION_bOffsetRgn(rgn, XOffset, YOffset))
|
/* Call the internal function */
|
||||||
|
if (!REGION_bOffsetRgn(prgn, cx, cy))
|
||||||
{
|
{
|
||||||
ret = ERROR;
|
iResult = ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = REGION_Complexity(rgn);
|
iResult = REGION_Complexity(prgn);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGION_UnlockRgn(rgn);
|
/* Unlock and return the result */
|
||||||
return ret;
|
REGION_UnlockRgn(prgn);
|
||||||
|
return iResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
APIENTRY
|
APIENTRY
|
||||||
NtGdiPtInRegion(
|
NtGdiPtInRegion(
|
||||||
HRGN hRgn,
|
_In_ HRGN hrgn,
|
||||||
INT X,
|
_In_ INT x,
|
||||||
INT Y)
|
_In_ INT y)
|
||||||
{
|
{
|
||||||
PREGION prgn;
|
PREGION prgn;
|
||||||
BOOL ret;
|
BOOL bResult;
|
||||||
|
|
||||||
prgn = REGION_LockRgn(hRgn);
|
/* Lock the region */
|
||||||
|
prgn = REGION_LockRgn(hrgn);
|
||||||
if (prgn == NULL)
|
if (prgn == NULL)
|
||||||
|
{
|
||||||
|
DPRINT1("NtGdiPtInRegion: hrgn error\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
ret = REGION_PtInRegion(prgn, X, Y);
|
/* Call the internal function */
|
||||||
|
bResult = REGION_PtInRegion(prgn, x, y);
|
||||||
|
|
||||||
|
/* Unlock and return the result */
|
||||||
REGION_UnlockRgn(prgn);
|
REGION_UnlockRgn(prgn);
|
||||||
return ret;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
APIENTRY
|
APIENTRY
|
||||||
NtGdiRectInRegion(
|
NtGdiRectInRegion(
|
||||||
HRGN hRgn,
|
_In_ HRGN hrgn,
|
||||||
LPRECTL unsaferc)
|
_In_ LPRECT prclUnsafe)
|
||||||
{
|
{
|
||||||
RECTL rc = { 0 };
|
RECTL rcTemp;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
|
||||||
|
|
||||||
|
/* Probe and copy the rect */
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
ProbeForRead(unsaferc, sizeof(RECT), 1);
|
ProbeForRead(prclUnsafe, sizeof(RECT), 1);
|
||||||
rc = *unsaferc;
|
rcTemp = *prclUnsafe;
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
Status = _SEH2_GetExceptionCode();
|
DPRINT1("NtGdiRectInRegion: Exception accessing the rect\n");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
/* Call the internal function */
|
||||||
{
|
return IntRectInRegion(hrgn, &rcTemp);
|
||||||
SetLastNtError(Status);
|
|
||||||
DPRINT1("NtGdiRectInRegion: Bogus rc\n");
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return IntRectInRegion(hRgn, &rc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
APIENTRY
|
APIENTRY
|
||||||
NtGdiSetRectRgn(
|
NtGdiSetRectRgn(
|
||||||
HRGN hRgn,
|
_In_ HRGN hrgn,
|
||||||
INT LeftRect,
|
_In_ INT xLeft,
|
||||||
INT TopRect,
|
_In_ INT yTop,
|
||||||
INT RightRect,
|
_In_ INT xRight,
|
||||||
INT BottomRect)
|
_In_ INT yBottom)
|
||||||
{
|
{
|
||||||
PREGION rgn;
|
PREGION prgn;
|
||||||
|
|
||||||
rgn = REGION_LockRgn(hRgn);
|
/* Lock the region */
|
||||||
if (rgn == NULL)
|
prgn = REGION_LockRgn(hrgn);
|
||||||
|
if (prgn == NULL)
|
||||||
{
|
{
|
||||||
return 0; // Per documentation
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGION_SetRectRgn(rgn, LeftRect, TopRect, RightRect, BottomRect);
|
/* Call the internal API */
|
||||||
|
REGION_SetRectRgn(prgn, xLeft, yTop, xRight, yBottom);
|
||||||
|
|
||||||
REGION_UnlockRgn(rgn);
|
/* Unlock the region and return success */
|
||||||
|
REGION_UnlockRgn(prgn);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue