https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ec24b547311110b47d330…
commit ec24b547311110b47d33024691ac1eaaeab5b569
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Jul 29 07:15:44 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Jul 29 07:15:44 2024 +0900
[IMM32][NTUSER] Use HandleToUlong, UlongToHandle etc. macros (#7180)
Respect coding standard.
JIRA issue: N/A
- Use HandleToUlong, UlongToHandle,
UlongToPtr etc. macros for type
casting.
- Remove redundant casts.
---
dll/win32/imm32/ctf.c | 4 ++--
dll/win32/imm32/ime.c | 4 ++--
dll/win32/imm32/imm.c | 4 ++--
dll/win32/imm32/utils.c | 8 ++++----
win32ss/user/ntuser/event.c | 2 +-
win32ss/user/ntuser/ime.c | 6 +++---
win32ss/user/ntuser/kbdlayout.c | 10 +++++-----
win32ss/user/ntuser/misc.c | 2 +-
win32ss/user/ntuser/msgqueue.c | 2 +-
win32ss/user/ntuser/simplecall.c | 2 +-
win32ss/user/ntuser/window.c | 2 +-
win32ss/user/ntuser/window.h | 2 +-
12 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c
index 0c69428184d..e3ec6989b7a 100644
--- a/dll/win32/imm32/ctf.c
+++ b/dll/win32/imm32/ctf.c
@@ -665,7 +665,7 @@ Imm32LoadCtfIme(VOID)
* NOTE: (HKL)0x04090409 is English US keyboard (default).
* The Cicero keyboard logically uses English US keyboard.
*/
- if (!ImmLoadLayout((HKL)ULongToHandle(0x04090409), &ImeInfoEx))
+ if (!ImmLoadLayout(ULongToHandle(0x04090409), &ImeInfoEx))
break;
/* Build a path string in system32. The installed IME file must be in system32.
*/
@@ -1179,7 +1179,7 @@ CtfImmTIMActivate(_In_ HKL hKL)
}
if (IS_IME_HKL(hKL))
- hKL = (HKL)UlongToHandle(MAKELONG(LOWORD(hKL), LOWORD(hKL)));
+ hKL = UlongToHandle(MAKELONG(LOWORD(hKL), LOWORD(hKL)));
if (!ImmLoadIME(hKL))
Imm32TF_InvalidAssemblyListCacheIfExist();
diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c
index ca61a3cf901..d4b748e5f98 100644
--- a/dll/win32/imm32/ime.c
+++ b/dll/win32/imm32/ime.c
@@ -297,7 +297,7 @@ PIMEDPI APIENTRY Imm32LoadImeDpi(HKL hKL, BOOL bLock)
pImeDpiNew->hKL = hKL;
lcid = LOWORD(hKL);
- if (TranslateCharsetInfo((LPDWORD)(DWORD_PTR)lcid, &ci, TCI_SRCLOCALE))
+ if (TranslateCharsetInfo(UlongToPtr(lcid), &ci, TCI_SRCLOCALE))
uCodePage = ci.ciACP;
else
uCodePage = CP_ACP;
@@ -859,7 +859,7 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
if (Imm32WriteImeLayout(hNewKL, pchFilePart, lpszLayoutText))
{
/* Load the keyboard layout */
- StringCchPrintfW(szImeKey, _countof(szImeKey), L"%08X",
(DWORD)(DWORD_PTR)hNewKL);
+ StringCchPrintfW(szImeKey, _countof(szImeKey), L"%08X",
HandleToUlong(hNewKL));
hNewKL = LoadKeyboardLayoutW(szImeKey, KLF_REPLACELANG);
}
else
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 175432ca09b..edbc4bcdb4e 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -171,7 +171,7 @@ Retry:
}
else
{
- hNewKL = (HKL)(DWORD_PTR)dwUnknown;
+ hNewKL = UlongToHandle(dwUnknown);
if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL)
Imm32ReleaseIME(hNewKL);
}
@@ -865,7 +865,7 @@ LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect)
{
hOldKL = GetKeyboardLayout(0);
LangID = LOWORD(hOldKL);
- hNewKL = (HKL)(DWORD_PTR)MAKELONG(LangID, LangID);
+ hNewKL = UlongToHandle(MAKELONG(LangID, LangID));
pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
if (pImeDpi)
diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c
index c9c4effe783..9fc0375b64d 100644
--- a/dll/win32/imm32/utils.c
+++ b/dll/win32/imm32/utils.c
@@ -819,7 +819,7 @@ BOOL APIENTRY Imm32LoadImeLangAndDesc(PIMEINFOEX pInfoEx, LPCVOID
pVerInfo)
}
if (pInfoEx->hkl == NULL)
- pInfoEx->hkl = (HKL)(DWORD_PTR)*pw;
+ pInfoEx->hkl = UlongToHandle(*pw);
/* Try the current language and the Unicode codepage (0x04B0) */
LangID = LANGIDFROMLCID(GetThreadLocale());
@@ -941,7 +941,7 @@ HKL APIENTRY Imm32AssignNewLayout(UINT cKLs, const REG_IME *pLayouts,
WORD wLang
if (!wNextID)
return NULL;
- return (HKL)(DWORD_PTR)MAKELONG(wLangID, wNextID);
+ return UlongToHandle(MAKELONG(wLangID, wNextID));
}
// Win: GetImeLayout
@@ -999,7 +999,7 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts)
}
Imm32StrToUInt(szImeKey, &Value, 16);
- hKL = (HKL)(DWORD_PTR)Value;
+ hKL = UlongToHandle(Value);
if (!IS_IME_HKL(hKL)) /* Not an IME */
{
WARN("\n");
@@ -1036,7 +1036,7 @@ BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart,
LPCWSTR pszLayou
return FALSE;
/* Get the IME key from hKL */
- StringCchPrintf(szImeKey, _countof(szImeKey), L"%08X",
(DWORD)(DWORD_PTR)hKL);
+ StringCchPrintf(szImeKey, _countof(szImeKey), L"%08X",
HandleToUlong(hKL));
/* Create a registry IME key */
lError = RegCreateKeyW(hkeyLayouts, szImeKey, &hkeyIME);
diff --git a/win32ss/user/ntuser/event.c b/win32ss/user/ntuser/event.c
index daf5bef14b3..e7e2c832d48 100644
--- a/win32ss/user/ntuser/event.c
+++ b/win32ss/user/ntuser/event.c
@@ -351,7 +351,7 @@ NtUserSetWinEventHook(
if (idThread)
{
PETHREAD Thread;
- Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)idThread, &Thread);
+ Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &Thread);
if (!NT_SUCCESS(Status))
{
EngSetLastError(ERROR_INVALID_THREAD_ID);
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index 1548c08ce38..2daa28f3f40 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -939,7 +939,7 @@ NtUserGetAppImeLevel(HWND hWnd)
pti = PsGetCurrentThreadWin32Thread();
if (pWnd->head.pti->ppi == pti->ppi)
- ret = (DWORD)(ULONG_PTR)UserGetProp(pWnd, AtomImeLevel, TRUE);
+ ret = HandleToUlong(UserGetProp(pWnd, AtomImeLevel, TRUE));
Quit:
UserLeave();
@@ -1078,7 +1078,7 @@ NtUserSetAppImeLevel(HWND hWnd, DWORD dwLevel)
pti = PsGetCurrentThreadWin32Thread();
if (pWnd->head.pti->ppi == pti->ppi)
- ret = UserSetProp(pWnd, AtomImeLevel, (HANDLE)(ULONG_PTR)dwLevel, TRUE);
+ ret = UserSetProp(pWnd, AtomImeLevel, UlongToHandle(dwLevel), TRUE);
Quit:
UserLeave();
@@ -1976,7 +1976,7 @@ PWND FASTCALL co_IntCreateDefaultImeWindow(PWND pwndTarget,
HINSTANCE hInst)
RtlInitLargeUnicodeString(&WindowName, L"Default IME", 0);
- ClassName.Buffer = (PWCH)(ULONG_PTR)gpsi->atomSysClass[ICLS_IME];
+ ClassName.Buffer = UlongToPtr(gpsi->atomSysClass[ICLS_IME]);
ClassName.Length = 0;
ClassName.MaximumLength = 0;
diff --git a/win32ss/user/ntuser/kbdlayout.c b/win32ss/user/ntuser/kbdlayout.c
index 08ea9ee531e..31c016d3e97 100644
--- a/win32ss/user/ntuser/kbdlayout.c
+++ b/win32ss/user/ntuser/kbdlayout.c
@@ -45,7 +45,7 @@ PKL FASTCALL IntHKLtoPKL(_Inout_ PTHREADINFO pti, _In_ HKL hKL)
pKL = pFirstKL;
/* hKL can have special value HKL_NEXT or HKL_PREV */
- if (hKL == (HKL)(ULONG_PTR)HKL_NEXT) /* Looking forward */
+ if (hKL == UlongToHandle(HKL_NEXT)) /* Looking forward */
{
do
{
@@ -54,7 +54,7 @@ PKL FASTCALL IntHKLtoPKL(_Inout_ PTHREADINFO pti, _In_ HKL hKL)
return pKL;
} while (pKL != pFirstKL);
}
- else if (hKL == (HKL)(ULONG_PTR)HKL_PREV) /* Looking backward */
+ else if (hKL == UlongToHandle(HKL_PREV)) /* Looking backward */
{
do
{
@@ -859,7 +859,7 @@ co_IntUnloadKeyboardLayoutEx(
if (!(dwFlags & 0x80000000) && pti->KeyboardLayout == pKL)
{
- pNextKL = IntHKLtoPKL(pti, (HKL)(ULONG_PTR)HKL_NEXT);
+ pNextKL = IntHKLtoPKL(pti, UlongToHandle(HKL_NEXT));
if (pNextKL)
{
UserRefObjectCo(pNextKL, &Ref2); /* Add reference */
@@ -1152,7 +1152,7 @@ NtUserGetKeyboardLayoutName(
if (IS_IME_HKL(pKl->hkl))
{
- Status = RtlIntegerToUnicodeString((ULONG)(ULONG_PTR)pKl->hkl, 16,
&ustrNameSafe);
+ Status = RtlIntegerToUnicodeString(HandleToUlong(pKl->hkl), 16,
&ustrNameSafe);
}
else
{
@@ -1244,7 +1244,7 @@ NtUserLoadKeyboardLayoutEx(
hSafeFile,
hOldKL,
&uszSafeKLID,
- (HKL)(DWORD_PTR)dwNewKL,
+ UlongToHandle(dwNewKL),
Flags);
if (hSafeFile)
ZwClose(hSafeFile);
diff --git a/win32ss/user/ntuser/misc.c b/win32ss/user/ntuser/misc.c
index 2b909893db6..0e2d851af41 100644
--- a/win32ss/user/ntuser/misc.c
+++ b/win32ss/user/ntuser/misc.c
@@ -435,7 +435,7 @@ NtUserGetGUIThreadInfo(
pti = PsGetCurrentThreadWin32Thread();
// Validate Tread ID
- W32Thread = IntTID2PTI((HANDLE)(DWORD_PTR)idThread);
+ W32Thread = IntTID2PTI(UlongToHandle(idThread));
if ( !W32Thread )
{
diff --git a/win32ss/user/ntuser/msgqueue.c b/win32ss/user/ntuser/msgqueue.c
index e26a3b65952..3a8b60704ff 100644
--- a/win32ss/user/ntuser/msgqueue.c
+++ b/win32ss/user/ntuser/msgqueue.c
@@ -910,7 +910,7 @@ co_MsqDispatchOneSentMessage(
if (Message->HookMessage == MSQ_ISHOOK)
{ // Direct Hook Call processor
Result = co_CallHook( Message->Msg.message, // HookId
- (INT)(INT_PTR)Message->Msg.hwnd, // Code
+ HandleToLong(Message->Msg.hwnd), // Code
Message->Msg.wParam,
Message->Msg.lParam);
}
diff --git a/win32ss/user/ntuser/simplecall.c b/win32ss/user/ntuser/simplecall.c
index 05ba8d018ec..fa7ee28d857 100644
--- a/win32ss/user/ntuser/simplecall.c
+++ b/win32ss/user/ntuser/simplecall.c
@@ -727,7 +727,7 @@ NtUserCallHwnd(
return 0;
}
- HelpId = (DWORD)(DWORD_PTR)UserGetProp(Window,
gpsi->atomContextHelpIdProp, TRUE);
+ HelpId = HandleToUlong(UserGetProp(Window, gpsi->atomContextHelpIdProp,
TRUE));
UserLeave();
return HelpId;
diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c
index ea67f811073..2d25e99cf67 100644
--- a/win32ss/user/ntuser/window.c
+++ b/win32ss/user/ntuser/window.c
@@ -441,7 +441,7 @@ DWORD FASTCALL IntGetWindowContextHelpId( PWND pWnd )
do
{
- HelpId = (DWORD)(DWORD_PTR)UserGetProp(pWnd, gpsi->atomContextHelpIdProp,
TRUE);
+ HelpId = HandleToUlong(UserGetProp(pWnd, gpsi->atomContextHelpIdProp, TRUE));
if (!HelpId) break;
pWnd = IntGetParent(pWnd);
}
diff --git a/win32ss/user/ntuser/window.h b/win32ss/user/ntuser/window.h
index a6c60a6354c..284378604b8 100644
--- a/win32ss/user/ntuser/window.h
+++ b/win32ss/user/ntuser/window.h
@@ -80,7 +80,7 @@ LONG_PTR FASTCALL co_UserSetWindowLongPtr(HWND, DWORD, LONG_PTR, BOOL);
HWND FASTCALL IntGetWindow(HWND,UINT);
LRESULT co_UserFreeWindow(PWND,PPROCESSINFO,PTHREADINFO,BOOLEAN);
-#define HWND_TERMINATOR ((HWND)(ULONG_PTR)1)
+#define HWND_TERMINATOR ((HWND)UlongToHandle(1))
typedef struct tagWINDOWLIST
{