[ros-diffs] [sserapion] 43965: [USER32] - Fix several user32 warnings. - Sync GetWindow*A/W with wine and unify all versions, commenting out a wine hack. - As a bonus implement GetWindowLongPtrA/W. - Tested to work in trunk.

sserapion at svn.reactos.org sserapion at svn.reactos.org
Thu Nov 5 02:56:29 CET 2009


Author: sserapion
Date: Thu Nov  5 02:56:29 2009
New Revision: 43965

URL: http://svn.reactos.org/svn/reactos?rev=43965&view=rev
Log:
[USER32]
- Fix several user32 warnings.
- Sync GetWindow*A/W with wine and unify all versions, commenting out a wine hack.
- As a bonus implement GetWindowLongPtrA/W.
- Tested to work in trunk.

Modified:
    branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/exit.c
    branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/misc.c
    branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/resources.c
    branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/stubs.c
    branches/ros-amd64-bringup/reactos/dll/win32/user32/windows/class.c

Modified: branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/exit.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/exit.c?rev=43965&r1=43964&r2=43965&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/exit.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/exit.c [iso-8859-1] Thu Nov  5 02:56:29 2009
@@ -101,7 +101,7 @@
   NTSTATUS Status;
 
   CsrRequest = MAKE_CSR_API(REGISTER_SERVICES_PROCESS, CSR_GUI);
-  Request.Data.RegisterServicesProcessRequest.ProcessId = (HANDLE)ServicesProcessId;
+  Request.Data.RegisterServicesProcessRequest.ProcessId = LongToHandle(ServicesProcessId);
 
   Status = CsrClientCallServer(&Request,
                    NULL,

Modified: branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/misc.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/misc.c?rev=43965&r1=43964&r2=43965&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] Thu Nov  5 02:56:29 2009
@@ -274,7 +274,7 @@
       return TRUE;
    else
       return (NtUserQueryWindow(Wnd->head.h, QUERY_WINDOW_UNIQUE_PROCESS_ID) ==
-              (DWORD)NtCurrentTeb()->ClientId.UniqueProcess );
+              (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess );
 }
 
 BOOL
@@ -300,7 +300,7 @@
     INT Index;
     USHORT generation;
 
