*
* $Id$
*/
+
#include <w32k.h>
+#define NDEBUG
+#include <debug.h>
+
static const USHORT HatchBrushes[NB_HATCH_STYLES][8] =
{
{0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00}, /* HS_HORIZONTAL */
GDIOBJ_SetOwnership(pBrush->hbmPattern, PsGetCurrentProcess());
NtGdiDeleteObject(pBrush->hbmPattern);
}
-
+
return TRUE;
}
Result = IntEngCreateXlate(0, 0, Dc->w.hPalette, Pattern->hDIBPalette);
}
- BITMAPOBJ_UnlockBitmap(BrushObj->hbmPattern);
+ BITMAPOBJ_UnlockBitmap(Pattern);
*Failed = FALSE;
}
/*
* At first get some basic parameters from the passed BitmapInfoHeader
- * structure. It can have one of the following formats:
+ * structure. It can have one of the following formats:
* - BITMAPCOREHEADER (the oldest one with totally different layout
* from the others)
* - BITMAPINFOHEADER (the standard and most common header)
*ColorTableSize = 0;
else
*ColorTableSize = 3;
-
+
return TRUE;
case BI_RGB:
*ColorTableSize = ClrUsed;
return TRUE;
}
-
+
case BI_RLE4:
if (BitCount == 4)
{
return TRUE;
default:
- return FALSE;
+ return FALSE;
}
}
ULONG_PTR DataPtr;
UINT PaletteEntryCount;
PBITMAPOBJ BitmapObject;
- UINT PaletteType;
+ INT PaletteType;
if (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
{
BitmapObject = BITMAPOBJ_LockBitmap(hPattern);
ASSERT(BitmapObject != NULL);
BitmapObject->hDIBPalette = BuildDIBPalette(BitmapInfo, &PaletteType);
- BITMAPOBJ_UnlockBitmap(hPattern);
+ BITMAPOBJ_UnlockBitmap(BitmapObject);
hBrush = BRUSHOBJ_AllocBrush();
if (hBrush == NULL)
GDIOBJ_SetOwnership(hPattern, NULL);
- BRUSHOBJ_UnlockBrush(hBrush);
-
+ BRUSHOBJ_UnlockBrush(BrushObject);
+
return hBrush;
}
HBRUSH hBrush;
PGDIBRUSHOBJ BrushObject;
HBITMAP hPattern;
-
+
if (Style < 0 || Style >= NB_HATCH_STYLES)
{
return 0;
}
- hPattern = NtGdiCreateBitmap(8, 8, 1, 1, HatchBrushes[Style]);
+ hPattern = NtGdiCreateBitmap(8, 8, 1, 1, (LPBYTE)HatchBrushes[Style]);
if (hPattern == NULL)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
GDIOBJ_SetOwnership(hPattern, NULL);
- BRUSHOBJ_UnlockBrush(hBrush);
-
+ BRUSHOBJ_UnlockBrush(BrushObject);
+
return hBrush;
}
HBRUSH hBrush;
PGDIBRUSHOBJ BrushObject;
HBITMAP hPattern;
-
+
hPattern = BITMAPOBJ_CopyBitmap(hBitmap);
if (hPattern == NULL)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
-
+
hBrush = BRUSHOBJ_AllocBrush();
if (hBrush == NULL)
{
GDIOBJ_SetOwnership(hPattern, NULL);
- BRUSHOBJ_UnlockBrush(hBrush);
-
+ BRUSHOBJ_UnlockBrush(BrushObject);
+
return hBrush;
}
{
HBRUSH hBrush;
PGDIBRUSHOBJ BrushObject;
-
+
hBrush = BRUSHOBJ_AllocBrush();
if (hBrush == NULL)
{
BrushObject->BrushAttr.lbColor = Color & 0xFFFFFF;
/* FIXME: Fill in the rest of fields!!! */
- BRUSHOBJ_UnlockBrush(hBrush);
-
+ BRUSHOBJ_UnlockBrush(BrushObject);
+
return hBrush;
}
{
HBRUSH hBrush;
PGDIBRUSHOBJ BrushObject;
-
+
hBrush = BRUSHOBJ_AllocBrush();
if (hBrush == NULL)
{
BrushObject = BRUSHOBJ_LockBrush(hBrush);
ASSERT(BrushObject != NULL);
BrushObject->flAttrs |= GDIBRUSH_IS_NULL;
- BRUSHOBJ_UnlockBrush(hBrush);
-
+ BRUSHOBJ_UnlockBrush(BrushObject);
+
return hBrush;
}
DestRect.top = YLeft + Height + dc->w.DCOrgY + 1;
DestRect.bottom = YLeft + dc->w.DCOrgY + 1;
}
-
+
+ IntLPtoDP(dc, (LPPOINT)&DestRect, 2);
+
BrushOrigin.x = BrushObj->ptOrigin.x + dc->w.DCOrgX;
BrushOrigin.y = BrushObj->ptOrigin.y + dc->w.DCOrgY;
IntGdiInitBrushInstance(&BrushInst, BrushObj, dc->XlateBrush);
ret = IntEngBitBlt(
- BitmapObj,
+ &BitmapObj->SurfObj,
NULL,
NULL,
dc->CombinedClip,
ROP3_TO_ROP4(ROP));
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return ret;
}
PPATRECT r;
PGDIBRUSHOBJ BrushObj;
DC *dc;
-
+
dc = DC_LockDc(hDC);
if (dc == NULL)
{
}
if (dc->IsIC)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
-
+
for (r = pRects, i = 0; i < cRects; i++)
{
BrushObj = BRUSHOBJ_LockBrush(r->hBrush);
r->r.bottom,
dwRop,
BrushObj);
- BRUSHOBJ_UnlockBrush(r->hBrush);
+ BRUSHOBJ_UnlockBrush(BrushObj);
}
r++;
}
- DC_UnlockDc( hDC );
-
+ DC_UnlockDc(dc);
+
return TRUE;
}
HBRUSH STDCALL
NtGdiCreateDIBBrush(
- CONST BITMAPINFO *BitmapInfoAndData,
- UINT ColorSpec,
- UINT BitmapInfoSize,
- CONST VOID *PackedDIB)
+ IN PVOID BitmapInfoAndData,
+ IN FLONG ColorSpec,
+ IN UINT BitmapInfoSize,
+ IN BOOL b8X8,
+ IN BOOL bPen,
+ IN PVOID PackedDIB)
{
BITMAPINFO *SafeBitmapInfoAndData;
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
HBRUSH hBrush;
SafeBitmapInfoAndData = EngAllocMem(0, BitmapInfoSize, 0);
return NULL;
}
- Status = MmCopyFromCaller(SafeBitmapInfoAndData, BitmapInfoAndData,
- BitmapInfoSize);
+ _SEH_TRY
+ {
+ ProbeForRead(BitmapInfoAndData,
+ BitmapInfoSize,
+ 1);
+ RtlCopyMemory(SafeBitmapInfoAndData,
+ BitmapInfoAndData,
+ BitmapInfoSize);
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+
if (!NT_SUCCESS(Status))
{
+ EngFreeMem(SafeBitmapInfoAndData);
SetLastNtError(Status);
return 0;
}
}
HBRUSH STDCALL
-NtGdiCreateSolidBrush(COLORREF Color)
+NtGdiCreateSolidBrush(COLORREF Color,
+ IN OPTIONAL HBRUSH hbr)
{
return IntGdiCreateSolidBrush(Color);
}
* NtGdiSetBrushOrgEx
*
* The NtGdiSetBrushOrgEx function sets the brush origin that GDI assigns to
- * the next brush an application selects into the specified device context.
+ * the next brush an application selects into the specified device context.
*
* Status
* @implemented
if (Point != NULL)
{
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
POINT SafePoint;
SafePoint.x = dc->w.brushOrgX;
SafePoint.y = dc->w.brushOrgY;
- Status = MmCopyToCaller(Point, &SafePoint, sizeof(POINT));
+ _SEH_TRY
+ {
+ ProbeForWrite(Point,
+ sizeof(POINT),
+ 1);
+ *Point = SafePoint;
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
dc->w.brushOrgX = XOrg;
dc->w.brushOrgY = YOrg;
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
NtGdiPolyPatBlt(
HDC hDC,
DWORD dwRop,
- PPATRECT pRects,
- INT cRects,
- ULONG Reserved)
+ IN PPOLYPATBLT pRects,
+ IN DWORD cRects,
+ IN DWORD Mode)
{
PPATRECT rb = NULL;
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
BOOL Ret;
-
+
if (cRects > 0)
{
rb = ExAllocatePoolWithTag(PagedPool, sizeof(PATRECT) * cRects, TAG_PATBLT);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
- Status = MmCopyFromCaller(rb, pRects, sizeof(PATRECT) * cRects);
+ _SEH_TRY
+ {
+ ProbeForRead(pRects,
+ cRects * sizeof(PATRECT),
+ 1);
+ RtlCopyMemory(rb,
+ pRects,
+ cRects * sizeof(PATRECT));
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+
if (!NT_SUCCESS(Status))
{
ExFreePool(rb);
return FALSE;
}
}
-
- Ret = IntGdiPolyPatBlt(hDC, dwRop, pRects, cRects, Reserved);
-
+
+ Ret = IntGdiPolyPatBlt(hDC, dwRop, (PPATRECT)pRects, cRects, Mode);
+
if (cRects > 0)
ExFreePool(rb);
}
if (dc->IsIC)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
if (BrushObj == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
ROP,
BrushObj);
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
- DC_UnlockDc(hDC);
+ BRUSHOBJ_UnlockBrush(BrushObj);
+ DC_UnlockDc(dc);
return ret;
}