ReactOS  0.4.15-dev-4570-g4f8bbd1
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 1253 of file imm.c.

1254 {
1255  HKL hKL;
1256  HIMC hIMC;
1257 
1258  TRACE("(%p, 0x%X, %p)\n", hinstDLL, fdwReason, lpReserved);
1259 
1260  switch (fdwReason)
1261  {
1262  case DLL_PROCESS_ATTACH:
1263  if (!ImmInitializeGlobals(hinstDLL))
1264  {
1265  ERR("ImmInitializeGlobals failed\n");
1266  return FALSE;
1267  }
1269  {
1270  ERR("User32InitializeImmEntryTable failed\n");
1271  return FALSE;
1272  }
1273  break;
1274 
1275  case DLL_THREAD_ATTACH:
1276  break;
1277 
1278  case DLL_THREAD_DETACH:
1279  if (!IS_IMM_MODE() || NtCurrentTeb()->Win32ThreadInfo == NULL)
1280  return TRUE;
1281 
1282  hKL = GetKeyboardLayout(0);
1284  Imm32DestroyInputContext(hIMC, hKL, TRUE);
1285  break;
1286 
1287  case DLL_PROCESS_DETACH:
1289  TRACE("imm32.dll is unloaded\n");
1290  break;
1291  }
1292 
1293  return TRUE;
1294 }
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 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:640
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
#define IS_IMM_MODE()
Definition: precomp.h:117
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 492 of file imm.c.

493 {
494  TRACE("We have to do something\n");
495 }
#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 722 of file imm.c.

723 {
724  DWORD dwIndex, cbPrivate;
725  PIMEDPI pImeDpi = NULL;
727  LPCANDIDATEINFO pCI;
728  LPGUIDELINE pGL;
729 
730  /* Create IC components */
731  pIC->hCompStr = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
732  pIC->hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO));
733  pIC->hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE));
734  pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
735  if (!pIC->hCompStr || !pIC->hCandInfo || !pIC->hGuideLine || !pIC->hMsgBuf)
736  goto Fail;
737 
738  /* Initialize IC components */
739  pCS = ImmLockIMCC(pIC->hCompStr);
740  if (!pCS)
741  goto Fail;
742  pCS->dwSize = sizeof(COMPOSITIONSTRING);
743  ImmUnlockIMCC(pIC->hCompStr);
744 
745  pCI = ImmLockIMCC(pIC->hCandInfo);
746  if (!pCI)
747  goto Fail;
748  pCI->dwSize = sizeof(CANDIDATEINFO);
749  ImmUnlockIMCC(pIC->hCandInfo);
750 
751  pGL = ImmLockIMCC(pIC->hGuideLine);
752  if (!pGL)
753  goto Fail;
754  pGL->dwSize = sizeof(GUIDELINE);
756 
757  pIC->dwNumMsgBuf = 0;
758  pIC->fOpen = FALSE;
759  pIC->fdwConversion = pIC->fdwSentence = 0;
760 
761  for (dwIndex = 0; dwIndex < MAX_CANDIDATEFORM; ++dwIndex)
762  pIC->cfCandForm[dwIndex].dwIndex = IMM_INVALID_CANDFORM;
763 
764  /* Get private data size */
765  pImeDpi = ImmLockImeDpi(hKL);
766  if (!pImeDpi)
767  {
768  cbPrivate = sizeof(DWORD);
769  }
770  else
771  {
772  /* Update CLIENTIMC */
773  pClientImc->uCodePage = pImeDpi->uCodePage;
774  if (ImeDpi_IsUnicode(pImeDpi))
775  pClientImc->dwFlags |= CLIENTIMC_WIDE;
776 
777  cbPrivate = pImeDpi->ImeInfo.dwPrivateDataSize;
778  }
779 
780  /* Create private data */
781  pIC->hPrivate = ImmCreateIMCC(cbPrivate);
782  if (!pIC->hPrivate)
783  goto Fail;
784 
785  if (pImeDpi)
786  {
787  /* Select the IME */
788  if (fSelect)
789  {
790  if (IS_IME_HKL(hKL))
791  pImeDpi->ImeSelect(hIMC, TRUE);
792  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pImeDpi->CtfImeSelectEx)
793  pImeDpi->CtfImeSelectEx(hIMC, TRUE, hKL);
794  }
795 
796  /* Set HKL */
797  pClientImc->hKL = hKL;
798 
799  ImmUnlockImeDpi(pImeDpi);
800  }
801 
802  return TRUE;
803 
804 Fail:
805  if (pImeDpi)
806  ImmUnlockImeDpi(pImeDpi);
807 
808  pIC->hMsgBuf = ImmDestroyIMCC(pIC->hMsgBuf);
809  pIC->hGuideLine = ImmDestroyIMCC(pIC->hGuideLine);
810  pIC->hCandInfo = ImmDestroyIMCC(pIC->hCandInfo);
811  pIC->hCompStr = ImmDestroyIMCC(pIC->hCompStr);
812  return FALSE;
813 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:758
UINT uCodePage
Definition: ntuser.h:1254
IMEINFO ImeInfo
Definition: ntuser.h:1253
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:976
#define TRUE
Definition: types.h:120
#define MAX_CANDIDATEFORM
Definition: imm.c:17
CANDIDATEFORM cfCandForm[4]
Definition: immdev.h:50
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:986
DWORD fdwConversion
Definition: immdev.h:43
HIMCC hPrivate
Definition: immdev.h:54
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:1325
#define FALSE
Definition: types.h:117
HIMCC hCandInfo
Definition: immdev.h:52
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1203
UINT uCodePage
Definition: ntuser.h:1308
HIMCC WINAPI ImmCreateIMCC(DWORD size)
Definition: utils.c:966
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:729
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:996
HIMCC hMsgBuf
Definition: immdev.h:56
DWORD dwPrivateDataSize
Definition: imm.h:157
HIMCC hCompStr
Definition: immdev.h:51
DWORD dwIndex
Definition: dimm.idl:79
#define IMM_INVALID_CANDFORM
Definition: precomp.h:51
HIMCC hGuideLine
Definition: immdev.h:53
DWORD dwNumMsgBuf
Definition: immdev.h:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
DWORD fdwSentence
Definition: immdev.h:44
#define Imm32Is16BitMode()
Definition: precomp.h:119
DWORD dwFlags
Definition: ntuser.h:1305
struct tagCANDIDATEINFO CANDIDATEINFO
#define Imm32IsCiceroMode()
Definition: precomp.h:118

Referenced by Imm32InternalLockIMC().

◆ Imm32DestroyImeModeSaver()

static VOID APIENTRY Imm32DestroyImeModeSaver ( LPINPUTCONTEXTDX  pIC)
static

Definition at line 618 of file imm.c.

619 {
620  PIME_STATE pState, pNext;
621  PIME_SUBSTATE pSubState, pSubNext;
622 
623  for (pState = pIC->pState; pState; pState = pNext)
624  {
625  pNext = pState->pNext;
626 
627  for (pSubState = pState->pSubState; pSubState; pSubState = pSubNext)
628  {
629  pSubNext = pSubState->pNext;
630  ImmLocalFree(pSubState);
631  }
632 
633  ImmLocalFree(pState);
634  }
635 
636  pIC->pState = NULL;
637 }
#define ImmLocalFree(lpData)
Definition: precomp.h:89
PIME_SUBSTATE pSubState
Definition: immdev.h:197
#define NULL
Definition: types.h:112
struct IME_STATE * pState
Definition: immdev.h:111
struct IME_STATE * pNext
Definition: immdev.h:191
struct IME_SUBSTATE * pNext
Definition: immdev.h:180

Referenced by Imm32DestroyInputContext().

◆ Imm32DestroyInputContext()

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

Definition at line 640 of file imm.c.

641 {
642  PIMEDPI pImeDpi;
643  LPINPUTCONTEXTDX pIC;
644  PCLIENTIMC pClientImc;
645  PIMC pIMC;
646 
647  if (!hIMC || !IS_IMM_MODE())
648  return FALSE;
649 
650  pIMC = ValidateHandle(hIMC, TYPE_INPUTCONTEXT);
651  if (!pIMC || pIMC->head.pti != Imm32CurrentPti())
652  {
653  ERR("invalid pIMC: %p\n", pIMC);
654  return FALSE;
655  }
656 
657  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
658  if (!pClientImc)
659  goto Finish;
660 
661  if ((pClientImc->dwFlags & CLIENTIMC_UNKNOWN2) && !bKeep)
662  {
663  ERR("CLIENTIMC_UNKNOWN2\n");
664  return FALSE;
665  }
666 
667  if (pClientImc->dwFlags & CLIENTIMC_DESTROY)
668  return TRUE;
669 
670  InterlockedIncrement(&pClientImc->cLockObj);
671 
672  if (!pClientImc->hInputContext)
673  goto Quit;
674 
675  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
676  if (!pIC)
677  {
678  ImmUnlockClientImc(pClientImc);
679  ERR("!pIC\n");
680  return FALSE;
681  }
682 
684 
685  if (pClientImc->hKL == hKL)
686  {
687  pImeDpi = ImmLockImeDpi(hKL);
688  if (pImeDpi)
689  {
690  if (IS_IME_HKL(hKL))
691  pImeDpi->ImeSelect(hIMC, FALSE);
692  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode())
693  pImeDpi->CtfImeSelectEx(hIMC, FALSE, hKL);
694 
695  ImmUnlockImeDpi(pImeDpi);
696  }
697 
698  pClientImc->hKL = NULL;
699  }
700 
701  ImmDestroyIMCC(pIC->hPrivate);
702  ImmDestroyIMCC(pIC->hMsgBuf);
703  ImmDestroyIMCC(pIC->hGuideLine);
704  ImmDestroyIMCC(pIC->hCandInfo);
705  ImmDestroyIMCC(pIC->hCompStr);
707  ImmUnlockIMC(hIMC);
708 
709 Quit:
710  pClientImc->dwFlags |= CLIENTIMC_DESTROY;
711  ImmUnlockClientImc(pClientImc);
712 
713 Finish:
714  if (bKeep)
715  return TRUE;
716  return NtUserDestroyInputContext(hIMC);
717 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:758
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:976
#define TRUE
Definition: types.h:120
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1023
LONG cLockObj
Definition: ntuser.h:1304
Definition: ntuser.h:190
static PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: precomp.h:162
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define CLIENTIMC_UNKNOWN2
Definition: ntuser.h:1330
#define CLIENTIMC_DESTROY
Definition: ntuser.h:1328
#define FALSE
Definition: types.h:117
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1203
struct tagCLIENTIMC * PCLIENTIMC
BOOL NTAPI NtUserDestroyInputContext(HIMC hIMC)
Definition: ime.c:1517
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:729
HANDLE hInputContext
Definition: ntuser.h:1303
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define IS_IMM_MODE()
Definition: precomp.h:117
#define ERR(fmt,...)
Definition: debug.h:110
#define InterlockedIncrement
Definition: armddk.h:53
THRDESKHEAD head
Definition: ntuser.h:192
#define NULL
Definition: types.h:112
#define Imm32Is16BitMode()
Definition: precomp.h:119
DWORD dwFlags
Definition: ntuser.h:1305
static VOID APIENTRY Imm32DestroyImeModeSaver(LPINPUTCONTEXTDX pIC)
Definition: imm.c:618
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:207
HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC)
Definition: ctf.c:33
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1032
#define Imm32IsCiceroMode()
Definition: precomp.h:118
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

Referenced by DllMain(), and ImmDestroyContext().

◆ Imm32InternalLockIMC()

LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC ( HIMC  hIMC,
BOOL  fSelect 
)

Definition at line 816 of file imm.c.

817 {
818  HANDLE hIC;
819  LPINPUTCONTEXT pIC = NULL;
820  PCLIENTIMC pClientImc;
821  WORD LangID;
823  HKL hOldKL, hNewKL;
824  PIMEDPI pImeDpi = NULL;
825 
826  pClientImc = ImmLockClientImc(hIMC);
827  if (!pClientImc)
828  return NULL;
829 
830  RtlEnterCriticalSection(&pClientImc->cs);
831 
832  if (pClientImc->hInputContext)
833  {
834  pIC = LocalLock(pClientImc->hInputContext);
835  if (pIC)
836  goto Success;
837  else
838  goto Failure;
839  }
840 
843  {
844  hOldKL = GetKeyboardLayout(0);
845  LangID = LOWORD(hOldKL);
846  hNewKL = (HKL)(DWORD_PTR)MAKELONG(LangID, LangID);
847 
848  pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
849  if (pImeDpi)
850  {
851  CtfImmTIMActivate(hNewKL);
852  }
853  }
854 
856  goto Failure;
857 
858  hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
859  pIC = LocalLock(hIC);
860  if (!pIC)
861  {
862  LocalFree(hIC);
863  goto Failure;
864  }
865  pClientImc->hInputContext = hIC;
866 
867  hNewKL = GetKeyboardLayout(dwThreadId);
868  if (!Imm32CreateInputContext(hIMC, pIC, pClientImc, hNewKL, fSelect))
869  {
870  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
871  goto Failure;
872  }
873 
874 Success:
876  RtlLeaveCriticalSection(&pClientImc->cs);
877  InterlockedIncrement(&pClientImc->cLockObj);
878  ImmUnlockClientImc(pClientImc);
879  return pIC;
880 
881 Failure:
882  RtlLeaveCriticalSection(&pClientImc->cs);
883  ImmUnlockClientImc(pClientImc);
884  return NULL;
885 }
LONG cLockObj
Definition: ntuser.h:1304
HRESULT APIENTRY CtfImmTIMCreateInputContext(HIMC hIMC)
Definition: ctf.c:42
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:722
#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:909
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:459
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1773
HANDLE hInputContext
Definition: ntuser.h:1303
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:1307
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
#define Imm32Is16BitMode()
Definition: precomp.h:119
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL)
Definition: ime.c:285
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 Imm32IsCiceroMode()
Definition: precomp.h:118
#define LOWORD(l)
Definition: pedump.c:82
HRESULT WINAPI CtfImmTIMActivate(HKL hKL)
Definition: ctf.c:67
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

Referenced by Imm32SelectInputContext(), and ImmLockIMC().

◆ Imm32NotifyIMEProc()

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

Definition at line 437 of file imm.c.

438 {
440  return TRUE;
441 }
#define TRUE
Definition: types.h:120
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
Definition: ime.c:652
#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 429 of file imm.c.

430 {
432  Imm32SelectInputContext(pSelect->hNewKL, pSelect->hOldKL, hIMC);
433  return TRUE;
434 }
#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:182
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 182 of file imm.c.

