[Win32SS|GDI] Implement seldom used API and update types for local DC's.

Two working in house application require these API. Known as FolCOL and Reach.
This commit is contained in:
James Tabor 2021-09-25 11:57:26 -05:00
parent a602bc3550
commit 970344bd16
8 changed files with 150 additions and 98 deletions

View file

@ -784,7 +784,7 @@ NtGdiCheckBitmapBits(
} }
/* /*
* @unimplemented * @implemented
*/ */
HBITMAP HBITMAP
APIENTRY APIENTRY
@ -792,7 +792,13 @@ NtGdiClearBitmapAttributes(
IN HBITMAP hbm, IN HBITMAP hbm,
IN DWORD dwFlags) IN DWORD dwFlags)
{ {
UNIMPLEMENTED; if ( dwFlags & SC_BB_STOCKOBJ )
{
if (GDIOBJ_ConvertFromStockObj((HGDIOBJ*)&hbm))
{
return hbm;
}
}
return NULL; return NULL;
} }
@ -1406,7 +1412,7 @@ NtGdiMonoBitmap(
} }
/* /*
* @unimplemented * @implemented
*/ */
HBITMAP HBITMAP
APIENTRY APIENTRY
@ -1414,7 +1420,13 @@ NtGdiSetBitmapAttributes(
IN HBITMAP hbm, IN HBITMAP hbm,
IN DWORD dwFlags) IN DWORD dwFlags)
{ {
UNIMPLEMENTED; if ( dwFlags & SC_BB_STOCKOBJ )
{
if (GDIOBJ_ConvertToStockObj((HGDIOBJ*)&hbm))
{
return hbm;
}
}
return NULL; return NULL;
} }

View file

@ -812,52 +812,23 @@ StretchDIBits(
DPRINT("StretchDIBits %p : %p : %u\n", lpBits, lpBitsInfo, iUsage); DPRINT("StretchDIBits %p : %p : %u\n", lpBits, lpBitsInfo, iUsage);
#if 0 #if 0
// Handle something other than a normal dc object. HANDLE_METADC( int,
if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) StretchDIBits,
{ 0,
if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) hdc,
return MFDRV_StretchBlt( hdc, XDest,
XDest, YDest,
YDest, nDestWidth,
nDestWidth, nDestHeight,
nDestHeight, XSrc,
XSrc, YSrc,
YSrc, nSrcWidth,
nSrcWidth, nSrcHeight,
nSrcHeight, lpBits,
lpBits, lpBitsInfo,
lpBitsInfo, iUsage,
iUsage, dwRop );
dwRop);
else
{
PLDC pLDC = GdiGetLDC(hdc);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return 0;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_StretchBlt(hdc,
XDest,
YDest,
nDestWidth,
nDestHeight,
XSrc,
YSrc,
nSrcWidth,
nSrcHeight,
lpBits,
lpBitsInfo,
iUsage,
dwRop);
}
return 0;
}
}
#endif #endif
if ( GdiConvertAndCheckDC(hdc) == NULL ) return 0; if ( GdiConvertAndCheckDC(hdc) == NULL ) return 0;
pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage, &ConvertedInfoSize, pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage, &ConvertedInfoSize,
@ -921,61 +892,45 @@ StretchDIBits(
} }
/* /*
* @unimplemented * @implemented
*/ */
DWORD DWORD
WINAPI WINAPI
GetBitmapAttributes(HBITMAP hbm) GetBitmapAttributes(HBITMAP hbm)
{ {
UNIMPLEMENTED; if ( GDI_HANDLE_IS_STOCKOBJ(hbm) )
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); {
return SC_BB_STOCKOBJ;
}
return 0; return 0;
} }
/* /*
* @unimplemented * @implemented
*/ */
HBITMAP HBITMAP
WINAPI WINAPI
SetBitmapAttributes(HBITMAP hbm, DWORD dwFlags) SetBitmapAttributes(HBITMAP hbm, DWORD dwFlags)
{ {
UNIMPLEMENTED; if ( dwFlags & ~SC_BB_STOCKOBJ )
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); {
return 0; return NULL;
}
return NtGdiSetBitmapAttributes( hbm, dwFlags );
} }
/* /*
* @unimplemented * @implemented
*/ */
HBITMAP HBITMAP
WINAPI WINAPI
ClearBitmapAttributes(HBITMAP hbm, DWORD dwFlags) ClearBitmapAttributes(HBITMAP hbm, DWORD dwFlags)
{ {
UNIMPLEMENTED; if ( dwFlags & ~SC_BB_STOCKOBJ )
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); {
return 0; return NULL;
}
return NtGdiClearBitmapAttributes( hbm, dwFlags );;
} }
/*
* @unimplemented
*
*/
HBITMAP
WINAPI
GdiConvertBitmapV5(
HBITMAP in_format_BitMap,
HBITMAP src_BitMap,
INT bpp,
INT unuse)
{
/* FIXME guessing the prototypes */
/*
* it have create a new bitmap with desired in format,
* then convert it src_bitmap to new format
* and return it as HBITMAP
*/
return FALSE;
}

