[ros-diffs] [fireball] 33928: - Revert 33689 as breaking mIRC installation. See issue #3328 for more details.

fireball at svn.reactos.org fireball at svn.reactos.org
Wed Jun 11 11:05:40 CEST 2008


Author: fireball
Date: Wed Jun 11 04:05:39 2008
New Revision: 33928

URL: http://svn.reactos.org/svn/reactos?rev=33928&view=rev
Log:
- Revert 33689 as breaking mIRC installation.
See issue #3328 for more details.

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/class.c?rev=33928&r1=33927&r2=33928&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/class.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/class.c [iso-8859-1] Wed Jun 11 04:05:39 2008
@@ -421,22 +421,15 @@
   LPSTR lpClassName,
   int nMaxCount)
 {
-    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);
+    ANSI_STRING ClassName;
+    int Result;
+
+    ClassName.MaximumLength = nMaxCount;
+    ClassName.Buffer = lpClassName;
+
+    Result = NtUserGetClassName(hWnd,
+                                (PUNICODE_STRING)&ClassName,
+                                TRUE);
 
     TRACE("%p class/atom: %s/%04x %x\n", hWnd,
         IS_ATOM(lpClassName) ? NULL : lpClassName,
@@ -463,7 +456,9 @@
     ClassName.MaximumLength = nMaxCount * sizeof(WCHAR);
     ClassName.Buffer = lpClassName;
 
-    Result = NtUserGetClassName(hWnd, FALSE, &ClassName);
+    Result = NtUserGetClassName(hWnd,
+                                &ClassName,
+                                FALSE);
 
     TRACE("%p class/atom: %S/%04x %x\n", hWnd,
         IS_ATOM(lpClassName) ? NULL : lpClassName,
@@ -634,24 +629,12 @@
 UINT
 STDCALL
 RealGetWindowClassW(
-  HWND  hWnd,
+  HWND  hwnd,
   LPWSTR pszType,
   UINT  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;
+	/* FIXME: Implement correct functionality of RealGetWindowClass */
+	return GetClassNameW(hwnd,pszType,cchType);
 }
 
 
@@ -661,33 +644,12 @@
 UINT
 STDCALL
 RealGetWindowClassA(
-  HWND  hWnd,
+  HWND  hwnd,
   LPSTR pszType,
   UINT  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;
+	/* FIXME: Implement correct functionality of RealGetWindowClass */
+	return GetClassNameA(hwnd,pszType,cchType);
 }
 
 /*

Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntuser.h?rev=33928&r1=33927&r2=33928&view=diff
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Wed Jun 11 04:05:39 2008
@@ -1255,11 +1255,18 @@
 		   LPWSTR *ppszMenuName,
 		   BOOL Ansi);
 
-UINT
+INT
 NTAPI
 NtUserGetClassName(HWND hWnd,
-                   BOOL bGetRealClass, // 0 GetClassNameA/W, 1 RealGetWindowClassA/W
+		   PUNICODE_STRING ClassName,
+                   BOOL Ansi);
+#if 0 // Real NtUserGetClassName
+INT
+NTAPI
+NtUserGetClassName(HWND hWnd,
+                   BOOL Unknown, // 0 GetClassNameW, 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/ntuser/class.c?rev=33928&r1=33927&r2=33928&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] Wed Jun 11 04:05:39 2008
@@ -1264,39 +1264,118 @@
 
 INT
 UserGetClassName(IN PWINDOWCLASS Class,
-                 IN OUT PUNICODE_STRING ClassName)
+                 IN OUT PUNICODE_STRING ClassName,
+                 IN BOOL Ansi)
 {
     NTSTATUS Status = STATUS_SUCCESS;
-    ULONG BufLen;
+    WCHAR szStaticTemp[32];
+    PWSTR szTemp = NULL;
+    ULONG BufLen = sizeof(szStaticTemp);
     INT Ret = 0;
 
     /* Note: Accessing the buffer in ClassName may raise an exception! */
 
     _SEH_TRY
     {
-        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);
+        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);
+        }
     }
     _SEH_HANDLE
     {
         SetLastNtError(_SEH_GetExceptionCode());
     }
     _SEH_END;
+
+    if (Ansi && szTemp != NULL && szTemp != szStaticTemp)
+    {
+        ExFreePool(szTemp);
+    }
 
     return Ret;
 }
@@ -2195,10 +2274,10 @@
 
 
 
-UINT NTAPI
-NtUserGetClassName(IN HWND hWnd,
-                   IN BOOL bGetRealClass, // 0 GetClassNameA/W, 1 RealGetWindowClassA/W
-                   OUT PUNICODE_STRING ClassName)
+INT NTAPI
+NtUserGetClassName (IN HWND hWnd,
+                    OUT PUNICODE_STRING ClassName,
+                    IN BOOL Ansi)
 {
     PWINDOW_OBJECT Window;
     UNICODE_STRING CapturedClassName;
@@ -2214,11 +2293,10 @@
             ProbeForWriteUnicodeString(ClassName);
             CapturedClassName = *ClassName;
 
-            /* TODO: Get real class name here if bGetRealClass == TRUE */
-
             /* get the class name */
             Ret = UserGetClassName(Window->Wnd->Class,
-                                   &CapturedClassName);
+                                   &CapturedClassName,
+                                   Ansi);
 
             if (Ret != 0)
             {



More information about the Ros-diffs mailing list