ReactOS  0.4.15-dev-5109-g2469ce2
imm.c File Reference
#include "precomp.h"
Include dependency graph for imm.c:

Go to the source code of this file.

Classes

struct  SELECT_LAYOUT
 

Macros

#define MAX_IMCC_SIZE   0x1000
 

Typedefs

typedef struct SELECT_LAYOUT SELECT_LAYOUT
 
typedef struct SELECT_LAYOUTLPSELECT_LAYOUT
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (imm)
 
static BOOL APIENTRY ImmInitializeGlobals (HMODULE hMod)
 
BOOL WINAPI ImmRegisterClient (PSHAREDINFO ptr, HINSTANCE hMod)
 
BOOL WINAPI ImmLoadLayout (HKL hKL, PIMEINFOEX pImeInfoEx)
 
BOOL WINAPI ImmFreeLayout (DWORD dwUnknown)
 
VOID APIENTRY Imm32SelectInputContext (HKL hNewKL, HKL hOldKL, HIMC hIMC)
 
static BOOL CALLBACK Imm32SelectContextProc (HIMC hIMC, LPARAM lParam)
 
static BOOL CALLBACK Imm32NotifyIMEProc (HIMC hIMC, LPARAM lParam)
 
BOOL WINAPI ImmActivateLayout (HKL hKL)
 
static VOID APIENTRY Imm32CiceroSetActiveContext (HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL)
 
HIMC WINAPI ImmAssociateContext (HWND hWnd, HIMC hIMC)
 
BOOL WINAPI ImmAssociateContextEx (HWND hWnd, HIMC hIMC, DWORD dwFlags)
 
HIMC WINAPI ImmCreateContext (void)
 
static VOID APIENTRY Imm32DestroyImeModeSaver (LPINPUTCONTEXTDX pIC)
 
BOOL APIENTRY Imm32DestroyInputContext (HIMC hIMC, HKL hKL, BOOL bKeep)
 
BOOL APIENTRY Imm32CreateInputContext (HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
 
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC (HIMC hIMC, BOOL fSelect)
 
BOOL WINAPI ImmDestroyContext (HIMC hIMC)
 
PCLIENTIMC WINAPI ImmLockClientImc (HIMC hImc)
 
VOID WINAPI ImmUnlockClientImc (PCLIENTIMC pClientImc)
 
static HIMC APIENTRY ImmGetSaveContext (HWND hWnd, DWORD dwContextFlags)
 
HIMC WINAPI ImmGetContext (HWND hWnd)
 
LPINPUTCONTEXT WINAPI ImmLockIMC (HIMC hIMC)
 
BOOL WINAPI ImmUnlockIMC (HIMC hIMC)
 
BOOL WINAPI ImmReleaseContext (HWND hWnd, HIMC hIMC)
 
HWND WINAPI ImmCreateSoftKeyboard (UINT uType, UINT hOwner, int x, int y)
 
BOOL WINAPI ImmDestroySoftKeyboard (HWND hSoftWnd)
 
BOOL WINAPI ImmShowSoftKeyboard (HWND hSoftWnd, int nCmdShow)
 
BOOL WINAPI ImmDisableTextFrameService (DWORD dwThreadId)
 
BOOL WINAPI ImmEnumInputContext (DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
 
BOOL WINAPI ImmSetActiveContext (HWND hWnd, HIMC hIMC, BOOL fActive)
 
BOOL WINAPI ImmWINNLSGetEnableStatus (HWND hWnd)
 
BOOL WINAPI ImmSetActiveContextConsoleIME (HWND hwnd, BOOL fFlag)
 
BOOL WINAPI User32InitializeImmEntryTable (DWORD)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
 

Variables

HMODULE ghImm32Inst = NULL
 
PSERVERINFO gpsi = NULL
 
SHAREDINFO gSharedInfo = { NULL }
 
BYTE gfImmInitialized = FALSE
 

Macro Definition Documentation

◆ MAX_IMCC_SIZE

#define MAX_IMCC_SIZE   0x1000

Typedef Documentation

◆ LPSELECT_LAYOUT

◆ SELECT_LAYOUT

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpReserved 
)

Definition at line 1245 of file imm.c.

1246 {
1247  HKL hKL;
1248  HIMC hIMC;
1249 
1250  TRACE("(%p, 0x%X, %p)\n", hinstDLL, fdwReason, lpReserved);
1251 
1252  switch (fdwReason)
1253  {
1254  case DLL_PROCESS_ATTACH:
1255  if (!ImmInitializeGlobals(hinstDLL))
1256  {
1257  ERR("ImmInitializeGlobals failed\n");
1258  return FALSE;
1259  }
1261  {
1262  ERR("User32InitializeImmEntryTable failed\n");
1263  return FALSE;
1264  }
1265  break;
1266 
1267  case DLL_THREAD_ATTACH:
1268  break;
1269 
1270  case DLL_THREAD_DETACH:
1271  if (!IS_IMM_MODE() || NtCurrentTeb()->Win32ThreadInfo == NULL)
1272  return TRUE;
1273 
1274  hKL = GetKeyboardLayout(0);
1276  Imm32DestroyInputContext(hIMC, hKL, TRUE);
1277  break;
1278 
1279  case DLL_PROCESS_DETACH:
1281  TRACE("imm32.dll is unloaded\n");
1282  break;
1283  }
1284 
1285  return TRUE;
1286 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:132
#define IS_IMM_MODE()
Definition: ntuser.h:1204
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define FALSE
Definition: types.h:117
BOOL APIENTRY Imm32DestroyInputContext(HIMC hIMC, HKL hKL, BOOL bKeep)
Definition: imm.c:632
BOOL WINAPI User32InitializeImmEntryTable(DWORD)
Definition: imm.c:126
static BOOL APIENTRY ImmInitializeGlobals(HMODULE hMod)
Definition: imm.c:22
DWORD HIMC
Definition: dimm.idl:75
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define TRACE(s)
Definition: solgame.cpp:4
RTL_CRITICAL_SECTION gcsImeDpi
Definition: ime.c:16
UINT_PTR HKL
Definition: msctf.idl:101
#define ERR(fmt,...)
Definition: debug.h:110
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112
#define IMM_INIT_MAGIC
Definition: imm.c:16
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

◆ Imm32CiceroSetActiveContext()

static VOID APIENTRY Imm32CiceroSetActiveContext ( HIMC  hIMC,
BOOL  fActive,
HWND  hWnd,
HKL  hKL 
)
static

Definition at line 484 of file imm.c.

485 {
486  TRACE("We have to do something\n");
487 }
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by ImmSetActiveContext().

◆ Imm32CreateInputContext()

BOOL APIENTRY Imm32CreateInputContext ( HIMC  hIMC,
LPINPUTCONTEXT  pIC,
PCLIENTIMC  pClientImc,
HKL  hKL,
BOOL  fSelect 
)

Definition at line 714 of file imm.c.

715 {
716  DWORD dwIndex, cbPrivate;
717  PIMEDPI pImeDpi = NULL;
719  LPCANDIDATEINFO pCI;
720  LPGUIDELINE pGL;
721 
722  /* Create IC components */
723  pIC->hCompStr = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
724  pIC->hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO));
725  pIC->hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE));
726  pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
727  if (!pIC->hCompStr || !pIC->hCandInfo || !pIC->hGuideLine || !pIC->hMsgBuf)
728  goto Fail;
729 
730  /* Initialize IC components */
731  pCS = ImmLockIMCC(pIC->hCompStr);
732  if (!pCS)
733  goto Fail;
734  pCS->dwSize = sizeof(COMPOSITIONSTRING);
735  ImmUnlockIMCC(pIC->hCompStr);
736 
737  pCI = ImmLockIMCC(pIC->hCandInfo);
738  if (!pCI)
739  goto Fail;
740  pCI->dwSize = sizeof(CANDIDATEINFO);
741  ImmUnlockIMCC(pIC->hCandInfo);
742 
743  pGL = ImmLockIMCC(pIC->hGuideLine);
744  if (!pGL)
745  goto Fail;
746  pGL->dwSize = sizeof(GUIDELINE);
748 
749  pIC->dwNumMsgBuf = 0;
750  pIC->fOpen = FALSE;
751  pIC->fdwConversion = pIC->fdwSentence = 0;
752 
753  for (dwIndex = 0; dwIndex < MAX_CANDIDATEFORM; ++dwIndex)
754  pIC->cfCandForm[dwIndex].dwIndex = IMM_INVALID_CANDFORM;
755 
756  /* Get private data size */
757  pImeDpi = ImmLockImeDpi(hKL);
758  if (!pImeDpi)
759  {
760  cbPrivate = sizeof(DWORD);
761  }
762  else
763  {
764  /* Update CLIENTIMC */
765  pClientImc->uCodePage = pImeDpi->uCodePage;
766  if (ImeDpi_IsUnicode(pImeDpi))
767  pClientImc->dwFlags |= CLIENTIMC_WIDE;
768 
769  cbPrivate = pImeDpi->ImeInfo.dwPrivateDataSize;
770  }
771 
772  /* Create private data */
773  pIC->hPrivate = ImmCreateIMCC(cbPrivate);
774  if (!pIC->hPrivate)
775  goto Fail;
776 
777  if (pImeDpi)
778  {
779  /* Select the IME */
780  if (fSelect)
781  {
782  if (IS_IME_HKL(hKL))
783  pImeDpi->ImeSelect(hIMC, TRUE);
784  else if (IS_CICERO_MODE() && !IS_16BIT_MODE())
785  pImeDpi->CtfImeSelectEx(hIMC, TRUE, hKL);
786  }
787 
788  /* Set HKL */
789  pClientImc->hKL = hKL;
790 
791  ImmUnlockImeDpi(pImeDpi);
792  }
793 
794  return TRUE;
795 
796 Fail:
797  if (pImeDpi)
798  ImmUnlockImeDpi(pImeDpi);
799 
800  pIC->hMsgBuf = ImmDestroyIMCC(pIC->hMsgBuf);
801  pIC->hGuideLine = ImmDestroyIMCC(pIC->hGuideLine);
802  pIC->hCandInfo = ImmDestroyIMCC(pIC->hCandInfo);
803  pIC->hCompStr = ImmDestroyIMCC(pIC->hCompStr);
804  return FALSE;
805 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:945
UINT uCodePage
Definition: ntuser.h:1257
IMEINFO ImeInfo
Definition: ntuser.h:1256
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:1099
#define TRUE
Definition: types.h:120
#define MAX_CANDIDATEFORM
Definition: imm.c:17
CANDIDATEFORM cfCandForm[4]
Definition: immdev.h:67
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:1109
DWORD fdwConversion
Definition: immdev.h:60
HIMCC hPrivate
Definition: immdev.h:71
DWORD dwSize
Definition: imm.h:205
int Fail
Definition: ehthrow.cxx:24
#define DWORD
Definition: nt_native.h:44
#define CLIENTIMC_WIDE
Definition: ntuser.h:1328
#define FALSE
Definition: types.h:117
HIMCC hCandInfo
Definition: immdev.h:69
UINT uCodePage
Definition: ntuser.h:1311
HIMCC WINAPI ImmCreateIMCC(DWORD size)
Definition: utils.c:1089
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:916
#define IS_CICERO_MODE()
Definition: ntuser.h:1205
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwSize
Definition: imm.h:195
#define ImeDpi_IsUnicode(pImeDpi)
Definition: precomp.h:116
struct tagGUIDELINE GUIDELINE
struct tagCOMPOSITIONSTRING COMPOSITIONSTRING
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:1119
HIMCC hMsgBuf
Definition: immdev.h:73
DWORD dwPrivateDataSize
Definition: imm.h:157
HIMCC hCompStr
Definition: immdev.h:68
#define IS_IME_HKL(hKL)
Definition: input.h:88
DWORD dwIndex
Definition: dimm.idl:79
#define IMM_INVALID_CANDFORM
Definition: precomp.h:51
HIMCC hGuideLine
Definition: immdev.h:70
DWORD dwNumMsgBuf
Definition: immdev.h:72
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
DWORD fdwSentence
Definition: immdev.h:61
DWORD dwFlags
Definition: ntuser.h:1308
struct tagCANDIDATEINFO CANDIDATEINFO
#define IS_16BIT_MODE()
Definition: precomp.h:117

