[User32|Win32k]

- Properly implement RealGetWindowClass, fixes the ApiTest. Keeping the Ansi support for now, will use it as a reference.

svn path=/trunk/; revision=51187
This commit is contained in:
James Tabor 2011-03-29 05:53:34 +00:00
parent 827e75cb89
commit 0bf0c70444
3 changed files with 40 additions and 29 deletions

View file

@ -696,22 +696,20 @@ GetClassNameA(
LPSTR lpClassName,
int nMaxCount)
{
ANSI_STRING ClassName;
int Result;
ClassName.MaximumLength = nMaxCount;
ClassName.Buffer = lpClassName;
Result = NtUserGetClassName(hWnd,
(PUNICODE_STRING)&ClassName,
TRUE);
WCHAR tmpbuf[MAX_ATOM_LEN + 1];
int len;
if (nMaxCount <= 0) return 0;
if (!GetClassNameW( hWnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0;
RtlUnicodeToMultiByteN( lpClassName, nMaxCount - 1, (PULONG)&len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) );
lpClassName[len] = 0;
TRACE("%p class/atom: %s/%04x %x\n", hWnd,
IS_ATOM(lpClassName) ? NULL : lpClassName,
IS_ATOM(lpClassName) ? lpClassName : 0,
nMaxCount);
return Result;
return len;
}
@ -732,8 +730,8 @@ GetClassNameW(
ClassName.Buffer = lpClassName;
Result = NtUserGetClassName(hWnd,
&ClassName,
FALSE);
FALSE,
&ClassName);
TRACE("%p class/atom: %S/%04x %x\n", hWnd,
IS_ATOM(lpClassName) ? NULL : lpClassName,
@ -914,8 +912,11 @@ RealGetWindowClassW(
LPWSTR pszType,
UINT cchType)
{
/* FIXME: Implement correct functionality of RealGetWindowClass */
return GetClassNameW(hwnd,pszType,cchType);
UNICODE_STRING ClassName;
ClassName.MaximumLength = cchType * sizeof(WCHAR);
ClassName.Buffer = (PWSTR)pszType;
return NtUserGetClassName(hwnd,TRUE,&ClassName);
}
@ -929,8 +930,14 @@ RealGetWindowClassA(
LPSTR pszType,
UINT cchType)
{
/* FIXME: Implement correct functionality of RealGetWindowClass */
return GetClassNameA(hwnd,pszType,cchType);
WCHAR tmpbuf[MAX_ATOM_LEN + 1];
UINT len;
if (cchType <= 0) return 0;
if (!RealGetWindowClassW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0;
RtlUnicodeToMultiByteN( pszType, cchType - 1, (PULONG)&len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) );
pszType[len] = 0;
return len;
}
/*

View file

@ -1761,18 +1761,11 @@ NtUserGetClassInfo(HINSTANCE hInstance,
LPWSTR *ppszMenuName,
BOOL Ansi);
INT
NTAPI
NtUserGetClassName(HWND hWnd,
PUNICODE_STRING ClassName,
BOOL Ansi);
#if 0 // Real NtUserGetClassName
INT
NTAPI
NtUserGetClassName(HWND hWnd,
BOOL Real, // 0 GetClassNameW, 1 RealGetWindowClassA/W
PUNICODE_STRING ClassName);
#endif
HANDLE
NTAPI

View file

@ -1398,6 +1398,7 @@ UserUnregisterClass(IN PUNICODE_STRING ClassName,
INT
UserGetClassName(IN PCLS Class,
IN OUT PUNICODE_STRING ClassName,
IN RTL_ATOM Atom,
IN BOOL Ansi)
{
NTSTATUS Status = STATUS_SUCCESS;
@ -1451,7 +1452,7 @@ UserGetClassName(IN PCLS Class,
/* query the class name */
Status = RtlQueryAtomInAtomTable(gAtomTable,
Class->atomClassName,
Atom ? Atom : Class->atomClassName,
NULL,
NULL,
szTemp,
@ -1485,7 +1486,7 @@ UserGetClassName(IN PCLS Class,
/* query the atom name */
Status = RtlQueryAtomInAtomTable(gAtomTable,
Class->atomClassName,
Atom ? Atom : Class->atomClassName,
NULL,
NULL,
ClassName->Buffer,
@ -2376,18 +2377,27 @@ NtUserGetClassInfo(
INT APIENTRY
NtUserGetClassName (IN HWND hWnd,
OUT PUNICODE_STRING ClassName,
IN BOOL Ansi)
IN BOOL Real,
OUT PUNICODE_STRING ClassName)
{
PWND Window;
UNICODE_STRING CapturedClassName;
INT Ret = 0;
INT iCls, Ret = 0;
RTL_ATOM Atom = 0;
UserEnterShared();
Window = UserGetWindowObject(hWnd);
if (Window != NULL)
{
if (Real && Window->fnid && !(Window->fnid & FNID_DESTROY))
{
if (LookupFnIdToiCls(Window->fnid, &iCls))
{
Atom = gpsi->atomSysClass[iCls];
}
}
_SEH2_TRY
{
ProbeForWriteUnicodeString(ClassName);
@ -2396,7 +2406,8 @@ NtUserGetClassName (IN HWND hWnd,
/* get the class name */
Ret = UserGetClassName(Window->pcls,
&CapturedClassName,
Ansi);
Atom,
FALSE);
if (Ret != 0)
{