https://git.reactos.org/?p=reactos.git;a=commitdiff;h=665871527ba4e88ad1d07…
commit 665871527ba4e88ad1d07b9fbda7635f7e826210
Author: jimtabor <james.tabor(a)reactos.org>
AuthorDate: Sat Jul 27 14:15:42 2019 -0500
Commit: jimtabor <james.tabor(a)reactos.org>
CommitDate: Sat Jul 27 14:15:42 2019 -0500
[GDI32] Allow functions to access printing support.
Reapplying lost committed code.
---
win32ss/gdi/gdi32/include/gdi32p.h | 2 ++
win32ss/gdi/gdi32/objects/arc.c | 10 +++++++
win32ss/gdi/gdi32/objects/bitmap.c | 32 ++++++++++++++++++++++
win32ss/gdi/gdi32/objects/painting.c | 52 ++++++++++++++++++++++++++++++++++--
win32ss/gdi/gdi32/objects/text.c | 2 ++
5 files changed, 96 insertions(+), 2 deletions(-)
diff --git a/win32ss/gdi/gdi32/include/gdi32p.h b/win32ss/gdi/gdi32/include/gdi32p.h
index c979ee9eee0..50c13f856a2 100644
--- a/win32ss/gdi/gdi32/include/gdi32p.h
+++ b/win32ss/gdi/gdi32/include/gdi32p.h
@@ -740,4 +740,6 @@ METADC_GetAndSetDCDWord(
_In_ USHORT usMF16Id,
_In_ DWORD dwError);
+HDC WINAPI GdiConvertAndCheckDC(HDC hdc);
+
/* EOF */
diff --git a/win32ss/gdi/gdi32/objects/arc.c b/win32ss/gdi/gdi32/objects/arc.c
index 37dd5145d0f..444b05a295b 100644
--- a/win32ss/gdi/gdi32/objects/arc.c
+++ b/win32ss/gdi/gdi32/objects/arc.c
@@ -26,6 +26,8 @@ Arc(
xEndArc,
yEndArc);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiArcInternal(GdiTypeArc,
hdc,
xLeft,
@@ -62,6 +64,8 @@ AngleArc(
RCAST(DWORD, eStartAngle),
RCAST(DWORD, eSweepAngle));
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiAngleArc(hdc,
x,
y,
@@ -96,6 +100,8 @@ ArcTo(
xRadial2,
yRadial2);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiArcInternal(GdiTypeArcTo,
hdc,
xLeft,
@@ -134,6 +140,8 @@ Chord(
xRadial2,
yRadial2);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiArcInternal(GdiTypeChord,
hdc,
xLeft,
@@ -176,6 +184,8 @@ Pie(
xRadial2,
yRadial2);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiArcInternal(GdiTypePie,
hdc,
xLeft,
diff --git a/win32ss/gdi/gdi32/objects/bitmap.c b/win32ss/gdi/gdi32/objects/bitmap.c
index 050cc031032..a3f4c482c6f 100644
--- a/win32ss/gdi/gdi32/objects/bitmap.c
+++ b/win32ss/gdi/gdi32/objects/bitmap.c
@@ -691,6 +691,34 @@ SetDIBitsToDevice(
lpbmi,
ColorUse);
+ // Handle the "Special Case"!
+ {
+ PLDC pldc;
+ ULONG hType = GDI_HANDLE_GET_TYPE(hdc);
+ if (hType != GDILoObjType_LO_DC_TYPE && hType !=
GDILoObjType_LO_METADC16_TYPE)
+ {
+ pldc = GdiGetLDC(hdc);
+ if (pldc)
+ {
+ if (pldc->Flags & LDC_STARTPAGE) StartPage(hdc);
+
+ if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc);
+
+ if (pldc->Flags & LDC_KILL_DOCUMENT)
+ {
+ LinesCopied = 0;
+ goto Exit;
+ }
+ }
+ else
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ LinesCopied = 0;
+ goto Exit;
+ }
+ }
+ }
+
if ((pConvertedInfo->bmiHeader.biCompression == BI_RLE8) ||
(pConvertedInfo->bmiHeader.biCompression == BI_RLE4))
{
@@ -742,6 +770,7 @@ SetDIBitsToDevice(
TRUE,
NULL);
}
+Exit:
if (Bits != pvSafeBits)
RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
if (lpbmi != pConvertedInfo)
@@ -826,6 +855,9 @@ StretchDIBits(
}
}
#endif
+
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return 0;
+
pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage, &ConvertedInfoSize,
FALSE);
if (!pConvertedInfo)
diff --git a/win32ss/gdi/gdi32/objects/painting.c b/win32ss/gdi/gdi32/objects/painting.c
index f41e7a78ab7..2f9564ceb22 100644
--- a/win32ss/gdi/gdi32/objects/painting.c
+++ b/win32ss/gdi/gdi32/objects/painting.c
@@ -13,6 +13,8 @@ LineTo(
{
HANDLE_METADC(BOOL, LineTo, FALSE, hdc, x, y);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiLineTo(hdc, x, y);
}
@@ -75,6 +77,8 @@ Ellipse(
{
HANDLE_METADC(BOOL, Ellipse, FALSE, hdc, left, top, right, bottom);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiEllipse(hdc, left, top, right, bottom);
}
@@ -93,6 +97,8 @@ Rectangle(
{
HANDLE_METADC(BOOL, Rectangle, FALSE, hdc, left, top, right, bottom);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiRectangle(hdc, left, top, right, bottom);
}
@@ -113,6 +119,8 @@ RoundRect(
{
HANDLE_METADC(BOOL, RoundRect, FALSE, hdc, left, top, right, bottom, width, height);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiRoundRect(hdc, left, top, right, bottom, width, height);
}
@@ -146,6 +154,8 @@ SetPixel(
{
HANDLE_METADC(COLORREF, SetPixel, CLR_INVALID, hdc, x, y, crColor);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiSetPixel(hdc, x, y, crColor);
}
@@ -181,6 +191,8 @@ FillRgn(
HANDLE_METADC(BOOL, FillRgn, FALSE, hdc, hrgn, hbr);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiFillRgn(hdc, hrgn, hbr);
}
@@ -203,6 +215,8 @@ FrameRgn(
HANDLE_METADC(BOOL, FrameRgn, FALSE, hdc, hrgn, hbr, nWidth, nHeight);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiFrameRgn(hdc, hrgn, hbr, nWidth, nHeight);
}
@@ -222,6 +236,8 @@ InvertRgn(
HANDLE_METADC(BOOL, InvertRgn, FALSE, hdc, hrgn);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiInvertRgn(hdc, hrgn);
}
@@ -251,6 +267,8 @@ PolyBezier(
{
HANDLE_METADC(BOOL, PolyBezier, FALSE, hdc, apt, cpt);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyPolyDraw(hdc ,(PPOINT)apt, &cpt, 1, GdiPolyBezier);
}
@@ -267,6 +285,8 @@ PolyBezierTo(
{
HANDLE_METADC(BOOL, PolyBezierTo, FALSE, hdc, apt, cpt);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyPolyDraw(hdc , (PPOINT)apt, &cpt, 1, GdiPolyBezierTo);
}
@@ -284,6 +304,8 @@ PolyDraw(
{
HANDLE_METADC(BOOL, PolyDraw, FALSE, hdc, apt, aj, cpt);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyDraw(hdc, (PPOINT)apt, (PBYTE)aj, cpt);
}
@@ -300,6 +322,8 @@ Polygon(
{
HANDLE_METADC(BOOL, Polygon, FALSE, hdc, apt, cpt);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyPolyDraw(hdc , (PPOINT)apt, (PULONG)&cpt, 1, GdiPolyPolygon);
}
@@ -316,6 +340,8 @@ Polyline(
{
HANDLE_METADC(BOOL, Polyline, FALSE, hdc, apt, cpt);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyPolyDraw(hdc, (PPOINT)apt, (PULONG)&cpt, 1, GdiPolyPolyLine);
}
@@ -332,6 +358,8 @@ PolylineTo(
{
HANDLE_METADC(BOOL, PolylineTo, FALSE, hdc, apt, cpt);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyPolyDraw(hdc , (PPOINT)apt, &cpt, 1, GdiPolyLineTo);
}
@@ -349,6 +377,8 @@ PolyPolygon(
{
HANDLE_METADC(BOOL, PolyPolygon, FALSE, hdc, apt, asz, csz);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyPolyDraw(hdc, (PPOINT)apt, (PULONG)asz, csz, GdiPolyPolygon);
}
@@ -369,6 +399,8 @@ PolyPolyline(
HANDLE_METADC(BOOL, PolyPolyline, FALSE, hdc, apt, asz, csz);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiPolyPolyDraw(hdc , (PPOINT)apt, (PULONG)asz, csz, GdiPolyPolyLine);
}
@@ -387,6 +419,8 @@ ExtFloodFill(
{
HANDLE_METADC(BOOL, ExtFloodFill, FALSE, hdc, xStart, yStart, crFill, fuFillType);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiExtFloodFill(hdc, xStart, yStart, crFill, fuFillType);
}
@@ -443,6 +477,8 @@ BitBlt(
cx,
dwRop);
+ if ( GdiConvertAndCheckDC(hdcDest) == NULL ) return FALSE;
+
return NtGdiBitBlt(hdcDest, xDest, yDest, cx, cy, hdcSrc, xSrc, ySrc, dwRop, 0, 0);
}
@@ -460,6 +496,8 @@ PatBlt(
HANDLE_METADC(BOOL, PatBlt, FALSE, hdc, nXLeft, nYLeft, nWidth, nHeight, dwRop);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
/* Get the DC attribute */
pdcattr = GdiGetDcAttr(hdc);
if (pdcattr && !(pdcattr->ulDirty_ & DC_DIBSECTION))
@@ -612,6 +650,8 @@ StretchBlt(
cySrc,
dwRop);
+ if ( GdiConvertAndCheckDC(hdcDest) == NULL ) return FALSE;
+
return NtGdiStretchBlt(hdcDest,
xDest,
yDest,
@@ -662,6 +702,8 @@ MaskBlt(
yMask,
dwRop);
+ if ( GdiConvertAndCheckDC(hdcDest) == NULL ) return FALSE;
+
return NtGdiMaskBlt(hdcDest,
xDest,
yDest,
@@ -709,6 +751,8 @@ PlgBlt(
xMask,
yMask);
+ if ( GdiConvertAndCheckDC(hdcDest) == NULL ) return FALSE;
+
return NtGdiPlgBlt(hdcDest,
(LPPOINT)ppt,
hdcSrc,
@@ -756,6 +800,8 @@ GdiAlphaBlend(
cySrc,
blendfn);
+ if ( GdiConvertAndCheckDC(hdcDst) == NULL ) return FALSE;
+
return NtGdiAlphaBlend(hdcDst,
xDst,
yDst,
@@ -804,7 +850,8 @@ GdiTransparentBlt(
cySrc,
crTransparent);
- /* FIXME some part need be done in user mode */
+ if ( GdiConvertAndCheckDC(hdcDst) == NULL ) return FALSE;
+
return NtGdiTransparentBlt(hdcDst, xDst, yDst, cxDst, cyDst, hdcSrc, xSrc, ySrc,
cxSrc, cySrc, crTransparent);
}
@@ -823,6 +870,7 @@ GdiGradientFill(
{
HANDLE_METADC(BOOL, GradientFill, FALSE, hdc, pVertex, nVertex, pMesh, nCount,
ulMode);
- /* FIXME some part need be done in user mode */
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
return NtGdiGradientFill(hdc, pVertex, nVertex, pMesh, nCount, ulMode);
}
diff --git a/win32ss/gdi/gdi32/objects/text.c b/win32ss/gdi/gdi32/objects/text.c
index 6d4936edfc0..e00e01e50fe 100644
--- a/win32ss/gdi/gdi32/objects/text.c
+++ b/win32ss/gdi/gdi32/objects/text.c
@@ -505,6 +505,8 @@ ExtTextOutW(
cwc,
lpDx);
+ if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
+
if (!(fuOptions & (ETO_GLYPH_INDEX | ETO_IGNORELANGUAGE)))
{
if (LoadLPK(LPK_ETO))