Referenced by Imm32InternalLockIMC().

◆ Imm32DestroyImeModeSaver()

static VOID APIENTRY Imm32DestroyImeModeSaver ( LPINPUTCONTEXTDX  pIC)
static

Definition at line 610 of file imm.c.

611 {
612  PIME_STATE pState, pNext;
613  PIME_SUBSTATE pSubState, pSubNext;
614 
615  for (pState = pIC->pState; pState; pState = pNext)
616  {
617  pNext = pState->pNext;
618 
619  for (pSubState = pState->pSubState; pSubState; pSubState = pSubNext)
620  {
621  pSubNext = pSubState->pNext;
622  ImmLocalFree(pSubState);
623  }
624 
625  ImmLocalFree(pState);
626  }
627 
628  pIC->pState = NULL;
629 }
#define ImmLocalFree(lpData)
Definition: precomp.h:89
PIME_SUBSTATE pSubState
Definition: immdev.h:214
#define NULL
Definition: types.h:112
struct IME_STATE * pState
Definition: immdev.h:128
struct IME_STATE * pNext
Definition: immdev.h:208
struct IME_SUBSTATE * pNext
Definition: immdev.h:197

Referenced by Imm32DestroyInputContext().

◆ Imm32DestroyInputContext()

BOOL APIENTRY Imm32DestroyInputContext ( HIMC  hIMC,
HKL  hKL,
BOOL  bKeep 
)

Definition at line 632 of file imm.c.

633 {
634  PIMEDPI pImeDpi;
635  LPINPUTCONTEXTDX pIC;
636  PCLIENTIMC pClientImc;
637  PIMC pIMC;
638 
639  if (!hIMC || !IS_IMM_MODE())
640  return FALSE;
641 
642  pIMC = ValidateHandle(hIMC, TYPE_INPUTCONTEXT);
643  if (!pIMC || pIMC->head.pti != Imm32CurrentPti())
644  {
645  ERR("invalid pIMC: %p\n", pIMC);
646  return FALSE;
647  }
648 
649  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
650  if (!pClientImc)
651  goto Finish;
652 
653  if ((pClientImc->dwFlags & CLIENTIMC_UNKNOWN2) && !bKeep)
654  {
655  ERR("CLIENTIMC_UNKNOWN2\n");
656  return FALSE;
657  }
658 
659  if (pClientImc->dwFlags & CLIENTIMC_DESTROY)
660  return TRUE;
661 
662  InterlockedIncrement(&pClientImc->cLockObj);
663 
664  if (!pClientImc->hInputContext)
665  goto Quit;
666 
667  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
668  if (!pIC)
669  {
670  ImmUnlockClientImc(pClientImc);
671  ERR("!pIC\n");
672  return FALSE;
673  }
674 
676 
677  if (pClientImc->hKL == hKL)
678  {
679  pImeDpi = ImmLockImeDpi(hKL);
680  if (pImeDpi)
681  {
682  if (IS_IME_HKL(hKL))
683  pImeDpi->ImeSelect(hIMC, FALSE);
684  else if (IS_CICERO_MODE() && !IS_16BIT_MODE())
685  pImeDpi->CtfImeSelectEx(hIMC, FALSE, hKL);
686 
687  ImmUnlockImeDpi(pImeDpi);
688  }
689 
690  pClientImc->hKL = NULL;
691  }
692 
693  ImmDestroyIMCC(pIC->hPrivate);
694  ImmDestroyIMCC(pIC->hMsgBuf);
695  ImmDestroyIMCC(pIC->hGuideLine);
696  ImmDestroyIMCC(pIC->hCandInfo);
697  ImmDestroyIMCC(pIC->hCompStr);
699  ImmUnlockIMC(hIMC);
700 
701 Quit:
702  pClientImc->dwFlags |= CLIENTIMC_DESTROY;
703  ImmUnlockClientImc(pClientImc);
704 
705 Finish:
706  if (bKeep)
707  return TRUE;
708  return NtUserDestroyInputContext(hIMC);
709 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:945
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:1099
#define TRUE
Definition: types.h:120
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
#define IS_IMM_MODE()
Definition: ntuser.h:1204
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1015
LONG cLockObj
Definition: ntuser.h:1307
Definition: ntuser.h:190
static PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: precomp.h:160
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define CLIENTIMC_UNKNOWN2
Definition: ntuser.h:1333
#define CLIENTIMC_DESTROY
Definition: ntuser.h:1331
#define FALSE
Definition: types.h:117
struct tagCLIENTIMC * PCLIENTIMC
BOOL NTAPI NtUserDestroyInputContext(HIMC hIMC)
Definition: ime.c:1538
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:916
HANDLE hInputContext
Definition: ntuser.h:1306
#define IS_CICERO_MODE()
Definition: ntuser.h:1205
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define ERR(fmt,...)
Definition: debug.h:110
#define IS_IME_HKL(hKL)
Definition: input.h:88
#define InterlockedIncrement
Definition: armddk.h:53
THRDESKHEAD head
Definition: ntuser.h:192
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1308
static VOID APIENTRY Imm32DestroyImeModeSaver(LPINPUTCONTEXTDX pIC)
Definition: imm.c:610
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:328
HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC)
Definition: ctf.c:41
#define IS_16BIT_MODE()
Definition: precomp.h:117
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1024
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:946

Referenced by DllMain(), and ImmDestroyContext().

◆ Imm32InternalLockIMC()

LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC ( HIMC  hIMC,
BOOL  fSelect 
)

Definition at line 808 of file imm.c.

