[NTUSER] Use UserHMGetHandle macro (#6244)
authorThamatip Chitpong <thamatip.chitpong@reactos.org>
Fri, 5 Jan 2024 00:16:44 +0000 (07:16 +0700)
committerGitHub <noreply@github.com>
Fri, 5 Jan 2024 00:16:44 +0000 (07:16 +0700)
Use UserHMGetHandle macro everywhere instead of obj->head.h for consistency.

20 files changed:
win32ss/user/ntuser/accelerator.c
win32ss/user/ntuser/caret.c
win32ss/user/ntuser/clipboard.c
win32ss/user/ntuser/cursoricon.c
win32ss/user/ntuser/defwnd.c
win32ss/user/ntuser/desktop.c
win32ss/user/ntuser/focus.c
win32ss/user/ntuser/hook.c
win32ss/user/ntuser/kbdlayout.c
win32ss/user/ntuser/menu.c
win32ss/user/ntuser/message.c
win32ss/user/ntuser/msgqueue.c
win32ss/user/ntuser/painting.c
win32ss/user/ntuser/scrollbar.c
win32ss/user/ntuser/shutdown.c
win32ss/user/ntuser/simplecall.c
win32ss/user/ntuser/timer.c
win32ss/user/ntuser/windc.c
win32ss/user/ntuser/window.c
win32ss/user/ntuser/winpos.c

index d164359..da56519 100644 (file)
@@ -54,7 +54,7 @@ co_IntTranslateAccelerator(
 
     ASSERT_REFS_CO(Window);
 
-    hWnd = Window->head.h;
+    hWnd = UserHMGetHandle(Window);
 
     TRACE("IntTranslateAccelerator(hwnd %p, message %x, wParam %x, lParam %x, fVirt 0x%x, key %x, cmd %x)\n",
           hWnd, pMsg->message, pMsg->wParam, pMsg->lParam, pAccel->fVirt, pAccel->key, pAccel->cmd);
@@ -104,7 +104,7 @@ co_IntTranslateAccelerator(
     if (MenuObject)
     {
         if ((MENU_FindItem (&MenuObject, &nPos, MF_BYPOSITION)))
-            hSubMenu = MenuObject->head.h;
+            hSubMenu = UserHMGetHandle(MenuObject);
         else
             hMenu = NULL;
     }
@@ -118,7 +118,7 @@ co_IntTranslateAccelerator(
         if (MenuObject)
         {
             if ((MENU_FindItem (&MenuObject, &nPos, MF_BYPOSITION)))
-                hSubMenu = MenuObject->head.h;
+                hSubMenu = UserHMGetHandle(MenuObject);
             else
                 hMenu = NULL;
         }
@@ -331,7 +331,7 @@ UserDestroyAccelTable(PVOID Object)
         Accel->Table = NULL;
     }
 
-    UserDeleteObject(Accel->head.h, TYPE_ACCELTABLE);
+    UserDeleteObject(UserHMGetHandle(Accel), TYPE_ACCELTABLE);
     return TRUE;
 }
 
index 60594c5..67e6e6c 100644 (file)
@@ -239,7 +239,7 @@ BOOL FASTCALL co_UserHideCaret(PWND Window OPTIONAL)
    pti = PsGetCurrentThreadWin32Thread();
    ThreadQueue = pti->MessageQueue;
 
-   if(Window && ThreadQueue->CaretInfo.hWnd != Window->head.h)
+   if(Window && ThreadQueue->CaretInfo.hWnd != UserHMGetHandle(Window))
    {
       EngSetLastError(ERROR_ACCESS_DENIED);
       return FALSE;
@@ -276,7 +276,7 @@ BOOL FASTCALL co_UserShowCaret(PWND Window OPTIONAL)
    pti = PsGetCurrentThreadWin32Thread();
    ThreadQueue = pti->MessageQueue;
 
-   if(Window && ThreadQueue->CaretInfo.hWnd != Window->head.h)
+   if(Window && ThreadQueue->CaretInfo.hWnd != UserHMGetHandle(Window))
    {
       EngSetLastError(ERROR_ACCESS_DENIED);
       return FALSE;
index fc8df56..72aaaa1 100644 (file)
@@ -382,7 +382,7 @@ UserClipboardRelease(PWND pWindow)
     if (!pWinStaObj)
         return;
 
-    co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_RENDERALLFORMATS, 0, 0);
+    co_IntSendMessage(UserHMGetHandle(pWinStaObj->spwndClipOwner), WM_RENDERALLFORMATS, 0, 0);
 
     /* If the window being destroyed is the current clipboard owner... */
     if (pWindow == pWinStaObj->spwndClipOwner)
@@ -400,9 +400,9 @@ UserClipboardRelease(PWND pWindow)
         pWinStaObj->fClipboardChanged = FALSE;
         if (pWinStaObj->spwndClipViewer)
         {
-            TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
+            TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", UserHMGetHandle(pWinStaObj->spwndClipViewer));
             // For 32-bit applications this message is sent as a notification
-            co_IntSendMessageNoWait(pWinStaObj->spwndClipViewer->head.h, WM_DRAWCLIPBOARD, 0, 0);
+            co_IntSendMessageNoWait(UserHMGetHandle(pWinStaObj->spwndClipViewer), WM_DRAWCLIPBOARD, 0, 0);
         }
     }
 
@@ -572,9 +572,9 @@ UserCloseClipboard(VOID)
         pWinStaObj->fClipboardChanged = FALSE;
         if (pWinStaObj->spwndClipViewer)
         {
-            TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
+            TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", UserHMGetHandle(pWinStaObj->spwndClipViewer));
             // For 32-bit applications this message is sent as a notification
-            co_IntSendMessageNoWait(pWinStaObj->spwndClipViewer->head.h, WM_DRAWCLIPBOARD, 0, 0);
+            co_IntSendMessageNoWait(UserHMGetHandle(pWinStaObj->spwndClipViewer), WM_DRAWCLIPBOARD, 0, 0);
         }
     }
 
@@ -610,7 +610,7 @@ NtUserGetOpenClipboardWindow(VOID)
         goto cleanup;
 
     if (pWinStaObj->spwndClipOpen)
-        hWnd = pWinStaObj->spwndClipOpen->head.h;
+        hWnd = UserHMGetHandle(pWinStaObj->spwndClipOpen);
 
     ObDereferenceObject(pWinStaObj);
 
@@ -643,7 +643,7 @@ NtUserChangeClipboardChain(HWND hWndRemove, HWND hWndNewNext)
             pWinStaObj->spwndClipViewer = UserGetWindowObject(hWndNewNext);
 
         if (pWinStaObj->spwndClipViewer)
-            bRet = (BOOL)co_IntSendMessage(pWinStaObj->spwndClipViewer->head.h, WM_CHANGECBCHAIN, (WPARAM)hWndRemove, (LPARAM)hWndNewNext);
+            bRet = (BOOL)co_IntSendMessage(UserHMGetHandle(pWinStaObj->spwndClipViewer), WM_CHANGECBCHAIN, (WPARAM)hWndRemove, (LPARAM)hWndNewNext);
     }
 
     ObDereferenceObject(pWinStaObj);
