[NtGDI] Fix brush attribute transfer.

This commit is contained in:
James Tabor 2021-09-28 19:08:45 -05:00
parent ef003fa47d
commit b5fae844de
2 changed files with 34 additions and 0 deletions

View file

@ -76,6 +76,17 @@ BRUSH::~BRUSH(
}
}
VOID
BRUSH::vReleaseAttribute(VOID)
{
if (this->pBrushAttr != &this->BrushAttr)
{
this->BrushAttr = *this->pBrushAttr;
GdiPoolFree(GetBrushAttrPool(), this->pBrushAttr);
this->pBrushAttr = &this->BrushAttr;
}
}
VOID
BRUSH::vDeleteObject(
_In_ PVOID pvObject)
@ -543,10 +554,19 @@ NtGdiSetBrushAttributes(
_In_ HBRUSH hbr,
_In_ DWORD dwFlags)
{
PBRUSH pbr;
if ( dwFlags & SC_BB_STOCKOBJ )
{
if (GDIOBJ_ConvertToStockObj((HGDIOBJ*)&hbr))
{
pbr = BRUSH::LockAny(hbr);
if (pbr == NULL)
{
ERR("Failed to lock brush %p\n", hbr);
return NULL;
}
pbr->vReleaseAttribute();
pbr->vUnlock();
return hbr;
}
}
@ -560,10 +580,22 @@ NtGdiClearBrushAttributes(
_In_ HBRUSH hbr,
_In_ DWORD dwFlags)
{
PBRUSH pbr;
if ( dwFlags & SC_BB_STOCKOBJ )
{
if (GDIOBJ_ConvertFromStockObj((HGDIOBJ*)&hbr))
{
pbr = BRUSH::LockAny(hbr);
if (pbr == NULL)
{
ERR("Failed to lock brush %p\n", hbr);
return NULL;
}
if (!pbr->bAllocateBrushAttr())
{
ERR("Failed to allocate brush attribute\n");
}
pbr->vUnlock();
return hbr;
}
}

View file

@ -113,6 +113,8 @@ public:
VOID
vSetSolidColor(
_In_ COLORREF crColor);
VOID vReleaseAttribute(VOID);
};
/* HACK! */