809 {
810  HANDLE hIC;
811  LPINPUTCONTEXT pIC = NULL;
812  PCLIENTIMC pClientImc;
813  WORD LangID;
815  HKL hOldKL, hNewKL;
816  PIMEDPI pImeDpi = NULL;
817 
818  pClientImc = ImmLockClientImc(hIMC);
819  if (!pClientImc)
820  return NULL;
821 
822  RtlEnterCriticalSection(&pClientImc->cs);
823 
824  if (pClientImc->hInputContext)
825  {
826  pIC = LocalLock(pClientImc->hInputContext);
827  if (pIC)
828  goto Success;
829  else
830  goto Failure;
831  }
832 
835  {
836  hOldKL = GetKeyboardLayout(0);
837  LangID = LOWORD(hOldKL);
838  hNewKL = (HKL)(DWORD_PTR)MAKELONG(LangID, LangID);
839 
840  pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
841  if (pImeDpi)
842  {
843  CtfImmTIMActivate(hNewKL);
844  }
845  }
846 
848  goto Failure;
849 
850  hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
851  pIC = LocalLock(hIC);
852  if (!pIC)
853  {
854  LocalFree(hIC);
855  goto Failure;
856  }
857  pClientImc->hInputContext = hIC;
858 
859  hNewKL = GetKeyboardLayout(dwThreadId);
860  if (!Imm32CreateInputContext(hIMC, pIC, pClientImc, hNewKL, fSelect))
861  {
862  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
863  goto Failure;
864  }
865 
866 Success:
868  RtlLeaveCriticalSection(&pClientImc->cs);
869  InterlockedIncrement(&pClientImc->cLockObj);
870  ImmUnlockClientImc(pClientImc);
871  return pIC;
872 
873 Failure:
874  RtlLeaveCriticalSection(&pClientImc->cs);
875  ImmUnlockClientImc(pClientImc);
876  return NULL;
877 }
LONG cLockObj
Definition: ntuser.h:1307
HRESULT APIENTRY CtfImmTIMCreateInputContext(HIMC hIMC)
Definition: ctf.c:50
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOL APIENTRY Imm32CreateInputContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
Definition: imm.c:714
#define DWORD
Definition: nt_native.h:44
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define MAKELONG(a, b)
Definition: typedefs.h:249
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:901
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:459
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1794
HANDLE hInputContext
Definition: ntuser.h:1306
#define IS_CICERO_MODE()
Definition: ntuser.h:1205
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1310
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define InterlockedIncrement
Definition: armddk.h:53
#define LHND
Definition: winbase.h:379
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL)
Definition: ime.c:295
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define IS_16BIT_MODE()
Definition: precomp.h:117
#define LOWORD(l)
Definition: pedump.c:82
HRESULT WINAPI CtfImmTIMActivate(HKL hKL)
Definition: ctf.c:75
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:946

Referenced by Imm32SelectInputContext(), and ImmLockIMC().

◆ Imm32NotifyIMEProc()

static BOOL CALLBACK Imm32NotifyIMEProc ( HIMC  hIMC,
LPARAM  lParam 
)
static

Definition at line 429 of file imm.c.

430 {
432  return TRUE;
433 }
#define TRUE
Definition: types.h:120
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
Definition: ime.c:839
#define NI_COMPOSITIONSTR
Definition: imm.h:298
unsigned long DWORD
Definition: ntddk_ex.h:95
LPARAM lParam
Definition: combotst.c:139

Referenced by ImmActivateLayout().

◆ Imm32SelectContextProc()

static BOOL CALLBACK Imm32SelectContextProc ( HIMC  hIMC,
LPARAM  lParam 
)
static

Definition at line 421 of file imm.c.

422 {
424  Imm32SelectInputContext(pSelect->hNewKL, pSelect->hOldKL, hIMC);
425  return TRUE;
426 }
#define TRUE
Definition: types.h:120
LPFN_SELECT pSelect
Definition: handle.c:32
VOID APIENTRY Imm32SelectInputContext(HKL hNewKL, HKL hOldKL, HIMC hIMC)
Definition: imm.c:174
struct SELECT_LAYOUT * LPSELECT_LAYOUT
LPARAM lParam
Definition: combotst.c:139

Referenced by ImmActivateLayout().

◆ Imm32SelectInputContext()

VOID APIENTRY Imm32SelectInputContext ( HKL  hNewKL,
HKL  hOldKL,
HIMC  hIMC 
)

Definition at line 174 of file imm.c.

