From 984be48dd5b455ed0f37ece2ea020e01af25c7c0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 30 Jul 2007 01:10:35 +0000 Subject: [PATCH] - rename NtGdiGetTextMetrics to NtGdigetTextMetricsW and add cj parameter - GetTextMetricsAW: call NtGdigetTextMetricW with cj set to sizeof(TMW_INTERNAL), use TextMetric member - update w32ksvc.db - update ntgdibad.h svn path=/trunk/; revision=28026 --- reactos/dll/win32/gdi32/objects/text.c | 22 ++++++---- reactos/include/reactos/win32k/ntgdibad.h | 6 --- .../subsystems/win32/win32k/objects/text.c | 42 ++++++++++++++----- reactos/tools/nci/w32ksvc.db | 2 +- 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/reactos/dll/win32/gdi32/objects/text.c b/reactos/dll/win32/gdi32/objects/text.c index 69833d7d7cd..9fd5d254782 100644 --- a/reactos/dll/win32/gdi32/objects/text.c +++ b/reactos/dll/win32/gdi32/objects/text.c @@ -86,14 +86,14 @@ GetTextMetricsA( LPTEXTMETRICA lptm ) { - TEXTMETRICW tmw; + TMW_INTERNAL tmwi; - if (! NtGdiGetTextMetrics(hdc, &tmw)) - { - return FALSE; - } + if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL))) + { + return FALSE; + } - return TextMetricW2A(lptm, &tmw); + return TextMetricW2A(lptm, &tmwi.TextMetric); } @@ -107,7 +107,15 @@ GetTextMetricsW( LPTEXTMETRICW lptm ) { - return NtGdiGetTextMetrics(hdc, lptm); + TMW_INTERNAL tmwi; + + if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL))) + { + return FALSE; + } + + *lptm = tmwi.TextMetric; + return TRUE; } diff --git a/reactos/include/reactos/win32k/ntgdibad.h b/reactos/include/reactos/win32k/ntgdibad.h index e7ebe94b4c5..7bb3daf4e0e 100644 --- a/reactos/include/reactos/win32k/ntgdibad.h +++ b/reactos/include/reactos/win32k/ntgdibad.h @@ -605,12 +605,6 @@ NtGdiGetTextCharset(HDC hDC); /* Needs to be done in user-mode, using shared GDI Object Attributes. */ COLORREF STDCALL NtGdiGetTextColor(HDC hDC); -/* Use NtGdiGetTextMetricsW with 0 at the end */ -BOOL -STDCALL -NtGdiGetTextMetrics(HDC hDC, - LPTEXTMETRICW tm); - /* Use NtGdiGetDCPoint with GdiGetViewPortExt */ BOOL STDCALL NtGdiGetViewportExtEx(HDC hDC, LPSIZE viewportExt); diff --git a/reactos/subsystems/win32/win32k/objects/text.c b/reactos/subsystems/win32/win32k/objects/text.c index 1c6966b119a..e24971298e1 100644 --- a/reactos/subsystems/win32/win32k/objects/text.c +++ b/reactos/subsystems/win32/win32k/objects/text.c @@ -3688,27 +3688,33 @@ NtGdiGetTextFaceW( return Count; } +W32KAPI BOOL -STDCALL -NtGdiGetTextMetrics(HDC hDC, - LPTEXTMETRICW tm) +APIENTRY +NtGdiGetTextMetricsW( + IN HDC hDC, + OUT TMW_INTERNAL * pUnsafeTmwi, + IN ULONG cj +) { PDC dc; PTEXTOBJ TextObj; PFONTGDI FontGDI; NTSTATUS Status = STATUS_SUCCESS; - TEXTMETRICW SafeTm; + TMW_INTERNAL tmwi; FT_Face Face; TT_OS2 *pOS2; TT_HoriHeader *pHori; ULONG Error; - if (NULL == tm) + if (NULL == pUnsafeTmwi) { SetLastWin32Error(STATUS_INVALID_PARAMETER); return FALSE; } + /* FIXME: check cj ? */ + if(!(dc = DC_LockDc(hDC))) { SetLastWin32Error(ERROR_INVALID_HANDLE); @@ -3736,7 +3742,9 @@ NtGdiGetTextMetrics(HDC hDC, } else { - memcpy(&SafeTm, &FontGDI->TextMetric, sizeof(TEXTMETRICW)); + memcpy(&tmwi.TextMetric, &FontGDI->TextMetric, sizeof(TEXTMETRICW)); + /* FIXME: Fill Diff member */ + RtlZeroMemory(&tmwi.Diff, sizeof(tmwi.Diff)); Status = STATUS_SUCCESS; IntLockFreeType; @@ -3757,10 +3765,24 @@ NtGdiGetTextMetrics(HDC hDC, IntUnLockFreeType; if (NT_SUCCESS(Status)) - { - FillTM(&SafeTm, FontGDI->face, pOS2, pHori); - Status = MmCopyToCaller(tm, &SafeTm, sizeof(TEXTMETRICW)); - } + { + FillTM(&tmwi.TextMetric, FontGDI->face, pOS2, pHori); + + if (cj > sizeof(TMW_INTERNAL)) + cj = sizeof(TMW_INTERNAL); + + Status = STATUS_SUCCESS; + _SEH_TRY + { + ProbeForWrite(pUnsafeTmwi, cj, 1); + RtlCopyMemory(pUnsafeTmwi,&tmwi,cj); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END + } } TEXTOBJ_UnlockText(TextObj); } diff --git a/reactos/tools/nci/w32ksvc.db b/reactos/tools/nci/w32ksvc.db index 701bbfefe44..f2ac57a1bf8 100644 --- a/reactos/tools/nci/w32ksvc.db +++ b/reactos/tools/nci/w32ksvc.db @@ -153,7 +153,7 @@ NtGdiGetTextExtentExW 8 NtGdiGetTextExtent 5 NtGdiGetTextExtentPoint32 4 NtGdiGetTextFaceW 4 -NtGdiGetTextMetrics 2 +NtGdiGetTextMetricsW 3 NtGdiGetViewportExtEx 2 NtGdiGetViewportOrgEx 2 NtGdiGetWinMetaFileBits 5