@@ -697,9 +697,9 @@ UserEmptyClipboard(VOID)
 
     if (pWinStaObj->spwndClipOwner)
     {
-        TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
+        TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", UserHMGetHandle(pWinStaObj->spwndClipOwner));
         // For 32-bit applications this message is sent as a notification
-        co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0);
+        co_IntSendMessage(UserHMGetHandle(pWinStaObj->spwndClipOwner), WM_DESTROYCLIPBOARD, 0, 0);
     }
 
     pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
@@ -786,7 +786,7 @@ NtUserGetClipboardOwner(VOID)
         goto cleanup;
 
     if (pWinStaObj->spwndClipOwner)
-        hWnd = pWinStaObj->spwndClipOwner->head.h;
+        hWnd = UserHMGetHandle(pWinStaObj->spwndClipOwner);
 
     ObDereferenceObject(pWinStaObj);
 
@@ -809,7 +809,7 @@ NtUserGetClipboardViewer(VOID)
         goto cleanup;
 
     if (pWinStaObj->spwndClipViewer)
-        hWnd = pWinStaObj->spwndClipViewer->head.h;
+        hWnd = UserHMGetHandle(pWinStaObj->spwndClipViewer);
 
     ObDereferenceObject(pWinStaObj);
 
@@ -966,7 +966,7 @@ NtUserGetClipboardData(UINT fmt, PGETCLIPBDATA pgcd)
     {
         /* Send WM_RENDERFORMAT message */
         pWinStaObj->fInDelayedRendering = TRUE;
-        co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_RENDERFORMAT, (WPARAM)uSourceFmt, 0);
+        co_IntSendMessage(UserHMGetHandle(pWinStaObj->spwndClipOwner), WM_RENDERFORMAT, (WPARAM)uSourceFmt, 0);
         pWinStaObj->fInDelayedRendering = FALSE;
 
         /* Data should be in clipboard now */
@@ -1133,7 +1133,7 @@ NtUserSetClipboardViewer(HWND hWndNewViewer)
     /* Return previous viewer. New viever window should
        send messages to rest of the chain */
     if (pWinStaObj->spwndClipViewer)
-        hWndNext = pWinStaObj->spwndClipViewer->head.h;
+        hWndNext = UserHMGetHandle(pWinStaObj->spwndClipViewer);
 
     /* Set new viewer window */
     pWinStaObj->spwndClipViewer = pWindow;
@@ -1142,9 +1142,9 @@ NtUserSetClipboardViewer(HWND hWndNewViewer)
     pWinStaObj->fClipboardChanged = FALSE;
     if (pWinStaObj->spwndClipViewer)
     {
-        TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
+        TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", UserHMGetHandle(pWinStaObj->spwndClipViewer));
         // For 32-bit applications this message is sent as a notification
-        co_IntSendMessageNoWait(pWinStaObj->spwndClipViewer->head.h, WM_DRAWCLIPBOARD, 0, 0);
+        co_IntSendMessageNoWait(UserHMGetHandle(pWinStaObj->spwndClipViewer), WM_DRAWCLIPBOARD, 0, 0);
     }
 
 cleanup:
index 1c51605..6560a44 100644 (file)
@@ -324,7 +324,7 @@ IntDestroyCurIconObject(
 
     /* We just mark the handle as being destroyed.
      * Deleting all the stuff will be deferred to the actual struct free. */
-    UserDeleteObject(CurIcon->head.h, TYPE_CURSOR);
+    UserDeleteObject(UserHMGetHandle(CurIcon), TYPE_CURSOR);
     return TRUE;
 }
 
@@ -659,7 +659,7 @@ NtUserGetCursorInfo(
 
     SafeCi.cbSize = sizeof(CURSORINFO);
     SafeCi.flags = ((CurIcon && CurInfo->ShowingCursor >= 0) ? CURSOR_SHOWING : 0);
-    SafeCi.hCursor = (CurIcon ? CurIcon->head.h : NULL);
+    SafeCi.hCursor = (CurIcon ? UserHMGetHandle(CurIcon) : NULL);
 
     SafeCi.ptScreenPos = gpsi->ptCursor;
 
@@ -973,7 +973,7 @@ NtUserFindExistingCursorIcon(
         }
     }
     if (CurIcon)
-        Ret = CurIcon->head.h;
+        Ret = UserHMGetHandle(CurIcon);
     UserLeave();
 
 done:
@@ -2145,7 +2145,7 @@ NtUserGetCursorFrameInfo(
         return NULL;
     }
 
-    ret = CurIcon->head.h;
+    ret = UserHMGetHandle(CurIcon);
 
     if (CurIcon->CURSORF_flags & CURSORF_ACON)
     {
@@ -2158,7 +2158,7 @@ NtUserGetCursorFrameInfo(
         }
         jiffies = AniCurIcon->ajifRate[istep];
         steps = AniCurIcon->cicur;
-        ret = AniCurIcon->aspcur[AniCurIcon->aicur[istep]]->head.h;
+        ret = UserHMGetHandle(AniCurIcon->aspcur[AniCurIcon->aicur[istep]]);
     }
 
     _SEH2_TRY
index 8305006..a9f4aa0 100644 (file)
@@ -613,7 +613,7 @@ IntDefWindowProc(
 
       case WM_SYSCOMMAND:
       {
-         TRACE("hwnd %p WM_SYSCOMMAND %lx %lx\n", Wnd->head.h, wParam, lParam );
+         TRACE("hwnd %p WM_SYSCOMMAND %lx %lx\n", UserHMGetHandle(Wnd), wParam, lParam );
          lResult = DefWndHandleSysCommand(Wnd, wParam, lParam);
          break;
       }
@@ -1285,7 +1285,7 @@ IntDefWindowProc(
                   _SEH2_END;
                }
                if (!lResult)
-                  lResult = co_HOOK_CallHooks(WH_CBT, HCBT_MOVESIZE, (WPARAM)Wnd->head.h, lParam ? (LPARAM)&rt : 0);
+                  lResult = co_HOOK_CallHooks(WH_CBT, HCBT_MOVESIZE, (WPARAM)UserHMGetHandle(Wnd), lParam ? (LPARAM)&rt : 0);
            }
             break;
          }
index c3ac7e0..6ccb291 100644 (file)
@@ -1405,7 +1405,7 @@ HWND FASTCALL IntGetMessageWindow(VOID)
         TRACE("No active desktop\n");
         return NULL;
     }
-    return pdo->spwndMessage->head.h;
+    return UserHMGetHandle(pdo->spwndMessage);
 }
 
 // Win: _GetMessageWindow
@@ -2458,7 +2458,7 @@ IntCreateDesktop(
     }
 
     pdesk->dwSessionId = PsGetCurrentProcessSessionId();