175 {
176  PCLIENTIMC pClientImc;
177  LPINPUTCONTEXTDX pIC;
178  LPGUIDELINE pGL;
179  LPCANDIDATEINFO pCI;
181  LOGFONTA LogFontA;
182  LOGFONTW LogFontW;
183  BOOL fOpen, bIsNewHKLIme = TRUE, bIsOldHKLIme = TRUE, bClientWide, bNewDpiWide;
184  DWORD cbNewPrivate = 0, cbOldPrivate = 0, dwConversion, dwSentence, dwSize, dwNewSize;
185  PIMEDPI pNewImeDpi = NULL, pOldImeDpi = NULL;
186  HANDLE hPrivate;
187  PIME_STATE pNewState = NULL, pOldState = NULL;
188 
189  pClientImc = ImmLockClientImc(hIMC);
190  if (!pClientImc)
191  return;
192 
193  pNewImeDpi = ImmLockImeDpi(hNewKL);
194 
195  if (hNewKL != hOldKL)
196  pOldImeDpi = ImmLockImeDpi(hOldKL);
197 
198  if (pNewImeDpi)
199  {
200  cbNewPrivate = pNewImeDpi->ImeInfo.dwPrivateDataSize;
201  pClientImc->uCodePage = pNewImeDpi->uCodePage;
202  }
203  else
204  {
205  pClientImc->uCodePage = CP_ACP;
206  }
207 
208  if (cbNewPrivate < sizeof(DWORD))
209  cbNewPrivate = sizeof(DWORD);
210 
211  if (pOldImeDpi)
212  cbOldPrivate = pOldImeDpi->ImeInfo.dwPrivateDataSize;
213 
214  if (cbOldPrivate < sizeof(DWORD))
215  cbOldPrivate = sizeof(DWORD);
216 
217  if (pClientImc->hKL == hOldKL)
218  {
219  if (pOldImeDpi)
220  {
221  if (IS_IME_HKL(hOldKL))
222  pOldImeDpi->ImeSelect(hIMC, FALSE);
223  else if (IS_CICERO_MODE() && !IS_16BIT_MODE())
224  pOldImeDpi->CtfImeSelectEx(hIMC, FALSE, hOldKL);
225  }
226  pClientImc->hKL = NULL;
227  }
228 
230  {
231  if (IS_IMM_MODE() && !IS_CICERO_MODE())
232  {
233  bIsNewHKLIme = IS_IME_HKL(hNewKL);
234  bIsOldHKLIme = IS_IME_HKL(hOldKL);
235  }
236  }
237 
239  if (!pIC)
240  {
241  if (pNewImeDpi)
242  {
243  if (IS_IME_HKL(hNewKL))
244  pNewImeDpi->ImeSelect(hIMC, TRUE);
245  else if (IS_CICERO_MODE() && !IS_16BIT_MODE())
246  pNewImeDpi->CtfImeSelectEx(hIMC, TRUE, hNewKL);
247 
248  pClientImc->hKL = hNewKL;
249  }
250  }
251  else
252  {
253  dwConversion = pIC->fdwConversion;
254  dwSentence = pIC->fdwSentence;
255  fOpen = pIC->fOpen;
256 
257  if (pNewImeDpi)
258  {
259  bClientWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
260  bNewDpiWide = ImeDpi_IsUnicode(pNewImeDpi);
261  if (bClientWide && !bNewDpiWide)
262  {
263  if (pIC->fdwInit & INIT_LOGFONT)
264  {
265  LogFontWideToAnsi(&pIC->lfFont.W, &LogFontA);
266  pIC->lfFont.A = LogFontA;
267  }
268  pClientImc->dwFlags &= ~CLIENTIMC_WIDE;
269  }
270  else if (!bClientWide && bNewDpiWide)
271  {
272  if (pIC->fdwInit & INIT_LOGFONT)
273  {
274  LogFontAnsiToWide(&pIC->lfFont.A, &LogFontW);
275  pIC->lfFont.W = LogFontW;
276  }
277  pClientImc->dwFlags |= CLIENTIMC_WIDE;
278  }
279  }
280 
281  if (cbOldPrivate != cbNewPrivate)
282  {
283  hPrivate = ImmReSizeIMCC(pIC->hPrivate, cbNewPrivate);
284  if (!hPrivate)
285  {
286  ImmDestroyIMCC(pIC->hPrivate);
287  hPrivate = ImmCreateIMCC(cbNewPrivate);
288  }
289  pIC->hPrivate = hPrivate;
290  }
291 
292 #define MAX_IMCC_SIZE 0x1000
293  dwSize = ImmGetIMCCSize(pIC->hMsgBuf);
294  if (ImmGetIMCCLockCount(pIC->hMsgBuf) || dwSize > MAX_IMCC_SIZE)
295  {
296  ImmDestroyIMCC(pIC->hMsgBuf);
297  pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
298  pIC->dwNumMsgBuf = 0;
299  }
300 
301  dwSize = ImmGetIMCCSize(pIC->hGuideLine);
302  dwNewSize = sizeof(GUIDELINE);
303  if (ImmGetIMCCLockCount(pIC->hGuideLine) ||
304  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
305  {
306  ImmDestroyIMCC(pIC->hGuideLine);
307  pIC->hGuideLine = ImmCreateIMCC(dwNewSize);
308  pGL = ImmLockIMCC(pIC->hGuideLine);
309  if (pGL)
310  {
311  pGL->dwSize = dwNewSize;
312  ImmUnlockIMCC(pIC->hGuideLine);
313  }
314  }
315 
316  dwSize = ImmGetIMCCSize(pIC->hCandInfo);
317  dwNewSize = sizeof(CANDIDATEINFO);
318  if (ImmGetIMCCLockCount(pIC->hCandInfo) ||
319  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
320  {
321  ImmDestroyIMCC(pIC->hCandInfo);
322  pIC->hCandInfo = ImmCreateIMCC(dwNewSize);
323  pCI = ImmLockIMCC(pIC->hCandInfo);
324  if (pCI)
325  {
326  pCI->dwSize = dwNewSize;
327  ImmUnlockIMCC(pIC->hCandInfo);
328  }
329  }
330 
331  dwSize = ImmGetIMCCSize(pIC->hCompStr);
332  dwNewSize = sizeof(COMPOSITIONSTRING);
333  if (ImmGetIMCCLockCount(pIC->hCompStr) ||
334  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
335  {
336  ImmDestroyIMCC(pIC->hCompStr);
337  pIC->hCompStr = ImmCreateIMCC(dwNewSize);
338  pCS = ImmLockIMCC(pIC->hCompStr);
339  if (pCS)
340  {
341  pCS->dwSize = dwNewSize;
342  ImmUnlockIMCC(pIC->hCompStr);
343  }
344  }
345 #undef MAX_IMCC_SIZE
346 
347  if (pOldImeDpi && bIsOldHKLIme)
348  {
349  pOldState = Imm32FetchImeState(pIC, hOldKL);
350  if (pOldState)
351  Imm32SaveImeStateSentence(pIC, pOldState, hOldKL);
352  }
353 
354  if (pNewImeDpi && bIsNewHKLIme)
355  pNewState = Imm32FetchImeState(pIC, hNewKL);
356 
357  if (pOldState != pNewState)
358  {
359  if (pOldState)
360  {
361  pOldState->fOpen = !!pIC->fOpen;
362  pOldState->dwConversion = (pIC->fdwConversion & ~IME_CMODE_EUDC);
363  pOldState->dwSentence = pIC->fdwSentence;
364  pOldState->dwInit = pIC->fdwInit;
365  }
366 
367  if (pNewState)
368  {
370  {
372  pIC->fOpen = TRUE;
373  }
374  else
375  {
376  pIC->fOpen = pNewState->fOpen;
377  }
378 
379  pIC->fdwConversion = (pNewState->dwConversion & ~IME_CMODE_EUDC);
380  pIC->fdwSentence = pNewState->dwSentence;
381  pIC->fdwInit = pNewState->dwInit;
382  }
383  }
384 
385  if (pNewState)
386  Imm32LoadImeStateSentence(pIC, pNewState, hNewKL);
387 
388  if (pNewImeDpi)
389  {
390  if (IS_IME_HKL(hNewKL))
391  pNewImeDpi->ImeSelect(hIMC, TRUE);
392  else if (IS_CICERO_MODE() && !IS_16BIT_MODE())
393  pNewImeDpi->CtfImeSelectEx(hIMC, TRUE, hNewKL);
394 
395  pClientImc->hKL = hNewKL;
396  }
397 
398  pIC->dwChange = 0;
399  if (pIC->fOpen != fOpen)
401  if (pIC->fdwConversion != dwConversion)
403  if (pIC->fdwSentence != dwSentence)
405 
406  ImmUnlockIMC(hIMC);
407  }
408 
409  ImmUnlockImeDpi(pOldImeDpi);
410  ImmUnlockImeDpi(pNewImeDpi);
411  ImmUnlockClientImc(pClientImc);
412 }
DWORD WINAPI ImmGetIMCCSize(HIMCC imcc)
Definition: utils.c:1147
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:945
UINT uCodePage
Definition: ntuser.h:1257
BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
Definition: ctf.c:67
IMEINFO ImeInfo
Definition: ntuser.h:1256
DWORD dwInit
Definition: immdev.h:213
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:1099
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:253
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
#define CP_ACP
Definition: compat.h:109
BOOL APIENTRY Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:535
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect)
Definition: imm.c:808
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:1109
#define INPUTCONTEXTDX_CHANGE_OPEN
Definition: immdev.h:151
DWORD dwChange
Definition: immdev.h:129
DWORD dwSize
Definition: imm.h:205
#define DWORD
Definition: nt_native.h:44
#define CLIENTIMC_WIDE
Definition: ntuser.h:1328
PIME_STATE APIENTRY Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL)
Definition: utils.c:491
#define MAX_IMCC_SIZE
#define FALSE
Definition: types.h:117
DWORD dwSentence
Definition: immdev.h:212
unsigned int BOOL
Definition: ntddk_ex.h:94
#define INIT_LOGFONT
Definition: immdev.h:146
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:901
UINT uCodePage
Definition: ntuser.h:1311
HIMCC WINAPI ImmCreateIMCC(DWORD size)
Definition: utils.c:1089
WORD fOpen
Definition: immdev.h:210
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:916
#define IS_CICERO_MODE()
Definition: ntuser.h:1205
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:266
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwSize
Definition: imm.h:195
#define ImeDpi_IsUnicode(pImeDpi)
Definition: precomp.h:116
struct tagGUIDELINE GUIDELINE
struct tagCOMPOSITIONSTRING COMPOSITIONSTRING
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:1119
DWORD dwPrivateDataSize
Definition: imm.h:157
#define INPUTCONTEXTDX_CHANGE_SENTENCE
Definition: immdev.h:153
#define IS_IME_HKL(hKL)
Definition: input.h:88
#define INPUTCONTEXTDX_CHANGE_FORCE_OPEN
Definition: immdev.h:154
DWORD dwConversion
Definition: immdev.h:211
HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size)
Definition: utils.c:1137
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1308
DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc)
Definition: utils.c:1129
#define INPUTCONTEXTDX_CHANGE_CONVERSION
Definition: immdev.h:152
BOOL APIENTRY Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:548
struct tagCANDIDATEINFO CANDIDATEINFO
#define IS_16BIT_MODE()
Definition: precomp.h:117
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1024
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:946
#define IME_CMODE_EUDC
Definition: imm.h:499

Referenced by Imm32SelectContextProc().

◆ ImmActivateLayout()

BOOL WINAPI ImmActivateLayout ( HKL  hKL)

Definition at line 438 of file imm.c.

439 {
440  PIMEDPI pImeDpi;
441  HKL hOldKL;
442  LPARAM lParam;
443  HWND hwndDefIME = NULL;
444  SELECT_LAYOUT SelectLayout;
445 
446  hOldKL = GetKeyboardLayout(0);
447 
448  if (hOldKL == hKL && !(GetWin32ClientInfo()->CI_flags & CI_IMMACTIVATE))
449  return TRUE;
450 
451  ImmLoadIME(hKL);
452 
453  if (hOldKL != hKL)
454  {
455  pImeDpi = ImmLockImeDpi(hOldKL);
456  if (pImeDpi)
457  {
460  else
461  lParam = CPS_CANCEL;
462  ImmUnlockImeDpi(pImeDpi);
463 
465  }
466 
467  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
468  if (IsWindow(hwndDefIME))
469  SendMessageW(hwndDefIME, WM_IME_SELECT, FALSE, (LPARAM)hOldKL);
470 
471  NtUserSetThreadLayoutHandles(hKL, hOldKL);
472  }
473 
474  SelectLayout.hNewKL = hKL;
475  SelectLayout.hOldKL = hOldKL;
477 
478  if (IsWindow(hwndDefIME))
479  SendMessageW(hwndDefIME, WM_IME_SELECT, TRUE, (LPARAM)hKL);
480 
481  return TRUE;
482 }
DWORD NTAPI NtUserSetThreadLayoutHandles(HKL hNewKL, HKL hOldKL)
Definition: ime.c:516
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:945
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1093
IMEINFO ImeInfo
Definition: ntuser.h:1256
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define WM_IME_SELECT
Definition: winuser.h:1823
BOOL WINAPI ImmLoadIME(HKL hKL)
Definition: ime.c:993
HKL hOldKL
Definition: imm.c:417
#define GetWin32ClientInfo()
Definition: ntuser.h:335
#define CPS_CANCEL
Definition: imm.h:315
#define FALSE
Definition: types.h:117
#define CPS_COMPLETE
Definition: imm.h:312
LONG_PTR LPARAM
Definition: windef.h:208
DWORD fdwProperty
Definition: imm.h:158
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:916
static BOOL CALLBACK Imm32NotifyIMEProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:429
UINT_PTR HKL
Definition: msctf.idl:101
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:825
#define IME_PROP_COMPLETE_ON_UNSELECT
Definition: imm.h:394
#define CI_IMMACTIVATE
Definition: ntuser.h:297
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112
HKL hNewKL
Definition: imm.c:416
static BOOL CALLBACK Imm32SelectContextProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:421
LPARAM lParam
Definition: combotst.c:139

Referenced by ImeWnd_OnImeSystem().

◆ ImmAssociateContext()

HIMC WINAPI ImmAssociateContext ( HWND  hWnd,
HIMC  hIMC 
)

Definition at line 492 of file imm.c.