183 {
184  PCLIENTIMC pClientImc;
185  LPINPUTCONTEXTDX pIC;
186  LPGUIDELINE pGL;
187  LPCANDIDATEINFO pCI;
189  LOGFONTA LogFontA;
190  LOGFONTW LogFontW;
191  BOOL fOpen, bIsNewHKLIme = TRUE, bIsOldHKLIme = TRUE, bClientWide, bNewDpiWide;
192  DWORD cbNewPrivate = 0, cbOldPrivate = 0, dwConversion, dwSentence, dwSize, dwNewSize;
193  PIMEDPI pNewImeDpi = NULL, pOldImeDpi = NULL;
194  HANDLE hPrivate;
195  PIME_STATE pNewState = NULL, pOldState = NULL;
196 
197  pClientImc = ImmLockClientImc(hIMC);
198  if (!pClientImc)
199  return;
200 
201  pNewImeDpi = ImmLockImeDpi(hNewKL);
202 
203  if (hNewKL != hOldKL)
204  pOldImeDpi = ImmLockImeDpi(hOldKL);
205 
206  if (pNewImeDpi)
207  {
208  cbNewPrivate = pNewImeDpi->ImeInfo.dwPrivateDataSize;
209  pClientImc->uCodePage = pNewImeDpi->uCodePage;
210  }
211  else
212  {
213  pClientImc->uCodePage = CP_ACP;
214  }
215 
216  if (cbNewPrivate < sizeof(DWORD))
217  cbNewPrivate = sizeof(DWORD);
218 
219  if (pOldImeDpi)
220  cbOldPrivate = pOldImeDpi->ImeInfo.dwPrivateDataSize;
221 
222  if (cbOldPrivate < sizeof(DWORD))
223  cbOldPrivate = sizeof(DWORD);
224 
225  if (pClientImc->hKL == hOldKL)
226  {
227  if (pOldImeDpi)
228  {
229  if (IS_IME_HKL(hOldKL))
230  pOldImeDpi->ImeSelect(hIMC, FALSE);
231  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pOldImeDpi->CtfImeSelectEx)
232  pOldImeDpi->CtfImeSelectEx(hIMC, FALSE, hOldKL);
233  }
234  pClientImc->hKL = NULL;
235  }
236 
238  {
239  if (IS_IMM_MODE() && !Imm32IsCiceroMode())
240  {
241  bIsNewHKLIme = IS_IME_HKL(hNewKL);
242  bIsOldHKLIme = IS_IME_HKL(hOldKL);
243  }
244  }
245 
247  if (!pIC)
248  {
249  if (pNewImeDpi)
250  {
251  if (IS_IME_HKL(hNewKL))
252  pNewImeDpi->ImeSelect(hIMC, TRUE);
253  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pNewImeDpi->CtfImeSelectEx)
254  pNewImeDpi->CtfImeSelectEx(hIMC, TRUE, hNewKL);
255 
256  pClientImc->hKL = hNewKL;
257  }
258  }
259  else
260  {
261  dwConversion = pIC->fdwConversion;
262  dwSentence = pIC->fdwSentence;
263  fOpen = pIC->fOpen;
264 
265  if (pNewImeDpi)
266  {
267  bClientWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
268  bNewDpiWide = ImeDpi_IsUnicode(pNewImeDpi);
269  if (bClientWide && !bNewDpiWide)
270  {
271  if (pIC->fdwInit & INIT_LOGFONT)
272  {
273  LogFontWideToAnsi(&pIC->lfFont.W, &LogFontA);
274  pIC->lfFont.A = LogFontA;
275  }
276  pClientImc->dwFlags &= ~CLIENTIMC_WIDE;
277  }
278  else if (!bClientWide && bNewDpiWide)
279  {
280  if (pIC->fdwInit & INIT_LOGFONT)
281  {
282  LogFontAnsiToWide(&pIC->lfFont.A, &LogFontW);
283  pIC->lfFont.W = LogFontW;
284  }
285  pClientImc->dwFlags |= CLIENTIMC_WIDE;
286  }
287  }
288 
289  if (cbOldPrivate != cbNewPrivate)
290  {
291  hPrivate = ImmReSizeIMCC(pIC->hPrivate, cbNewPrivate);
292  if (!hPrivate)
293  {
294  ImmDestroyIMCC(pIC->hPrivate);
295  hPrivate = ImmCreateIMCC(cbNewPrivate);
296  }
297  pIC->hPrivate = hPrivate;
298  }
299 
300 #define MAX_IMCC_SIZE 0x1000
301  dwSize = ImmGetIMCCSize(pIC->hMsgBuf);
302  if (ImmGetIMCCLockCount(pIC->hMsgBuf) || dwSize > MAX_IMCC_SIZE)
303  {
304  ImmDestroyIMCC(pIC->hMsgBuf);
305  pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
306  pIC->dwNumMsgBuf = 0;
307  }
308 
309  dwSize = ImmGetIMCCSize(pIC->hGuideLine);
310  dwNewSize = sizeof(GUIDELINE);
311  if (ImmGetIMCCLockCount(pIC->hGuideLine) ||
312  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
313  {
314  ImmDestroyIMCC(pIC->hGuideLine);
315  pIC->hGuideLine = ImmCreateIMCC(dwNewSize);
316  pGL = ImmLockIMCC(pIC->hGuideLine);
317  if (pGL)
318  {
319  pGL->dwSize = dwNewSize;
320  ImmUnlockIMCC(pIC->hGuideLine);
321  }
322  }
323 
324  dwSize = ImmGetIMCCSize(pIC->hCandInfo);
325  dwNewSize = sizeof(CANDIDATEINFO);
326  if (ImmGetIMCCLockCount(pIC->hCandInfo) ||
327  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
328  {
329  ImmDestroyIMCC(pIC->hCandInfo);
330  pIC->hCandInfo = ImmCreateIMCC(dwNewSize);
331  pCI = ImmLockIMCC(pIC->hCandInfo);
332  if (pCI)
333  {
334  pCI->dwSize = dwNewSize;
335  ImmUnlockIMCC(pIC->hCandInfo);
336  }
337  }
338 
339  dwSize = ImmGetIMCCSize(pIC->hCompStr);
340  dwNewSize = sizeof(COMPOSITIONSTRING);
341  if (ImmGetIMCCLockCount(pIC->hCompStr) ||
342  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
343  {
344  ImmDestroyIMCC(pIC->hCompStr);
345  pIC->hCompStr = ImmCreateIMCC(dwNewSize);
346  pCS = ImmLockIMCC(pIC->hCompStr);
347  if (pCS)
348  {
349  pCS->dwSize = dwNewSize;
350  ImmUnlockIMCC(pIC->hCompStr);
351  }
352  }
353 #undef MAX_IMCC_SIZE
354 
355  if (pOldImeDpi && bIsOldHKLIme)
356  {
357  pOldState = Imm32FetchImeState(pIC, hOldKL);
358  if (pOldState)
359  Imm32SaveImeStateSentence(pIC, pOldState, hOldKL);
360  }
361 
362  if (pNewImeDpi && bIsNewHKLIme)
363  pNewState = Imm32FetchImeState(pIC, hNewKL);
364 
365  if (pOldState != pNewState)
366  {
367  if (pOldState)
368  {
369  pOldState->fOpen = !!pIC->fOpen;
370  pOldState->dwConversion = (pIC->fdwConversion & ~IME_CMODE_EUDC);
371  pOldState->dwSentence = pIC->fdwSentence;
372  pOldState->dwInit = pIC->fdwInit;
373  }
374 
375  if (pNewState)
376  {
378  {
380  pIC->fOpen = TRUE;
381  }
382  else
383  {
384  pIC->fOpen = pNewState->fOpen;
385  }
386 
387  pIC->fdwConversion = (pNewState->dwConversion & ~IME_CMODE_EUDC);
388  pIC->fdwSentence = pNewState->dwSentence;
389  pIC->fdwInit = pNewState->dwInit;
390  }
391  }
392 
393  if (pNewState)
394  Imm32LoadImeStateSentence(pIC, pNewState, hNewKL);
395 
396  if (pNewImeDpi)
397  {
398  if (IS_IME_HKL(hNewKL))
399  pNewImeDpi->ImeSelect(hIMC, TRUE);
400  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pNewImeDpi->CtfImeSelectEx)
401  pNewImeDpi->CtfImeSelectEx(hIMC, TRUE, hNewKL);
402 
403  pClientImc->hKL = hNewKL;
404  }
405 
406  pIC->dwChange = 0;
407  if (pIC->fOpen != fOpen)
409  if (pIC->fdwConversion != dwConversion)
411  if (pIC->fdwSentence != dwSentence)
413 
414  ImmUnlockIMC(hIMC);
415  }
416 
417  ImmUnlockImeDpi(pOldImeDpi);
418  ImmUnlockImeDpi(pNewImeDpi);
419  ImmUnlockClientImc(pClientImc);
420 }
DWORD WINAPI ImmGetIMCCSize(HIMCC imcc)
Definition: utils.c:1024
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:758
UINT uCodePage
Definition: ntuser.h:1254
BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
Definition: ctf.c:59
IMEINFO ImeInfo
Definition: ntuser.h:1253
DWORD dwInit
Definition: immdev.h:196
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:976
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:132
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
BOOL APIENTRY Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:414
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect)
Definition: imm.c:816
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:986
#define INPUTCONTEXTDX_CHANGE_OPEN
Definition: immdev.h:134
DWORD dwChange
Definition: immdev.h:112
DWORD dwSize
Definition: imm.h:205
#define DWORD
Definition: nt_native.h:44
#define CLIENTIMC_WIDE
Definition: ntuser.h:1325
PIME_STATE APIENTRY Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL)
Definition: utils.c:370
#define MAX_IMCC_SIZE
#define FALSE
Definition: types.h:117
DWORD dwSentence
Definition: immdev.h:195
unsigned int BOOL
Definition: ntddk_ex.h:94
#define INIT_LOGFONT
Definition: immdev.h:129
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1203
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
UINT uCodePage
Definition: ntuser.h:1308
HIMCC WINAPI ImmCreateIMCC(DWORD size)
Definition: utils.c:966
WORD fOpen
Definition: immdev.h:193
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:729
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:145
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:996
DWORD dwPrivateDataSize
Definition: imm.h:157
#define IS_IMM_MODE()
Definition: precomp.h:117
#define INPUTCONTEXTDX_CHANGE_SENTENCE
Definition: immdev.h:136
#define INPUTCONTEXTDX_CHANGE_FORCE_OPEN
Definition: immdev.h:137
DWORD dwConversion
Definition: immdev.h:194
HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size)
Definition: utils.c:1014
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define Imm32Is16BitMode()
Definition: precomp.h:119
DWORD dwFlags
Definition: ntuser.h:1305
DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc)
Definition: utils.c:1006
#define INPUTCONTEXTDX_CHANGE_CONVERSION
Definition: immdev.h:135
BOOL APIENTRY Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:427
struct tagCANDIDATEINFO CANDIDATEINFO
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1032
#define Imm32IsCiceroMode()
Definition: precomp.h:118
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954
#define IME_CMODE_EUDC
Definition: imm.h:499

