[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.
This commit is contained in:
Katayama Hirofumi MZ 2024-07-29 07:15:44 +09:00 committed by GitHub
parent 0cd20b7a1c
commit ec24b54731
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 24 additions and 24 deletions

View file

@ -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();

View file

@ -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

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -435,7 +435,7 @@ NtUserGetGUIThreadInfo(
pti = PsGetCurrentThreadWin32Thread();
// Validate Tread ID
W32Thread = IntTID2PTI((HANDLE)(DWORD_PTR)idThread);
W32Thread = IntTID2PTI(UlongToHandle(idThread));
if ( !W32Thread )
{

View file

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

View file

@ -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;

View file

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

View file

@ -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
{