493 {
494  PWND pWnd;
495  HWND hwndFocus;
496  DWORD dwValue;
497  HIMC hOldIMC;
498 
499  TRACE("(%p, %p)\n", hWnd, hIMC);
500 
501  if (!IS_IMM_MODE())
502  return NULL;
503 
504  pWnd = ValidateHwnd(hWnd);
505  if (!pWnd)
506  return NULL;
507 
508  if (hIMC && Imm32IsCrossThreadAccess(hIMC))
509  return NULL;
510 
511  hOldIMC = pWnd->hImc;
512  if (hOldIMC == hIMC)
513  return hIMC;
514 
515  dwValue = NtUserAssociateInputContext(hWnd, hIMC, 0);
516  if (dwValue == 0)
517  return hOldIMC;
518  if (dwValue != 1)
519  return NULL;
520 
522  if (hwndFocus == hWnd)
523  {
524  ImmSetActiveContext(hWnd, hOldIMC, FALSE);
525  ImmSetActiveContext(hWnd, hIMC, TRUE);
526  }
527 
528  return hOldIMC;
529 }
DWORD NTAPI NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: ime.c:1705
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:19
HIMC hImc
Definition: ntuser.h:719
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1121
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4177
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2925
#define FALSE
Definition: types.h:117
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: precomp.h:100
Definition: ntuser.h:672
#define NULL
Definition: types.h:112
#define ValidateHwnd(hwnd)
Definition: precomp.h:85

Referenced by ActiveIMMApp_AssociateContext(), Test1(), test_ImmThreads(), and test_InvalidIMC().

◆ ImmAssociateContextEx()

BOOL WINAPI ImmAssociateContextEx ( HWND  hWnd,
HIMC  hIMC,
DWORD  dwFlags 
)

Definition at line 534 of file imm.c.

535 {
536  HWND hwndFocus;
537  PWND pFocusWnd;
538  HIMC hOldIMC = NULL;
539  DWORD dwValue;
540 
541  TRACE("(%p, %p, 0x%lX)\n", hWnd, hIMC, dwFlags);
542 
543  if (!IS_IMM_MODE())
544  return FALSE;
545 
546  if (hIMC && !(dwFlags & IACE_DEFAULT) && Imm32IsCrossThreadAccess(hIMC))
547  return FALSE;
548 
550  pFocusWnd = ValidateHwnd(hwndFocus);
551  if (pFocusWnd)
552  hOldIMC = pFocusWnd->hImc;
553 
554  dwValue = NtUserAssociateInputContext(hWnd, hIMC, dwFlags);
555  switch (dwValue)
556  {
557  case 0:
558  return TRUE;
559 
560  case 1:
561  pFocusWnd = ValidateHwnd(hwndFocus);
562  if (pFocusWnd)
563  {
564  hIMC = pFocusWnd->hImc;
565  if (hIMC != hOldIMC)
566  {
567  ImmSetActiveContext(hwndFocus, hOldIMC, FALSE);
568  ImmSetActiveContext(hwndFocus, hIMC, TRUE);
569  }
570  }
571  return TRUE;
572 
573  default:
574  return FALSE;
575  }
576 }
DWORD NTAPI NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: ime.c:1705
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:19
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1121
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4177
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2925
#define FALSE
Definition: types.h:117
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: precomp.h:100
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: ntuser.h:672
HWND pFocusWnd
Definition: magnifier.c:66
#define NULL
Definition: types.h:112
#define IACE_DEFAULT
Definition: imm.h:582
#define ValidateHwnd(hwnd)
Definition: precomp.h:85

Referenced by ActiveIMMApp_AssociateContextEx().

◆ ImmCreateContext()

HIMC WINAPI ImmCreateContext ( void  )

Definition at line 581 of file imm.c.

582 {
583  PCLIENTIMC pClientImc;
584  HIMC hIMC;
585 
586  TRACE("()\n");
587 
588  if (!IS_IMM_MODE())
589  return NULL;
590 
591  pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
592  if (pClientImc == NULL)
593  return NULL;
594 
595  hIMC = NtUserCreateInputContext((ULONG_PTR)pClientImc);
596  if (hIMC == NULL)
597  {
598  ImmLocalFree(pClientImc);
599  return NULL;
600  }
601 
602  RtlInitializeCriticalSection(&pClientImc->cs);
603 
605 
606  return hIMC;
607 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
#define IS_IMM_MODE()
Definition: ntuser.h:1204
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:355
#define DWORD
Definition: nt_native.h:44
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define ImmLocalFree(lpData)
Definition: precomp.h:89
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1310
HIMC NTAPI NtUserCreateInputContext(ULONG_PTR dwClientImcData)
Definition: ime.c:1609
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD dwCompatFlags
Definition: ntuser.h:1309

Referenced by ActiveIMMApp_CreateContext(), ImmGetContextThreadFunc(), Test1(), test_ImmAssociateContextEx(), test_ImmDefaultHwnd(), test_ImmDestroyContext(), test_ImmGetIMCLockCount(), test_ImmNotifyIME(), and test_InvalidIMC().

◆ ImmCreateSoftKeyboard()

HWND WINAPI ImmCreateSoftKeyboard ( UINT  uType,
UINT  hOwner,
int  x,
int  y 
)

Definition at line 1054 of file imm.c.

1055 {
1056  FIXME("(%d, %d, %d, %d): stub\n", uType, hOwner, x, y);
1058  return 0;
1059 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define FIXME(fmt,...)
Definition: debug.h:111
#define SetLastError(x)
Definition: compat.h:611
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ ImmDestroyContext()

BOOL WINAPI ImmDestroyContext ( HIMC  hIMC)

Definition at line 882 of file imm.c.

883 {
884  HKL hKL;
885 
886  TRACE("(%p)\n", hIMC);
887 
888  if (!IS_IMM_MODE())
889  return FALSE;
890 
891  if (Imm32IsCrossThreadAccess(hIMC))
892  return FALSE;
893 
894  hKL = GetKeyboardLayout(0);
895  return Imm32DestroyInputContext(hIMC, hKL, FALSE);
896 }
#define IS_IMM_MODE()
Definition: ntuser.h:1204
#define FALSE
Definition: types.h:117
BOOL APIENTRY Imm32DestroyInputContext(HIMC hIMC, HKL hKL, BOOL bKeep)
Definition: imm.c:632
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: precomp.h:100
UINT_PTR HKL
Definition: msctf.idl:101
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194

Referenced by ActiveIMMApp_DestroyContext(), Test1(), test_ImmDefaultHwnd(), test_ImmDestroyContext(), test_ImmGetIMCLockCount(), test_ImmNotifyIME(), test_ImmThreads(), and test_InvalidIMC().

◆ ImmDestroySoftKeyboard()

BOOL WINAPI ImmDestroySoftKeyboard ( HWND  hSoftWnd)

Definition at line 1064 of file imm.c.

1065 {
1066  TRACE("(%p)\n", hSoftWnd);
1067  return DestroyWindow(hSoftWnd);
1068 }
BOOL WINAPI DestroyWindow(_In_ HWND)
#define TRACE(s)
Definition: solgame.cpp:4

◆ ImmDisableTextFrameService()

BOOL WINAPI ImmDisableTextFrameService ( DWORD  dwThreadId)

Definition at line 1084 of file imm.c.

1085 {
1086  FIXME("Stub\n");
1087  return FALSE;
1088 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ ImmEnumInputContext()

BOOL WINAPI ImmEnumInputContext ( DWORD  dwThreadId,
IMCENUMPROC  lpfn,
LPARAM  lParam 
)

Definition at line 1093 of file imm.c.

1094 {
1095  HIMC *phList;
1096  DWORD dwIndex, dwCount;
1097  BOOL ret = TRUE;
1098  HIMC hIMC;
1099 
1100  TRACE("(%lu, %p, %p)\n", dwThreadId, lpfn, lParam);
1101 
1102  dwCount = Imm32BuildHimcList(dwThreadId, &phList);
1103  if (!dwCount)
1104  return FALSE;
1105 
1106  for (dwIndex = 0; dwIndex < dwCount; ++dwIndex)
1107  {
1108  hIMC = phList[dwIndex];
1109  ret = (*lpfn)(hIMC, lParam);
1110  if (!ret)
1111  break;
1112  }
1113 
1114  ImmLocalFree(phList);
1115  return ret;
1116 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
DWORD APIENTRY Imm32BuildHimcList(DWORD dwThreadId, HIMC **pphList)
Definition: utils.c:400
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ImmLocalFree(lpData)
Definition: precomp.h:89
int ret
DWORD dwThreadId
Definition: fdebug.c:31
LPARAM lParam
Definition: combotst.c:139

Referenced by Imm32SendNotification(), and ImmActivateLayout().

◆ ImmFreeLayout()

BOOL WINAPI ImmFreeLayout ( DWORD  dwUnknown)

Definition at line 109 of file imm.c.

110 {
111  WCHAR szKBD[KL_NAMELENGTH];
112  UINT iKL, cKLs;
113  HKL hOldKL, hNewKL, *pList;
114  PIMEDPI pImeDpi;
115  LANGID LangID;
116 
117  TRACE("(0x%lX)\n", dwUnknown);
118 
119  hOldKL = GetKeyboardLayout(0);
120 
121  if (dwUnknown == 1)
122  {
123  if (!IS_IME_HKL(hOldKL))
124  return TRUE;
125 
127 
128  cKLs = GetKeyboardLayoutList(0, NULL);
129  if (cKLs)
130  {
131  pList = ImmLocalAlloc(0, cKLs * sizeof(HKL));
132  if (pList == NULL)
133  return FALSE;
134 
135  cKLs = GetKeyboardLayoutList(cKLs, pList);
136  for (iKL = 0; iKL < cKLs; ++iKL)
137  {
138  if (!IS_IME_HKL(pList[iKL]))
139  {
140  LangID = LOWORD(pList[iKL]);
141  break;
142  }
143  }
144 
146  }
147 
148  StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID);
149  if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE))
150  LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200);
151  }
152  else if (dwUnknown == 2)
153  {
155 Retry:
156  for (pImeDpi = gpImeDpiList; pImeDpi; pImeDpi = pImeDpi->pNext)
157  {
158  if (Imm32ReleaseIME(pImeDpi->hKL))
159  goto Retry;
160  }
162  }
163  else
164  {
165  hNewKL = (HKL)(DWORD_PTR)dwUnknown;
166  if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL)
167  Imm32ReleaseIME(hNewKL);
168  }
169 
170  return TRUE;
171 }
#define KL_NAMELENGTH
Definition: winuser.h:122
#define KLF_ACTIVATE
Definition: winuser.h:111
#define TRUE
Definition: types.h:120
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:355
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
WORD LANGID
Definition: typedefs.h:81
PIMEDPI gpImeDpiList
Definition: ime.c:17
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
FxChildList * pList
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
RTL_CRITICAL_SECTION gcsImeDpi
Definition: ime.c:16
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
#define _countof(array)
Definition: sndvol32.h:68
#define ImmLocalFree(lpData)
Definition: precomp.h:89
struct IMEDPI * pNext
Definition: ntuser.h:1253
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:310
#define LANGIDFROMLCID(l)
Definition: nls.h:18
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define IS_IME_HKL(hKL)
Definition: input.h:88
BOOL APIENTRY Imm32ReleaseIME(HKL hKL)
Definition: ime.c:321
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
HKL WINAPI LoadKeyboardLayoutW(_In_ LPCWSTR, _In_ UINT)
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define LOWORD(l)
Definition: pedump.c:82
HKL hKL
Definition: ntuser.h:1255

Referenced by ImeWnd_OnImeSystem().

◆ ImmGetContext()

◆ ImmGetSaveContext()

static HIMC APIENTRY ImmGetSaveContext ( HWND  hWnd,
DWORD  dwContextFlags 
)
static

Definition at line 966 of file imm.c.

967 {
968  HIMC hIMC;
969  PCLIENTIMC pClientImc;
970  PWND pWnd;
971 
972  if (!IS_IMM_MODE())
973  return NULL;
974 
975  if (!hWnd)
976  {
978  goto Quit;
979  }
980 
981  pWnd = ValidateHwnd(hWnd);
982  if (!pWnd || Imm32IsCrossProcessAccess(hWnd))
983  return NULL;
984 
985  hIMC = pWnd->hImc;
986  if (!hIMC && (dwContextFlags & 1))
988 
989 Quit:
990  pClientImc = ImmLockClientImc(hIMC);
991  if (pClientImc == NULL)
992  return NULL;
993  if ((dwContextFlags & 2) && (pClientImc->dwFlags & CLIENTIMC_DISABLEIME))
994  hIMC = NULL;
995  ImmUnlockClientImc(pClientImc);
996  return hIMC;
997 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
#define IS_IMM_MODE()
Definition: ntuser.h:1204
HWND hWnd
Definition: settings.c:17
HIMC hImc
Definition: ntuser.h:719
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4177
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:901
DWORD HIMC
Definition: dimm.idl:75
#define CLIENTIMC_DISABLEIME
Definition: ntuser.h:1332
Definition: ntuser.h:672
#define QUERY_WINDOW_DEFAULT_ICONTEXT
Definition: ntuser.h:2930
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1308
static BOOL Imm32IsCrossProcessAccess(HWND hWnd)
Definition: precomp.h:108
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:946

Referenced by ImmGetContext(), ImmSetActiveContext(), and ImmWINNLSGetEnableStatus().

◆ ImmInitializeGlobals()

static BOOL APIENTRY ImmInitializeGlobals ( HMODULE  hMod)
static

Definition at line 22 of file imm.c.

23 {
25 
26  if (hMod)
27  ghImm32Inst = hMod;
28 
29  if (gfImmInitialized)
30  return TRUE;
31 
33  if (NT_ERROR(status))
34  return FALSE;
35 
37  return TRUE;
38 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
HMODULE ghImm32Inst
Definition: imm.c:16
#define FALSE
Definition: types.h:117
RTL_CRITICAL_SECTION gcsImeDpi
Definition: ime.c:16
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define NT_ERROR(Status)
Definition: umtypes.h:106
BYTE gfImmInitialized
Definition: imm.c:19
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by DllMain(), and ImmRegisterClient().

◆ ImmLoadLayout()

BOOL WINAPI ImmLoadLayout ( HKL  hKL,
PIMEINFOEX  pImeInfoEx 
)

Definition at line 54 of file imm.c.

55 {
56  DWORD cbData, dwType;
57  HKEY hLayoutKey;
58  LONG error;
59  WCHAR szLayout[MAX_PATH];
60 
61  TRACE("(%p, %p)\n", hKL, pImeInfoEx);
62 
63  ZeroMemory(pImeInfoEx, sizeof(IMEINFOEX));
64 
65  if (IS_IME_HKL(hKL) || !IS_CICERO_MODE() || IS_16BIT_MODE())
66  {
67  StringCchPrintfW(szLayout, _countof(szLayout), L"%s\\%08lX",
69 
70  error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szLayout, 0, KEY_READ, &hLayoutKey);
71  if (error)
72  {
73  ERR("RegOpenKeyExW: 0x%08lX\n", error);
74  return FALSE;
75  }
76  }
77  else
78  {
80  if (error)
81  {
82  ERR("RegOpenKeyExW: 0x%08lX\n", error);
83  return FALSE;
84  }
85  }
86 
87  cbData = sizeof(pImeInfoEx->wszImeFile);
88  error = RegQueryValueExW(hLayoutKey, L"Ime File", NULL, &dwType,
89  (LPBYTE)pImeInfoEx->wszImeFile, &cbData);
90  pImeInfoEx->wszImeFile[_countof(pImeInfoEx->wszImeFile) - 1] = UNICODE_NULL;
91 
92  RegCloseKey(hLayoutKey);
93 
94  pImeInfoEx->fLoadFlag = 0;
95 
96  if (error != ERROR_SUCCESS || dwType != REG_SZ)
97  {
98  ERR("RegQueryValueExW: 0x%lX, 0x%lX\n", error, dwType);
99  return FALSE;
100  }
101 
102  pImeInfoEx->hkl = hKL;
103  return Imm32LoadImeVerInfo(pImeInfoEx);
104 }
BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Definition: utils.c:763
#define ERROR_SUCCESS
Definition: deptool.c:10
#define error(str)
Definition: mkdosfs.c:1605
#define KEY_READ
Definition: nt_native.h:1023
#define HandleToUlong(h)
Definition: basetsd.h:79
#define ZeroMemory
Definition: winbase.h:1667
#define REGKEY_IMM
Definition: precomp.h:61
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
#define MAX_PATH
Definition: compat.h:34
#define IS_CICERO_MODE()
Definition: ntuser.h:1205
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
WCHAR wszImeFile[80]
Definition: ntuser.h:1187
#define IS_IME_HKL(hKL)
Definition: input.h:88
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define NULL
Definition: types.h:112
INT fLoadFlag
Definition: ntuser.h:1183
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define IS_16BIT_MODE()
Definition: precomp.h:117
#define RegCloseKey(hKey)
Definition: registry.h:47
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by User32CallImmLoadLayoutFromKernel().

◆ ImmLockClientImc()

PCLIENTIMC WINAPI ImmLockClientImc ( HIMC  hImc)

Definition at line 901 of file imm.c.

902 {
903  PIMC pIMC;
904  PCLIENTIMC pClientImc;
905 
906  TRACE("(%p)\n", hImc);
907 
908  if (!hImc)
909  return NULL;
910 
911  pIMC = ValidateHandle(hImc, TYPE_INPUTCONTEXT);
912  if (!pIMC || !Imm32CheckImcProcess(pIMC))
913  return NULL;
914 
915  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
916  if (pClientImc)
917  {
918  if (pClientImc->dwFlags & CLIENTIMC_DESTROY)
919  return NULL;
920  goto Finish;
921  }
922 
923  pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
924  if (!pClientImc)
925  return NULL;
926 
927  RtlInitializeCriticalSection(&pClientImc->cs);
929 
930  if (!NtUserUpdateInputContext(hImc, UIC_CLIENTIMCDATA, (DWORD_PTR)pClientImc))
931  {
932  ImmLocalFree(pClientImc);
933  return NULL;
934  }
935 
936  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN2;
937 
938 Finish:
939  InterlockedIncrement(&pClientImc->cLockObj);
940  return pClientImc;
941 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:355
Definition: ntuser.h:190
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define DWORD
Definition: nt_native.h:44
#define CLIENTIMC_UNKNOWN2
Definition: ntuser.h:1333
#define CLIENTIMC_DESTROY
Definition: ntuser.h:1331
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct tagCLIENTIMC * PCLIENTIMC
#define ImmLocalFree(lpData)
Definition: precomp.h:89
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1310
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define InterlockedIncrement
Definition: armddk.h:53
BOOL NTAPI NtUserUpdateInputContext(HIMC hIMC, DWORD dwType, DWORD_PTR dwValue)
Definition: ime.c:1765
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
Definition: utils.c:342
DWORD dwFlags
Definition: ntuser.h:1308
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:328
DWORD dwCompatFlags
Definition: ntuser.h:1309

Referenced by Imm32InternalLockIMC(), Imm32IsImcAnsi(), Imm32PostMessages(), Imm32ProcessRequest(), Imm32SelectInputContext(), ImmGenerateMessage(), ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetCompositionFontA(), ImmGetCompositionFontW(), ImmGetCompositionStringA(), ImmGetCompositionStringW(), ImmGetGuideLineAW(), ImmGetIMCLockCount(), ImmGetSaveContext(), ImmSetActiveContext(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), ImmUnlockIMC(), and ImmWINNLSEnableIME().

◆ ImmLockIMC()

◆ ImmRegisterClient()

BOOL WINAPI ImmRegisterClient ( PSHAREDINFO  ptr,
HINSTANCE  hMod 
)

Definition at line 44 of file imm.c.

45 {
46  gSharedInfo = *ptr;
48  return ImmInitializeGlobals(hMod);
49 }
PSERVERINFO gpsi
Definition: imm.c:17
static PVOID ptr
Definition: dispmode.c:27
static BOOL APIENTRY ImmInitializeGlobals(HMODULE hMod)
Definition: imm.c:22
PSERVERINFO psi
Definition: ntuser.h:1097
SHAREDINFO gSharedInfo
Definition: imm.c:18

Referenced by DllMain(), and User32InitializeImmEntryTable().

◆ ImmReleaseContext()

◆ ImmSetActiveContext()

BOOL WINAPI ImmSetActiveContext ( HWND  hWnd,
HIMC  hIMC,
BOOL  fActive 
)

Definition at line 1121 of file imm.c.

1122 {
1123  PCLIENTIMC pClientImc;
1124  LPINPUTCONTEXTDX pIC;
1125  PIMEDPI pImeDpi;
1126  HKL hKL;
1127  BOOL fOpen = FALSE;
1128  DWORD dwConversion = 0, iShow = ISC_SHOWUIALL;
1129  HWND hwndDefIME;
1130 
1131  TRACE("(%p, %p, %d)\n", hWnd, hIMC, fActive);
1132 
1133  if (!IS_IMM_MODE())
1134  return FALSE;
1135 
1136  pClientImc = ImmLockClientImc(hIMC);
1137 
1138  if (!fActive)
1139  {
1140  if (pClientImc)
1141  pClientImc->dwFlags &= ~CLIENTIMC_UNKNOWN4;
1142  }
1143  else if (hIMC)
1144  {
1145  if (!pClientImc)
1146  return FALSE;
1147 
1148  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1149  if (!pIC)
1150  {
1151  ImmUnlockClientImc(pClientImc);
1152  return FALSE;
1153  }
1154 
1155  pIC->hWnd = hWnd;
1156  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN5;
1157 
1158  if (pIC->dwUIFlags & 2)
1160 
1161  fOpen = pIC->fOpen;
1162  dwConversion = pIC->fdwConversion;
1163 
1164  ImmUnlockIMC(hIMC);
1165  }
1166  else
1167  {
1168  hIMC = ImmGetSaveContext(hWnd, 1);
1169  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1170  if (pIC)
1171  {
1172  pIC->hWnd = hWnd;
1173  ImmUnlockIMC(hIMC);
1174  }
1175  hIMC = NULL;
1176  }
1177 
1178  hKL = GetKeyboardLayout(0);
1179 
1180  if (IS_CICERO_MODE() && !IS_16BIT_MODE())
1181  {
1182  Imm32CiceroSetActiveContext(hIMC, fActive, hWnd, hKL);
1183  hKL = GetKeyboardLayout(0);
1184  }
1185 
1186  pImeDpi = ImmLockImeDpi(hKL);
1187  if (pImeDpi)
1188  {
1189  if (IS_IME_HKL(hKL))
1190  pImeDpi->ImeSetActiveContext(hIMC, fActive);
1191  ImmUnlockImeDpi(pImeDpi);
1192  }
1193 
1194  if (IsWindow(hWnd))
1195  {
1196  SendMessageW(hWnd, WM_IME_SETCONTEXT, fActive, iShow);
1197  if (fActive)
1198  NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion);
1199  }
1200  else if (!fActive)
1201  {
1202  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
1203  if (hwndDefIME)
1204  SendMessageW(hwndDefIME, WM_IME_SETCONTEXT, 0, iShow);
1205  }
1206 
1207  if (pClientImc)
1208  ImmUnlockClientImc(pClientImc);
1209 
1210  return TRUE;
1211 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:945
DWORD dwUIFlags
Definition: immdev.h:126
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1015
HWND hWnd
Definition: settings.c:17
DWORD NTAPI NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
Definition: ime.c:810
static VOID APIENTRY Imm32CiceroSetActiveContext(HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL)
Definition: imm.c:484
#define CLIENTIMC_UNKNOWN5
Definition: ntuser.h:1329
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:901
#define ISC_SHOWUIALLCANDIDATEWINDOW
Definition: imm.h:307
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_IME_SETCONTEXT
Definition: winuser.h:1819
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:916
#define IS_CICERO_MODE()
Definition: ntuser.h:1205
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ISC_SHOWUIALL
Definition: imm.h:308
UINT_PTR HKL
Definition: msctf.idl:101
#define IS_IME_HKL(hKL)
Definition: input.h:88
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:825
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static HIMC APIENTRY ImmGetSaveContext(HWND hWnd, DWORD dwContextFlags)
Definition: imm.c:966
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1308
#define IS_16BIT_MODE()
Definition: precomp.h:117
#define CLIENTIMC_UNKNOWN4
Definition: ntuser.h:1330
#define ISC_SHOWUIGUIDELINE
Definition: imm.h:306
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1024
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:946

Referenced by ImmAssociateContext(), ImmAssociateContextEx(), ImmSetActiveContextConsoleIME(), ImmWINNLSEnableIME(), and User32SetImeActivenessOfWindow().

◆ ImmSetActiveContextConsoleIME()

BOOL WINAPI ImmSetActiveContextConsoleIME ( HWND  hwnd,
BOOL  fFlag 
)

Definition at line 1231 of file imm.c.

1232 {
1233  HIMC hIMC;
1234  TRACE("(%p, %d)\n", hwnd, fFlag);
1235 
1236  hIMC = ImmGetContext(hwnd);
1237  if (hIMC)
1238  return ImmSetActiveContext(hwnd, hIMC, fFlag);
1239  return FALSE;
1240 }
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1121
#define FALSE
Definition: types.h:117
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1002
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022

◆ ImmShowSoftKeyboard()

BOOL WINAPI ImmShowSoftKeyboard ( HWND  hSoftWnd,
int  nCmdShow 
)

Definition at line 1073 of file imm.c.

1074 {
1075  TRACE("(%p, %d)\n", hSoftWnd, nCmdShow);
1076  if (hSoftWnd)
1077  return ShowWindow(hSoftWnd, nCmdShow);
1078  return FALSE;
1079 }
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4

◆ ImmUnlockClientImc()

VOID WINAPI ImmUnlockClientImc ( PCLIENTIMC  pClientImc)

Definition at line 946 of file imm.c.

947 {
948  LONG cLocks;
949  HANDLE hInputContext;
950 
951  TRACE("(%p)\n", pClientImc);
952 
953  cLocks = InterlockedDecrement(&pClientImc->cLockObj);
954  if (cLocks != 0 || !(pClientImc->dwFlags & CLIENTIMC_DESTROY))
955  return;
956 
957  hInputContext = pClientImc->hInputContext;
958  if (hInputContext)
959  LocalFree(hInputContext);
960 
961  RtlDeleteCriticalSection(&pClientImc->cs);
962  ImmLocalFree(pClientImc);
963 }
LONG cLockObj
Definition: ntuser.h:1307
static LONG cLocks
Definition: compobj.c:119
#define CLIENTIMC_DESTROY
Definition: ntuser.h:1331
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE hInputContext
Definition: ntuser.h:1306
#define ImmLocalFree(lpData)
Definition: precomp.h:89
#define InterlockedDecrement
Definition: armddk.h:52
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1310
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
DWORD dwFlags
Definition: ntuser.h:1308
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by Imm32DestroyInputContext(), Imm32InternalLockIMC(), Imm32IsImcAnsi(), Imm32PostMessages(), Imm32ProcessRequest(), Imm32SelectInputContext(), ImmGenerateMessage(), ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetCompositionFontA(), ImmGetCompositionFontW(), ImmGetCompositionStringA(), ImmGetCompositionStringW(), ImmGetGuideLineAW(), ImmGetIMCLockCount(), ImmGetSaveContext(), ImmSetActiveContext(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), ImmUnlockIMC(), ImmWINNLSEnableIME(), and START_TEST().

◆ ImmUnlockIMC()

BOOL WINAPI ImmUnlockIMC ( HIMC  hIMC)

Definition at line 1024 of file imm.c.

1025 {
1026  PCLIENTIMC pClientImc;
1027 
1028  pClientImc = ImmLockClientImc(hIMC);
1029  if (pClientImc == NULL)
1030  return FALSE;
1031 
1032  if (pClientImc->hInputContext)
1033  LocalUnlock(pClientImc->hInputContext);
1034 
1035  InterlockedDecrement(&pClientImc->cLockObj);
1036  ImmUnlockClientImc(pClientImc);
1037  return TRUE;
1038 }
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
#define TRUE
Definition: types.h:120
LONG cLockObj
Definition: ntuser.h:1307
#define FALSE
Definition: types.h:117
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:901
HANDLE hInputContext
Definition: ntuser.h:1306
#define InterlockedDecrement
Definition: armddk.h:52
#define NULL
Definition: types.h:112
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:946

Referenced by ImeWnd_OnImeNotify(), ImeWnd_OnImeSetContext(), ImeWnd_OnImeSystem(), Imm32CShapeToggle(), Imm32CSymbolToggle(), Imm32DestroyInputContext(), Imm32ImeNonImeToggle(), Imm32KEnglish(), Imm32KHanjaConvert(), Imm32KShapeToggle(), Imm32OpenICAndCS(), Imm32SelectInputContext(), Imm32SendNotificationProc(), ImmGenerateMessage(), ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetCandidateWindow(), ImmGetCompositionFontA(), ImmGetCompositionFontW(), ImmGetCompositionStringA(), ImmGetCompositionStringW(), ImmGetCompositionWindow(), ImmGetConversionStatus(), ImmGetGuideLineAW(), ImmGetImeMenuItemsAW(), ImmGetOpenStatus(), ImmGetStatusWindowPos(), ImmGetVirtualKey(), ImmProcessKey(), ImmRequestMessageAW(), ImmSetActiveContext(), ImmSetCandidateWindow(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), ImmSetCompositionStringAW(), ImmSetCompositionWindow(), ImmSetConversionStatus(), ImmSetOpenStatus(), ImmSetStatusWindowPos(), ImmTranslateMessage(), Test1(), test_ImmDestroyContext(), test_ImmGetIMCLockCount(), test_ImmMessages(), and test_InvalidIMC().

◆ ImmWINNLSGetEnableStatus()

BOOL WINAPI ImmWINNLSGetEnableStatus ( HWND  hWnd)

Definition at line 1217 of file imm.c.

1218 {
1220  {
1222  return FALSE;
1223  }
1224 
1225  return !!ImmGetSaveContext(hWnd, 2);
1226 }
HWND hWnd
Definition: settings.c:17
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean(VOID)
Definition: utils.c:45
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:611
static HIMC APIENTRY ImmGetSaveContext(HWND hWnd, DWORD dwContextFlags)
Definition: imm.c:966
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

Referenced by WINNLSGetEnableStatus().

◆ User32InitializeImmEntryTable()

BOOL WINAPI User32InitializeImmEntryTable ( DWORD  )

Definition at line 126 of file imm.c.

127 {
128  TRACE("Imm (%x)\n", magic);
129 
130  if (magic != IMM_INIT_MAGIC)
131  return FALSE;
132 
133  /* Check whether the IMM table has already been initialized */
134  if (IMM_FN(ImmWINNLSEnableIME) != IMMSTUB_ImmWINNLSEnableIME)
135  return TRUE;
136 
138 
139  if (ghImm32 == NULL && !gbImmInitializing)
140  {
141  WCHAR ImmFile[MAX_PATH];
142  User32GetImmFileName(ImmFile, _countof(ImmFile));
143  ghImm32 = LoadLibraryW(ImmFile);
144  if (ghImm32 == NULL)
145  {
146  ERR("Did not load imm32.dll!\n");
147  return FALSE;
148  }
149  }
150 
152 }
#define TRUE
Definition: types.h:120
u32_t magic(void)
HRESULT User32GetImmFileName(_Out_ LPWSTR lpBuffer, _In_ size_t cchBuffer)
Definition: imm.c:57
BOOL WINAPI ImmRegisterClient(PSHAREDINFO ptr, HINSTANCE hMod)
Definition: imm.c:44
#define FALSE
Definition: types.h:117
#define LoadLibraryW(x)
Definition: compat.h:606
BOOL gbImmInitializing
Definition: imm.c:22
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
SHAREDINFO gSharedInfo
Definition: imm.c:18
BOOL WINAPI ImmWINNLSEnableIME(HWND hWnd, BOOL enable)
Definition: ime.c:2007
static BOOL IntInitializeImmEntryTable(VOID)
Definition: imm.c:70
#define ERR(fmt,...)
Definition: debug.h:110
HINSTANCE ghImm32
Definition: imm.c:20
#define NULL
Definition: types.h:112
#define IMM_INIT_MAGIC
Definition: imm.c:16
#define IMM_FN(name)
Definition: user32p.h:56

Referenced by DllMain().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( imm  )

Variable Documentation

◆ gfImmInitialized

BYTE gfImmInitialized = FALSE

Definition at line 19 of file imm.c.

Referenced by ImmInitializeGlobals().

◆ ghImm32Inst

HMODULE ghImm32Inst = NULL

Definition at line 16 of file imm.c.

Referenced by ImmInitializeGlobals().

◆ gpsi

PSERVERINFO gpsi = NULL

Definition at line 17 of file imm.c.

Referenced by alloc_user_entry(), co_IntCreateDefaultImeWindow(), co_IntInitializeDesktopGraphics(), co_IntSendActivateMessages(), co_IntSendMessageTimeout(), co_IntSetCaretPos(), co_IntSetupOBM(), co_IntSetWndIcons(), co_IntShellHookNotify(), co_MsqInsertMouseMessage(), co_MsqSendMessage(), co_UserCreateWindowEx(), co_UserDestroyWindow(), co_UserShowCaret(), co_WinPosSetWindowPos(), CreateSysColorObjects(), CtfImmSetLangBand(), DefWndControlColor(), DefWndGetIcon(), DefWndHandleSetCursor(), DefWndSetIcon(), DrawFocusRect(), EnumerateCallback(), free_user_entry(), GetLastInputInfo(), GetSysColor(), GetSysColorBrush(), GetSystemMetrics(), ImmRegisterClient(), InitMetrics(), InitUserAtoms(), IntCheckImeShowStatus(), IntCoalesceMouseMove(), IntCreateClass(), IntCreateDesktop(), IntCreateWindow(), IntDeactivateWindow(), IntDefWindowProc(), IntDrawState(), IntFlashWindowEx(), IntGetSysColor(), IntGetSysColorBrush(), IntGetWindowContextHelpId(), IntGrayString(), IntIsFontRenderingEnabled(), IntIsGhostWindow(), IntLastInputTick(), IntNotifyWinEvent(), IntRealChildWindowFromPoint(), IntRemoveEvent(), IntSetCaretBlinkTime(), IntSetSrvEventMask(), IntSetSysColors(), IntTranslateKbdMessage(), IsDialogMessageW(), IsWinEventHookInstalled(), LoadSystemCursors(), LoadUserApiHook(), MENU_AdjustMenuItemRect(), MENU_CalcItemSize(), MENU_DrawMenuItem(), MENU_DrawScrollArrows(), MENU_EnsureMenuItemVisible(), MENU_InitPopup(), MouseSafetyOnDrawEnd(), NC_IconForWindow(), NotifyWinEvent(), NtUserCallHwnd(), NtUserCallHwndParam(), NtUserCallNoParam(), NtUserCallOneParam(), NtUserCreateCaret(), NtUserGetCaretBlinkTime(), NtUserGetClassName(), NtUserGetComboBoxInfo(), NtUserGetCursorInfo(), NtUserGetListBoxInfo(), NtUserInitializeClientPfnArrays(), NtUserMessageCall(), NtUserNotifyWinEvent(), NtUserProcessConnect(), NtUserSetImeOwnerWindow(), PostTimerMessages(), ProcessKeyEvent(), RealGetSystemMetrics(), RegisterControlAtoms(), SpiUpdatePerUserSystemParameters(), SystemTimerProc(), UITOOLS_DrawCheckedRect(), UpdatePerUserImmEnabling(), UserAttachThreadInput(), UserChangeDisplaySettings(), UserClipCursor(), UserDrawWindowFrame(), UserGetSystemMetrics(), UserInitialize(), UserPaintCaption(), UserPostMessage(), UserPostThreadMessage(), UserRegisterUserApiHook(), UserSendMouseInput(), UserSendNotifyMessage(), UserSetCursor(), UserSetCursorPos(), UserShowCursor(), UserUnregisterUserApiHook(), and UserUpdateMonitorSize().

◆ gSharedInfo

SHAREDINFO gSharedInfo = { NULL }