Referenced by Imm32SelectContextProc().

◆ ImmActivateLayout()

BOOL WINAPI ImmActivateLayout ( HKL  hKL)

Definition at line 446 of file imm.c.

447 {
448  PIMEDPI pImeDpi;
449  HKL hOldKL;
450  LPARAM lParam;
451  HWND hwndDefIME = NULL;
452  SELECT_LAYOUT SelectLayout;
453 
454  hOldKL = GetKeyboardLayout(0);
455 
456  if (hOldKL == hKL && !(GetWin32ClientInfo()->CI_flags & CI_IMMACTIVATE))
457  return TRUE;
458 
459  ImmLoadIME(hKL);
460 
461  if (hOldKL != hKL)
462  {
463  pImeDpi = ImmLockImeDpi(hOldKL);
464  if (pImeDpi)
465  {
468  else
469  lParam = CPS_CANCEL;
470  ImmUnlockImeDpi(pImeDpi);
471 
473  }
474 
475  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
476  if (IsWindow(hwndDefIME))
477  SendMessageW(hwndDefIME, WM_IME_SELECT, FALSE, (LPARAM)hOldKL);
478 
479  NtUserSetThreadLayoutHandles(hKL, hOldKL);
480  }
481 
482  SelectLayout.hNewKL = hKL;
483  SelectLayout.hOldKL = hOldKL;
485 
486  if (IsWindow(hwndDefIME))
487  SendMessageW(hwndDefIME, WM_IME_SELECT, TRUE, (LPARAM)hKL);
488 
489  return TRUE;
490 }
DWORD NTAPI NtUserSetThreadLayoutHandles(HKL hNewKL, HKL hOldKL)
Definition: ime.c:516
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:758
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1101
IMEINFO ImeInfo
Definition: ntuser.h:1253
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define WM_IME_SELECT
Definition: winuser.h:1820
BOOL WINAPI ImmLoadIME(HKL hKL)
Definition: ime.c:806
HKL hOldKL
Definition: imm.c:425
#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:729
static BOOL CALLBACK Imm32NotifyIMEProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:437
UINT_PTR HKL
Definition: msctf.idl:101
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:638
#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:424
static BOOL CALLBACK Imm32SelectContextProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:429
LPARAM lParam
Definition: combotst.c:139

Referenced by ImeWnd_OnImeSystem().

◆ ImmAssociateContext()

HIMC WINAPI ImmAssociateContext ( HWND  hWnd,
HIMC  hIMC 
)

Definition at line 500 of file imm.c.

501 {
502  PWND pWnd;
503  HWND hwndFocus;
504  DWORD dwValue;
505  HIMC hOldIMC;
506 
507  TRACE("(%p, %p)\n", hWnd, hIMC);
508 
509  if (!IS_IMM_MODE())
510  return NULL;
511 
512  pWnd = ValidateHwnd(hWnd);
513  if (!pWnd)
514  return NULL;
515 
516  if (hIMC && Imm32IsCrossThreadAccess(hIMC))
517  return NULL;
518 
519  hOldIMC = pWnd->hImc;
520  if (hOldIMC == hIMC)
521  return hIMC;
522 
523  dwValue = NtUserAssociateInputContext(hWnd, hIMC, 0);
524  if (dwValue == 0)
525  return hOldIMC;
526  if (dwValue != 1)
527  return NULL;
528 
530  if (hwndFocus == hWnd)
531  {
532  ImmSetActiveContext(hWnd, hOldIMC, FALSE);
533  ImmSetActiveContext(hWnd, hIMC, TRUE);
534  }
535 
536  return hOldIMC;
537 }
DWORD NTAPI NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: ime.c:1684
#define TRUE
Definition: types.h:120
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:1129
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4172
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2922
#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
#define IS_IMM_MODE()
Definition: precomp.h:117
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 542 of file imm.c.

543 {
544  HWND hwndFocus;
545  PWND pFocusWnd;
546  HIMC hOldIMC = NULL;
547  DWORD dwValue;
548 
549  TRACE("(%p, %p, 0x%lX)\n", hWnd, hIMC, dwFlags);
550 
551  if (!IS_IMM_MODE())
552  return FALSE;
553 
554  if (hIMC && !(dwFlags & IACE_DEFAULT) && Imm32IsCrossThreadAccess(hIMC))
555  return FALSE;
556 
558  pFocusWnd = ValidateHwnd(hwndFocus);
559  if (pFocusWnd)
560  hOldIMC = pFocusWnd->hImc;
561 
562  dwValue = NtUserAssociateInputContext(hWnd, hIMC, dwFlags);
563  switch (dwValue)
564  {
565  case 0:
566  return TRUE;
567 
568  case 1:
569  pFocusWnd = ValidateHwnd(hwndFocus);
570  if (pFocusWnd)
571  {
572  hIMC = pFocusWnd->hImc;
573  if (hIMC != hOldIMC)
574  {
575  ImmSetActiveContext(hwndFocus, hOldIMC, FALSE);
576  ImmSetActiveContext(hwndFocus, hIMC, TRUE);
577  }
578  }
579  return TRUE;
580 
581  default:
582  return FALSE;
583  }
584 }
DWORD NTAPI NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: ime.c:1684
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:19
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1129
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4172
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2922
#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
#define IS_IMM_MODE()
Definition: precomp.h:117
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 589 of file imm.c.

