Author: tkreuzer
Date: Sat Nov 8 15:34:47 2014
New Revision: 65324
URL:
http://svn.reactos.org/svn/reactos?rev=65324&view=rev
Log:
[GDI32]
- Add annotations for text function
- Improve formatting and some variable names
- No code change
Modified:
trunk/reactos/win32ss/gdi/gdi32/objects/text.c
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/text.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/objects/text.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/objects/text.c [iso-8859-1] Sat Nov 8 15:34:47 2014
@@ -9,26 +9,238 @@
BOOL
WINAPI
TextOutA(
- HDC hdc,
- int nXStart,
- int nYStart,
- LPCSTR lpString,
- int cchString)
+ _In_ HDC hdc,
+ _In_ INT nXStart,
+ _In_ INT nYStart,
+ _In_reads_(cchString) LPCSTR lpString,
+ _In_ INT cchString)
+{
+ ANSI_STRING StringA;
+ UNICODE_STRING StringU;
+ BOOL bResult;
+
+ if (lpString != NULL)
+ {
+ RtlInitAnsiString(&StringA, (LPSTR)lpString);
+ RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
+ }
+ else
+ {
+ StringU.Buffer = NULL;
+ }
+
+ bResult = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString);
+
+ RtlFreeUnicodeString(&StringU);
+ return bResult;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+TextOutW(
+ _In_ HDC hdc,
+ _In_ INT nXStart,
+ _In_ INT nYStart,
+ _In_reads_(cchString) LPCWSTR lpString,
+ _In_ INT cchString)
+{
+ return NtGdiExtTextOutW(hdc,
+ nXStart,
+ nYStart,
+ 0, NULL,
+ (LPWSTR)lpString,
+ cchString,
+ NULL,
+ 0);
+}
+
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+PolyTextOutA(
+ _In_ HDC hdc,
+ _In_reads_(cStrings) const POLYTEXTA *pptxt,
+ _In_ INT cStrings)
+{
+ for (; cStrings>0; cStrings--, pptxt++)
+ {
+ if (!ExtTextOutA(hdc,
+ pptxt->x,
+ pptxt->y,
+ pptxt->uiFlags,
+ &pptxt->rcl,
+ pptxt->lpstr,
+ pptxt->n,
+ pptxt->pdx))
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+PolyTextOutW(
+ _In_ HDC hdc,
+ _In_reads_(cStrings) const POLYTEXTW *pptxt,
+ _In_ INT cStrings)
+{
+ for (; cStrings>0; cStrings--, pptxt++)
+ {
+ if (!ExtTextOutW(hdc,
+ pptxt->x,
+ pptxt->y,
+ pptxt->uiFlags,
+ &pptxt->rcl,
+ pptxt->lpstr,
+ pptxt->n,
+ pptxt->pdx))
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+DWORD
+WINAPI
+GdiGetCodePage(
+ _In_ HDC hdc)
+{
+ PDC_ATTR pdcattr;
+
+ /* Get the DC attribute */
+ pdcattr = GdiGetDcAttr(hdc);
+ if (pdcattr == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ if (pdcattr->ulDirty_ & DIRTY_CHARSET)
+ return LOWORD(NtGdiGetCharSet(hdc));
+
+ return LOWORD(pdcattr->iCS_CP);
+}
+
+
+/*
+ * @unimplemented
+ */
+INT
+WINAPI
+GetTextCharacterExtra(
+ _In_ HDC hdc)
+{
+ PDC_ATTR pdcattr;
+
+ /* Get the DC attribute */
+ pdcattr = GdiGetDcAttr(hdc);
+ if (pdcattr == NULL)
+ {
+ /* Do not set LastError here! */
+ return 0x8000000;
+ }
+
+ return pdcattr->lTextExtra;
+}
+
+
+/*
+ * @implemented
+ */
+INT
+WINAPI
+GetTextCharset(
+ _In_ HDC hdc)
+{
+ /* MSDN docs say this is equivalent */
+ return NtGdiGetTextCharsetInfo(hdc,NULL,0);
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextMetricsA(
+ _In_ HDC hdc,
+ _Out_ LPTEXTMETRICA lptm)
+{
+ TMW_INTERNAL tmwi;
+
+ if (!NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL)))
+ {
+ return FALSE;
+ }
+
+ FONT_TextMetricWToA(&tmwi.TextMetric, lptm);
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextMetricsW(
+ _In_ HDC hdc,
+ _Out_ LPTEXTMETRICW lptm)
+{
+ TMW_INTERNAL tmwi;
+
+ if (!NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL)))
+ {
+ return FALSE;
+ }
+
+ *lptm = tmwi.TextMetric;
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+APIENTRY
+GetTextExtentPointA(
+ _In_ HDC hdc,
+ _In_reads_(cchString) LPCSTR lpString,
+ _In_ INT cchString,
+ _Out_ LPSIZE lpsz)
{
ANSI_STRING StringA;
UNICODE_STRING StringU;
BOOL ret;
- if (NULL != lpString)
- {
- RtlInitAnsiString(&StringA, (LPSTR)lpString);
- RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
- }
- else
- StringU.Buffer = NULL;
-
- ret = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString);
+ RtlInitAnsiString(&StringA, (LPSTR)lpString);
+ RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
+
+ ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpsz);
+
RtlFreeUnicodeString(&StringU);
+
return ret;
}
@@ -37,170 +249,126 @@
* @implemented
*/
BOOL
-WINAPI
-TextOutW(
- HDC hdc,
- int nXStart,
- int nYStart,
- LPCWSTR lpString,
- int cchString)
-{
- return NtGdiExtTextOutW(hdc, nXStart, nYStart, 0, NULL, (LPWSTR)lpString, cchString,
NULL, 0);
-}
-
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-PolyTextOutA( HDC hdc, const POLYTEXTA *pptxt, INT cStrings )
-{
- for (; cStrings>0; cStrings--, pptxt++)
- if (!ExtTextOutA( hdc, pptxt->x, pptxt->y, pptxt->uiFlags,
&pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx ))
- return FALSE;
- return TRUE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-PolyTextOutW( HDC hdc, const POLYTEXTW *pptxt, INT cStrings )
-{
- for (; cStrings>0; cStrings--, pptxt++)
- if (!ExtTextOutW( hdc, pptxt->x, pptxt->y, pptxt->uiFlags,
&pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx ))
- return FALSE;
- return TRUE;
-}
-
-
-/*
- * @implemented
- */
-DWORD
-WINAPI
-GdiGetCodePage(HDC hdc)
-{
- PDC_ATTR pdcattr;
-
- /* Get the DC attribute */
- pdcattr = GdiGetDcAttr(hdc);
- if (pdcattr == NULL)
+APIENTRY
+GetTextExtentPointW(
+ _In_ HDC hdc,
+ _In_reads_(cchString) LPCWSTR lpString,
+ _In_ INT cchString,
+ _Out_ LPSIZE lpsz)
+{
+ return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpsz, 0);
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextExtentExPointW(
+ _In_ HDC hdc,
+ _In_reads_(cchString) LPCWSTR lpszString,
+ _In_ INT cchString,
+ _In_ INT nMaxExtent,
+ _Out_opt_ LPINT lpnFit,
+ _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx,
+ _Out_ LPSIZE lpSize)
+{
+
+ /* Windows doesn't check nMaxExtent validity in unicode version */
+ if (nMaxExtent < -1)
+ {
+ DPRINT("nMaxExtent is invalid: %d\n", nMaxExtent);
+ }
+
+ return NtGdiGetTextExtentExW (
+ hdc, (LPWSTR)lpszString, cchString, nMaxExtent, (PULONG)lpnFit,
(PULONG)lpnDx, lpSize, 0 );
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextExtentExPointWPri(
+ _In_ HDC hdc,
+ _In_reads_(cwc) LPWSTR lpwsz,
+ _In_ ULONG cwc,
+ _In_ ULONG dxMax,
+ _Out_opt_ ULONG *pcCh,
+ _Out_writes_to_opt_(cwc, *pcCh) PULONG pdxOut,
+ _In_ LPSIZE psize)
+{
+ return NtGdiGetTextExtentExW(hdc, lpwsz, cwc, dxMax, pcCh, pdxOut, psize, 0);
+}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextExtentExPointA(
+ _In_ HDC hdc,
+ _In_reads_(cchString) LPCSTR lpszStr,
+ _In_ INT cchString,
+ _In_ INT nMaxExtent,
+ _Out_opt_ LPINT lpnFit,
+ _Out_writes_to_opt_ (cchString, *lpnFit) LPINT lpnDx,
+ _Out_ LPSIZE lpSize)
+{
+ NTSTATUS Status;
+ LPWSTR lpszStrW;
+ BOOL bResult = FALSE;
+
+ if (nMaxExtent < -1)
{
SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- if (pdcattr->ulDirty_ & DIRTY_CHARSET)
- return LOWORD(NtGdiGetCharSet(hdc));
-
- return LOWORD(pdcattr->iCS_CP);
-}
-
-
-/*
- * @unimplemented
- */
-int
-WINAPI
-GetTextCharacterExtra(
- HDC hdc
-)
-{
- PDC_ATTR pdcattr;
-
- /* Get the DC attribute */
- pdcattr = GdiGetDcAttr(hdc);
- if (pdcattr == NULL)
- {
- /* Do not set LastError here! */
- return 0x8000000;
- }
-
- return pdcattr->lTextExtra;
-}
-
-
-/*
- * @implemented
- */
-int
-WINAPI
-GetTextCharset(HDC hdc)
-{
- /* MSDN docs say this is equivalent */
- return NtGdiGetTextCharsetInfo(hdc,NULL,0);
-}
-
-
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-GetTextMetricsA(
- HDC hdc,
- LPTEXTMETRICA lptm
-)
-{
- TMW_INTERNAL tmwi;
-
- if (!NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL)))
- {
return FALSE;
}
- FONT_TextMetricWToA(&tmwi.TextMetric, lptm);
- return TRUE;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-GetTextMetricsW(
- HDC hdc,
- LPTEXTMETRICW lptm
-)
-{
- TMW_INTERNAL tmwi;
-
- if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL)))
- {
+ Status = HEAP_strdupA2W(&lpszStrW, lpszStr);
+ if (!NT_SUCCESS (Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
- *lptm = tmwi.TextMetric;
- return TRUE;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-APIENTRY
-GetTextExtentPointA(
- HDC hdc,
- LPCSTR lpString,
- int cchString,
- LPSIZE lpSize
-)
+ bResult = NtGdiGetTextExtentExW(hdc,
+ lpszStrW,
+ cchString,
+ nMaxExtent,
+ (PULONG)lpnFit,
+ (PULONG)lpnDx,
+ lpSize,
+ 0);
+
+ HEAP_free(lpszStrW);
+
+ return bResult;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextExtentPoint32A(
+ _In_ HDC hdc,
+ _In_reads_(cchString) LPCSTR lpString,
+ _In_ INT cchString,
+ _Out_ LPSIZE lpSize)
{
ANSI_STRING StringA;
UNICODE_STRING StringU;
BOOL ret;
- RtlInitAnsiString(&StringA, (LPSTR)lpString);
+ StringA.Buffer = (LPSTR)lpString;
+ StringA.Length = cchString;
RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
- ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpSize);
+ ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cchString, lpSize);
RtlFreeUnicodeString(&StringU);
@@ -212,195 +380,77 @@
* @implemented
*/
BOOL
-APIENTRY
-GetTextExtentPointW(
- HDC hdc,
- LPCWSTR lpString,
- int cchString,
- LPSIZE lpSize
-)
+WINAPI
+GetTextExtentPoint32W(
+ _In_ HDC hdc,
+ _In_reads_(cchString) LPCWSTR lpString,
+ _In_ int cchString,
+ _Out_ LPSIZE lpSize)
{
return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0);
}
-
-/*
- * @implemented
- */
-BOOL
-APIENTRY
-GetTextExtentExPointW(
- HDC hdc,
- LPCWSTR lpszStr,
- int cchString,
- int nMaxExtent,
- LPINT lpnFit,
- LPINT alpDx,
- LPSIZE lpSize
-)
-{
-
- /* Windows doesn't check nMaxExtent validity in unicode version */
- if(nMaxExtent < -1)
- DPRINT("nMaxExtent is invalid: %d\n", nMaxExtent);
-
- return NtGdiGetTextExtentExW (
- hdc, (LPWSTR)lpszStr, cchString, nMaxExtent, (PULONG)lpnFit,
(PULONG)alpDx, lpSize, 0 );
-}
-
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-GetTextExtentExPointWPri(HDC hdc,
- LPWSTR lpwsz,
- ULONG cwc,
- ULONG dxMax,
- ULONG *pcCh,
- PULONG pdxOut,
- LPSIZE psize)
-{
- return NtGdiGetTextExtentExW(hdc,lpwsz,cwc,dxMax,pcCh,pdxOut,psize,0);
-}
-
-/*
- * @implemented
- */
-BOOL
-APIENTRY
-GetTextExtentExPointA(
- HDC hdc,
- LPCSTR lpszStr,
- int cchString,
- int nMaxExtent,
- LPINT lpnFit,
- LPINT alpDx,
- LPSIZE lpSize
-)
-{
- NTSTATUS Status;
- LPWSTR lpszStrW;
- BOOL rc = 0;
-
- if(nMaxExtent < -1)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- Status = HEAP_strdupA2W ( &lpszStrW, lpszStr );
- if (!NT_SUCCESS (Status))
- SetLastError (RtlNtStatusToDosError(Status));
- else
- {
- rc = NtGdiGetTextExtentExW (
- hdc, lpszStrW, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx,
lpSize, 0 );
-
- HEAP_free ( lpszStrW );
- }
-
- return rc;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-APIENTRY
-GetTextExtentPoint32A(
- HDC hdc,
- LPCSTR lpString,
- int cchString,
- LPSIZE lpSize
-)
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextExtentExPointI(
+ _In_ HDC hdc,
+ _In_reads_(cgi) LPWORD pgiIn,
+ _In_ INT cgi,
+ _In_ INT nMaxExtent,
+ _Out_opt_ LPINT lpnFit,
+ _Out_writes_to_opt_(cwchString, *lpnFit) LPINT lpnDx,
+ _Out_ LPSIZE lpSize)
+{
+ return NtGdiGetTextExtentExW(hdc,
+ pgiIn,
+ cgi,
+ nMaxExtent,
+ (PULONG)lpnFit,
+ (PULONG)lpnDx,
+ lpSize,
+ GTEF_INDICES);
+}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetTextExtentPointI(
+ _In_ HDC hdc,
+ _In_reads_(cgi) LPWORD pgiIn,
+ _In_ int cgi,
+ _Out_ LPSIZE lpSize)
+{
+ return NtGdiGetTextExtent(hdc, pgiIn, cgi, lpSize, GTEF_INDICES);
+}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+ExtTextOutA(
+ _In_ HDC hdc,
+ _In_ INT x,
+ _In_ INT y,
+ _In_ UINT fuOptions,
+ _In_opt_ const RECT *lprc,
+ _In_reads_opt_(cch) LPCSTR lpString,
+ _In_ UINT cch,
+ _In_reads_opt_(cch) const INT *lpDx)
{
ANSI_STRING StringA;
UNICODE_STRING StringU;
BOOL ret;
- StringA.Buffer = (LPSTR)lpString;
- StringA.Length = cchString;
- RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
-
- ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cchString, lpSize);
-
- RtlFreeUnicodeString(&StringU);
-
- return ret;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-APIENTRY
-GetTextExtentPoint32W(
- HDC hdc,
- LPCWSTR lpString,
- int cchString,
- LPSIZE lpSize
-)
-{
- return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0);
-}
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-GetTextExtentExPointI(HDC hdc,
- LPWORD pgiIn,
- int cgi,
- int nMaxExtent,
- LPINT lpnFit,
- LPINT alpDx,
- LPSIZE lpSize)
-{
- return NtGdiGetTextExtentExW(hdc,pgiIn,cgi,nMaxExtent,(ULONG *)lpnFit, (PULONG)
alpDx,lpSize,GTEF_INDICES);
-}
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-GetTextExtentPointI(HDC hdc,
- LPWORD pgiIn,
- int cgi,
- LPSIZE lpSize)
-{
- return NtGdiGetTextExtent(hdc,pgiIn,cgi,lpSize,GTEF_INDICES);
-}
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-ExtTextOutA(
- HDC hdc,
- int X,
- int Y,
- UINT fuOptions,
- CONST RECT *lprc,
- LPCSTR lpString,
- UINT cchString,
- CONST INT *lpDx
-)
-{
- ANSI_STRING StringA;
- UNICODE_STRING StringU;
- BOOL ret;
-
RtlInitAnsiString(&StringA, (LPSTR)lpString);
RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
- ret = ExtTextOutW(hdc, X, Y, fuOptions, lprc, StringU.Buffer, cchString, lpDx);
+ ret = ExtTextOutW(hdc, x, y, fuOptions, lprc, StringU.Buffer, cch, lpDx);
RtlFreeUnicodeString(&StringU);
@@ -414,17 +464,24 @@
BOOL
WINAPI
ExtTextOutW(
- HDC hdc,
- int X,
- int Y,
- UINT fuOptions,
- CONST RECT *lprc,
- LPCWSTR lpString,
- UINT cchString,
- CONST INT *lpDx
-)
-{
- return NtGdiExtTextOutW(hdc, X, Y, fuOptions, (LPRECT)lprc, (LPWSTR)lpString,
cchString, (LPINT)lpDx, 0);
+ _In_ HDC hdc,
+ _In_ INT x,
+ _In_ INT y,
+ _In_ UINT fuOptions,
+ _In_opt_ const RECT *lprc,
+ _In_reads_opt_(cwc) LPCWSTR lpString,
+ _In_ UINT cwc,
+ _In_reads_opt_(cwc) const INT *lpDx)
+{
+ return NtGdiExtTextOutW(hdc,
+ x,
+ y,
+ fuOptions,
+ (LPRECT)lprc,
+ (LPWSTR)lpString,
+ cwc,
+ (LPINT)lpDx,
+ 0);
}
@@ -433,12 +490,13 @@
*/
INT
WINAPI
-GetTextFaceW(HDC hDC,
- INT nCount,
- PWSTR pFaceName)
+GetTextFaceW(
+ _In_ HDC hdc,
+ _In_ INT cwcMax,
+ _Out_writes_to_opt_(cwcMax, return) LPWSTR pFaceName)
{
/* Validate parameters */
- if (pFaceName && nCount <= 0)
+ if (pFaceName && cwcMax <= 0)
{
/* Set last error and return failure */
GdiSetLastError(ERROR_INVALID_PARAMETER);
@@ -446,22 +504,25 @@
}
/* Forward to kernel */
- return NtGdiGetTextFaceW(hDC, nCount, pFaceName, FALSE);
-}
-
-
-/*
- * @implemented
- */
-int
-WINAPI
-GetTextFaceA( HDC hdc, INT count, LPSTR name )
+ return NtGdiGetTextFaceW(hdc, cwcMax, pFaceName, FALSE);
+}
+
+
+/*
+ * @implemented
+ */
+INT
+WINAPI
+GetTextFaceA(
+ _In_ HDC hdc,
+ _In_ INT cchMax,
+ _Out_writes_to_opt_(cchMax, return) LPSTR lpName)
{
INT res;
LPWSTR nameW;
/* Validate parameters */
- if (name && count <= 0)
+ if (lpName && cchMax <= 0)
{
/* Set last error and return failure */
GdiSetLastError(ERROR_INVALID_PARAMETER);
@@ -474,16 +535,20 @@
{
return 0;
}
+
GetTextFaceW( hdc, res, nameW );
- if (name)
- {
- if (count && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count,
NULL, NULL))
- name[count-1] = 0;
- res = strlen(name);
+ if (lpName)
+ {
+ if (cchMax && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, lpName, cchMax,
NULL, NULL))
+ lpName[cchMax-1] = 0;
+ res = strlen(lpName);
}
else
+ {
res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
+ }
+
HeapFree( GetProcessHeap(), 0, nameW );
return res;
}
@@ -494,27 +559,28 @@
*/
INT
WINAPI
-GetTextFaceAliasW(HDC hdc,
- int cChar,
- LPWSTR pszOut)
-{
- if ( pszOut && !cChar )
+GetTextFaceAliasW(
+ _In_ HDC hdc,
+ _In_ INT cwcMax,
+ _Out_writes_to_opt_(cwcMax, return) LPWSTR pszOut)
+{
+ if (pszOut && !cwcMax)
{
GdiSetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- return NtGdiGetTextFaceW(hdc,cChar,pszOut,TRUE);
+
+ return NtGdiGetTextFaceW(hdc, cwcMax, pszOut, TRUE);
}
BOOL
WINAPI
GetFontResourceInfoW(
- LPCWSTR lpFileName,
- DWORD *pdwBufSize,
- void* lpBuffer,
- DWORD dwType
-)
+ _In_z_ LPCWSTR lpFileName,
+ _Inout_ DWORD *pdwBufSize,
+ _Out_writes_to_(*pdwBufSize, *pdwBufSize) PVOID lpBuffer,
+ _In_ DWORD dwType)
{
BOOL bRet;
UNICODE_STRING NtFileName;
@@ -545,29 +611,23 @@
RtlFreeHeap(RtlGetProcessHeap(), 0, NtFileName.Buffer);
- if (!bRet)
- {
- return FALSE;
- }
-
- return TRUE;
+ return bRet;
}
/*
* @unimplemented
*/
-int
+INT
WINAPI
SetTextCharacterExtra(
- HDC hdc,
- int CharExtra
-)
-{
- INT cExtra;
+ _In_ HDC hdc,
+ _In_ INT nCharExtra)
+{
PDC_ATTR pdcattr;
-
- if (CharExtra == 0x80000000)
+ INT nOldCharExtra;
+
+ if (nCharExtra == 0x80000000)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0x80000000;
@@ -576,7 +636,7 @@
#if 0
if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
{
- return MFDRV_SetTextCharacterExtra( hdc, CharExtra ); // Wine port.
+ return MFDRV_SetTextCharacterExtra( hdc, nCharExtra ); // Wine port.
}
#endif
@@ -597,9 +657,9 @@
}
}
- cExtra = pdcattr->lTextExtra;
- pdcattr->lTextExtra = CharExtra;
- return cExtra;
+ nOldCharExtra = pdcattr->lTextExtra;
+ pdcattr->lTextExtra = nCharExtra;
+ return nOldCharExtra;
}
/*
@@ -608,7 +668,8 @@
*/
UINT
WINAPI
-GetTextAlign(HDC hdc)
+GetTextAlign(
+ _In_ HDC hdc)
{
PDC_ATTR pdcattr;
@@ -630,7 +691,8 @@
*/
COLORREF
WINAPI
-GetTextColor(HDC hdc)
+GetTextColor(
+ _In_ HDC hdc)
{
PDC_ATTR pdcattr;
@@ -651,11 +713,12 @@
*/
UINT
WINAPI
-SetTextAlign(HDC hdc,
- UINT fMode)
+SetTextAlign(
+ _In_ HDC hdc,
+ _In_ UINT fMode)
{
PDC_ATTR pdcattr;
- INT OldMode;
+ INT fOldMode;
/* Get the DC attribute */
pdcattr = GdiGetDcAttr(hdc);
@@ -686,7 +749,7 @@
}
#endif
- OldMode = pdcattr->lTextAlign;
+ fOldMode = pdcattr->lTextAlign;
pdcattr->lTextAlign = fMode; // Raw
if (pdcattr->dwLayout & LAYOUT_RTL)
{
@@ -694,7 +757,7 @@
}
pdcattr->flTextAlign = fMode & TA_MASK;
- return OldMode;
+ return fOldMode;
}
@@ -704,12 +767,11 @@
COLORREF
WINAPI
SetTextColor(
- HDC hdc,
- COLORREF crColor
-)
+ _In_ HDC hdc,
+ _In_ COLORREF crColor)
{
PDC_ATTR pdcattr;
- COLORREF OldColor = CLR_INVALID;
+ COLORREF crOldColor = CLR_INVALID;
/* Get the DC attribute */
pdcattr = GdiGetDcAttr(hdc);
@@ -740,15 +802,16 @@
}
#endif
- OldColor = (COLORREF) pdcattr->ulForegroundClr;
- pdcattr->ulForegroundClr = (ULONG) crColor;
-
- if ( pdcattr->crForegroundClr != crColor )
+ crOldColor = (COLORREF) pdcattr->ulForegroundClr;
+ pdcattr->ulForegroundClr = (ULONG)crColor;
+
+ if (pdcattr->crForegroundClr != crColor)
{
pdcattr->ulDirty_ |= (DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL);
pdcattr->crForegroundClr = crColor;
}
- return OldColor;
+
+ return crOldColor;
}
/*
@@ -757,10 +820,9 @@
BOOL
WINAPI
SetTextJustification(
- HDC hdc,
- int extra,
- int breaks
-)
+ _In_ HDC hdc,
+ _In_ INT nBreakExtra,
+ _In_ INT nBreakCount)
{
PDC_ATTR pdcattr;
@@ -776,7 +838,7 @@
if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
{
if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC)
- return MFDRV_SetTextJustification( hdc, extra, breaks )
+ return MFDRV_SetTextJustification( hdc, nBreakExtra, nBreakCount )
else
{
SetLastError(ERROR_INVALID_HANDLE);
@@ -793,8 +855,8 @@
}
}
- pdcattr->cBreak = breaks;
- pdcattr->lBreakExtra = extra;
+ pdcattr->cBreak = nBreakCount;
+ pdcattr->lBreakExtra = nBreakExtra;
return TRUE;
}
@@ -803,32 +865,35 @@
*/
UINT
WINAPI
-GetStringBitmapA(HDC hdc,
- LPSTR psz,
- BOOL DoCall,
- UINT cj,
- BYTE *lpSB)
+GetStringBitmapA(
+ _In_ HDC hdc,
+ _In_ LPSTR psz,
+ _In_ BOOL bDoCall,
+ _In_ UINT cj,
+ _Out_writes_(cj) BYTE *lpSB)
{
NTSTATUS Status;
PWSTR pwsz;
- UINT retValue = 0;
-
- if (DoCall)
- {
- Status = HEAP_strdupA2W ( &pwsz, psz );
- if ( !NT_SUCCESS (Status) )
- {
- SetLastError (RtlNtStatusToDosError(Status));
- }
- else
- {
- retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
- HEAP_free ( pwsz );
- }
- }
-
- return retValue;
+ UINT uResult = 0;
+
+ if (!bDoCall)
+ {
+ return 0;
+ }
+
+ Status = HEAP_strdupA2W(&pwsz, psz);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError (RtlNtStatusToDosError(Status));
+ }
+ else
+ {
+ uResult = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
+ HEAP_free(pwsz);
+ }
+
+ return uResult;
}
@@ -837,35 +902,39 @@
*/
UINT
WINAPI
-GetStringBitmapW(HDC hdc,
- LPWSTR pwsz,
- BOOL doCall,
- UINT cj,
- BYTE *lpSB)
-{
- UINT retValue = 0;
-
- if (doCall)
- {
- retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
- }
-
- return retValue;
-
-}
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-GetETM(HDC hdc,
- EXTTEXTMETRIC *petm)
-{
- BOOL Ret = NtGdiGetETM(hdc, petm);
-
- if (Ret && petm)
+GetStringBitmapW(
+ _In_ HDC hdc,
+ _In_ LPWSTR pwsz,
+ _In_ BOOL bDoCall,
+ _In_ UINT cj,
+ _Out_writes_(cj) BYTE *lpSB)
+{
+ if (!bDoCall)
+ {
+ return 0;
+ }
+
+ return NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
+
+}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetETM(
+ _In_ HDC hdc,
+ _Out_ EXTTEXTMETRIC *petm)
+{
+ BOOL bResult;
+
+ bResult = NtGdiGetETM(hdc, petm);
+
+ if (bResult && petm)
+ {
petm->emKernPairs = (WORD)GetKerningPairsA(hdc, 0, 0);
-
- return Ret;
-}
+ }
+
+ return bResult;
+}