View file

@ -340,39 +340,45 @@ SetBrushOrgEx(HDC hdc,
} }
/* /*
* @unimplemented * @implemented
*/ */
DWORD DWORD
WINAPI WINAPI
GetBrushAttributes(HBRUSH hbr) GetBrushAttributes(HBRUSH hbr)
{ {
UNIMPLEMENTED; if ( GDI_HANDLE_IS_STOCKOBJ(hbr) )
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); {
return SC_BB_STOCKOBJ;
}
return 0; return 0;
} }
/* /*
* @unimplemented * @implemented
*/ */
HBRUSH HBRUSH
WINAPI WINAPI
SetBrushAttributes(HBRUSH hbm, DWORD dwFlags) SetBrushAttributes(HBRUSH hbm, DWORD dwFlags)
{ {
UNIMPLEMENTED; if ( dwFlags & ~SC_BB_STOCKOBJ )
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); {
return 0; return NULL;
}
return NtGdiSetBrushAttributes(hbm, dwFlags);
} }
/* /*
* @unimplemented * @implemented
*/ */
HBRUSH HBRUSH
WINAPI WINAPI
ClearBrushAttributes(HBRUSH hbm, DWORD dwFlags) ClearBrushAttributes(HBRUSH hbm, DWORD dwFlags)
{ {
UNIMPLEMENTED; if ( dwFlags & ~SC_BB_STOCKOBJ )
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); {
return 0; return NULL;
}
return NtGdiClearBrushAttributes(hbm, dwFlags);
} }
/* /*

View file

@ -106,12 +106,12 @@ SetColorSpace(
{ {
HCOLORSPACE rhCS = GetColorSpace(hDC); HCOLORSPACE rhCS = GetColorSpace(hDC);
if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) if (GDI_HANDLE_GET_TYPE(hDC) == GDILoObjType_LO_DC_TYPE)
{ {
if (NtGdiSetColorSpace(hDC, hCS)) return rhCS; if (NtGdiSetColorSpace(hDC, hCS)) return rhCS;
} }
#if 0 #if 0
if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC) if (GDI_HANDLE_GET_TYPE(hDC) != GDILoObjType_LO_METADC16_TYPE)
{ {
PLDC pLDC = GdiGetLDC(hDC); PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC ) if ( !pLDC )
@ -119,7 +119,7 @@ SetColorSpace(
SetLastError(ERROR_INVALID_HANDLE); SetLastError(ERROR_INVALID_HANDLE);
return NULL; return NULL;
} }
if (pLDC->iType == LDC_EMFLDC) if (pLDC->iType == LDC_EMFLDC && !EMFDC_SetColorSpace( pLDC, hCS ))
{ {
return NULL; return NULL;
} }
@ -327,3 +327,26 @@ SetICMMode(
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0; return 0;
} }
/*
* @unimplemented
*
*/
HBITMAP
WINAPI
GdiConvertBitmapV5(
HBITMAP in_format_BitMap,
HBITMAP src_BitMap,
INT bpp,
INT unuse)
{
/* FIXME guessing the prototypes */
/*
* it have create a new bitmap with desired in format,
* then convert it src_bitmap to new format
* and return it as HBITMAP
*/
return FALSE;
}

View file

@ -543,7 +543,13 @@ NtGdiSetBrushAttributes(
_In_ HBRUSH hbr, _In_ HBRUSH hbr,
_In_ DWORD dwFlags) _In_ DWORD dwFlags)
{ {
FIXME("NtGdiSetBrushAttributes is unimplemented\n"); if ( dwFlags & SC_BB_STOCKOBJ )
{
if (GDIOBJ_ConvertToStockObj((HGDIOBJ*)&hbr))
{
return hbr;
}
}
return NULL; return NULL;
} }
@ -554,7 +560,13 @@ NtGdiClearBrushAttributes(
_In_ HBRUSH hbr, _In_ HBRUSH hbr,
_In_ DWORD dwFlags) _In_ DWORD dwFlags)
{ {
FIXME("NtGdiClearBrushAttributes is unimplemented\n"); if ( dwFlags & SC_BB_STOCKOBJ )
{
if (GDIOBJ_ConvertFromStockObj((HGDIOBJ*)&hbr))
{
return hbr;
}
}
return NULL; return NULL;
} }