590 {
591  PCLIENTIMC pClientImc;
592  HIMC hIMC;
593 
594  TRACE("()\n");
595 
596  if (!IS_IMM_MODE())
597  return NULL;
598 
599  pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
600  if (pClientImc == NULL)
601  return NULL;
602 
603  hIMC = NtUserCreateInputContext((ULONG_PTR)pClientImc);
604  if (hIMC == NULL)
605  {
606  ImmLocalFree(pClientImc);
607  return NULL;
608  }
609 
610  RtlInitializeCriticalSection(&pClientImc->cs);
611 
613 
614  return hIMC;
615 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#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:1307
#define IS_IMM_MODE()
Definition: precomp.h:117
HIMC NTAPI NtUserCreateInputContext(ULONG_PTR dwClientImcData)
Definition: ime.c:1588
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD dwCompatFlags
Definition: ntuser.h:1306

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 1062 of file imm.c.

1063 {
1064  FIXME("(%d, %d, %d, %d): stub\n", uType, hOwner, x, y);
1066  return 0;
1067 }
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 890 of file imm.c.

891 {
892  HKL hKL;
893 
894  TRACE("(%p)\n", hIMC);
895 
896  if (!IS_IMM_MODE())
897  return FALSE;
898 
899  if (Imm32IsCrossThreadAccess(hIMC))
900  return FALSE;
901 
902  hKL = GetKeyboardLayout(0);
903  return Imm32DestroyInputContext(hIMC, hKL, FALSE);
904 }
#define FALSE
Definition: types.h:117
BOOL APIENTRY Imm32DestroyInputContext(HIMC hIMC, HKL hKL, BOOL bKeep)
Definition: imm.c:640
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: precomp.h:100
#define IS_IMM_MODE()
Definition: precomp.h:117
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 1072 of file imm.c.

1073 {
1074  TRACE("(%p)\n", hSoftWnd);
1075  return DestroyWindow(hSoftWnd);
1076 }
BOOL WINAPI DestroyWindow(_In_ HWND)
#define TRACE(s)
Definition: solgame.cpp:4

◆ ImmDisableTextFrameService()

BOOL WINAPI ImmDisableTextFrameService ( DWORD  dwThreadId)

Definition at line 1092 of file imm.c.

1093 {
1094  FIXME("Stub\n");
1095  return FALSE;
1096 }
#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 1101 of file imm.c.

1102 {
1103  HIMC *phList;
1104  DWORD dwIndex, dwCount;
1105  BOOL ret = TRUE;
1106  HIMC hIMC;
1107 
1108  TRACE("(%lu, %p, %p)\n", dwThreadId, lpfn, lParam);
1109 
1110  dwCount = Imm32BuildHimcList(dwThreadId, &phList);
1111  if (!dwCount)
1112  return FALSE;
1113 
1114  for (dwIndex = 0; dwIndex < dwCount; ++dwIndex)
1115  {
1116  hIMC = phList[dwIndex];
1117  ret = (*lpfn)(hIMC, lParam);
1118  if (!ret)
1119  break;
1120  }
1121 
1122  ImmLocalFree(phList);
1123  return ret;
1124 }
#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:279
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 Imm32SendChange(), and ImmActivateLayout().

◆ ImmFreeLayout()

BOOL WINAPI ImmFreeLayout ( DWORD  dwUnknown)

Definition at line 117 of file imm.c.

118 {
119  WCHAR szKBD[9];
120  UINT iKL, cKLs;
121  HKL hOldKL, hNewKL, *pList;
122  PIMEDPI pImeDpi;
123  LANGID LangID;
124 
125  TRACE("(0x%lX)\n", dwUnknown);
126 
127  hOldKL = GetKeyboardLayout(0);
128 
129  if (dwUnknown == 1)
130  {
131  if (!IS_IME_HKL(hOldKL))
132  return TRUE;
133 
135 
136  cKLs = GetKeyboardLayoutList(0, NULL);
137  if (cKLs)
138  {
139  pList = ImmLocalAlloc(0, cKLs * sizeof(HKL));
140  if (pList == NULL)
141  return FALSE;
142 
143  cKLs = GetKeyboardLayoutList(cKLs, pList);
144  for (iKL = 0; iKL < cKLs; ++iKL)
145  {
146  if (!IS_IME_HKL(pList[iKL]))
147  {
148  LangID = LOWORD(pList[iKL]);
149  break;
150  }
151  }
152 
154  }
155 
156  StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID);
157  if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE))
158  LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200);
159  }
160  else if (dwUnknown == 2)
161  {
163 Retry:
164  for (pImeDpi = gpImeDpiList; pImeDpi; pImeDpi = pImeDpi->pNext)
165  {
166  if (Imm32ReleaseIME(pImeDpi->hKL))
167  goto Retry;
168  }
170  }
171  else
172  {
173  hNewKL = (HKL)(DWORD_PTR)dwUnknown;
174  if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL)
175  Imm32ReleaseIME(hNewKL);
176  }
177 
178  return TRUE;
179 }
#define KLF_ACTIVATE
Definition: winuser.h:111
#define TRUE
Definition: types.h:120
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
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 IS_IME_HKL(hkl)
Definition: ntuser.h:1203
#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:1250
_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
BOOL APIENTRY Imm32ReleaseIME(HKL hKL)
Definition: ime.c:311
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:1252

Referenced by ImeWnd_OnImeSystem().

◆ ImmGetContext()

◆ ImmGetSaveContext()

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

Definition at line 974 of file imm.c.