-    pdesk->DesktopWindow = pWnd->head.h;
+    pdesk->DesktopWindow = UserHMGetHandle(pWnd);
     pdesk->pDeskInfo->spwnd = pWnd;
     pWnd->fnid = FNID_DESKTOP;
 
index 2d6ed37..108ef84 100644 (file)
@@ -789,7 +789,7 @@ co_IntSetForegroundMessageQueue(
       ptiChg = Wnd->head.pti;
       IntSetFocusMessageQueue(Wnd->head.pti->MessageQueue);
       gptiForeground = Wnd->head.pti;
-      //ERR("Set Foreground pti 0x%p Q 0x%p hWnd 0x%p\n",Wnd->head.pti, Wnd->head.pti->MessageQueue,Wnd->head.h);
+      //ERR("Set Foreground pti 0x%p Q 0x%p hWnd 0x%p\n", Wnd->head.pti, Wnd->head.pti->MessageQueue, UserHMGetHandle(Wnd));
    }
    else
    {
@@ -879,7 +879,7 @@ co_IntSetForegroundMessageQueue(
               }
               else
               {
-                 //ERR("SFWAMQ : SAW I pti 0x%p hWnd 0x%p\n",ptiChg,Wnd->head.h);
+                 //ERR("SFWAMQ : SAW I pti 0x%p hWnd 0x%p\n", ptiChg, Wnd ? UserHMGetHandle(Wnd) : NULL);
                  Ret = co_IntSetActiveWindow(Wnd, MouseActivate, TRUE/*Type*/, FALSE);
                  //if (!Ret) ERR("SFWAMQ : ISAW : return error\n");
                  return Ret;
@@ -898,7 +898,7 @@ co_IntSetForegroundMessageQueue(
       if ( pumqPrev && pumq == pumqPrev )
       {
           HANDLE tid = Wnd ? PsGetThreadId(Wnd->head.pti->pEThread) : NULL;
-          //ERR("SFWAMQ : DAW I pti 0x%p tid 0x%p hWnd 0x%p\n",ptiPrev,tid,Wnd ? Wnd->head.h : 0);
+          //ERR("SFWAMQ : DAW I pti 0x%p tid 0x%p hWnd 0x%p\n", ptiPrev, tid, Wnd ? UserHMGetHandle(Wnd) : NULL);
           IntDeactivateWindow(pti, tid);
       }
    }
@@ -1287,7 +1287,7 @@ UserSetActiveWindow( _In_opt_ PWND Wnd )
       !(gpqForegroundPrev->spwndActivePrev->state2 & WNDS2_BOTTOMMOST) &&
        (Wnd = VerifyWnd(gpqForegroundPrev->spwndActivePrev)) != NULL )
   {
-     TRACE("USAW:PAW hwnd %p\n",Wnd?Wnd->head.h:NULL);
+     TRACE("USAW:PAW hwnd %p\n", UserHMGetHandle(Wnd));
      return IntUserSetActiveWindow(Wnd, FALSE, TRUE, FALSE);
   }
 
@@ -1295,7 +1295,7 @@ UserSetActiveWindow( _In_opt_ PWND Wnd )
   if ( pti->MessageQueue->spwndActive &&
       (Wnd = VerifyWnd(pti->MessageQueue->spwndActive)) != NULL )
   {
-      //ERR("USAW:AOWM hwnd %p\n",Wnd?Wnd->head.h:NULL);
+      //ERR("USAW:AOWM hwnd %p\n", UserHMGetHandle(Wnd));
       if (!ActivateOtherWindowMin(Wnd))
       {
          // Okay, now go find someone else to play with!
@@ -1351,7 +1351,7 @@ co_UserSetFocus(PWND Window)
          if (pwndTop->spwndParent == NULL) break;
       }
       ////
-      if (co_HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)Window->head.h, (LPARAM)hWndPrev))
+      if (co_HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)UserHMGetHandle(Window), (LPARAM)hWndPrev))
       {
          ERR("SetFocus 1 WH_CBT Call Hook return!\n");
          return 0;
@@ -1401,7 +1401,7 @@ co_UserSetFocus(PWND Window)
 
       IntSendFocusMessages( pti, Window);
 
-      TRACE("Focus: %p -> %p\n", hWndPrev, Window->head.h);
+      TRACE("Focus: %p -> %p\n", hWndPrev, UserHMGetHandle(Window));
    }
    else /* NULL hwnd passed in */
    {
index b9da033..dd92e69 100644 (file)
@@ -982,7 +982,7 @@ IntGetGlobalHookHandles(PDESKTOP pdo, int HookId)
     {
         pHook = CONTAINING_RECORD(pElem, HOOK, Chain);
         NT_ASSERT(i < cHooks);
-        pList[i++] = pHook->head.h;
+        pList[i++] = UserHMGetHandle(pHook);
     }
     pList[i] = NULL;
 
index 33875c2..4efe2ee 100644 (file)
@@ -362,7 +362,7 @@ cleanup:
     {
         /* We have failed - destroy created object */
         if (pkf)
-            UserDeleteObject(pkf->head.h, TYPE_KBDFILE);
+            UserDeleteObject(UserHMGetHandle(pkf), TYPE_KBDFILE);
     }
 
     return pRet;
@@ -398,7 +398,7 @@ co_UserLoadKbdLayout(PUNICODE_STRING pustrKLID, HKL hKL)
     if (!pKl->spkf)
     {
         ERR("UserLoadKbdFile(%wZ) failed!\n", pustrKLID);
-        UserDeleteObject(pKl->head.h, TYPE_KBDLAYOUT);
+        UserDeleteObject(UserHMGetHandle(pKl), TYPE_KBDLAYOUT);
         return NULL;
     }
 
@@ -406,7 +406,7 @@ co_UserLoadKbdLayout(PUNICODE_STRING pustrKLID, HKL hKL)
     if (!NT_SUCCESS(RtlUnicodeStringToInteger(pustrKLID, 16, (PULONG)&lCid)))
     {
         ERR("RtlUnicodeStringToInteger failed for '%wZ'\n", pustrKLID);
-        UserDeleteObject(pKl->head.h, TYPE_KBDLAYOUT);
+        UserDeleteObject(UserHMGetHandle(pKl), TYPE_KBDLAYOUT);
         return NULL;
     }
 
@@ -461,7 +461,7 @@ UnloadKbdFile(_In_ PKBDFILE pkf)
         *ppkfLink = pkf->pkfNext;
 
     EngUnloadImage(pkf->hBase);
-    UserDeleteObject(pkf->head.h, TYPE_KBDFILE);
+    UserDeleteObject(UserHMGetHandle(pkf), TYPE_KBDFILE);
 }
 
 /*
@@ -501,7 +501,7 @@ UserUnloadKbl(PKL pKl)
     {
         ExFreePoolWithTag(pKl->piiex, USERTAG_IME);
     }
-    UserDeleteObject(pKl->head.h, TYPE_KBDLAYOUT);
+    UserDeleteObject(UserHMGetHandle(pKl), TYPE_KBDLAYOUT);
     return TRUE;
 }
 
index 1f09af6..a9aace7 100644 (file)
@@ -347,7 +347,7 @@ IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
          /* Remove all menu items */
          IntDestroyMenu( Menu, bRecurse);
 
