Author: gbrunmar
Date: Sun May 25 03:36:30 2008
New Revision: 33689
URL:
http://svn.reactos.org/svn/reactos?rev=33689&view=rev
Log:
* Changed to correct signature of NtUserGetClassName()
* Implemented correct behaviour in GetRealWindowClass(), but in reality just shifted the
todo parts to NtUserGetClassName() instead.
Modified:
trunk/reactos/dll/win32/user32/windows/class.c
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/class.c
Modified: trunk/reactos/dll/win32/user32/windows/class.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/c…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/class.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/class.c [iso-8859-1] Sun May 25 03:36:30 2008
@@ -421,15 +421,22 @@
LPSTR lpClassName,
int nMaxCount)
{
- ANSI_STRING ClassName;
- int Result;
-
- ClassName.MaximumLength = nMaxCount;
- ClassName.Buffer = lpClassName;
-
- Result = NtUserGetClassName(hWnd,
- (PUNICODE_STRING)&ClassName,
- TRUE);
+ UNICODE_STRING ClassName;
+ INT Result;
+
+ 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, 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 @@
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 @@
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 @@
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;
}
/*
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Sun May 25 03:36:30 2008
@@ -1160,18 +1160,11 @@
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
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] Sun May 25 03:36:30
2008
@@ -1255,118 +1255,39 @@
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)
- {
- 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);
- }
- 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);
- }
+ 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);
}
_SEH_HANDLE
{
SetLastNtError(_SEH_GetExceptionCode());
}
_SEH_END;
-
- if (Ansi && szTemp != NULL && szTemp != szStaticTemp)
- {
- ExFreePool(szTemp);
- }
return Ret;
}
@@ -2265,10 +2186,10 @@
-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 @@
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)
{