975 {
976  HIMC hIMC;
977  PCLIENTIMC pClientImc;
978  PWND pWnd;
979 
980  if (!IS_IMM_MODE())
981  return NULL;
982 
983  if (!hWnd)
984  {
986  goto Quit;
987  }
988 
989  pWnd = ValidateHwnd(hWnd);
990  if (!pWnd || Imm32IsCrossProcessAccess(hWnd))
991  return NULL;
992 
993  hIMC = pWnd->hImc;
994  if (!hIMC && (dwContextFlags & 1))
996 
997 Quit:
998  pClientImc = ImmLockClientImc(hIMC);
999  if (pClientImc == NULL)
1000  return NULL;
1001  if ((dwContextFlags & 2) && (pClientImc->dwFlags & CLIENTIMC_UNKNOWN3))
1002  hIMC = NULL;
1003  ImmUnlockClientImc(pClientImc);
1004  return hIMC;
1005 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
HWND hWnd
Definition: settings.c:17
HIMC hImc
Definition: ntuser.h:719
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4172
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
DWORD HIMC
Definition: dimm.idl:75
#define CLIENTIMC_UNKNOWN3
Definition: ntuser.h:1329
#define IS_IMM_MODE()
Definition: precomp.h:117
Definition: ntuser.h:672
#define QUERY_WINDOW_DEFAULT_ICONTEXT
Definition: ntuser.h:2927
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1305
static BOOL Imm32IsCrossProcessAccess(HWND hWnd)
Definition: precomp.h:108
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

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;
57  HKEY hLayoutKey = NULL, hLayoutsKey = NULL;
58  LONG error;
59  WCHAR szLayout[MAX_PATH];
60 
61  TRACE("(%p, %p)\n", hKL, pImeInfoEx);
62 
63  if (IS_IME_HKL(hKL) || !Imm32IsCiceroMode() || Imm32Is16BitMode())
64  {
65  Imm32UIntToStr((DWORD)(DWORD_PTR)hKL, 16, szLayout, _countof(szLayout));
66 
68  if (error)
69  {
70  ERR("RegOpenKeyW: 0x%08lX\n", error);
71  return FALSE;
72  }
73 
74  error = RegOpenKeyW(hLayoutsKey, szLayout, &hLayoutKey);
75  if (error)
76  {
77  ERR("RegOpenKeyW: 0x%08lX\n", error);
78  RegCloseKey(hLayoutsKey);
79  return FALSE;
80  }
81  }
82  else
83  {
85  if (error)
86  {
87  ERR("RegOpenKeyW: 0x%08lX\n", error);
88  return FALSE;
89  }
90  }
91 
92  cbData = sizeof(pImeInfoEx->wszImeFile);
93  error = RegQueryValueExW(hLayoutKey, L"Ime File", 0, 0,
94  (LPBYTE)pImeInfoEx->wszImeFile, &cbData);
95  pImeInfoEx->wszImeFile[_countof(pImeInfoEx->wszImeFile) - 1] = 0;
96 
97  RegCloseKey(hLayoutKey);
98  if (hLayoutsKey)
99  RegCloseKey(hLayoutsKey);
100 
101  pImeInfoEx->fLoadFlag = 0;
102 
103  if (error)
104  {
105  ERR("RegQueryValueExW: 0x%08lX\n", error);
106  pImeInfoEx->hkl = NULL;
107  return FALSE;
108  }
109 
110  pImeInfoEx->hkl = hKL;
111  return Imm32LoadImeVerInfo(pImeInfoEx);
112 }
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:33
BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Definition: utils.c:642
#define error(str)
Definition: mkdosfs.c:1605
#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
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1203
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define ERR(fmt,...)
Definition: debug.h:110
WCHAR wszImeFile[80]
Definition: ntuser.h:1187
#define NULL
Definition: types.h:112
INT fLoadFlag
Definition: ntuser.h:1183
#define Imm32Is16BitMode()
Definition: precomp.h:119
#define Imm32IsCiceroMode()
Definition: precomp.h:118
#define RegCloseKey(hKey)
Definition: registry.h:47
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ ImmLockClientImc()

PCLIENTIMC WINAPI ImmLockClientImc ( HIMC  hImc)

Definition at line 909 of file imm.c.

910 {
911  PIMC pIMC;
912  PCLIENTIMC pClientImc;
913 
914  TRACE("(%p)\n", hImc);
915 
916  if (!hImc)
917  return NULL;
918 
919  pIMC = ValidateHandle(hImc, TYPE_INPUTCONTEXT);
920  if (!pIMC || !Imm32CheckImcProcess(pIMC))
921  return NULL;
922 
923  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
924  if (pClientImc)
925  {
926  if (pClientImc->dwFlags & CLIENTIMC_DESTROY)
927  return NULL;
928  goto Finish;
929  }
930 
931  pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
932  if (!pClientImc)
933  return NULL;
934 
935  RtlInitializeCriticalSection(&pClientImc->cs);
937 
938  if (!NtUserUpdateInputContext(hImc, UIC_CLIENTIMCDATA, (DWORD_PTR)pClientImc))
939  {
940  ImmLocalFree(pClientImc);
941  return NULL;
942  }
943 
944  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN2;
945 
946 Finish:
947  InterlockedIncrement(&pClientImc->cLockObj);
948  return pClientImc;
949 }
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:234
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:1330
#define CLIENTIMC_DESTROY
Definition: ntuser.h:1328
#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:1307
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:1744
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
Definition: utils.c:221
DWORD dwFlags
Definition: ntuser.h:1305
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:207
DWORD dwCompatFlags
Definition: ntuser.h:1306

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

◆ 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 1129 of file imm.c.

