From 75543614da115b5d5cf07ddd5b7d2a9ad22918e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 23 Mar 2004 07:59:47 +0000 Subject: [PATCH] - Implement GetCharWidthA/W() - Fix memory overwrite in NtGdiGetCharWidth32() Fixes bug #258 svn path=/trunk/; revision=8845 --- reactos/iface/addsys/w32ksvc.db | 1 - reactos/include/win32k/text.h | 7 --- reactos/lib/gdi32/misc/stubsa.c | 36 +-------------- reactos/lib/gdi32/misc/stubsw.c | 34 +------------- reactos/lib/gdi32/objects/font.c | 69 +++++++++++++++++++++++++++- reactos/subsys/win32k/objects/text.c | 17 ++----- 6 files changed, 73 insertions(+), 91 deletions(-) diff --git a/reactos/iface/addsys/w32ksvc.db b/reactos/iface/addsys/w32ksvc.db index 11c8d75ede3..3a28544c83a 100644 --- a/reactos/iface/addsys/w32ksvc.db +++ b/reactos/iface/addsys/w32ksvc.db @@ -104,7 +104,6 @@ NtGdiGetBrushOrgEx 2 NtGdiGetCharABCWidths 4 NtGdiGetCharABCWidthsFloat 4 NtGdiGetCharacterPlacement 6 -NtGdiGetCharWidth 4 NtGdiGetCharWidth32 4 NtGdiGetCharWidthFloat 4 NtGdiGetClipBox 2 diff --git a/reactos/include/win32k/text.h b/reactos/include/win32k/text.h index 8129784095b..c75715483b3 100644 --- a/reactos/include/win32k/text.h +++ b/reactos/include/win32k/text.h @@ -99,13 +99,6 @@ NtGdiGetCharacterPlacement(HDC hDC, LPGCP_RESULTSW Results, DWORD Flags); -BOOL -STDCALL -NtGdiGetCharWidth(HDC hDC, - UINT FirstChar, - UINT LastChar, - LPINT Buffer); - BOOL STDCALL NtGdiGetCharWidth32(HDC hDC, diff --git a/reactos/lib/gdi32/misc/stubsa.c b/reactos/lib/gdi32/misc/stubsa.c index 531307de99f..baa66c4a87d 100644 --- a/reactos/lib/gdi32/misc/stubsa.c +++ b/reactos/lib/gdi32/misc/stubsa.c @@ -1,4 +1,4 @@ -/* $Id: stubsa.c,v 1.28 2004/03/23 00:18:54 gvg Exp $ +/* $Id: stubsa.c,v 1.29 2004/03/23 07:59:47 gvg Exp $ * * reactos/lib/gdi32/misc/stubs.c * @@ -208,40 +208,6 @@ EnumFontsA ( } -/* - * @unimplemented - */ -BOOL -STDCALL -GetCharWidthA ( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPINT lpBuffer - ) -{ - /* FIXME what to do with iFirstChar and iLastChar ??? */ - return NtGdiGetCharWidth ( hdc, iFirstChar, iLastChar, lpBuffer ); -} - - -/* - * @unimplemented - */ -BOOL -STDCALL -GetCharWidth32A( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPINT lpBuffer - ) -{ - /* FIXME what to do with iFirstChar and iLastChar ??? */ - return NtGdiGetCharWidth32 ( hdc, iFirstChar, iLastChar, lpBuffer ); -} - - /* * @unimplemented */ diff --git a/reactos/lib/gdi32/misc/stubsw.c b/reactos/lib/gdi32/misc/stubsw.c index be9db44c9ae..12e1b752ed0 100644 --- a/reactos/lib/gdi32/misc/stubsw.c +++ b/reactos/lib/gdi32/misc/stubsw.c @@ -1,4 +1,4 @@ -/* $Id: stubsw.c,v 1.25 2004/03/23 00:18:54 gvg Exp $ +/* $Id: stubsw.c,v 1.26 2004/03/23 07:59:47 gvg Exp $ * * reactos/lib/gdi32/misc/stubs.c * @@ -133,38 +133,6 @@ EnumFontsW( } -/* - * @implemented - */ -BOOL -STDCALL -GetCharWidthW ( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPINT lpBuffer - ) -{ - return NtGdiGetCharWidth ( hdc, iFirstChar, iLastChar, lpBuffer ); -} - - -/* - * @implemented - */ -BOOL -STDCALL -GetCharWidth32W( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPINT lpBuffer - ) -{ - return NtGdiGetCharWidth32 ( hdc, iFirstChar, iLastChar, lpBuffer ); -} - - /* * @implemented */ diff --git a/reactos/lib/gdi32/objects/font.c b/reactos/lib/gdi32/objects/font.c index f7f301d6ac2..bfcbe7f9a33 100644 --- a/reactos/lib/gdi32/objects/font.c +++ b/reactos/lib/gdi32/objects/font.c @@ -1,4 +1,4 @@ -/* $Id: font.c,v 1.1 2004/03/23 00:18:54 gvg Exp $ +/* $Id: font.c,v 1.2 2004/03/23 07:59:47 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -15,6 +15,7 @@ #include #include #include +#include #include #define NDEBUG @@ -330,3 +331,69 @@ EnumFontFamiliesA(HDC Dc, LPCSTR Family, FONTENUMPROCA EnumFontFamProc, return IntEnumFontFamilies(Dc, &LogFont, EnumFontFamProc, lParam, FALSE); } + + +/* + * @implemented + */ +BOOL +STDCALL +GetCharWidthA ( + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + LPINT lpBuffer + ) +{ + /* FIXME what to do with iFirstChar and iLastChar ??? */ + return NtGdiGetCharWidth32 ( hdc, iFirstChar, iLastChar, lpBuffer ); +} + + +/* + * @implemented + */ +BOOL +STDCALL +GetCharWidth32A( + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + LPINT lpBuffer + ) +{ + /* FIXME what to do with iFirstChar and iLastChar ??? */ + return NtGdiGetCharWidth32 ( hdc, iFirstChar, iLastChar, lpBuffer ); +} + + +/* + * @implemented + */ +BOOL +STDCALL +GetCharWidthW ( + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + LPINT lpBuffer + ) +{ + return NtGdiGetCharWidth32 ( hdc, iFirstChar, iLastChar, lpBuffer ); +} + + +/* + * @implemented + */ +BOOL +STDCALL +GetCharWidth32W( + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + LPINT lpBuffer + ) +{ + return NtGdiGetCharWidth32 ( hdc, iFirstChar, iLastChar, lpBuffer ); +} diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index b890f7528a7..505ab2525e2 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: text.c,v 1.82 2004/03/23 00:18:54 gvg Exp $ */ +/* $Id: text.c,v 1.83 2004/03/23 07:59:47 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN @@ -1892,17 +1892,6 @@ NtGdiGetCharacterPlacement(HDC hDC, UNIMPLEMENTED; } -BOOL -STDCALL -NtGdiGetCharWidth(HDC hDC, - UINT FirstChar, - UINT LastChar, - LPINT Buffer) -{ - DPRINT1("NtGdiGetCharWidth isnt really unimplemented - keep going anyway\n"); - return 1; -} - BOOL STDCALL NtGdiGetCharWidth32(HDC hDC, @@ -1924,7 +1913,7 @@ NtGdiGetCharWidth32(HDC hDC, return FALSE; } - BufferSize = (LastChar - FirstChar) * sizeof(INT); + BufferSize = (LastChar - FirstChar + 1) * sizeof(INT); SafeBuffer = ExAllocatePoolWithTag(PagedPool, BufferSize, TAG_GDITEXT); if (SafeBuffer == NULL) { @@ -1982,7 +1971,7 @@ NtGdiGetCharWidth32(HDC hDC, { glyph_index = FT_Get_Char_Index(face, i); FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); - SafeBuffer[i] = face->glyph->advance.x >> 6; + SafeBuffer[i - FirstChar] = face->glyph->advance.x >> 6; } IntUnLockFreeType; TEXTOBJ_UnlockText(dc->w.hFont);