Win64 patch 9/9 (user32)

Ge van Geldorp ge at gse.nl
Mon Jul 10 01:59:33 CDT 2006


Changelog:
  Ge van Geldorp <ge at gse.nl>
  - Implement Get/SetWindowLongPtrA/W

 dlls/user/message.c            |    2 +
 dlls/user/spy.c                |    3 +
 dlls/user/user_private.h       |    1 
 dlls/user/win.c                |   96 ++++++++++++++++++++++++++++++----------
 include/wine/server_protocol.h |    4 +-
 server/trace.c                 |    4 +-
 6 files changed, 81 insertions(+), 29 deletions(-)

diff --git a/dlls/user/message.c b/dlls/user/message.c
index fd84ef0..dd7663c 100644
--- a/dlls/user/message.c
+++ b/dlls/user/message.c
@@ -1184,6 +1184,8 @@ static LRESULT handle_internal_message( 
         return (LRESULT)SetParent( hwnd, (HWND)wparam );
     case WM_WINE_SETWINDOWLONG:
         return (LRESULT)SetWindowLongW( hwnd, wparam, lparam );
+    case WM_WINE_SETWINDOWLONGPTR:
+        return (LRESULT)SetWindowLongPtrW( hwnd, wparam, lparam );
     case WM_WINE_ENABLEWINDOW:
         if (hwnd == GetDesktopWindow()) return 0;
         return EnableWindow( hwnd, wparam );
diff --git a/dlls/user/spy.c b/dlls/user/spy.c
index 56be180..f948f18 100644
--- a/dlls/user/spy.c
+++ b/dlls/user/spy.c
@@ -1036,7 +1036,7 @@ static const char * const CCMMessageType
     "CCM_SETNOTIFYWINDOW"
 };
 
-#define SPY_MAX_WINEMSGNUM   6
+#define SPY_MAX_WINEMSGNUM   7
 static const char * const WINEMessageTypeNames[SPY_MAX_WINEMSGNUM + 1] =
 {
     "WM_WINE_DESTROYWINDOW",
@@ -1044,6 +1044,7 @@ static const char * const WINEMessageTyp
     "WM_WINE_SHOWWINDOW",
     "WM_WINE_SETPARENT",
     "WM_WINE_SETWINDOWLONG",
+    "WM_WINE_SETWINDOWLONGPTR",
     "WM_WINE_ENABLEWINDOW"
 };
 
diff --git a/dlls/user/user_private.h b/dlls/user/user_private.h
index ffb2796..476991c 100644
--- a/dlls/user/user_private.h
+++ b/dlls/user/user_private.h
@@ -89,6 +89,7 @@ enum wine_internal_message
     WM_WINE_SHOWWINDOW,
     WM_WINE_SETPARENT,
     WM_WINE_SETWINDOWLONG,
+    WM_WINE_SETWINDOWLONGPTR,
     WM_WINE_ENABLEWINDOW,
     WM_WINE_SETACTIVEWINDOW,
     WM_WINE_KEYBOARD_LL_HOOK,
