mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
* Changed to correct signature of NtUserGetClassName()
* Implemented correct behaviour in GetRealWindowClass(), but in reality just shifted the todo parts to NtUserGetClassName() instead. svn path=/trunk/; revision=33689
This commit is contained in:
parent
61350d2a48
commit
21f3bde4eb
3 changed files with 79 additions and 126 deletions
|
@ -421,15 +421,22 @@ GetClassNameA(
|
|||
LPSTR lpClassName,
|
||||
int nMaxCount)
|
||||
{
|
||||
ANSI_STRING ClassName;
|
||||
int Result;
|
||||
UNICODE_STRING ClassName;
|
||||
INT Result;
|
||||
|
||||
ClassName.MaximumLength = nMaxCount;
|
||||
ClassName.Buffer = lpClassName;
|
||||
ClassName.MaximumLength = nMaxCount * sizeof(WCHAR);
|
||||
ClassName.Buffer = LocalAlloc(LMEM_FIXED, ClassName.MaximumLength);
|
||||
if (ClassName.Buffer == NULL)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result = NtUserGetClassName(hWnd,
|
||||
(PUNICODE_STRING)&ClassName,
|
||||
TRUE);
|
||||
Result = NtUserGetClassName(hWnd, FALSE, &ClassName);
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, ClassName.Buffer, Result, lpClassName, nMaxCount - 1, NULL, NULL);
|
||||
lpClassName[nMaxCount - 1] = '\0';
|
||||
LocalFree(ClassName.Buffer);
|
||||
|
||||
TRACE("%p class/atom: %s/%04x %x\n", hWnd,
|
||||
IS_ATOM(lpClassName) ? NULL : lpClassName,
|
||||
|
@ -456,9 +463,7 @@ GetClassNameW(
|
|||
ClassName.MaximumLength = nMaxCount * sizeof(WCHAR);
|
||||
ClassName.Buffer = lpClassName;
|
||||
|
||||
Result = NtUserGetClassName(hWnd,
|
||||
&ClassName,
|
||||
FALSE);
|
||||
Result = NtUserGetClassName(hWnd, FALSE, &ClassName);
|
||||
|
||||
TRACE("%p class/atom: %S/%04x %x\n", hWnd,
|
||||
IS_ATOM(lpClassName) ? NULL : lpClassName,
|
||||
|
@ -629,12 +634,24 @@ SetWindowWord ( HWND hWnd,int nIndex,WORD wNewWord )
|
|||
UINT
|
||||
STDCALL
|
||||
RealGetWindowClassW(
|
||||
HWND hwnd,
|
||||
HWND hWnd,
|
||||
LPWSTR pszType,
|
||||
UINT cchType)
|
||||
{
|
||||
/* FIXME: Implement correct functionality of RealGetWindowClass */
|
||||
return GetClassNameW(hwnd,pszType,cchType);
|
||||
UNICODE_STRING ClassName;
|
||||
UINT Length;
|
||||
|
||||
ClassName.MaximumLength = cchType * sizeof(WCHAR);
|
||||
ClassName.Buffer = pszType;
|
||||
|
||||
Length = NtUserGetClassName(hWnd, TRUE, &ClassName);
|
||||
|
||||
TRACE("%p class/atom: %S/%04x %x\n", hWnd,
|
||||
IS_ATOM(pszType) ? NULL : pszType,
|
||||
IS_ATOM(pszType) ? pszType : 0,
|
||||
cchType);
|
||||
|
||||
return Length;
|
||||
}
|
||||
|
||||
|
||||
|
@ -644,12 +661,33 @@ RealGetWindowClassW(
|
|||
UINT
|
||||
STDCALL
|
||||
RealGetWindowClassA(
|
||||
HWND hwnd,
|
||||
HWND hWnd,
|
||||
LPSTR pszType,
|
||||
UINT cchType)
|
||||
{
|
||||
/* FIXME: Implement correct functionality of RealGetWindowClass */
|
||||
return GetClassNameA(hwnd,pszType,cchType);
|
||||
UNICODE_STRING ClassName;
|
||||
UINT Length;
|
||||
|
||||
ClassName.MaximumLength = cchType * sizeof(WCHAR);
|
||||
ClassName.Buffer = LocalAlloc(LMEM_FIXED, ClassName.MaximumLength);
|
||||
if (ClassName.Buffer == NULL)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Length = NtUserGetClassName(hWnd, TRUE, &ClassName);
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, ClassName.Buffer, Length, pszType, cchType - 1, NULL, NULL);
|
||||
pszType[cchType - 1] = '\0';
|
||||
LocalFree(ClassName.Buffer);
|
||||
|
||||
TRACE("%p class/atom: %s/%04x %x\n", hWnd,
|
||||
IS_ATOM(pszType) ? NULL : pszType,
|
||||
IS_ATOM(pszType) ? pszType : 0,
|
||||
cchType);
|
||||
|
||||
return Length;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1160,18 +1160,11 @@ NtUserGetClassInfo(HINSTANCE hInstance,
|
|||
LPWSTR *ppszMenuName,
|
||||
BOOL Ansi);
|
||||
|
||||
INT
|
||||
UINT
|
||||
NTAPI
|
||||
NtUserGetClassName(HWND hWnd,
|
||||
PUNICODE_STRING ClassName,
|
||||
BOOL Ansi);
|
||||
#if 0 // Real NtUserGetClassName
|
||||
INT
|
||||
NTAPI
|
||||
NtUserGetClassName(HWND hWnd,
|
||||
BOOL Unknown, // 0 GetClassNameW, 1 RealGetWindowClassA/W
|
||||
BOOL bGetRealClass, // 0 GetClassNameA/W, 1 RealGetWindowClassA/W
|
||||
PUNICODE_STRING ClassName);
|
||||
#endif
|
||||
|
||||
HANDLE
|
||||
NTAPI
|
||||
|
|
|
@ -1255,107 +1255,33 @@ UserUnregisterClass(IN PUNICODE_STRING ClassName,
|
|||
|
||||
INT
|
||||
UserGetClassName(IN PWINDOWCLASS Class,
|
||||
IN OUT PUNICODE_STRING ClassName,
|
||||
IN BOOL Ansi)
|
||||
IN OUT PUNICODE_STRING ClassName)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
WCHAR szStaticTemp[32];
|
||||
PWSTR szTemp = NULL;
|
||||
ULONG BufLen = sizeof(szStaticTemp);
|
||||
ULONG BufLen;
|
||||
INT Ret = 0;
|
||||
|
||||
/* Note: Accessing the buffer in ClassName may raise an exception! */
|
||||
|
||||
_SEH_TRY
|
||||
{
|
||||
if (Ansi)
|
||||
BufLen = ClassName->MaximumLength;
|
||||
|
||||
/* query the atom name */
|
||||
Status = RtlQueryAtomInAtomTable(gAtomTable,
|
||||
Class->Atom,
|
||||
NULL,
|
||||
NULL,
|
||||
ClassName->Buffer,
|
||||
&BufLen);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
PANSI_STRING AnsiClassName = (PANSI_STRING)ClassName;
|
||||
UNICODE_STRING UnicodeClassName;
|
||||
|
||||
/* limit the size of the static buffer on the stack to the
|
||||
size of the buffer provided by the caller */
|
||||
if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength)
|
||||
{
|
||||
BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR);
|
||||
}
|
||||
|
||||
/* find out how big the buffer needs to be */
|
||||
Status = RtlQueryAtomInAtomTable(gAtomTable,
|
||||
Class->Atom,
|
||||
NULL,
|
||||
NULL,
|
||||
szStaticTemp,
|
||||
&BufLen);
|
||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength)
|
||||
{
|
||||
/* the buffer required exceeds the ansi buffer provided,
|
||||
pretend like we're using the ansi buffer and limit the
|
||||
size to the buffer size provided */
|
||||
BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR);
|
||||
}
|
||||
|
||||
/* allocate a temporary buffer that can hold the unicode class name */
|
||||
szTemp = ExAllocatePool(PagedPool,
|
||||
BufLen);
|
||||
if (szTemp == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
_SEH_LEAVE;
|
||||
}
|
||||
|
||||
/* query the class name */
|
||||
Status = RtlQueryAtomInAtomTable(gAtomTable,
|
||||
Class->Atom,
|
||||
NULL,
|
||||
NULL,
|
||||
szTemp,
|
||||
&BufLen);
|
||||
}
|
||||
else
|
||||
szTemp = szStaticTemp;
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* convert the atom name to ansi */
|
||||
|
||||
RtlInitUnicodeString(&UnicodeClassName,
|
||||
szTemp);
|
||||
|
||||
Status = RtlUnicodeStringToAnsiString(AnsiClassName,
|
||||
&UnicodeClassName,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
_SEH_LEAVE;
|
||||
}
|
||||
}
|
||||
|
||||
Ret = BufLen / sizeof(WCHAR);
|
||||
SetLastNtError(Status);
|
||||
_SEH_LEAVE;
|
||||
}
|
||||
else /* !Ansi */
|
||||
{
|
||||
BufLen = ClassName->MaximumLength;
|
||||
|
||||
/* query the atom name */
|
||||
Status = RtlQueryAtomInAtomTable(gAtomTable,
|
||||
Class->Atom,
|
||||
NULL,
|
||||
NULL,
|
||||
ClassName->Buffer,
|
||||
&BufLen);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
_SEH_LEAVE;
|
||||
}
|
||||
|
||||
Ret = BufLen / sizeof(WCHAR);
|
||||
}
|
||||
Ret = BufLen / sizeof(WCHAR);
|
||||
}
|
||||
_SEH_HANDLE
|
||||
{
|
||||
|
@ -1363,11 +1289,6 @@ UserGetClassName(IN PWINDOWCLASS Class,
|
|||
}
|
||||
_SEH_END;
|
||||
|
||||
if (Ansi && szTemp != NULL && szTemp != szStaticTemp)
|
||||
{
|
||||
ExFreePool(szTemp);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
@ -2265,10 +2186,10 @@ Cleanup:
|
|||
|
||||
|
||||
|
||||
INT NTAPI
|
||||
NtUserGetClassName (IN HWND hWnd,
|
||||
OUT PUNICODE_STRING ClassName,
|
||||
IN BOOL Ansi)
|
||||
UINT NTAPI
|
||||
NtUserGetClassName(IN HWND hWnd,
|
||||
IN BOOL bGetRealClass, // 0 GetClassNameA/W, 1 RealGetWindowClassA/W
|
||||
OUT PUNICODE_STRING ClassName)
|
||||
{
|
||||
PWINDOW_OBJECT Window;
|
||||
UNICODE_STRING CapturedClassName;
|
||||
|
@ -2284,10 +2205,11 @@ NtUserGetClassName (IN HWND hWnd,
|
|||
ProbeForWriteUnicodeString(ClassName);
|
||||
CapturedClassName = *ClassName;
|
||||
|
||||
/* TODO: Get real class name here if bGetRealClass == TRUE */
|
||||
|
||||
/* get the class name */
|
||||
Ret = UserGetClassName(Window->Wnd->Class,
|
||||
&CapturedClassName,
|
||||
Ansi);
|
||||
&CapturedClassName);
|
||||
|
||||
if (Ret != 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue