[BOOTDATA][NTUSER] Add UserIsIMMEnabled and use it (#4882)

This PR enables SRVINFO_IMM32 also for non-CJK. You can disable this flag by setting zero to the LoadIMM registry value if you're non-CJK.
CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-11-15 17:10:06 +09:00 committed by GitHub
parent ba1ed89f91
commit a2c6af0da4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 69 additions and 15 deletions

View file

@ -512,7 +512,7 @@ HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontMapper",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix",,0x00000012 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\IME Compatibility",,0x00000012 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\IME Compatibility",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\IMM","LoadIMM",0x00010003,0 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\IMM","LoadIMM",0x00010003,1
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\IMM","LoadCTFIME",0x00010003,0 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\IMM","LoadCTFIME",0x00010003,0
; DOS Device ports ; DOS Device ports

View file

@ -54,6 +54,10 @@ BOOL
NTAPI NTAPI
RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData); RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData);
DWORD
NTAPI
RegGetSectionDWORD(LPCWSTR pszSection, LPWSTR pszValue, DWORD dwDefault);
VOID FASTCALL VOID FASTCALL
SetLastNtError( SetLastNtError(
NTSTATUS Status); NTSTATUS Status);

View file

@ -562,7 +562,7 @@ DWORD FASTCALL UserBuildHimcList(PTHREADINFO pti, DWORD dwCount, HIMC *phList)
} }
else else
{ {
for (pti = GetW32ThreadInfo()->ppi->ptiList; pti; pti = pti->ptiSibling) for (pti = gptiCurrent->ppi->ptiList; pti; pti = pti->ptiSibling)
{ {
for (pIMC = pti->spDefaultImc; pIMC; pIMC = pIMC->pImcNext) for (pIMC = pti->spDefaultImc; pIMC; pIMC = pIMC->pImcNext)
{ {
@ -716,7 +716,7 @@ NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCo
if (dwThreadId == 0) if (dwThreadId == 0)
{ {
pti = GetW32ThreadInfo(); pti = gptiCurrent;
} }
else if (dwThreadId == INVALID_THREAD_ID) else if (dwThreadId == INVALID_THREAD_ID)
{ {

View file

@ -14,6 +14,26 @@ static BOOL Setup = FALSE;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
BOOL FASTCALL UserIsDBCSEnabled(VOID)
{
return NLS_MB_CODE_PAGE_TAG;
}
BOOL FASTCALL UserIsIMMEnabled(VOID)
{
static WCHAR s_szLoadIMM[] = L"LoadIMM";
if (NLS_MB_CODE_PAGE_TAG)
return TRUE;
return !!RegGetSectionDWORD(L"IMM", s_szLoadIMM, TRUE);
}
BOOL FASTCALL UserIsCiceroEnabled(VOID)
{
return FALSE; /* FIXME: Cicero is not supported yet */
}
BOOL BOOL
NTAPI NTAPI
InitMetrics(VOID) InitMetrics(VOID)
@ -169,12 +189,14 @@ InitMetrics(VOID)
piSysMet[90] = 0; piSysMet[90] = 0;
#endif #endif
/*gpsi->dwSRVIFlags |= SRVINFO_CICERO_ENABLED;*/ /* Cicero is not supported yet */ if (UserIsDBCSEnabled())
gpsi->dwSRVIFlags |= SRVINFO_DBCSENABLED; /* DBCS Support */
if (NLS_MB_CODE_PAGE_TAG) /* Is the system multi-byte codepage? */ if (UserIsIMMEnabled())
{ gpsi->dwSRVIFlags |= SRVINFO_IMM32; /* IME Support */
gpsi->dwSRVIFlags |= (SRVINFO_DBCSENABLED | SRVINFO_IMM32); /* DBCS+IME Support */
} if (UserIsCiceroEnabled())
gpsi->dwSRVIFlags |= SRVINFO_CICERO_ENABLED; /* Cicero support */
Setup = TRUE; Setup = TRUE;

View file

@ -155,6 +155,36 @@ RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData)
return NT_SUCCESS(Status); return NT_SUCCESS(Status);
} }
NTSTATUS
NTAPI
RegOpenSectionKey(
LPCWSTR pszSection,
PHKEY phkey)
{
WCHAR szKey[MAX_PATH] =
L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\";
RtlStringCchCatW(szKey, _countof(szKey), pszSection);
return RegOpenKey(szKey, phkey);
}
DWORD
NTAPI
RegGetSectionDWORD(LPCWSTR pszSection, LPWSTR pszValue, DWORD dwDefault)
{
HKEY hKey;
DWORD dwValue;
if (NT_ERROR(RegOpenSectionKey(pszSection, &hKey)))
return dwDefault;
if (!RegReadDWORD(hKey, pszValue, &dwValue))
dwValue = dwDefault;
ZwClose(hKey);
return dwValue;
}
_Success_(return!=FALSE) _Success_(return!=FALSE)
BOOL BOOL
NTAPI NTAPI

View file

@ -124,16 +124,11 @@ NtUserCallNoParam(DWORD Routine)
break; break;
case NOPARAM_ROUTINE_UPDATEPERUSERIMMENABLING: case NOPARAM_ROUTINE_UPDATEPERUSERIMMENABLING:
// TODO: This should also check the registry! if (UserIsIMMEnabled())
// see https://www.pctipsbox.com/fix-available-for-ie7-memory-leaks-on-xp-sp3/ for more information
if (NLS_MB_CODE_PAGE_TAG)
{
gpsi->dwSRVIFlags |= SRVINFO_IMM32; gpsi->dwSRVIFlags |= SRVINFO_IMM32;
}
else else
{
gpsi->dwSRVIFlags &= ~SRVINFO_IMM32; gpsi->dwSRVIFlags &= ~SRVINFO_IMM32;
}
Result = TRUE; // Always return TRUE. Result = TRUE; // Always return TRUE.
break; break;

View file

@ -83,6 +83,9 @@ NTSTATUS FASTCALL InitSessionImpl(VOID);
BOOL NTAPI InitMetrics(VOID); BOOL NTAPI InitMetrics(VOID);
LONG NTAPI UserGetSystemMetrics(ULONG Index); LONG NTAPI UserGetSystemMetrics(ULONG Index);
BOOL FASTCALL UserIsDBCSEnabled(VOID);
BOOL FASTCALL UserIsIMMEnabled(VOID);
BOOL FASTCALL UserIsCiceroEnabled(VOID);
/*************** KEYBOARD.C ***************/ /*************** KEYBOARD.C ***************/