-    Index = (((UINT)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
+    Index = (((UINT_PTR)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
 
     if (Index < 0 || Index >= gHandleTable->nb_handles)
         return NULL;
@@ -308,7 +308,7 @@
     if (!gHandleEntries[Index].type || !gHandleEntries[Index].ptr)
         return NULL;
 
-    generation = (UINT)handle >> 16;
+    generation = (UINT_PTR)handle >> 16;
 
     if (generation == gHandleEntries[Index].generation || !generation || generation == 0xffff)
         return &gHandleEntries[Index];

Modified: branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/resources.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/resources.c?rev=43965&r1=43964&r2=43965&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/resources.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/resources.c [iso-8859-1] Thu Nov  5 02:56:29 2009
@@ -174,7 +174,7 @@
         return FALSE;
     }
 
-    ConfigRet  = UnRegNotify((ULONG) Handle );
+    ConfigRet  = UnRegNotify( HandleToUlong(Handle) );
     if (ConfigRet != CR_SUCCESS)
     {
         switch (ConfigRet)

Modified: branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/stubs.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/stubs.c?rev=43965&r1=43964&r2=43965&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/stubs.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/dll/win32/user32/misc/stubs.c [iso-8859-1] Thu Nov  5 02:56:29 2009
@@ -193,11 +193,11 @@
             SysColorBrushes[i] = pBrushes[i];
         }
 
-        return (DWORD) pOldCol; /* FIXME: pointer truncation */
+        return PtrToLong(pOldCol); /* FIXME: pointer truncation */
     }
     if (!pPens && !pBrushes) /* "restore" call */
     {
-        LPVOID pOldCol = (LPVOID)n; /* FIXME: not 64-bit safe */
+        LPVOID pOldCol = LongToPtr(n); /* FIXME: not 64-bit safe */
         LPVOID p = pOldCol;
         DWORD nCount = *(DWORD *)p;
         p = (char*)p + sizeof(DWORD);

Modified: branches/ros-amd64-bringup/reactos/dll/win32/user32/windows/class.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/dll/win32/user32/windows/class.c?rev=43965&r1=43964&r2=43965&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/dll/win32/user32/windows/class.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/dll/win32/user32/windows/class.c [iso-8859-1] Thu Nov  5 02:56:29 2009
@@ -658,157 +658,133 @@
 }
 
 
-/*
- * @implemented
- */
-LONG
-WINAPI
-GetWindowLongA ( HWND hWnd, int nIndex )
-{
-    PWND Wnd;
-
-    Wnd = ValidateHwnd(hWnd);
-    if (Wnd == NULL)
+LONG_PTR Internal_GetWindowLong( HWND hwnd, INT offset, UINT size, BOOL unicode )
+{
+    LONG_PTR retvalue = 0;
+    WND *wndPtr;
+
+    if (offset == GWLP_HWNDPARENT)
+    {
+        HWND parent = GetAncestor( hwnd, GA_PARENT );
+        if (parent == GetDesktopWindow()) parent = GetWindow( hwnd, GW_OWNER );
+        return (ULONG_PTR)parent;
+    }
+
+    if (!(wndPtr = ValidateHwnd( hwnd )))
+    {
+        SetLastError( ERROR_INVALID_WINDOW_HANDLE );
         return 0;
-
-    if (nIndex >= 0)
-    {
-        if ((DWORD)nIndex + sizeof(LONG) > Wnd->cbwndExtra)
+    }
+
+    if (offset >= 0)
+    {
+        if (offset > (int)(wndPtr->cbwndExtra - size))
         {
-            SetLastError(ERROR_INVALID_PARAMETER);
+            WARN("Invalid offset %d\n", offset );
+            SetLastError( ERROR_INVALID_INDEX );
             return 0;
         }
-        return *((LONG *)((PCHAR)(Wnd + 1) + nIndex));
-    }
-    else
-    {
-        switch (nIndex)
+        retvalue = *((LONG_PTR *)((PCHAR)(wndPtr + 1) + offset));
+
+        /* WINE: special case for dialog window procedure */
+        //if ((offset == DWLP_DLGPROC) && (size == sizeof(LONG_PTR)) && (wndPtr->flags & WIN_ISDIALOG))
+        //    retvalue = (LONG_PTR)IntGetWndProc( (WNDPROC)retvalue, unicode );
+        return retvalue;
+    }
+
+    switch(offset)
+    {
+    case GWLP_USERDATA:  retvalue = wndPtr->dwUserData; break;
+    case GWL_STYLE:      retvalue = wndPtr->style; break;
+    case GWL_EXSTYLE:    retvalue = wndPtr->ExStyle; break;
+    case GWLP_ID:        retvalue = wndPtr->IDMenu; break;
+    case GWLP_HINSTANCE: retvalue = (ULONG_PTR)wndPtr->hModule; break;
+    case GWLP_WNDPROC:
+	{
+		if (!TestWindowProcess(wndPtr))
+		{
+			SetLastError(ERROR_ACCESS_DENIED);
+			retvalue = 0;
+		}
+		retvalue = (ULONG_PTR)IntGetWndProc(wndPtr, unicode);
+        break;
+	}
+    default:
+        WARN("Unknown offset %d\n", offset );
+        SetLastError( ERROR_INVALID_INDEX );
+        break;
+    }
+    return retvalue;
+
+}
+/*
+ * @implemented
+ */
+LONG
+WINAPI
+GetWindowLongA ( HWND hWnd, int nIndex )
+{
+    return Internal_GetWindowLong( hWnd, nIndex, sizeof(LONG), FALSE );
+}
+
+/*
+ * @implemented
+ */
+LONG
+WINAPI
+GetWindowLongW(HWND hWnd, int nIndex)
+{
+    return Internal_GetWindowLong( hWnd, nIndex, sizeof(LONG), TRUE );
+}
+
+#ifdef _WIN64
+/*
+ * @unimplemented
+ */
+LONG_PTR
+WINAPI
+GetWindowLongPtrA(HWND hWnd,
+                  INT nIndex)
+{
+    return Internal_GetWindowLong( hWnd, nIndex, sizeof(LONG_PTR), FALSE );
+}
+
+/*
+ * @unimplemented
+ */
+LONG_PTR
+WINAPI
+GetWindowLongPtrW(HWND hWnd,
+                  INT nIndex)
+{
+    return Internal_GetWindowLong( hWnd, nIndex, sizeof(LONG_PTR), TRUE );
+
+}
+#endif // _WIN64
+
+/*
+ * @implemented
+ */
+WORD
+WINAPI
+GetWindowWord(HWND hWnd, int nIndex)
+{
+    switch(nIndex)
+    {
+    case GWLP_ID:
+    case GWLP_HINSTANCE:
+    case GWLP_HWNDPARENT:
+        break;
+    default:
+        if (nIndex < 0)
         {
-            case GWL_EXSTYLE:
-                return Wnd->ExStyle;
-            case GWL_STYLE:
-                return Wnd->style;
-            case GWL_HINSTANCE:
-                return (LONG)Wnd->hModule;
-            case GWL_ID:
-                return Wnd->IDMenu;
-            case GWL_USERDATA:
-                return Wnd->dwUserData;
-
-            case GWL_HWNDPARENT:
-            {
-                HWND parent = GetAncestor( hWnd, GA_PARENT );
-                if (parent == GetDesktopWindow()) parent = GetWindow( hWnd, GW_OWNER );
-                return (LONG)parent;
-            }
-            case GWL_WNDPROC:
-                if (!TestWindowProcess(Wnd))
-                {
-                   SetLastError(ERROR_ACCESS_DENIED);
-                   return 0;
-                }
-                return IntGetWndProc(Wnd, TRUE);
-
-            default:
-                SetLastError(ERROR_INVALID_PARAMETER);
-                return 0;
-        }
-    }
-}
-
-
-/*
- * @implemented
- */
-LONG
-WINAPI
-GetWindowLongW(HWND hWnd, int nIndex)
-{
-    PWND Wnd;
-
-    Wnd = ValidateHwnd(hWnd);
-    if (Wnd == NULL)
-        return 0;
-
-    if (nIndex >= 0)
-    {
-        if ((DWORD)nIndex + sizeof(LONG) > Wnd->cbwndExtra)
-        {
-            SetLastError(ERROR_INVALID_PARAMETER);
+            WARN("Invalid offset %d\n", nIndex );
+            SetLastError( ERROR_INVALID_INDEX );
             return 0;
         }
-        return *((LONG *)((PCHAR)(Wnd + 1) + nIndex));
-    }
-    else
-    {
-        switch (nIndex)
-        {
-            case GWL_EXSTYLE:
-                return Wnd->ExStyle;
-            case GWL_STYLE:
-                return Wnd->style;
-            case GWL_HINSTANCE:
-                return (LONG)Wnd->hModule;
-            case GWL_ID:
-                return Wnd->IDMenu;
-            case GWL_USERDATA:
-                return Wnd->dwUserData;
-
-            case GWL_HWNDPARENT:
-            {
-                HWND parent = GetAncestor( hWnd, GA_PARENT );
-                if (parent == GetDesktopWindow()) parent = GetWindow( hWnd, GW_OWNER );
-                return (LONG)parent;
-            }
-            case GWL_WNDPROC:
-                if (!TestWindowProcess(Wnd))
-                {
-                   SetLastError(ERROR_ACCESS_DENIED);
-                   return 0;
-                }
-                return IntGetWndProc(Wnd, FALSE);
-
-            default:
-                SetLastError(ERROR_INVALID_PARAMETER);
-                return 0;
-        }
-    }
-}
-
-#ifdef _WIN64
-/*
- * @unimplemented
- */
-LONG_PTR
-WINAPI
-GetWindowLongPtrA(HWND hWnd,
-                  INT nIndex)
-{
-    UNIMPLEMENTED;
-    return 0;
-}
-
-/*
- * @unimplemented
- */
-LONG_PTR
-WINAPI
-GetWindowLongPtrW(HWND hWnd,
-                  INT nIndex)
-{
-    UNIMPLEMENTED;
-    return 0;
-}
-#endif // _WIN64
-
-/*
- * @implemented
- */
-WORD
-WINAPI
-GetWindowWord(HWND hWnd, int nIndex)
-{
-  return (WORD)GetWindowLongW(hWnd, nIndex);
+        break;
+    }
+    return Internal_GetWindowLong( hWnd, nIndex, sizeof(WORD), FALSE );
 }
 
 /*




More information about the Ros-diffs mailing list