-         ret = UserDeleteObject(Menu->head.h, TYPE_MENU);
+         ret = UserDeleteObject(UserHMGetHandle(Menu), TYPE_MENU);
          TRACE("IntDestroyMenuObject %d\n",ret);
          return ret;
       }
@@ -903,7 +903,7 @@ IntGetMenuInfo(PMENU Menu, PROSMENUINFO lpmi)
      lpmi->dwArrowsOn = Menu->dwArrowsOn;
 
      lpmi->fFlags = Menu->fFlags;
-     lpmi->Self = Menu->head.h;
+     lpmi->Self = UserHMGetHandle(Menu);
      lpmi->TimeToHide = Menu->TimeToHide;
      lpmi->Wnd = Menu->hWnd;
    }
@@ -991,7 +991,7 @@ IntGetMenuItemInfo(PMENU Menu, /* UNUSED PARAM!! */
    }
    if(lpmii->fMask & MIIM_SUBMENU)
    {
-      lpmii->hSubMenu = MenuItem->spSubMenu ? MenuItem->spSubMenu->head.h : NULL;
+      lpmii->hSubMenu = (MenuItem->spSubMenu ? UserHMGetHandle(MenuItem->spSubMenu) : NULL);
    }
 
    if ((lpmii->fMask & MIIM_STRING) ||
@@ -5939,7 +5939,7 @@ NtUserGetMenuBarInfo(
         {
            if (UserHMGetHandle(pPopupMenu->spmenu) != hMenu)
            {
-              ERR("Window Pop Up hMenu %p not the same as Get hMenu %p!\n",pPopupMenu->spmenu->head.h,hMenu);
+              ERR("Window Pop Up hMenu %p not the same as Get hMenu %p!\n", UserHMGetHandle(pPopupMenu->spmenu), hMenu);
            }
         }
         break;
index 92d0019..ce9da97 100644 (file)
@@ -777,7 +777,7 @@ static LRESULT handle_internal_message( PWND pWnd, UINT msg, WPARAM wparam, LPAR
     if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
        return 0;
 
-    TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, pWnd->head.h);
+    TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, UserHMGetHandle(pWnd));
 
     switch(msg)
     {
@@ -1377,7 +1377,7 @@ UserPostMessage( HWND Wnd,
 
         if (List != NULL)
         {
-            UserPostMessage(DesktopWindow->head.h, Msg, wParam, lParam);
+            UserPostMessage(UserHMGetHandle(DesktopWindow), Msg, wParam, lParam);
             for (i = 0; List[i]; i++)
             {
                 PWND pwnd = UserGetWindowObject(List[i]);
@@ -1683,7 +1683,7 @@ co_IntSendMessageTimeout( HWND hWnd,
     if (hWnd != HWND_TOPMOST)
     {
        /* Send message to the desktop window too! */
-       co_IntSendMessageTimeoutSingle(DesktopWindow->head.h, Msg, wParam, lParam, uFlags, uTimeout, uResult);
+       co_IntSendMessageTimeoutSingle(UserHMGetHandle(DesktopWindow), Msg, wParam, lParam, uFlags, uTimeout, uResult);
     }
 
     Children = IntWinListChildren(DesktopWindow);
@@ -2062,7 +2062,7 @@ UserSendNotifyMessage( HWND hWnd,
 
         if (List != NULL)
         {
-            UserSendNotifyMessage(DesktopWindow->head.h, Msg, wParam, lParam);
+            UserSendNotifyMessage(UserHMGetHandle(DesktopWindow), Msg, wParam, lParam);
             for (i = 0; List[i]; i++)
             {
                PWND pwnd = UserGetWindowObject(List[i]);
index a808073..bcec001 100644 (file)
@@ -634,7 +634,7 @@ co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook
    else
    {
        pwnd = IntTopLevelWindowFromPoint(Msg->pt.x, Msg->pt.y);
-       if (pwnd) Msg->hwnd = pwnd->head.h;
+       if (pwnd) Msg->hwnd = UserHMGetHandle(pwnd);
    }
 
    hdcScreen = IntGetScreenDC();
@@ -813,7 +813,7 @@ MsqRemoveWindowMessagesFromQueue(PWND Window)
    {
       PostedMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
 
-      if (PostedMessage->Msg.hwnd == Window->head.h)
+      if (PostedMessage->Msg.hwnd == UserHMGetHandle(Window))
       {
          if (PostedMessage->Msg.message == WM_QUIT && pti->QuitPosted == 0)
          {
@@ -837,7 +837,7 @@ MsqRemoveWindowMessagesFromQueue(PWND Window)
    {
       SentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE, ListEntry);
 
-      if(SentMessage->Msg.hwnd == Window->head.h)
+      if(SentMessage->Msg.hwnd == UserHMGetHandle(Window))
       {
          ERR("Remove Window Messages %p From Sent Queue\n",SentMessage);
 #if 0 // Should mark these as invalid and allow the rest clean up, so far no harm by just commenting out. See CORE-9210.
@@ -1984,7 +1984,7 @@ co_MsqPeekHardwareMessage(IN PTHREADINFO pti,
  */
       if ( ( !Window || // 1
             ( Window == PWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2
-            ( Window != PWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) || // 3
+            ( Window != PWND_BOTTOM && UserHMGetHandle(Window) == CurrentMessage->Msg.hwnd ) || // 3
             ( is_mouse_message(CurrentMessage->Msg.message) ) ) && // Null window for anything mouse.
             ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) ||
               ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
@@ -2072,7 +2072,7 @@ MsqPeekMessage(IN PTHREADINFO pti,
  */
       if ( ( !Window || // 1
             ( Window == PWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2
-            ( Window != PWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) ) && // 3
+            ( Window != PWND_BOTTOM && UserHMGetHandle(Window) == CurrentMessage->Msg.hwnd ) ) && // 3
             ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) ||
               ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
       {
index a79a631..e6fb2d6 100644 (file)
@@ -403,7 +403,7 @@ VOID FASTCALL
 co_IntPaintWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
 {
    HDC hDC;
-   HWND hWnd = Wnd->head.h;
+   HWND hWnd = UserHMGetHandle(Wnd);
    HRGN TempRegion = NULL;
 
    Wnd->state &= ~WNDS_PAINTNOTPROCESSED;
@@ -518,7 +518,7 @@ co_IntPaintWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
 VOID FASTCALL
 co_IntUpdateWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
 {
-   HWND hWnd = Wnd->head.h;
+   HWND hWnd = UserHMGetHandle(Wnd);
 
    if ( Wnd->hrgnUpdate != NULL || Wnd->state & WNDS_INTERNALPAINT )
    {
index 0f1173b..ee737d5 100644 (file)
@@ -761,7 +761,7 @@ co_IntCreateScrollBars(PWND Window)
    Size = 3 * (sizeof(SBINFOEX));
    if(!(Window->pSBInfoex = ExAllocatePoolWithTag(PagedPool, Size, TAG_SBARINFO)))
    {
-      ERR("Unable to allocate memory for scrollbar information for window %p\n", Window->head.h);
+      ERR("Unable to allocate memory for scrollbar information for window %p\n", UserHMGetHandle(Window));
       return FALSE;
    }
 
@@ -769,7 +769,7 @@ co_IntCreateScrollBars(PWND Window)
 
    if(!(Window->pSBInfo = DesktopHeapAlloc(Window->head.rpdesk, sizeof(SBINFO))))
    {
-      ERR("Unable to allocate memory for scrollbar information for window %p\n", Window->head.h);
+      ERR("Unable to allocate memory for scrollbar information for window %p\n", UserHMGetHandle(Window));
       return FALSE;
    }
 
index 860db7c..d7a15e9 100644 (file)
@@ -46,7 +46,7 @@ IntClientShutdown(IN PWND pWindow,
 
             if (wParam & MCS_QUERYENDSESSION)
             {
-                if (!co_IntSendMessage(WndChild->head.h, WM_QUERYENDSESSION, 0, lParams))
+                if (!co_IntSendMessage(UserHMGetHandle(WndChild), WM_QUERYENDSESSION, 0, lParams))
                 {
                     lResult = MCSR_DONOTSHUTDOWN;
                     break;
@@ -54,7 +54,7 @@ IntClientShutdown(IN PWND pWindow,
             }
             else
             {
-                co_IntSendMessage(WndChild->head.h, WM_ENDSESSION, KillTimers, lParams);
+                co_IntSendMessage(UserHMGetHandle(WndChild), WM_ENDSESSION, KillTimers, lParams);
                 if (KillTimers)
                 {
                     DestroyTimersForWindow(WndChild->head.pti, WndChild);
@@ -70,14 +70,14 @@ IntClientShutdown(IN PWND pWindow,
     /* Send to the caller */
     if (wParam & MCS_QUERYENDSESSION)
     {
-        if (!co_IntSendMessage(pWindow->head.h, WM_QUERYENDSESSION, 0, lParams))
+        if (!co_IntSendMessage(UserHMGetHandle(pWindow), WM_QUERYENDSESSION, 0, lParams))
         {
             lResult = MCSR_DONOTSHUTDOWN;
         }
     }
     else
     {
-        co_IntSendMessage(pWindow->head.h, WM_ENDSESSION, KillTimers, lParams);
+        co_IntSendMessage(UserHMGetHandle(pWindow), WM_ENDSESSION, KillTimers, lParams);
         if (KillTimers)
         {
             DestroyTimersForWindow(pWindow->head.pti, pWindow);
index 6cfcf8e..05ba8d0 100644 (file)
@@ -540,7 +540,7 @@ NtUserCallTwoParam(
 
             if (fAltTab && (Window->style & WS_MINIMIZE))
             {
-                MSG msg = { Window->head.h, WM_SYSCOMMAND, SC_RESTORE, 0 };
+                MSG msg = { UserHMGetHandle(Window), WM_SYSCOMMAND, SC_RESTORE, 0 };
                 MsqPostMessage(Window->head.pti, &msg, FALSE, QS_POSTMESSAGE, 0, 0);
             }
             break;
index df1ebb0..4a9fd3c 100644 (file)
@@ -411,7 +411,7 @@ PostTimerMessages(PWND Window)
           (pTmr->pti == pti) &&
           ((pTmr->pWnd == Window) || (Window == NULL)) )
         {
-           Msg.hwnd    = (pTmr->pWnd) ? pTmr->pWnd->head.h : 0;
+           Msg.hwnd    = (pTmr->pWnd ? UserHMGetHandle(pTmr->pWnd) : NULL);
            Msg.message = (pTmr->flags & TMRF_SYSTEM) ? WM_SYSTIMER : WM_TIMER;
            Msg.wParam  = (WPARAM) pTmr->nID;
            Msg.lParam  = (LPARAM) pTmr->pfn;
index 40163ad..a80ea2a 100644 (file)
@@ -99,7 +99,7 @@ DceAllocDCE(PWND Window OPTIONAL, DCE_TYPE Type)
   }
   DCECount++;
   TRACE("Alloc DCE's! %d\n",DCECount);
-  pDce->hwndCurrent = (Window ? Window->head.h : NULL);
+  pDce->hwndCurrent = (Window ? UserHMGetHandle(Window) : NULL);
   pDce->pwndOrg  = Window;
   pDce->pwndClip = Window;
   pDce->hrgnClip = NULL;
@@ -215,7 +215,7 @@ DceUpdateVisRgn(DCE *Dce, PWND Window, ULONG Flags)
       {
          DcxFlags = Flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW);
       }
-      RgnVisible = DceGetVisRgn(Parent, DcxFlags, Window->head.h, Flags);
+      RgnVisible = DceGetVisRgn(Parent, DcxFlags, UserHMGetHandle(Window), Flags);
    }
    else if (Window == NULL)
    {
@@ -470,7 +470,7 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
             {
                DceEmpty = Dce;
             }
-            else if (Dce->hwndCurrent == (Wnd ? Wnd->head.h : NULL) &&
+            else if (Dce->hwndCurrent == (Wnd ? UserHMGetHandle(Wnd) : NULL) &&
                      ((Dce->DCXFlags & DCX_CACHECOMPAREMASK) == DcxFlags))
             {
                UpdateClipOrigin = TRUE;
@@ -489,7 +489,7 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       }
       if (Dce == NULL) return NULL;
 
-      Dce->hwndCurrent = (Wnd ? Wnd->head.h : NULL);
+      Dce->hwndCurrent = (Wnd ? UserHMGetHandle(Wnd) : NULL);
       Dce->pwndOrg = Dce->pwndClip = Wnd;
    }
    else // If we are here, we are POWNED or having CLASS.
@@ -505,7 +505,7 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
           if (!(Dce->DCXFlags & DCX_CACHE))
           {
              // Check for Window handle than HDC match for CLASS.
-             if (Dce->hwndCurrent == Wnd->head.h)
+             if (Dce->hwndCurrent == UserHMGetHandle(Wnd))
              {
                 bUpdateVisRgn = FALSE;
                 break;
@@ -699,7 +699,7 @@ DceFreeWindowDCE(PWND Window)
   {
      pDCE = CONTAINING_RECORD(ListEntry, DCE, List);
      ListEntry = ListEntry->Flink;
-     if ( pDCE->hwndCurrent == Window->head.h &&
+     if ( pDCE->hwndCurrent == UserHMGetHandle(Window) &&
           !(pDCE->DCXFlags & DCX_DCEEMPTY) )
      {
         if (!(pDCE->DCXFlags & DCX_CACHE)) /* Owned or Class DCE */
@@ -747,7 +747,7 @@ DceFreeWindowDCE(PWND Window)
                * We should change this to TRACE when ReactOS is more stable
                * (for 1.0?).
                */
-              ERR("[%p] GetDC() without ReleaseDC()!\n", Window->head.h);
+              ERR("[%p] GetDC() without ReleaseDC()!\n", UserHMGetHandle(Window));
               DceReleaseDC(pDCE, FALSE);
            }
            pDCE->DCXFlags |= DCX_DCEEMPTY;
@@ -834,7 +834,7 @@ DceResetActiveDCEs(PWND Window)
       ListEntry = ListEntry->Flink;
       if (0 == (pDCE->DCXFlags & (DCX_DCEEMPTY|DCX_INDESTROY)))
       {
-         if (Window->head.h == pDCE->hwndCurrent)
+         if (UserHMGetHandle(Window) == pDCE->hwndCurrent)
          {
             CurrentWindow = Window;
          }
index 9cfa7d4..49200a5 100644 (file)
@@ -295,7 +295,7 @@ IntWinListChildren(PWND Window)
     Index = 0;
     for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
     {
-        List[Index++] = Child->head.h;
+        List[Index++] = UserHMGetHandle(Child);
     }
     List[Index] = NULL;
 
@@ -340,7 +340,7 @@ IntWinListOwnedPopups(PWND Window)
     for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
     {
         if (Child->spwndOwner == Window && !IntWndIsDefaultIme(Child))
-            List[Index++] = Child->head.h;
+            List[Index++] = UserHMGetHandle(Child);
     }
     List[Index] = NULL;
 
@@ -657,10 +657,10 @@ LRESULT co_UserFreeWindow(PWND Window,
    /* reset shell window handles */
    if (ThreadData->rpdesk)
    {
-      if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
+      if (UserHMGetHandle(Window) == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
          ThreadData->rpdesk->rpwinstaParent->ShellWindow = NULL;
 
-      if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellListView)
+      if (UserHMGetHandle(Window) == ThreadData->rpdesk->rpwinstaParent->ShellListView)
          ThreadData->rpdesk->rpwinstaParent->ShellListView = NULL;
    }
 
@@ -1342,7 +1342,7 @@ co_UserSetParent(HWND hWndChild, HWND hWndNewParent)
 
    if (WndOldParent)
    {
-      hWndOldParent = WndOldParent->head.h;
+      hWndOldParent = UserHMGetHandle(WndOldParent);
       UserDereferenceObject(WndOldParent);
    }
 
@@ -1579,7 +1579,7 @@ NtUserBuildHwndList(
                   _SEH2_TRY
                   {
                      ProbeForWrite(phwndList, sizeof(HWND), 1);
-                     *phwndList = Window->head.h;
+                     *phwndList = UserHMGetHandle(Window);
                      phwndList++;
                   }
                   _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -1657,7 +1657,7 @@ NtUserBuildHwndList(
                   _SEH2_TRY
                   {
                      ProbeForWrite(phwndList, sizeof(HWND), 1);
-                     *phwndList = Window->head.h;
+                     *phwndList = UserHMGetHandle(Window);
                      phwndList++;
                   }
                   _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -1698,10 +1698,10 @@ static void IntSendParentNotify( PWND pWindow, UINT msg )
         {
             USER_REFERENCE_ENTRY Ref;
             UserRefObjectCo(pWindow->spwndParent, &Ref);
-            co_IntSendMessage( pWindow->spwndParent->head.h,
+            co_IntSendMessage( UserHMGetHandle(pWindow->spwndParent),
                                WM_PARENTNOTIFY,
                                MAKEWPARAM( msg, pWindow->IDMenu),
-                               (LPARAM)pWindow->head.h );
+                               (LPARAM)UserHMGetHandle(pWindow) );
             UserDerefObjectCo(pWindow->spwndParent);
         }
     }
@@ -2215,12 +2215,12 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs,
    }
 
    /* Now find the parent and the owner window */
-   hWndParent = pti->rpdesk->pDeskInfo->spwnd->head.h;
+   hWndParent = UserHMGetHandle(pti->rpdesk->pDeskInfo->spwnd);
    hWndOwner = NULL;
 
     if (Cs->hwndParent == HWND_MESSAGE)
     {
-        Cs->hwndParent = hWndParent = pti->rpdesk->spwndMessage->head.h;
+        Cs->hwndParent = hWndParent = UserHMGetHandle(pti->rpdesk->spwndMessage);
     }
     else if (Cs->hwndParent)
     {
@@ -2470,7 +2470,7 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs,
 
    Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
    //rc = Window->rcWindow;
-   //Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
+   //Result = co_IntSendMessageNoWait(UserHMGetHandle(Window), WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
    //Window->rcClient = rc;
 
    RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left,
@@ -2869,7 +2869,7 @@ BOOLEAN co_UserDestroyWindow(PVOID Object)
       return TRUE;
    }
 
-   hWnd = Window->head.h;
+   hWnd = UserHMGetHandle(Window);
    ti = PsGetCurrentThreadWin32Thread();
 
    TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
@@ -3078,7 +3078,7 @@ IntFindWindow(PWND Parent,
       if(ChildAfter)
       {
          /* skip handles before and including ChildAfter */
-         while(*phWnd && (*(phWnd++) != ChildAfter->head.h))
+         while(*phWnd && (*(phWnd++) != UserHMGetHandle(ChildAfter)))
             ;
       }
 
@@ -3104,7 +3104,7 @@ IntFindWindow(PWND Parent,
                 (Child->strName.Length < 0xFFFF &&
                  !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
              {
-                Ret = Child->head.h;
+                Ret = UserHMGetHandle(Child);
                 break;
              }
          }
@@ -3241,7 +3241,7 @@ NtUserFindWindowEx(HWND hwndParent,
 
    _SEH2_TRY
    {
-       if(Parent->head.h == Desktop)
+       if(UserHMGetHandle(Parent) == Desktop)
        {
           HWND *List, *phWnd;
           PWND TopLevelWindow;
@@ -3259,7 +3259,7 @@ NtUserFindWindowEx(HWND hwndParent,
              if(ChildAfter)
              {
                 /* skip handles before and including ChildAfter */
-                while(*phWnd && (*(phWnd++) != ChildAfter->head.h))
+                while(*phWnd && (*(phWnd++) != UserHMGetHandle(ChildAfter)))
                    ;
              }
 
@@ -3289,7 +3289,7 @@ NtUserFindWindowEx(HWND hwndParent,
 
                 if (WindowMatches && ClassMatches)
                 {
-                   Ret = TopLevelWindow->head.h;
+                   Ret = UserHMGetHandle(TopLevelWindow);
                    break;
                 }
 
@@ -3297,7 +3297,7 @@ NtUserFindWindowEx(HWND hwndParent,
                 {
                    /* window returns the handle of the top-level window, in case it found
                       the child window */
-                   Ret = TopLevelWindow->head.h;
+                   Ret = UserHMGetHandle(TopLevelWindow);
                    break;
                 }
 
@@ -3342,7 +3342,7 @@ PWND FASTCALL UserGetAncestor(PWND Wnd, UINT Type)
 {
    PWND WndAncestor, Parent;
 
-   if (Wnd->head.h == IntGetDesktopWindow())
+   if (UserHMGetHandle(Wnd) == IntGetDesktopWindow())
    {
       return NULL;
    }
@@ -3989,10 +3989,10 @@ co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULO
 
          case GWLP_HWNDPARENT: // LONG_PTR
             Parent = Window->spwndParent;
-            if (Parent && (Parent->head.h == IntGetDesktopWindow()))
-               OldValue = (LONG_PTR) IntSetOwner(Window->head.h, (HWND) NewValue);
+            if (Parent && (UserHMGetHandle(Parent) == IntGetDesktopWindow()))
+               OldValue = (LONG_PTR)IntSetOwner(UserHMGetHandle(Window), (HWND)NewValue);
             else
-               OldValue = (LONG_PTR) co_UserSetParent(Window->head.h, (HWND) NewValue);
+               OldValue = (LONG_PTR)co_UserSetParent(UserHMGetHandle(Window), (HWND)NewValue);
             break;
 
          case GWLP_ID: // LONG
index ccba1ab..80984a1 100644 (file)
@@ -289,7 +289,7 @@ BOOL FASTCALL ActivateOtherWindowMin(PWND Wnd)
     USER_REFERENCE_ENTRY Ref;
     PTHREADINFO pti = gptiCurrent;
 
-    //ERR("AOWM 1 %p\n",Wnd->head.h);
+    //ERR("AOWM 1 %p\n", UserHMGetHandle(Wnd));
     ActivePrev = (pti->MessageQueue->spwndActivePrev != NULL);
     FindTopWnd = TRUE;
 
@@ -320,7 +320,7 @@ BOOL FASTCALL ActivateOtherWindowMin(PWND Wnd)
                 //ERR("ActivateOtherWindowMin Set FG 1\n");
                 co_IntSetForegroundWindow(pWndSetActive);
                 UserDerefObjectCo(pWndSetActive);
-                //ERR("AOWM 2 Exit Good %p\n",pWndSetActive->head.h);
+                //ERR("AOWM 2 Exit Good %p\n", UserHMGetHandle(pWndSetActive));
                 return TRUE;
              }
              if (!pWndTemp ) pWndTemp = pWndSetActive;
@@ -357,7 +357,7 @@ BOOL FASTCALL ActivateOtherWindowMin(PWND Wnd)
        //ERR("ActivateOtherWindowMin Set FG 2\n");
        co_IntSetForegroundWindow(pWndSetActive);
        UserDerefObjectCo(pWndSetActive);
-       //ERR("AOWM 3 Exit Good %p\n",pWndSetActive->head.h);
+       //ERR("AOWM 3 Exit Good %p\n", UserHMGetHandle(pWndSetActive));
        return TRUE;
     }
     //ERR("AOWM 4 Bad\n");
@@ -460,7 +460,7 @@ done:
    if (gpqForeground && (!gpqForeground->spwndActive || Wnd == gpqForeground->spwndActive))
    {
       /* ReactOS can pass WndTo = NULL to co_IntSetForegroundWindow and returns FALSE. */
-      //ERR("WinPosActivateOtherWindow Set FG 0x%p hWnd %p\n",WndTo, WndTo ? WndTo->head.h : 0);
+      //ERR("WinPosActivateOtherWindow Set FG 0x%p hWnd %p\n", WndTo, WndTo ? UserHMGetHandle(WndTo) : NULL);
       if (co_IntSetForegroundWindow(WndTo))
       {
          if (WndTo) UserDerefObjectCo(WndTo);
@@ -999,7 +999,7 @@ co_WinPosGetMinMaxInfo(PWND Window, POINT* MaxSize, POINT* MaxPos,
 
     if (!EMPTYPOINT(Window->InternalPos.MaxPos)) MinMax.ptMaxPosition = Window->InternalPos.MaxPos;
 
-    co_IntSendMessage(Window->head.h, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
+    co_IntSendMessage(UserHMGetHandle(Window), WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
 
     /* if the app didn't change the values, adapt them for the current monitor */
     if ((monitor = UserGetPrimaryMonitor()))
@@ -1205,7 +1205,7 @@ co_WinPosDoNCCALCSize(PWND Window, PWINDOWPOS WinPos, RECTL* WindowRect, RECTL*
       params.lppos = &winposCopy;
       winposCopy = *WinPos;
 
-      wvrFlags = co_IntSendMessage(Window->head.h, WM_NCCALCSIZE, TRUE, (LPARAM) &params);
+      wvrFlags = co_IntSendMessage(UserHMGetHandle(Window), WM_NCCALCSIZE, TRUE, (LPARAM)&params);
 
       /* If the application send back garbage, ignore it */
       if (params.rgrc[0].left <= params.rgrc[0].right &&
@@ -1276,8 +1276,8 @@ co_WinPosDoWinPosChanging(PWND Window,
    if (!(WinPos->flags & SWP_NOSENDCHANGING)
           && !((WinPos->flags & SWP_AGG_NOCLIENTCHANGE) && (WinPos->flags & SWP_SHOWWINDOW)))
    {
-      TRACE("Sending WM_WINDOWPOSCHANGING to hwnd %p flags %04x.\n", Window->head.h,WinPos->flags);
-      co_IntSendMessage(Window->head.h, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos);
+      TRACE("Sending WM_WINDOWPOSCHANGING to hwnd %p flags %04x.\n", UserHMGetHandle(Window), WinPos->flags);
+      co_IntSendMessage(UserHMGetHandle(Window), WM_WINDOWPOSCHANGING, 0, (LPARAM)WinPos);
    }
 
    /* Calculate new position and size */
@@ -1370,7 +1370,7 @@ WinPosDoOwnedPopups(PWND Window, HWND hWndInsertAfter)
       return hWndInsertAfter;
    }
 
-   Owner = Window->spwndOwner ? Window->spwndOwner->head.h : NULL;
+   Owner = (Window->spwndOwner ? UserHMGetHandle(Window->spwndOwner) : NULL);
 
    if (Owner)
    {
@@ -1491,7 +1491,7 @@ WinPosDoOwnedPopups(PWND Window, HWND hWndInsertAfter)
          if (!(Wnd = ValidateHwndNoErr(List[i])))
             continue;
 
-         Owner = Wnd->spwndOwner ? Wnd->spwndOwner->head.h : NULL;
+         Owner = (Wnd->spwndOwner ? UserHMGetHandle(Wnd->spwndOwner) : NULL);
 
          if (Owner != UserHMGetHandle(Window)) continue;
 
@@ -1671,7 +1671,7 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWND Wnd)
              * itself.
              */
             if ((WinPos->hwnd == WinPos->hwndInsertAfter) ||
-                ((InsAfterWnd->spwndNext) && (WinPos->hwnd == InsAfterWnd->spwndNext->head.h)))
+                ((InsAfterWnd->spwndNext) && (WinPos->hwnd == UserHMGetHandle(InsAfterWnd->spwndNext))))
             {
                WinPos->flags |= SWP_NOZORDER;
             }
@@ -1822,7 +1822,7 @@ co_WinPosSetWindowPos(
 
    bPointerInWindow = IntPtInWindow(Window, gpsi->ptCursor.x, gpsi->ptCursor.y);
 
-   WinPos.hwnd = Window->head.h;
+   WinPos.hwnd = UserHMGetHandle(Window);
    WinPos.hwndInsertAfter = WndInsertAfter;
    WinPos.x = x;
    WinPos.y = y;
@@ -1870,7 +1870,7 @@ co_WinPosSetWindowPos(
 
    Ancestor = UserGetAncestor(Window, GA_PARENT);
    if ( (WinPos.flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER &&
-         Ancestor && Ancestor->head.h == IntGetDesktopWindow() )
+         Ancestor && UserHMGetHandle(Ancestor) == IntGetDesktopWindow() )
    {
       WinPos.hwndInsertAfter = WinPosDoOwnedPopups(Window, WinPos.hwndInsertAfter);
    }
@@ -1962,7 +1962,7 @@ co_WinPosSetWindowPos(
                            RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ALLCHILDREN);
 
       if (UserIsDesktopWindow(Window->spwndParent))
-         co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (WPARAM)Window->head.h, 0);
+         co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (WPARAM)UserHMGetHandle(Window), 0);
 
       Window->style &= ~WS_VISIBLE; //IntSetStyle( Window, 0, WS_VISIBLE );
       Window->head.pti->cVisWindows--;
@@ -1974,7 +1974,7 @@ co_WinPosSetWindowPos(
       {
          if ((Window->style & WS_POPUP) && (Window->ExStyle & WS_EX_APPWINDOW))
          {
-            co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)Window->head.h, 0);
+            co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)UserHMGetHandle(Window), 0);
             if (!(WinPos.flags & SWP_NOACTIVATE))
                UpdateShellHook(Window);
          }
@@ -1985,7 +1985,7 @@ co_WinPosSetWindowPos(
       {
          if (!UserIsDesktopWindow(Window))
          {
-            co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)Window->head.h, 0);
+            co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)UserHMGetHandle(Window), 0);
             if (!(WinPos.flags & SWP_NOACTIVATE))
                UpdateShellHook(Window);
          }
@@ -2317,7 +2317,7 @@ co_WinPosSetWindowPos(
 
    /* And last, send the WM_WINDOWPOSCHANGED message */
 
-   TRACE("\tstatus hwnd %p flags = %04x\n",Window?Window->head.h:NULL,WinPos.flags & SWP_AGG_STATUSFLAGS);
+   TRACE("\tstatus hwnd %p flags = %04x\n", Window ? UserHMGetHandle(Window) : NULL, WinPos.flags & SWP_AGG_STATUSFLAGS);
 
    if (((WinPos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE)
             && !((flags & SWP_AGG_NOCLIENTCHANGE) && (flags & SWP_SHOWWINDOW)))
@@ -2370,7 +2370,7 @@ co_WinPosGetNonClientSize(PWND Window, RECT* WindowRect, RECT* ClientRect)
    ASSERT_REFS_CO(Window);
 
    *ClientRect = *WindowRect;
-   Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect);
+   Result = co_IntSendMessageNoWait(UserHMGetHandle(Window), WM_NCCALCSIZE, FALSE, (LPARAM)ClientRect);
 
    FixClientRect(ClientRect, WindowRect);
 
@@ -2424,7 +2424,7 @@ co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT* NewPos)
    wpl.length = sizeof(wpl);
    IntGetWindowPlacement( Wnd, &wpl );
 
-   if (co_HOOK_CallHooks( WH_CBT, HCBT_MINMAX, (WPARAM)Wnd->head.h, ShowFlag))
+   if (co_HOOK_CallHooks(WH_CBT, HCBT_MINMAX, (WPARAM)UserHMGetHandle(Wnd), ShowFlag))
    {
       ERR("WinPosMinMaximize WH_CBT Call Hook return!\n");
       return SWP_NOSIZE | SWP_NOMOVE;
@@ -2439,7 +2439,7 @@ co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT* NewPos)
          case SW_FORCEMINIMIZE:
              return SWP_NOSIZE | SWP_NOMOVE;
          }
-         if (!co_IntSendMessageNoWait(Wnd->head.h, WM_QUERYOPEN, 0, 0))
+         if (!co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_QUERYOPEN, 0, 0))
          {
             return(SWP_NOSIZE | SWP_NOMOVE);
          }
@@ -2582,7 +2582,7 @@ co_WinPosShowWindow(PWND Wnd, INT Cmd)
    style = Wnd->style;
 
    TRACE("co_WinPosShowWindow START hwnd %p Cmd %d usicmd %u\n",
-         Wnd->head.h, Cmd, pti->ppi->usi.wShowWindow);
+         UserHMGetHandle(Wnd), Cmd, pti->ppi->usi.wShowWindow);
 
    if ( pti->ppi->usi.dwFlags & STARTF_USESHOWWINDOW )
    {
@@ -2741,10 +2741,10 @@ co_WinPosShowWindow(PWND Wnd, INT Cmd)
 
    if ((ShowFlag != WasVisible || Cmd == SW_SHOWNA) && Cmd != SW_SHOWMAXIMIZED && !(Swp & SWP_STATECHANGED))
    {
-      co_IntSendMessageNoWait(Wnd->head.h, WM_SHOWWINDOW, ShowFlag, 0);
+      co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_SHOWWINDOW, ShowFlag, 0);
 #if 0 // Fix wine msg test_SetParent:WmSetParentSeq_1:2
       if (!(Wnd->state2 & WNDS2_WIN31COMPAT)) // <------------- XP sets this bit!
-         co_IntSendMessageNoWait(Wnd->head.h, WM_SETVISIBLE, ShowFlag, 0);
+         co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_SETVISIBLE, ShowFlag, 0);
 #endif
       if (!VerifyWnd(Wnd)) return WasVisible;
    }
@@ -2914,7 +2914,7 @@ co_WinPosSearchChildren(
 
     if (ScopeWin->head.pti == PsGetCurrentThreadWin32Thread())
     {
-       *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0, MAKELONG(Point->x, Point->y));
+       *HitTest = (USHORT)co_IntSendMessage(UserHMGetHandle(ScopeWin), WM_NCHITTEST, 0, MAKELONG(Point->x, Point->y));
 
        if ((*HitTest) == (USHORT)HTTRANSPARENT)
        {