Win64 patch 8/9 (user32)

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


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

 dlls/user/class.c              |  214 +++++++++++++++++++++++-----------------
 include/wine/server_protocol.h |    4 -
 server/trace.c                 |    4 -
 3 files changed, 126 insertions(+), 96 deletions(-)

diff --git a/dlls/user/class.c b/dlls/user/class.c
index a08d7b5..bbcaeff 100644
--- a/dlls/user/class.c
+++ b/dlls/user/class.c
@@ -102,9 +102,10 @@ inline static void release_class_ptr( CL
  *
  * Set class info with the wine server.
  */
-static BOOL set_server_info( HWND hwnd, INT offset, LONG newval )
+static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size )
 {
     BOOL ret;
+    LONG newlong;
 
     SERVER_START_REQ( set_class_info )
     {
@@ -131,8 +132,14 @@ static BOOL set_server_info( HWND hwnd, 
             assert( offset >= 0 );
             req->flags = SET_CLASS_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) )
+            {
+                newlong = (LONG) newval;
+                memcpy( &req->extra_value, &newlong, sizeof(LONG) );
+            }
+            else
+                memcpy( &req->extra_value, &newval, sizeof(LONG_PTR) );
             break;
         }
         ret = !wine_server_call_err( req );
@@ -634,12 +641,16 @@ WORD WINAPI GetClassWord( HWND hwnd, INT
 
 
 /***********************************************************************
- *		GetClassLongW (USER32.@)
+ *             CLASS_GetClassLong
+ *
+ * Implementation of GetClassLong(Ptr)A/W
  */
-DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
+static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size,
+                                     BOOL unicode )
 {
     CLASS *class;
-    DWORD retvalue = 0;
+    DWORD retdword = 0;
+    ULONG_PTR retvalue = 0;
 
     TRACE("%p %d\n", hwnd, offset);
 
@@ -652,7 +663,7 @@ DWORD WINAPI GetClassLongW( HWND hwnd, I
             req->window = hwnd;
             req->flags = 0;
             req->extra_offset = (offset >= 0) ? offset : -1;
-            req->extra_size = (offset >= 0) ? sizeof(retvalue) : 0;
+            req->extra_size = (offset >= 0) ? size : 0;
             if (!wine_server_call_err( req ))
             {
                 switch(offset)
@@ -676,13 +687,24 @@ DWORD WINAPI GetClassLongW( HWND hwnd, I
                     retvalue = reply->old_extra;
                     break;
                 case GCLP_HMODULE:
-                    retvalue = (DWORD)reply->old_instance;
+                    retvalue = (ULONG_PTR)reply->old_instance;
                     break;
                 case GCW_ATOM:
                     retvalue = reply->old_atom;
                     break;
                 default:
-                    if (offset >= 0) memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) );
+                    if (offset >= 0)
+                    {
+                        if (size == sizeof(DWORD))
+                        {
+                            memcpy( &retdword, &reply->old_extra_value,
+                                    sizeof(DWORD) );
+                            retvalue = retdword;
+                        }
+                        else
+                            memcpy( &retvalue, &reply->old_extra_value,
+                                    sizeof(ULONG_PTR) );
+                    }
                     else SetLastError( ERROR_INVALID_INDEX );
                     break;
                 }
@@ -694,8 +716,18 @@ DWORD WINAPI GetClassLongW( HWND hwnd, I
 
     if (offset >= 0)
     {
-        if (offset <= class->cbClsExtra - sizeof(LONG))
-            memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
+        if (offset <= class->cbClsExtra - size)
+        {
+            if (size == sizeof(DWORD))
+            {
+                memcpy( &retdword, (char *)(class + 1) + offset,
+                        sizeof(DWORD) );
+                retvalue = retdword;
+            }
+            else
+                memcpy( &retvalue, (char *)(class + 1) + offset,
+                        sizeof(ULONG_PTR) );
+        }
         else
             SetLastError( ERROR_INVALID_INDEX );
         release_class_ptr( class );
@@ -705,34 +737,38 @@ DWORD WINAPI GetClassLongW( HWND hwnd, I
     switch(offset)
     {
     case GCLP_HBRBACKGROUND:
-        retvalue = (DWORD)class->hbrBackground;
+        retvalue = (ULONG_PTR)class->hbrBackground;
         break;
     case GCLP_HCURSOR:
-        retvalue = (DWORD)class->hCursor;
+        retvalue = (ULONG_PTR)class->hCursor;
         break;
     case GCLP_HICON:
-        retvalue = (DWORD)class->hIcon;
+        retvalue = (ULONG_PTR)class->hIcon;
         break;
     case GCLP_HICONSM:
-        retvalue = (DWORD)class->hIconSm;
+        retvalue = (ULONG_PTR)class->hIconSm;
         break;
     case GCL_STYLE:
-        retvalue = (DWORD)class->style;
+        retvalue = (ULONG_PTR)class->style;
         break;
     case GCL_CBWNDEXTRA:
-        retvalue = (DWORD)class->cbWndExtra;
+        retvalue = (ULONG_PTR)class->cbWndExtra;
         break;
     case GCL_CBCLSEXTRA:
-        retvalue = (DWORD)class->cbClsExtra;
+        retvalue = (ULONG_PTR)class->cbClsExtra;
         break;
     case GCLP_HMODULE:
-        retvalue = (DWORD)class->hInstance;
+        retvalue = (ULONG_PTR)class->hInstance;
         break;
     case GCLP_WNDPROC:
-        retvalue = (DWORD)WINPROC_GetProc( class->winproc, TRUE );
+        retvalue = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
         break;
     case GCLP_MENUNAME:
-        retvalue = (DWORD)CLASS_GetMenuNameW( class );
+        retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
+        if (unicode)
+            retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
+        else
+            retvalue = (ULONG_PTR)CLASS_GetMenuNameA( class );
         break;
     case GCW_ATOM:
         retvalue = (DWORD)class->atomName;
@@ -747,34 +783,21 @@ DWORD WINAPI GetClassLongW( HWND hwnd, I
 
 
 /***********************************************************************
- *		GetClassLongA (USER32.@)
+ *		GetClassLongW (USER32.@)
  */
-DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
+DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
 {
-    CLASS *class;
-    DWORD retvalue;
-
-    if (offset != GCLP_WNDPROC && offset != GCLP_MENUNAME)
-        return GetClassLongW( hwnd, offset );
-
-    TRACE("%p %d\n", hwnd, offset);
-
-    if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
+    return (DWORD)CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), TRUE );
+}
 
-    if (class == CLASS_OTHER_PROCESS)
-    {
-        FIXME( "offset %d not supported on other process window %p\n", offset, hwnd );
-        SetLastError( ERROR_INVALID_HANDLE );
-        return 0;
-    }
 
-    if (offset == GCLP_WNDPROC)
-        retvalue = (DWORD)WINPROC_GetProc( class->winproc, FALSE );
-    else  /* GCL_MENUNAME */
-        retvalue = (DWORD)CLASS_GetMenuNameA( class );
 
-    release_class_ptr( class );
-    return retvalue;
+/***********************************************************************
+ *		GetClassLongA (USER32.@)
+ */
+DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
+{
+    return (DWORD)CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), FALSE );
 }
 
 
@@ -813,12 +836,17 @@ WORD WINAPI SetClassWord( HWND hwnd, INT
 
 
 /***********************************************************************
- *		SetClassLongW (USER32.@)
+ *             CLASS_SetClassLong
+ *
+ * Implementation of SetClassLong(Ptr)A/W
  */
-DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
+static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
+                                     UINT size, BOOL unicode )
 {
     CLASS *class;
-    DWORD retval = 0;
+    ULONG_PTR retval = 0;
+    DWORD retdword;
+    LONG newlong;
 
     TRACE("%p %d %lx\n", hwnd, offset, newval);
 
@@ -826,57 +854,71 @@ DWORD WINAPI SetClassLongW( HWND hwnd, I
 
     if (offset >= 0)
     {
-        if (set_server_info( hwnd, offset, newval ))
+        if (set_server_info( hwnd, offset, newval, size ))
         {
             void *ptr = (char *)(class + 1) + offset;
-            memcpy( &retval, ptr, sizeof(retval) );
-            memcpy( ptr, &newval, sizeof(newval) );
+            if ( size == sizeof(LONG) )
+            {
+                memcpy( &retdword, ptr, sizeof(DWORD) );
+                retval = retdword;
+                newlong = (LONG) newval;
+                memcpy( ptr, &newlong, sizeof(LONG) );
+            }
+            else
+            {
+                memcpy( &retval, ptr, sizeof(ULONG_PTR) );
+                memcpy( ptr, &newval, sizeof(LONG_PTR) );
+            }
         }
     }
     else switch(offset)
     {
     case GCLP_MENUNAME:
-        CLASS_SetMenuNameW( class, (LPCWSTR)newval );
+        if ( unicode )
+            CLASS_SetMenuNameW( class, (LPCWSTR)newval );
+        else
+            CLASS_SetMenuNameA( class, (LPCSTR)newval );
         retval = 0;  /* Old value is now meaningless anyway */
         break;
     case GCLP_WNDPROC:
-        retval = (DWORD)WINPROC_GetProc( class->winproc, TRUE );
-        class->winproc = WINPROC_AllocProc( NULL, (WNDPROC)newval );
+        retval = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
+        class->winproc = WINPROC_AllocProc( unicode ? NULL : (WNDPROC)newval,
+                                            unicode ? (WNDPROC)newval : NULL );
         break;
     case GCLP_HBRBACKGROUND:
-        retval = (DWORD)class->hbrBackground;
+        retval = (ULONG_PTR)class->hbrBackground;
         class->hbrBackground = (HBRUSH)newval;
         break;
     case GCLP_HCURSOR:
-        retval = (DWORD)class->hCursor;
+        retval = (ULONG_PTR)class->hCursor;
         class->hCursor = (HCURSOR)newval;
         break;
     case GCLP_HICON:
-        retval = (DWORD)class->hIcon;
+        retval = (ULONG_PTR)class->hIcon;
         class->hIcon = (HICON)newval;
         break;
     case GCLP_HICONSM:
-        retval = (DWORD)class->hIconSm;
+        retval = (ULONG_PTR)class->hIconSm;
         class->hIconSm = (HICON)newval;
         break;
     case GCL_STYLE:
-        if (!set_server_info( hwnd, offset, newval )) break;
-        retval = (DWORD)class->style;
+        if (!set_server_info( hwnd, offset, newval, sizeof(DWORD) )) break;
+        retval = (ULONG_PTR)class->style;
         class->style = newval;
         break;
     case GCL_CBWNDEXTRA:
-        if (!set_server_info( hwnd, offset, newval )) break;
-        retval = (DWORD)class->cbWndExtra;
+        if (!set_server_info( hwnd, offset, newval, sizeof(DWORD) )) break;
+        retval = (ULONG_PTR)class->cbWndExtra;
         class->cbWndExtra = newval;
         break;
     case GCLP_HMODULE:
-        if (!set_server_info( hwnd, offset, newval )) break;
+        if (!set_server_info( hwnd, offset, newval, sizeof(DWORD) )) break;
         retval = (DWORD)class->hInstance;
         class->hInstance = (HINSTANCE)newval;
         break;
     case GCW_ATOM:
-        if (!set_server_info( hwnd, offset, newval )) break;
-        retval = (DWORD)class->atomName;
+        if (!set_server_info( hwnd, offset, newval, sizeof(DWORD) )) break;
+        retval = (ULONG_PTR)class->atomName;
         class->atomName = newval;
         break;
     case GCL_CBCLSEXTRA:  /* cannot change this one */
@@ -892,32 +934,24 @@ DWORD WINAPI SetClassLongW( HWND hwnd, I
 
 
 /***********************************************************************
- *		SetClassLongA (USER32.@)
+ *		SetClassLongW (USER32.@)
  */
-DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
+DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
 {
-    CLASS *class;
-    DWORD retval;
+    TRACE("%p %d %lx\n", hwnd, offset, newval);
 
-    if (offset != GCLP_WNDPROC && offset != GCLP_MENUNAME)
-        return SetClassLongW( hwnd, offset, newval );
+    return (DWORD)CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), TRUE );
+}
 
-    TRACE("%p %d %lx\n", hwnd, offset, newval);
 
-    if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
+/***********************************************************************
+ *		SetClassLongA (USER32.@)
+ */
+DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
+{
+    TRACE("%p %d %lx\n", hwnd, offset, newval);
 
-    if (offset == GCLP_WNDPROC)
-    {
-        retval = (DWORD)WINPROC_GetProc( class->winproc, FALSE );
-        class->winproc = WINPROC_AllocProc( (WNDPROC)newval, NULL );
-    }
-    else  /* GCL_MENUNAME */
-    {
-        CLASS_SetMenuNameA( class, (LPCSTR)newval );
-        retval = 0;  /* Old value is now meaningless anyway */
-    }
-    release_class_ptr( class );
-    return retval;
+    return (DWORD)CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), FALSE );
 }
 
 
@@ -1144,8 +1178,7 @@ #endif
  */
 ULONG_PTR WINAPI GetClassLongPtrA( HWND hwnd, INT offset )
 {
-    FIXME("\n");
-    return 0;
+    return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), FALSE );
 }
 
 /***********************************************************************
@@ -1153,8 +1186,7 @@ ULONG_PTR WINAPI GetClassLongPtrA( HWND 
  */
 ULONG_PTR WINAPI GetClassLongPtrW( HWND hwnd, INT offset )
 {
-    FIXME("\n");
-    return 0;
+    return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), TRUE );
 }
 
 /***********************************************************************
@@ -1162,8 +1194,7 @@ ULONG_PTR WINAPI GetClassLongPtrW( HWND 
  */
 ULONG_PTR WINAPI SetClassLongPtrW( HWND hwnd, INT offset, LONG_PTR newval )
 {
-    FIXME("\n");
-    return 0;
+    return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), TRUE );
 }
 
 /***********************************************************************
@@ -1171,6 +1202,5 @@ ULONG_PTR WINAPI SetClassLongPtrW( HWND 
  */
 ULONG_PTR WINAPI SetClassLongPtrA( HWND hwnd, INT offset, LONG_PTR newval )
 {
-    FIXME("\n");
-    return 0;
+    return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), FALSE );
 }
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index c39f83c..dd9757a 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -3401,7 +3401,7 @@ struct set_class_info_request
     void*          instance;
     int            extra_offset;
     size_t         extra_size;
