Skip to content

Commit

Permalink
[NTUSER] Use UserHMGetHandle macro (reactos#6244)
Browse files Browse the repository at this point in the history
Use UserHMGetHandle macro everywhere instead of obj->head.h for consistency.
  • Loading branch information
TAN-Gaming authored Jan 5, 2024
1 parent 90432c1 commit 90ed686
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 121 deletions.
8 changes: 4 additions & 4 deletions win32ss/user/ntuser/accelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -331,7 +331,7 @@ UserDestroyAccelTable(PVOID Object)
Accel->Table = NULL;
}

UserDeleteObject(Accel->head.h, TYPE_ACCELTABLE);
UserDeleteObject(UserHMGetHandle(Accel), TYPE_ACCELTABLE);
return TRUE;
}

Expand Down
4 changes: 2 additions & 2 deletions win32ss/user/ntuser/caret.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
30 changes: 15 additions & 15 deletions win32ss/user/ntuser/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -610,7 +610,7 @@ NtUserGetOpenClipboardWindow(VOID)
goto cleanup;

if (pWinStaObj->spwndClipOpen)
hWnd = pWinStaObj->spwndClipOpen->head.h;
hWnd = UserHMGetHandle(pWinStaObj->spwndClipOpen);

ObDereferenceObject(pWinStaObj);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -786,7 +786,7 @@ NtUserGetClipboardOwner(VOID)
goto cleanup;

if (pWinStaObj->spwndClipOwner)
hWnd = pWinStaObj->spwndClipOwner->head.h;
hWnd = UserHMGetHandle(pWinStaObj->spwndClipOwner);

ObDereferenceObject(pWinStaObj);

Expand All @@ -809,7 +809,7 @@ NtUserGetClipboardViewer(VOID)
goto cleanup;

if (pWinStaObj->spwndClipViewer)
hWnd = pWinStaObj->spwndClipViewer->head.h;
hWnd = UserHMGetHandle(pWinStaObj->spwndClipViewer);

ObDereferenceObject(pWinStaObj);

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions win32ss/user/ntuser/cursoricon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -973,7 +973,7 @@ NtUserFindExistingCursorIcon(
}
}
if (CurIcon)
Ret = CurIcon->head.h;
Ret = UserHMGetHandle(CurIcon);
UserLeave();

done:
Expand Down Expand Up @@ -2145,7 +2145,7 @@ NtUserGetCursorFrameInfo(
return NULL;
}

ret = CurIcon->head.h;
ret = UserHMGetHandle(CurIcon);

if (CurIcon->CURSORF_flags & CURSORF_ACON)
{
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions win32ss/user/ntuser/defwnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions win32ss/user/ntuser/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions win32ss/user/ntuser/focus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -1287,15 +1287,15 @@ 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);
}

// Activate anyone but the active window.
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!
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
{
Expand Down
2 changes: 1 addition & 1 deletion win32ss/user/ntuser/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions win32ss/user/ntuser/kbdlayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ UserLoadKbdFile(PUNICODE_STRING pwszKLID)
{
/* We have failed - destroy created object */
if (pkf)
UserDeleteObject(pkf->head.h, TYPE_KBDFILE);
UserDeleteObject(UserHMGetHandle(pkf), TYPE_KBDFILE);
}

return pRet;
Expand Down Expand Up @@ -398,15 +398,15 @@ 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;
}

// Up to Language Identifiers..
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;
}

Expand Down Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions win32ss/user/ntuser/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) ||
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 90ed686

Please sign in to comment.