1130 {
1131  PCLIENTIMC pClientImc;
1132  LPINPUTCONTEXTDX pIC;
1133  PIMEDPI pImeDpi;
1134  HKL hKL;
1135  BOOL fOpen = FALSE;
1136  DWORD dwConversion = 0, iShow = ISC_SHOWUIALL;
1137  HWND hwndDefIME;
1138 
1139  TRACE("(%p, %p, %d)\n", hWnd, hIMC, fActive);
1140 
1141  if (!IS_IMM_MODE())
1142  return FALSE;
1143 
1144  pClientImc = ImmLockClientImc(hIMC);
1145 
1146  if (!fActive)
1147  {
1148  if (pClientImc)
1149  pClientImc->dwFlags &= ~CLIENTIMC_UNKNOWN4;
1150  }
1151  else if (hIMC)
1152  {
1153  if (!pClientImc)
1154  return FALSE;
1155 
1156  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1157  if (!pIC)
1158  {
1159  ImmUnlockClientImc(pClientImc);
1160  return FALSE;
1161  }
1162 
1163  pIC->hWnd = hWnd;
1164  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN5;
1165 
1166  if (pIC->dwUIFlags & 2)
1168 
1169  fOpen = pIC->fOpen;
1170  dwConversion = pIC->fdwConversion;
1171 
1172  ImmUnlockIMC(hIMC);
1173  }
1174  else
1175  {
1176  hIMC = ImmGetSaveContext(hWnd, 1);
1177  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1178  if (pIC)
1179  {
1180  pIC->hWnd = hWnd;
1181  ImmUnlockIMC(hIMC);
1182  }
1183  hIMC = NULL;
1184  }
1185 
1186  hKL = GetKeyboardLayout(0);
1187 
1188  if (Imm32IsCiceroMode() && !Imm32Is16BitMode())
1189  {
1190  Imm32CiceroSetActiveContext(hIMC, fActive, hWnd, hKL);
1191  hKL = GetKeyboardLayout(0);
1192  }
1193 
1194  pImeDpi = ImmLockImeDpi(hKL);
1195  if (pImeDpi)
1196  {
1197  if (IS_IME_HKL(hKL))
1198  pImeDpi->ImeSetActiveContext(hIMC, fActive);
1199  ImmUnlockImeDpi(pImeDpi);
1200  }
1201 
1202  if (IsWindow(hWnd))
1203  {
1204  SendMessageW(hWnd, WM_IME_SETCONTEXT, fActive, iShow);
1205  if (fActive)
1206  NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion);
1207  }
1208  else if (!fActive)
1209  {
1210  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
1211  if (hwndDefIME)
1212  SendMessageW(hwndDefIME, WM_IME_SETCONTEXT, 0, iShow);
1213  }
1214 
1215  if (pClientImc)
1216  ImmUnlockClientImc(pClientImc);
1217 
1218  return TRUE;
1219 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:758
DWORD dwUIFlags
Definition: immdev.h:109
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1023
HWND hWnd
Definition: settings.c:17
DWORD NTAPI NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
Definition: ime.c:809
static VOID APIENTRY Imm32CiceroSetActiveContext(HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL)
Definition: imm.c:492
#define CLIENTIMC_UNKNOWN5
Definition: ntuser.h:1326
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1203
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
#define ISC_SHOWUIALLCANDIDATEWINDOW
Definition: imm.h:307
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_IME_SETCONTEXT
Definition: winuser.h:1816
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:729
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ISC_SHOWUIALL
Definition: imm.h:308
#define IS_IMM_MODE()
Definition: precomp.h:117
UINT_PTR HKL
Definition: msctf.idl:101
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:638
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static HIMC APIENTRY ImmGetSaveContext(HWND hWnd, DWORD dwContextFlags)
Definition: imm.c:974
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112
#define Imm32Is16BitMode()
Definition: precomp.h:119
DWORD dwFlags
Definition: ntuser.h:1305
#define CLIENTIMC_UNKNOWN4
Definition: ntuser.h:1327
#define ISC_SHOWUIGUIDELINE
Definition: imm.h:306
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1032
#define Imm32IsCiceroMode()
Definition: precomp.h:118
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

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

◆ ImmSetActiveContextConsoleIME()

BOOL WINAPI ImmSetActiveContextConsoleIME ( HWND  hwnd,
BOOL  fFlag 
)

Definition at line 1239 of file imm.c.

1240 {
1241  HIMC hIMC;
1242  TRACE("(%p, %d)\n", hwnd, fFlag);
1243 
1244  hIMC = ImmGetContext(hwnd);
1245  if (hIMC)
1246  return ImmSetActiveContext(hwnd, hIMC, fFlag);
1247  return FALSE;
1248 }
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1129
#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:1010
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022

◆ ImmShowSoftKeyboard()

BOOL WINAPI ImmShowSoftKeyboard ( HWND  hSoftWnd,
int  nCmdShow 
)

Definition at line 1081 of file imm.c.

1082 {
1083  TRACE("(%p, %d)\n", hSoftWnd, nCmdShow);
1084  if (hSoftWnd)
1085  return ShowWindow(hSoftWnd, nCmdShow);
1086  return FALSE;
1087 }
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 954 of file imm.c.

955 {
956  LONG cLocks;
957  HANDLE hInputContext;
958 
959  TRACE("(%p)\n", pClientImc);
960 
961  cLocks = InterlockedDecrement(&pClientImc->cLockObj);
962  if (cLocks != 0 || !(pClientImc->dwFlags & CLIENTIMC_DESTROY))
963  return;
964 
965  hInputContext = pClientImc->hInputContext;
966  if (hInputContext)
967  LocalFree(hInputContext);
968 
969  RtlDeleteCriticalSection(&pClientImc->cs);
970  ImmLocalFree(pClientImc);
971 }
LONG cLockObj
Definition: ntuser.h:1304
static LONG cLocks
Definition: compobj.c:119
#define CLIENTIMC_DESTROY
Definition: ntuser.h:1328
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE hInputContext
Definition: ntuser.h:1303
#define ImmLocalFree(lpData)
Definition: precomp.h:89
#define InterlockedDecrement
Definition: armddk.h:52
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1307
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
DWORD dwFlags
Definition: ntuser.h:1305
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(), and START_TEST().

◆ ImmUnlockIMC()

BOOL WINAPI ImmUnlockIMC ( HIMC  hIMC)

Definition at line 1032 of file imm.c.

1033 {
1034  PCLIENTIMC pClientImc;
1035 
1036  pClientImc = ImmLockClientImc(hIMC);
1037  if (pClientImc == NULL)
1038  return FALSE;
1039 
1040  if (pClientImc->hInputContext)
1041  LocalUnlock(pClientImc->hInputContext);
1042 
1043  InterlockedDecrement(&pClientImc->cLockObj);
1044  ImmUnlockClientImc(pClientImc);
1045  return TRUE;
1046 }
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
#define TRUE
Definition: types.h:120
LONG cLockObj
Definition: ntuser.h:1304
#define FALSE
Definition: types.h:117
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
HANDLE hInputContext
Definition: ntuser.h:1303
#define InterlockedDecrement
Definition: armddk.h:52
#define NULL
Definition: types.h:112
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

Referenced by ImeWnd_OnImeNotify(), ImeWnd_OnImeSetContext(), ImeWnd_OnImeSystem(), Imm32CShapeToggle(), Imm32CSymbolToggle(), Imm32DestroyInputContext(), Imm32ImeNonImeToggle(), Imm32KEnglish(), Imm32KHanjaConvert(), Imm32KShapeToggle(), Imm32OpenICAndCS(), Imm32SelectInputContext(), Imm32SendChangeProc(), 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 1225 of file imm.c.

1226 {
1228  {
1230  return FALSE;
1231  }
1232 
1233  return !!ImmGetSaveContext(hWnd, 2);
1234 }
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:974
#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
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(), DefWndControlColor(), DefWndGetIcon(), DefWndHandleSetCursor(), DefWndSetIcon(), DrawFocusRect(), EnumerateCallback(), free_user_entry(), GetLastInputInfo(), GetSysColor(), GetSysColorBrush(), GetSystemMetrics(), Imm32UnknownProcess1(), 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 }