diff --git a/dlls/user/win.c b/dlls/user/win.c
index fa2af00..53227ae 100644
--- a/dlls/user/win.c
+++ b/dlls/user/win.c
@@ -1823,9 +1823,11 @@ WORD WINAPI SetWindowWord( HWND hwnd, IN
  *
  * Helper function for GetWindowLong().
  */
-static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, BOOL unicode )
+static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, UINT size,
+                                   BOOL unicode )
 {
     LONG_PTR retvalue = 0;
+    DWORD retlong = 0;
     WND *wndPtr;
 
     if (offset == GWLP_HWNDPARENT)
@@ -1864,7 +1866,18 @@ static LONG_PTR WIN_GetWindowLong( HWND 
                 case GWLP_HINSTANCE: retvalue = (ULONG_PTR)reply->old_instance; break;
                 case GWLP_USERDATA:  retvalue = (ULONG_PTR)reply->old_user_data; break;
                 default:
-                    if (offset >= 0) retvalue = reply->old_extra_value;
+                    if (offset >= 0)
+                    {
+                        if (size == sizeof(LONG))
+                        {
+                            memcpy( &retlong, &reply->old_extra_value,
+                                    sizeof(LONG) );
+                            retvalue = retlong;
+                        }
+                        else
+                            memcpy( &retvalue, &reply->old_extra_value,
+                                    sizeof(ULONG_PTR) );
+                    }
                     else SetLastError( ERROR_INVALID_INDEX );
                     break;
                 }
@@ -1878,14 +1891,23 @@ static LONG_PTR WIN_GetWindowLong( HWND 
 
     if (offset >= 0)
     {
-        if (offset > (int)(wndPtr->cbWndExtra - sizeof(LONG)))
+        if (offset > (int)(wndPtr->cbWndExtra - size))
         {
             WARN("Invalid offset %d\n", offset );
             WIN_ReleasePtr( wndPtr );
             SetLastError( ERROR_INVALID_INDEX );
             return 0;
         }
-        retvalue = *(LONG_PTR *)(((char *)wndPtr->wExtra) + offset);
+        if (size == sizeof(LONG))
+        {
+            memcpy( &retlong, (char *)(wndPtr->wExtra) + offset,
+                    sizeof(LONG) );
+            retvalue = retlong;
+        }
+        else
+            memcpy( &retvalue, (char *)(wndPtr->wExtra) + offset,
+                    sizeof(ULONG_PTR) );
+
         /* Special case for dialog window procedure */
         if ((offset == DWLP_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
             retvalue = (LONG_PTR)WINPROC_GetProc( (WNDPROC)retvalue, unicode );
@@ -1919,11 +1941,13 @@ static LONG_PTR WIN_GetWindowLong( HWND 
  * 0 is the failure code. However, in the case of failure SetLastError
  * must be set to distinguish between a 0 return value and a failure.
  */
-static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval, BOOL unicode )
+static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
+                                   UINT size, BOOL unicode )
 {
     STYLESTRUCT style;
     BOOL ok;
     LONG_PTR retval = 0;
+    LONG retlong, newlong;
     WND *wndPtr;
 
     TRACE( "%p %d %lx %c\n", hwnd, offset, newval, unicode ? 'W' : 'A' );
@@ -1952,7 +1976,10 @@ static LONG_PTR WIN_SetWindowLong( HWND 
             SetLastError( ERROR_ACCESS_DENIED );
             return 0;
         }
-        return SendMessageW( hwnd, WM_WINE_SETWINDOWLONG, offset, newval );
+        if (size == sizeof(LONG_PTR))
+            return SendMessageW( hwnd, WM_WINE_SETWINDOWLONGPTR, offset, newval );
+        else
+            return SendMessageW( hwnd, WM_WINE_SETWINDOWLONG, offset, newval );
     }
 
     /* first some special cases */
@@ -2011,14 +2038,14 @@ static LONG_PTR WIN_SetWindowLong( HWND 
         }
         /* fall through */
     default:
-        if (offset < 0 || offset > (int)(wndPtr->cbWndExtra - sizeof(LONG_PTR)))
+        if (offset < 0 || offset > (int)(wndPtr->cbWndExtra - size))
         {
             WARN("Invalid offset %d\n", offset );
             WIN_ReleasePtr( wndPtr );
             SetLastError( ERROR_INVALID_INDEX );
             return 0;
         }
-        else
+        else if (size == sizeof(LONG_PTR))
         {
             LONG_PTR *ptr = (LONG_PTR *)((char *)wndPtr->wExtra + offset);
             if (*ptr == newval)  /* already set to the same value */
@@ -2027,6 +2054,15 @@ static LONG_PTR WIN_SetWindowLong( HWND 
                 return newval;
             }
         }
+        else
+        {
+            LONG *ptr = (LONG *)((char *)wndPtr->wExtra + offset);
+            if (*ptr == (LONG) newval)  /* already set to the same value */
+            {
+                WIN_ReleasePtr( wndPtr );
+                return newval;
+            }
+        }
         break;
     }
 
@@ -2063,8 +2099,14 @@ static LONG_PTR WIN_SetWindowLong( HWND 
         default:
             req->flags = SET_WIN_EXTRA;
             req->extra_offset = offset;
-            req->extra_size = sizeof(newval);
-            memcpy( &req->extra_value, &newval, sizeof(newval) );
+            req->extra_size = size;
+            if (size == sizeof(LONG_PTR))
+                memcpy( &req->extra_value, &newval, sizeof(LONG_PTR) );
+            else
+            {
+                newlong = (LONG) newval;
+                memcpy( &req->extra_value, &newlong, sizeof(LONG) );
+            }
         }
         if ((ok = !wine_server_call_err( req )))
         {
@@ -2095,8 +2137,18 @@ static LONG_PTR WIN_SetWindowLong( HWND 
             default:
                 {
                     void *ptr = (char *)wndPtr->wExtra + offset;
-                    memcpy( &retval, ptr, sizeof(retval) );
-                    memcpy( ptr, &newval, sizeof(newval) );
+                    if ( size == sizeof(LONG) )
+                    {
+                        memcpy( &retval, ptr, sizeof(ULONG_PTR) );
+                        memcpy( ptr, &newval, sizeof(LONG_PTR) );
+                    }
+                    else
+                    {
+                        memcpy( &retlong, ptr, sizeof(LONG) );
+                        retval = retlong;
+                        newlong = (LONG) newval;
+                        memcpy( ptr, &newlong, sizeof(LONG) );
+                    }
                 }
                 break;
             }
@@ -2170,7 +2222,7 @@ LONG WINAPI GetWindowLong16( HWND16 hwnd
  */
 LONG WINAPI GetWindowLongA( HWND hwnd, INT offset )
 {
-    return WIN_GetWindowLong( hwnd, offset, FALSE );
+    return WIN_GetWindowLong( hwnd, offset, sizeof(LONG), FALSE );
 }
 
 
@@ -2179,7 +2231,7 @@ LONG WINAPI GetWindowLongA( HWND hwnd, I
  */
 LONG WINAPI GetWindowLongW( HWND hwnd, INT offset )
 {
-    return WIN_GetWindowLong( hwnd, offset, TRUE );
+    return WIN_GetWindowLong( hwnd, offset, sizeof(LONG), TRUE );
 }
 
 
@@ -2223,7 +2275,7 @@ LONG WINAPI SetWindowLong16( HWND16 hwnd
  */
 LONG WINAPI SetWindowLongA( HWND hwnd, INT offset, LONG newval )
 {
-    return WIN_SetWindowLong( hwnd, offset, newval, FALSE );
+    return WIN_SetWindowLong( hwnd, offset, newval, sizeof(LONG), FALSE );
 }
 
 
@@ -2298,7 +2350,7 @@ LONG WINAPI SetWindowLongW(
     INT offset, /* [in] offset, in bytes, of location to alter */
     LONG newval /* [in] new value of location */
 ) {
-    return WIN_SetWindowLong( hwnd, offset, newval, TRUE );
+    return WIN_SetWindowLong( hwnd, offset, newval, sizeof(LONG), TRUE );
 }
 
 
@@ -3196,8 +3248,7 @@ #endif
  */
 LONG_PTR WINAPI GetWindowLongPtrW( HWND hwnd, INT offset )
 {
-    FIXME("\n");
-    return 0;
+    return WIN_GetWindowLong( hwnd, offset, sizeof(LONG_PTR), TRUE );
 }
 
 /*****************************************************************************
@@ -3205,8 +3256,7 @@ LONG_PTR WINAPI GetWindowLongPtrW( HWND 
  */
 LONG_PTR WINAPI GetWindowLongPtrA( HWND hwnd, INT offset )
 {
-    FIXME("\n");
-    return 0;
+    return WIN_GetWindowLong( hwnd, offset, sizeof(LONG_PTR), FALSE );
 }
 
 /*****************************************************************************
@@ -3214,8 +3264,7 @@ LONG_PTR WINAPI GetWindowLongPtrA( HWND 
  */
 LONG_PTR WINAPI SetWindowLongPtrW( HWND hwnd, INT offset, LONG_PTR newval )
 {
-    FIXME("\n");
-    return 0;
+    return WIN_SetWindowLong( hwnd, offset, newval, sizeof(LONG_PTR), TRUE );
 }
 
 /*****************************************************************************
@@ -3223,6 +3272,5 @@ LONG_PTR WINAPI SetWindowLongPtrW( HWND 
  */
 LONG_PTR WINAPI SetWindowLongPtrA( HWND hwnd, INT offset, LONG_PTR newval )
 {
-    FIXME("\n");
-    return 0;
+    return WIN_SetWindowLong( hwnd, offset, newval, sizeof(LONG_PTR), FALSE );
 }
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index dd9757a..374c09a 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -2605,7 +2605,7 @@ struct set_window_info_request
     void*          user_data;
     int            extra_offset;
     size_t         extra_size;
-    unsigned int   extra_value;
+    unsigned long  extra_value;
 };
 struct set_window_info_reply
 {
@@ -2615,7 +2615,7 @@ struct set_window_info_reply
     unsigned int   old_id;
     void*          old_instance;
     void*          old_user_data;
-    unsigned int   old_extra_value;
+    unsigned long  old_extra_value;
 };
 #define SET_WIN_STYLE     0x01
 #define SET_WIN_EXSTYLE   0x02
diff --git a/server/trace.c b/server/trace.c
index 20c94c4..4daf315 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -2363,7 +2363,7 @@ static void dump_set_window_info_request
     fprintf( stderr, " user_data=%p,", req->user_data );
     fprintf( stderr, " extra_offset=%d,", req->extra_offset );
     fprintf( stderr, " extra_size=%lu,", (unsigned long)req->extra_size );
-    fprintf( stderr, " extra_value=%08x", req->extra_value );
+    fprintf( stderr, " extra_value=%08lx", req->extra_value );
 }
 
 static void dump_set_window_info_reply( const struct set_window_info_reply *req )
@@ -2373,7 +2373,7 @@ static void dump_set_window_info_reply( 
     fprintf( stderr, " old_id=%08x,", req->old_id );
     fprintf( stderr, " old_instance=%p,", req->old_instance );
     fprintf( stderr, " old_user_data=%p,", req->old_user_data );
-    fprintf( stderr, " old_extra_value=%08x", req->old_extra_value );
+    fprintf( stderr, " old_extra_value=%08lx", req->old_extra_value );
 }
 
 static void dump_set_parent_request( const struct set_parent_request *req )
-- 
1.4.0




More information about the wine-patches mailing list