-    unsigned int   extra_value;
+    unsigned long  extra_value;
 };
 struct set_class_info_reply
 {
@@ -3411,7 +3411,7 @@ struct set_class_info_reply
     int            old_extra;
     int            old_win_extra;
     void*          old_instance;
-    unsigned int   old_extra_value;
+    unsigned long  old_extra_value;
 };
 #define SET_CLASS_ATOM      0x0001
 #define SET_CLASS_STYLE     0x0002
diff --git a/server/trace.c b/server/trace.c
index 9b5cc39..20c94c4 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -2983,7 +2983,7 @@ static void dump_set_class_info_request(
     fprintf( stderr, " instance=%p,", req->instance );
     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_class_info_reply( const struct set_class_info_reply *req )
@@ -2993,7 +2993,7 @@ static void dump_set_class_info_reply( c
     fprintf( stderr, " old_extra=%d,", req->old_extra );
     fprintf( stderr, " old_win_extra=%d,", req->old_win_extra );
     fprintf( stderr, " old_instance=%p,", req->old_instance );
-    fprintf( stderr, " old_extra_value=%08x", req->old_extra_value );
+    fprintf( stderr, " old_extra_value=%08lx", req->old_extra_value );
 }
 
 static void dump_set_clipboard_info_request( const struct set_clipboard_info_request *req )
-- 
1.4.0




More information about the wine-patches mailing list