user32: Make MDI get_client_info checks more strict. Take 2

Dmitry Timoshkov dmitry at codeweavers.com
Tue Jun 19 04:19:38 CDT 2007


Hello,

as pointed out by Alexandre previous version didn't pass 'make test'.

An app I have here calls DefMDIChildProc in the wndproc of every window
it creates, even of a top level one.

Changelog:
    user32: Make MDI get_client_info checks more strict.

---
 dlls/user32/mdi.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c
index 5825220..25f111b 100644
--- a/dlls/user32/mdi.c
+++ b/dlls/user32/mdi.c
@@ -202,13 +202,15 @@ static MDICLIENTINFO *get_client_info( HWND client )
     WND *win = WIN_GetPtr( client );
     if (win)
     {
-        if (win == WND_OTHER_PROCESS)
+        if (win == WND_OTHER_PROCESS || win == WND_DESKTOP)
         {
-            if (IsWindow(client)) ERR( "client %p belongs to other process\n", client );
+            if (IsWindow(client)) WARN( "client %p belongs to other process\n", client );
             return NULL;
         }
-        if (win->cbWndExtra < sizeof(MDICLIENTINFO)) WARN( "%p is not an MDI client\n", client );
-        else ret = (MDICLIENTINFO *)win->wExtra;
+        if (win->flags & WIN_ISMDICLIENT)
+            ret = (MDICLIENTINFO *)win->wExtra;
+        else
+            WARN( "%p is not an MDI client\n", client );
         WIN_ReleasePtr( win );
     }
     return ret;
@@ -1038,10 +1040,20 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message,
 
     TRACE("%p %04x (%s) %08lx %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
 
-    if (!(ci = get_client_info( hwnd ))) return 0;
+    if (message != WM_NCCREATE && !(ci = get_client_info( hwnd )))
+        return unicode ? DefWindowProcW( hwnd, message, wParam, lParam ) :
+                         DefWindowProcA( hwnd, message, wParam, lParam );
 
     switch (message)
     {
+      case WM_NCCREATE:
+      {
+          WND *wndPtr = WIN_GetPtr( hwnd );
+          wndPtr->flags |= WIN_ISMDICLIENT;
+          WIN_ReleasePtr( wndPtr );
+          return 1;
+      }
+
       case WM_CREATE:
       {
           /* Since we are using only cs->lpCreateParams, we can safely
@@ -1049,8 +1061,6 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message,
           LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
           WND *wndPtr = WIN_GetPtr( hwnd );
 
-          wndPtr->flags |= WIN_ISMDICLIENT;
-
 	/* Translation layer doesn't know what's in the cs->lpCreateParams
 	 * so we have to keep track of what environment we're in. */
 
-- 
1.5.1.6






More information about the wine-patches mailing list