View file

@ -1484,6 +1484,40 @@ GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj)
return TRUE; return TRUE;
} }
BOOL
NTAPI
GDIOBJ_ConvertFromStockObj(HGDIOBJ *phObj)
{
PENTRY pentry;
POBJ pobj;
/* Reference the handle entry */
pentry = ENTRY_ReferenceEntryByHandle(*phObj, 0);
if (!pentry)
{
DPRINT1("GDIOBJ: Requested handle 0x%p is not valid.\n", *phObj);
return FALSE;
}
/* Update the entry */
pentry->FullUnique &= ~GDI_ENTRY_STOCK_MASK;
pentry->ObjectOwner.ulObj = 0;
/* Get the pointer to the BASEOBJECT */
pobj = pentry->einfo.pobj;
/* Calculate the new handle */
pobj->hHmgr = (HGDIOBJ)((ULONG_PTR)pobj->hHmgr & ~GDI_HANDLE_STOCK_MASK);
/* Return the new handle */
*phObj = pobj->hHmgr;
/* Dereference the handle */
GDIOBJ_vDereferenceObject(pobj);
return TRUE;
}
POBJ NTAPI POBJ NTAPI
GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize) GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize)
{ {

View file

@ -195,6 +195,7 @@ GDIOBJ_pvGetObjectAttr(
POBJ pobj); POBJ pobj);
BOOL NTAPI GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj); BOOL NTAPI GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
BOOL NTAPI GDIOBJ_ConvertFromStockObj(HGDIOBJ *phObj);
POBJ NTAPI GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize); POBJ NTAPI GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize);
PGDIOBJ NTAPI GDIOBJ_ShareLockObj(HGDIOBJ hObj, DWORD ObjectType); PGDIOBJ NTAPI GDIOBJ_ShareLockObj(HGDIOBJ hObj, DWORD ObjectType);
PVOID NTAPI GDI_MapHandleTable(PEPROCESS Process); PVOID NTAPI GDI_MapHandleTable(PEPROCESS Process);

View file

@ -174,16 +174,23 @@
#define LDC_INIT_PAGE 0x00000080 #define LDC_INIT_PAGE 0x00000080
#define LDC_STARTPAGE 0x00000100 #define LDC_STARTPAGE 0x00000100
#define LDC_NEXTBAND 0x00000200 #define LDC_NEXTBAND 0x00000200
#define LDC_FONTHASH 0x00001000
#define LDC_CLOCKWISE 0x00002000 #define LDC_CLOCKWISE 0x00002000
#define LDC_NEWFONT 0x00008000
#define LDC_KILL_DOCUMENT 0x00010000 #define LDC_KILL_DOCUMENT 0x00010000
#define LDC_META_PRINT 0x00020000 #define LDC_META_PRINT 0x00020000
#define LDC_DIRECT 0x00040000 #define LDC_DIRECT 0x00040000
#define LDC_RESET_BANDING 0x00080000 #define LDC_RESET_BANDING 0x00080000
#define LDC_DOWNLOADFONTS 0x00100000
#define LDC_RESETDC 0x00200000 #define LDC_RESETDC 0x00200000
#define LDC_UFIMAP 0x00400000 #define LDC_UFIMAP 0x00400000
#define LDC_INFODC 0x01000000 /* If CreateIC was passed. */ #define LDC_INFODC 0x01000000 /* If CreateIC was passed. */
#define LDC_DEVCAPS 0x02000000 #define LDC_DEVCAPS 0x02000000
#define LDC_XPS_PASS 0x08000000 // Guessing, not sure.
#define LDC_ATENDPAGE 0x10000000 #define LDC_ATENDPAGE 0x10000000
#define LDC_COLORPAGE 0x20000000
#define UFIHASHTABLESIZE 64
/* DC_ATTR Xform Flags */ /* DC_ATTR Xform Flags */
#define METAFILE_TO_WORLD_IDENTITY 0x00000001 #define METAFILE_TO_WORLD_IDENTITY 0x00000001
@ -210,6 +217,8 @@
#define ATTR_RGN_VALID 0x00000010 #define ATTR_RGN_VALID 0x00000010
#define ATTR_RGN_DIRTY 0x00000020 #define ATTR_RGN_DIRTY 0x00000020
/* Set/Clear Bitmap/Brush Stock Attribute */
#define SC_BB_STOCKOBJ 1
/* TYPES *********************************************************************/ /* TYPES *********************************************************************/