ReactOS  0.4.15-dev-3316-g067ca88
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 Imm32InitInstance (HMODULE hMod)
 
BOOL WINAPI ImmRegisterClient (PSHAREDINFO ptr, HINSTANCE hMod)
 
BOOL WINAPI ImmLoadLayout (HKL hKL, PIMEINFOEX pImeInfoEx)
 
BOOL WINAPI ImmFreeLayout (DWORD dwUnknown)
 
VOID APIENTRY Imm32SelectLayout (HKL hNewKL, HKL hOldKL, HIMC hIMC)
 
static BOOL CALLBACK Imm32SelectLayoutProc (HIMC hIMC, LPARAM lParam)
 
static BOOL CALLBACK Imm32NotifyCompStrProc (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 Imm32FreeImeStates (LPINPUTCONTEXTDX pIC)
 
BOOL APIENTRY Imm32CleanupContext (HIMC hIMC, HKL hKL, BOOL bKeep)
 
BOOL APIENTRY Imm32InitContext (HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
 
LPINPUTCONTEXT APIENTRY Imm32LockIMCEx (HIMC hIMC, BOOL fSelect)
 
BOOL WINAPI ImmDestroyContext (HIMC hIMC)
 
PCLIENTIMC WINAPI ImmLockClientImc (HIMC hImc)
 
VOID WINAPI ImmUnlockClientImc (PCLIENTIMC pClientImc)
 
static HIMC APIENTRY Imm32GetContextEx (HWND hWnd, DWORD dwContextFlags)
 
HIMC WINAPI ImmGetContext (HWND hWnd)
 
BOOL WINAPI CtfImmIsCiceroEnabled (VOID)
 
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 ImmSetActiveContextConsoleIME (HWND hwnd, BOOL fFlag)
 
BOOL WINAPI User32InitializeImmEntryTable (DWORD)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
 

Variables

HMODULE g_hImm32Inst = NULL
 
PSERVERINFO g_psi = NULL
 
SHAREDINFO g_SharedInfo = { NULL }
 
BYTE g_bClientRegd = FALSE
 

Macro Definition Documentation

◆ MAX_IMCC_SIZE

#define MAX_IMCC_SIZE   0x1000

Typedef Documentation

◆ LPSELECT_LAYOUT

◆ SELECT_LAYOUT

Function Documentation

◆ CtfImmIsCiceroEnabled()

BOOL WINAPI CtfImmIsCiceroEnabled ( VOID  )

Definition at line 1019 of file imm.c.

1020 {
1021  return Imm32IsCiceroMode();
1022 }
#define Imm32IsCiceroMode()
Definition: precomp.h:115

◆ DllMain()

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

Definition at line 1243 of file imm.c.

1244 {
1245  HKL hKL;
1246  HIMC hIMC;
1247  PTEB pTeb;
1248 
1249  TRACE("(%p, 0x%X, %p)\n", hinstDLL, fdwReason, lpReserved);
1250 
1251  switch (fdwReason)
1252  {
1253  case DLL_PROCESS_ATTACH:
1254  if (!Imm32InitInstance(hinstDLL))
1255  {
1256  ERR("Imm32InitInstance failed\n");
1257  return FALSE;
1258  }
1260  {
1261  ERR("User32InitializeImmEntryTable failed\n");
1262  return FALSE;
1263  }
1264  break;
1265 
1266  case DLL_THREAD_ATTACH:
1267  break;
1268 
1269  case DLL_THREAD_DETACH:
1270  if (!Imm32IsImmMode())
1271  return TRUE;
1272 
1273  pTeb = NtCurrentTeb();
1274  if (pTeb->Win32ThreadInfo == NULL)
1275  return TRUE;
1276 
1277  hKL = GetKeyboardLayout(0);
1278  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
1279  hIMC = (HIMC)NtUserGetThreadState(4);
1280  Imm32CleanupContext(hIMC, hKL, TRUE);
1281  break;
1282 
1283  case DLL_PROCESS_DETACH:
1285  TRACE("imm32.dll is unloaded\n");
1286  break;
1287  }
1288 
1289  return TRUE;
1290 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
PVOID Win32ThreadInfo
Definition: compat.h:705
RTL_CRITICAL_SECTION g_csImeDpi
Definition: ime.c:17
#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
static BOOL APIENTRY Imm32InitInstance(HMODULE hMod)
Definition: imm.c:22
BOOL WINAPI User32InitializeImmEntryTable(DWORD)
Definition: imm.c:108
BOOL APIENTRY Imm32CleanupContext(HIMC hIMC, HKL hKL, BOOL bKeep)
Definition: imm.c:634
DWORD HIMC
Definition: dimm.idl:75
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define TRACE(s)
Definition: solgame.cpp:4
UINT_PTR HKL
Definition: msctf.idl:101
#define ERR(fmt,...)
Definition: debug.h:110
Definition: compat.h:694
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define Imm32IsImmMode()
Definition: precomp.h:114
#define NULL
Definition: types.h:112
#define IMM_INIT_MAGIC
Definition: imm.c:17
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 489 of file imm.c.

490 {
491  FIXME("We have to do something\n");
492 }
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by ImmSetActiveContext().

◆ Imm32CleanupContext()

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

Definition at line 634 of file imm.c.

635 {
636  PIMEDPI pImeDpi;
637  LPINPUTCONTEXTDX pIC;
638  PCLIENTIMC pClientImc;
639  PIMC pIMC;
640 
641  if (!Imm32IsImmMode() || hIMC == NULL)
642  return FALSE;
643 
645  if (!pIMC || pIMC->head.pti != NtCurrentTeb()->Win32ThreadInfo)
646  return FALSE;
647 
648  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
649  if (!pClientImc)
650  return FALSE;
651 
652  if (pClientImc->hInputContext == NULL)
653  {
654  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN1;
655  ImmUnlockClientImc(pClientImc);
656  if (!bKeep)
657  return NtUserDestroyInputContext(hIMC);
658  return TRUE;
659  }
660 
661  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
662  if (pIC == NULL)
663  {
664  ImmUnlockClientImc(pClientImc);
665  return FALSE;
666  }
667 
668  FIXME("We have do something to do here\n");
669 
670  if (pClientImc->hKL == hKL)
671  {
672  pImeDpi = ImmLockImeDpi(hKL);
673  if (pImeDpi != NULL)
674  {
675  if (IS_IME_HKL(hKL))
676  {
677  pImeDpi->ImeSelect(hIMC, FALSE);
678  }
679  else if (Imm32IsCiceroMode() && pImeDpi->CtfImeSelectEx)
680  {
681  pImeDpi->CtfImeSelectEx(hIMC, FALSE, hKL);
682  }
683  ImmUnlockImeDpi(pImeDpi);
684  }
685  pClientImc->hKL = NULL;
686  }
687 
688  pIC->hPrivate = ImmDestroyIMCC(pIC->hPrivate);
689  pIC->hMsgBuf = ImmDestroyIMCC(pIC->hMsgBuf);
690  pIC->hGuideLine = ImmDestroyIMCC(pIC->hGuideLine);
691  pIC->hCandInfo = ImmDestroyIMCC(pIC->hCandInfo);
692  pIC->hCompStr = ImmDestroyIMCC(pIC->hCompStr);
693 
694  Imm32FreeImeStates(pIC);
695 
696  ImmUnlockIMC(hIMC);
697 
698  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN1;
699  ImmUnlockClientImc(pClientImc);
700 
701  if (!bKeep)
702  return NtUserDestroyInputContext(hIMC);
703 
704  return TRUE;
705 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:755
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:927
#define TRUE
Definition: types.h:120
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1029
static VOID APIENTRY Imm32FreeImeStates(LPINPUTCONTEXTDX pIC)
Definition: imm.c:615
Definition: ntuser.h:190
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
#define CLIENTIMC_UNKNOWN1
Definition: ntuser.h:1317
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:144
struct tagCLIENTIMC * PCLIENTIMC
BOOL NTAPI NtUserDestroyInputContext(HIMC hIMC)
Definition: ntstubs.c:429
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
HANDLE hInputContext
Definition: ntuser.h:1293
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
THRDESKHEAD head
Definition: ntuser.h:192
#define Imm32IsImmMode()
Definition: precomp.h:114
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1295
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1038
#define Imm32IsCiceroMode()
Definition: precomp.h:115
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX

Referenced by DllMain(), and ImmDestroyContext().

◆ Imm32FreeImeStates()

static VOID APIENTRY Imm32FreeImeStates ( LPINPUTCONTEXTDX  pIC)
static

Definition at line 615 of file imm.c.

616 {
617  PIME_STATE pState, pStateNext;
618  PIME_SUBSTATE pSubState, pSubStateNext;
619 
620  pState = pIC->pState;
621  pIC->pState = NULL;
622  for (; pState; pState = pStateNext)
623  {
624  pStateNext = pState->pNext;
625  for (pSubState = pState->pSubState; pSubState; pSubState = pSubStateNext)
626  {
627  pSubStateNext = pSubState->pNext;
628  Imm32HeapFree(pSubState);
629  }
630  Imm32HeapFree(pState);
631  }
632 }
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
Definition: imm.h:178
PIME_SUBSTATE pSubState
Definition: imm.h:186
#define NULL
Definition: types.h:112
struct IME_STATE * pState
Definition: imm.h:100
struct IME_STATE * pNext
Definition: imm.h:180
struct IME_SUBSTATE * pNext
Definition: imm.h:169

Referenced by Imm32CleanupContext().

◆ Imm32GetContextEx()

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

Definition at line 971 of file imm.c.

972 {
973  HIMC hIMC;
974  PCLIENTIMC pClientImc;
975  PWND pWnd;
976 
977  if (!Imm32IsImmMode())
978  return NULL;
979 
980  if (!hWnd)
981  {
982  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
983  hIMC = (HIMC)NtUserGetThreadState(4);
984  goto Quit;
985  }
986 
987  pWnd = ValidateHwndNoErr(hWnd);
988  if (!pWnd || Imm32IsCrossProcessAccess(hWnd))
989  return NULL;
990 
991  hIMC = pWnd->hImc;
992  if (!hIMC && (dwContextFlags & 1))
994 
995 Quit:
996  pClientImc = ImmLockClientImc(hIMC);
997  if (pClientImc == NULL)
998  return NULL;
999  if ((dwContextFlags & 2) && (pClientImc->dwFlags & CLIENTIMC_UNKNOWN3))
1000  hIMC = NULL;
1001  ImmUnlockClientImc(pClientImc);
1002  return hIMC;
1003 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
HWND hWnd
Definition: settings.c:17
HIMC hImc
Definition: ntuser.h:710
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3929
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
DWORD HIMC
Definition: dimm.idl:75
#define CLIENTIMC_UNKNOWN3
Definition: ntuser.h:1318
PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
Definition: utils.c:171
Definition: ntuser.h:663
#define QUERY_WINDOW_DEFAULT_ICONTEXT
Definition: ntuser.h:2908
#define Imm32IsImmMode()
Definition: precomp.h:114
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1295
static BOOL Imm32IsCrossProcessAccess(HWND hWnd)
Definition: precomp.h:105
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952

Referenced by ImmGetContext(), and ImmSetActiveContext().

◆ Imm32InitContext()

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

Definition at line 708 of file imm.c.

709 {
710  DWORD dwIndex, cbPrivate;
711  PIMEDPI pImeDpi = NULL;
713  LPCANDIDATEINFO pCI;
714  LPGUIDELINE pGL;
715  /* NOTE: Windows does recursive call ImmLockIMC here but we don't do so. */
716 
717  /* Create IC components */
718  pIC->hCompStr = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
719  pIC->hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO));
720  pIC->hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE));
721  pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
722  if (!pIC->hCompStr || !pIC->hCandInfo || !pIC->hGuideLine || !pIC->hMsgBuf)
723  goto Fail;
724 
725  /* Initialize IC components */
726  pCS = ImmLockIMCC(pIC->hCompStr);
727  if (!pCS)
728  goto Fail;
729  pCS->dwSize = sizeof(COMPOSITIONSTRING);
730  ImmUnlockIMCC(pIC->hCompStr);
731 
732  pCI = ImmLockIMCC(pIC->hCandInfo);
733  if (!pCI)
734  goto Fail;
735  pCI->dwSize = sizeof(CANDIDATEINFO);
736  ImmUnlockIMCC(pIC->hCandInfo);
737 
738  pGL = ImmLockIMCC(pIC->hGuideLine);
739  if (!pGL)
740  goto Fail;
741  pGL->dwSize = sizeof(GUIDELINE);
743 
744  pIC->dwNumMsgBuf = 0;
745  pIC->fOpen = FALSE;
746  pIC->fdwConversion = pIC->fdwSentence = 0;
747 
748  for (dwIndex = 0; dwIndex < MAX_CANDIDATEFORM; ++dwIndex)
749  pIC->cfCandForm[dwIndex].dwIndex = IMM_INVALID_CANDFORM;
750 
751  /* Get private data size */
752  pImeDpi = ImmLockImeDpi(hKL);
753  if (!pImeDpi)
754  {
755  cbPrivate = sizeof(DWORD);
756  }
757  else
758  {
759  /* Update CLIENTIMC */
760  pClientImc->uCodePage = pImeDpi->uCodePage;
761  if (ImeDpi_IsUnicode(pImeDpi))
762  pClientImc->dwFlags |= CLIENTIMC_WIDE;
763 
764  cbPrivate = pImeDpi->ImeInfo.dwPrivateDataSize;
765  }
766 
767  /* Create private data */
768  pIC->hPrivate = ImmCreateIMCC(cbPrivate);
769  if (!pIC->hPrivate)
770  goto Fail;
771 
772  if (pImeDpi)
773  {
774  /* Select the IME */
775  if (fSelect)
776  {
777  if (IS_IME_HKL(hKL))
778  pImeDpi->ImeSelect(hIMC, TRUE);
779  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pImeDpi->CtfImeSelectEx)
780  pImeDpi->CtfImeSelectEx(hIMC, TRUE, hKL);
781  }
782 
783  /* Set HKL */
784  pClientImc->hKL = hKL;
785 
786  ImmUnlockImeDpi(pImeDpi);
787  }
788 
789  return TRUE;
790 
791 Fail:
792  if (pImeDpi)
793  ImmUnlockImeDpi(pImeDpi);
794 
795  pIC->hMsgBuf = ImmDestroyIMCC(pIC->hMsgBuf);
796  pIC->hGuideLine = ImmDestroyIMCC(pIC->hGuideLine);
797  pIC->hCandInfo = ImmDestroyIMCC(pIC->hCandInfo);
798  pIC->hCompStr = ImmDestroyIMCC(pIC->hCompStr);
799  return FALSE;
800 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:755
UINT uCodePage
Definition: ntuser.h:1244
IMEINFO ImeInfo
Definition: ntuser.h:1243
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:927
#define TRUE
Definition: types.h:120
CANDIDATEFORM cfCandForm[4]
Definition: imm.h:39
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:937
DWORD fdwConversion
Definition: imm.h:32
HIMCC hPrivate
Definition: imm.h:43
BOOL fOpen
Definition: imm.h:29
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:1314
#define FALSE
Definition: types.h:117
HIMCC hCandInfo
Definition: imm.h:41
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
UINT uCodePage
Definition: ntuser.h:1298
#define MAX_CANDIDATEFORM
Definition: precomp.h:53
HIMCC WINAPI ImmCreateIMCC(DWORD size)
Definition: utils.c:917
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwSize
Definition: imm.h:195
#define ImeDpi_IsUnicode(pImeDpi)
Definition: precomp.h:113
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:947
struct tagCANDIDATEINFO CANDIDATEINFO
HIMCC hMsgBuf
Definition: imm.h:45
DWORD dwPrivateDataSize
Definition: imm.h:157
struct tagGUIDELINE GUIDELINE
HIMCC hCompStr
Definition: imm.h:40
DWORD dwIndex
Definition: dimm.idl:79
#define IMM_INVALID_CANDFORM
Definition: precomp.h:51
HIMCC hGuideLine
Definition: imm.h:42
struct tagCOMPOSITIONSTRING COMPOSITIONSTRING
DWORD dwNumMsgBuf
Definition: imm.h:44
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
DWORD fdwSentence
Definition: imm.h:33
#define Imm32Is16BitMode()
Definition: precomp.h:116
DWORD dwFlags
Definition: ntuser.h:1295
#define Imm32IsCiceroMode()
Definition: precomp.h:115

Referenced by Imm32LockIMCEx().

◆ Imm32InitInstance()

static BOOL APIENTRY Imm32InitInstance ( HMODULE  hMod)
static

Definition at line 22 of file imm.c.

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

Referenced by DllMain(), and ImmRegisterClient().

◆ Imm32LockIMCEx()

LPINPUTCONTEXT APIENTRY Imm32LockIMCEx ( HIMC  hIMC,
BOOL  fSelect 
)

Definition at line 802 of file imm.c.

803 {
804  HANDLE hIC;
805  LPINPUTCONTEXT pIC = NULL;
806  PCLIENTIMC pClientImc;
807  WORD Word;
809  HKL hKL, hNewKL;
810  PIMEDPI pImeDpi = NULL;
811  BOOL bInited;
812 
813  pClientImc = ImmLockClientImc(hIMC);
814  if (!pClientImc)
815  return NULL;
816 
817  RtlEnterCriticalSection(&pClientImc->cs);
818 
819  if (!pClientImc->hInputContext)
820  {
822 
824  {
825  hKL = GetKeyboardLayout(0);
826  Word = LOWORD(hKL);
827  hNewKL = (HKL)(DWORD_PTR)MAKELONG(Word, Word);
828 
829  pImeDpi = ImmLockOrLoadImeDpi(hNewKL);
830  if (pImeDpi)
831  {
832  FIXME("We have to do something here\n");
833  }
834  }
835 
836  if (!NtUserQueryInputContext(hIMC, 2))
837  {
838  RtlLeaveCriticalSection(&pClientImc->cs);
839  goto Quit;
840  }
841 
842  hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
843  if (!hIC)
844  {
845  RtlLeaveCriticalSection(&pClientImc->cs);
846  goto Quit;
847  }
848  pClientImc->hInputContext = hIC;
849 
850  pIC = LocalLock(pClientImc->hInputContext);
851  if (!pIC)
852  {
853  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
854  RtlLeaveCriticalSection(&pClientImc->cs);
855  goto Quit;
856  }
857 
859  // bInited = Imm32InitContext(hIMC, hKL, fSelect);
860  bInited = Imm32InitContext(hIMC, pIC, pClientImc, hKL, fSelect);
861  LocalUnlock(pClientImc->hInputContext);
862 
863  if (!bInited)
864  {
865  pIC = NULL;
866  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
867  RtlLeaveCriticalSection(&pClientImc->cs);
868  goto Quit;
869  }
870  }
871 
872  FIXME("We have to do something here\n");
873 
874  RtlLeaveCriticalSection(&pClientImc->cs);
875  pIC = LocalLock(pClientImc->hInputContext);
876  InterlockedIncrement(&pClientImc->cLockObj);
877 
878 Quit:
879  ImmUnlockClientImc(pClientImc);
880  return pIC;
881 }
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
LONG cLockObj
Definition: ntuser.h:1294
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOL APIENTRY Imm32InitContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
Definition: imm.c:708
#define DWORD
Definition: nt_native.h:44
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define FIXME(fmt,...)
Definition: debug.h:111
#define MAKELONG(a, b)
Definition: typedefs.h:249
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
HANDLE hInputContext
Definition: ntuser.h:1293
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:1297
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:116
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL)
Definition: ime.c:281
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define Imm32IsCiceroMode()
Definition: precomp.h:115
#define LOWORD(l)
Definition: pedump.c:82
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:660
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952

Referenced by Imm32SelectLayout(), and ImmLockIMC().

◆ Imm32NotifyCompStrProc()

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

Definition at line 434 of file imm.c.

435 {
437  return TRUE;
438 }
#define TRUE
Definition: types.h:120
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
Definition: ime.c:648
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NI_COMPOSITIONSTR
Definition: imm.h:301
LPARAM lParam
Definition: combotst.c:139

Referenced by ImmActivateLayout().

◆ Imm32SelectLayout()

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

Definition at line 181 of file imm.c.

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

Referenced by Imm32SelectLayoutProc().

◆ Imm32SelectLayoutProc()

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

Definition at line 427 of file imm.c.

428 {
430  Imm32SelectLayout(pSelect->hNewKL, pSelect->hOldKL, hIMC);
431  return TRUE;
432 }
#define TRUE
Definition: types.h:120
LPFN_SELECT pSelect
Definition: handle.c:32
VOID APIENTRY Imm32SelectLayout(HKL hNewKL, HKL hOldKL, HIMC hIMC)
Definition: imm.c:181
struct SELECT_LAYOUT * LPSELECT_LAYOUT
LPARAM lParam
Definition: combotst.c:139

Referenced by ImmActivateLayout().

◆ ImmActivateLayout()

BOOL WINAPI ImmActivateLayout ( HKL  hKL)

Definition at line 443 of file imm.c.

444 {
445  PIMEDPI pImeDpi;
446  HKL hOldKL;
447  LPARAM lParam;
448  HWND hwndDefIME = NULL;
449  SELECT_LAYOUT SelectLayout;
450 
451  hOldKL = GetKeyboardLayout(0);
452 
453  if (hOldKL == hKL && !(GetWin32ClientInfo()->CI_flags & CI_IMMACTIVATE))
454  return TRUE;
455 
456  ImmLoadIME(hKL);
457 
458  if (hOldKL != hKL)
459  {
460  pImeDpi = ImmLockImeDpi(hOldKL);
461  if (pImeDpi)
462  {
465  else
466  lParam = CPS_CANCEL;
467  ImmUnlockImeDpi(pImeDpi);
468 
470  }
471 
472  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
473  if (IsWindow(hwndDefIME))
474  SendMessageW(hwndDefIME, WM_IME_SELECT, FALSE, (LPARAM)hOldKL);
475 
476  NtUserSetThreadLayoutHandles(hKL, hOldKL);
477  }
478 
479  SelectLayout.hNewKL = hKL;
480  SelectLayout.hOldKL = hOldKL;
482 
483  if (IsWindow(hwndDefIME))
484  SendMessageW(hwndDefIME, WM_IME_SELECT, TRUE, (LPARAM)hKL);
485 
486  return TRUE;
487 }
DWORD NTAPI NtUserSetThreadLayoutHandles(HKL hNewKL, HKL hOldKL)
Definition: ntstubs.c:897
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:755
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1107
IMEINFO ImeInfo
Definition: ntuser.h:1243
#define CPS_COMPLETE
Definition: imm.h:315
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define WM_IME_SELECT
Definition: winuser.h:1816
BOOL WINAPI ImmLoadIME(HKL hKL)
Definition: ime.c:803
HKL hOldKL
Definition: imm.c:424
#define GetWin32ClientInfo()
Definition: ntuser.h:326
static BOOL CALLBACK Imm32SelectLayoutProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:427
#define FALSE
Definition: types.h:117
static BOOL CALLBACK Imm32NotifyCompStrProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:434
LONG_PTR LPARAM
Definition: windef.h:208
DWORD fdwProperty
Definition: imm.h:158
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
#define CPS_CANCEL
Definition: imm.h:318
UINT_PTR HKL
Definition: msctf.idl:101
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:633
#define CI_IMMACTIVATE
Definition: ntuser.h:288
#define IME_PROP_COMPLETE_ON_UNSELECT
Definition: imm.h:397
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:423
LPARAM lParam
Definition: combotst.c:139

◆ ImmAssociateContext()

HIMC WINAPI ImmAssociateContext ( HWND  hWnd,
HIMC  hIMC 
)

Definition at line 497 of file imm.c.

498 {
499  PWND pWnd;
500  HWND hwndFocus;
501  DWORD dwValue;
502  HIMC hOldIMC;
503 
504  TRACE("(%p, %p)\n", hWnd, hIMC);
505 
506  if (!Imm32IsImmMode())
507  return NULL;
508 
509  pWnd = ValidateHwndNoErr(hWnd);
510  if (!pWnd)
511  return NULL;
512 
513  if (hIMC && Imm32IsCrossThreadAccess(hIMC))
514  return NULL;
515 
516  hOldIMC = pWnd->hImc;
517  if (hOldIMC == hIMC)
518  return hIMC;
519 
520  dwValue = NtUserAssociateInputContext(hWnd, hIMC, 0);
521  if (dwValue == 0)
522  return hOldIMC;
523  if (dwValue != 1)
524  return NULL;
525 
527  if (hwndFocus == hWnd)
528  {
529  ImmSetActiveContext(hWnd, hOldIMC, FALSE);
530  ImmSetActiveContext(hWnd, hIMC, TRUE);
531  }
532 
533  return hOldIMC;
534 }
DWORD NTAPI NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: ntstubs.c:14
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:19
HIMC hImc
Definition: ntuser.h:710
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1135
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3929
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2903
#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:98
PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
Definition: utils.c:171
Definition: ntuser.h:663
#define Imm32IsImmMode()
Definition: precomp.h:114
#define NULL
Definition: types.h:112

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

◆ ImmAssociateContextEx()

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

Definition at line 539 of file imm.c.

540 {
541  HWND hwndFocus;
542  PWND pFocusWnd;
543  HIMC hOldIMC = NULL;
544  DWORD dwValue;
545 
546  TRACE("(%p, %p, 0x%lX)\n", hWnd, hIMC, dwFlags);
547 
548  if (!Imm32IsImmMode())
549  return FALSE;
550 
551  if (hIMC && !(dwFlags & IACE_DEFAULT) && Imm32IsCrossThreadAccess(hIMC))
552  return FALSE;
553 
555  pFocusWnd = ValidateHwndNoErr(hwndFocus);
556  if (pFocusWnd)
557  hOldIMC = pFocusWnd->hImc;
558 
559  dwValue = NtUserAssociateInputContext(hWnd, hIMC, dwFlags);
560  switch (dwValue)
561  {
562  case 0:
563  return TRUE;
564 
565  case 1:
566  pFocusWnd = ValidateHwndNoErr(hwndFocus);
567  if (pFocusWnd)
568  {
569  hIMC = pFocusWnd->hImc;
570  if (hIMC != hOldIMC)
571  {
572  ImmSetActiveContext(hwndFocus, hOldIMC, FALSE);
573  ImmSetActiveContext(hwndFocus, hIMC, TRUE);
574  }
575  }
576  return TRUE;
577 
578  default:
579  return FALSE;
580  }
581 }
DWORD NTAPI NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: ntstubs.c:14
#define IACE_DEFAULT
Definition: imm.h:586
#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:1135
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3929
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2903
#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:98
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
Definition: utils.c:171
Definition: ntuser.h:663
HWND pFocusWnd
Definition: magnifier.c:66
#define Imm32IsImmMode()
Definition: precomp.h:114
#define NULL
Definition: types.h:112

Referenced by ActiveIMMApp_AssociateContextEx().

◆ ImmCreateContext()

HIMC WINAPI ImmCreateContext ( void  )

Definition at line 586 of file imm.c.

587 {
588  PCLIENTIMC pClientImc;
589  HIMC hIMC;
590 
591  TRACE("()\n");
592 
593  if (!Imm32IsImmMode())
594  return NULL;
595 
596  pClientImc = Imm32HeapAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
597  if (pClientImc == NULL)
598  return NULL;
599 
600  hIMC = NtUserCreateInputContext(pClientImc);
601  if (hIMC == NULL)
602  {
603  Imm32HeapFree(pClientImc);
604  return NULL;
605  }
606 
607  RtlInitializeCriticalSection(&pClientImc->cs);
608 
609  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
610  pClientImc->unknown = NtUserGetThreadState(13);
611 
612  return hIMC;
613 }
HIMC NTAPI NtUserCreateInputContext(PCLIENTIMC pClientImc)
Definition: ntstubs.c:421
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
DWORD unknown
Definition: ntuser.h:1296
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1297
#define Imm32IsImmMode()
Definition: precomp.h:114
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

Referenced by ActiveIMMApp_CreateContext(), ImmGetContextThreadFunc(), START_TEST(), 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 1068 of file imm.c.

1069 {
1070  FIXME("(%d, %d, %d, %d): stub\n", uType, hOwner, x, y);
1072  return 0;
1073 }
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 886 of file imm.c.

887 {
888  HKL hKL;
889 
890  TRACE("(%p)\n", hIMC);
891 
892  if (!Imm32IsImmMode())
893  return FALSE;
894 
895  if (Imm32IsCrossThreadAccess(hIMC))
896  return FALSE;
897 
898  hKL = GetKeyboardLayout(0);
899  return Imm32CleanupContext(hIMC, hKL, FALSE);
900 }
#define FALSE
Definition: types.h:117
BOOL APIENTRY Imm32CleanupContext(HIMC hIMC, HKL hKL, BOOL bKeep)
Definition: imm.c:634
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: precomp.h:98
UINT_PTR HKL
Definition: msctf.idl:101
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define Imm32IsImmMode()
Definition: precomp.h:114

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

◆ ImmDestroySoftKeyboard()

BOOL WINAPI ImmDestroySoftKeyboard ( HWND  hSoftWnd)

Definition at line 1078 of file imm.c.

1079 {
1080  TRACE("(%p)\n", hSoftWnd);
1081  return DestroyWindow(hSoftWnd);
1082 }
BOOL WINAPI DestroyWindow(_In_ HWND)
#define TRACE(s)
Definition: solgame.cpp:4

◆ ImmDisableTextFrameService()

BOOL WINAPI ImmDisableTextFrameService ( DWORD  dwThreadId)

Definition at line 1098 of file imm.c.

1099 {
1100  FIXME("Stub\n");
1101  return FALSE;
1102 }
#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 1107 of file imm.c.

1108 {
1109  HIMC *phList;
1110  DWORD dwIndex, dwCount;
1111  BOOL ret = TRUE;
1112  HIMC hIMC;
1113 
1114  TRACE("(%lu, %p, %p)\n", dwThreadId, lpfn, lParam);
1115 
1116  dwCount = Imm32AllocAndBuildHimcList(dwThreadId, &phList);
1117  if (!dwCount)
1118  return FALSE;
1119 
1120  for (dwIndex = 0; dwIndex < dwCount; ++dwIndex)
1121  {
1122  hIMC = phList[dwIndex];
1123  ret = (*lpfn)(hIMC, lParam);
1124  if (!ret)
1125  break;
1126  }
1127 
1128  Imm32HeapFree(phList);
1129  return ret;
1130 }
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList)
Definition: utils.c:236
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 = Imm32HeapAlloc(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 = g_pImeDpiList; 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 }
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
RTL_CRITICAL_SECTION g_csImeDpi
Definition: ime.c:17
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
#define KLF_ACTIVATE
Definition: winuser.h:111
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
WORD LANGID
Definition: typedefs.h:81
#define FALSE
Definition: types.h:117
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
FxChildList * pList
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:787
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
#define _countof(array)
Definition: sndvol32.h:68
struct IMEDPI * pNext
Definition: ntuser.h:1240
static const WCHAR L[]
Definition: oid.c:1250
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:310
PIMEDPI g_pImeDpiList
Definition: ime.c:18
#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:306
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:1242

◆ ImmGetContext()

◆ 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:32
BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Definition: utils.c:589
#define error(str)
Definition: mkdosfs.c:1605
#define REGKEY_IMM
Definition: precomp.h:61
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
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:1193
#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
static const WCHAR L[]
Definition: oid.c:1250
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define ERR(fmt,...)
Definition: debug.h:110
WCHAR wszImeFile[80]
Definition: ntuser.h:1178
#define NULL
Definition: types.h:112
INT fLoadFlag
Definition: ntuser.h:1174
#define Imm32Is16BitMode()
Definition: precomp.h:116
#define Imm32IsCiceroMode()
Definition: precomp.h:115
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ ImmLockClientImc()

PCLIENTIMC WINAPI ImmLockClientImc ( HIMC  hImc)

Definition at line 905 of file imm.c.

906 {
907  PIMC pIMC;
908  PCLIENTIMC pClientImc;
909 
910  TRACE("(%p)\n", hImc);
911 
912  if (hImc == NULL)
913  return NULL;
914 
916  if (pIMC == NULL || !Imm32CheckImcProcess(pIMC))
917  return NULL;
918 
919  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
920  if (!pClientImc)
921  {
922  pClientImc = Imm32HeapAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
923  if (!pClientImc)
924  return NULL;
925 
926  RtlInitializeCriticalSection(&pClientImc->cs);
927 
928  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
929  pClientImc->unknown = NtUserGetThreadState(13);
930 
931  if (!NtUserUpdateInputContext(hImc, 0, pClientImc))
932  {
933  Imm32HeapFree(pClientImc);
934  return NULL;
935  }
936 
937  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN2;
938  }
939  else
940  {
941  if (pClientImc->dwFlags & CLIENTIMC_UNKNOWN1)
942  return NULL;
943  }
944 
945  InterlockedIncrement(&pClientImc->cLockObj);
946  return pClientImc;
947 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
LONG cLockObj
Definition: ntuser.h:1294
Definition: ntuser.h:190
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define CLIENTIMC_UNKNOWN2
Definition: ntuser.h:1319
DWORD unknown
Definition: ntuser.h:1296
#define CLIENTIMC_UNKNOWN1
Definition: ntuser.h:1317
DWORD NTAPI NtUserUpdateInputContext(HIMC hIMC, DWORD Unknown1, LPVOID pClientImc)
Definition: ntstubs.c:351
#define TRACE(s)
Definition: solgame.cpp:4
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:144
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct tagCLIENTIMC * PCLIENTIMC
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1297
#define InterlockedIncrement
Definition: armddk.h:53
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
Definition: utils.c:181
DWORD dwFlags
Definition: ntuser.h:1295

Referenced by Imm32GetContextEx(), Imm32IsImcAnsi(), Imm32LockIMCEx(), Imm32PostMessages(), Imm32ProcessRequest(), Imm32SelectLayout(), ImmGenerateMessage(), ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetCompositionFontA(), ImmGetCompositionFontW(), ImmGetCompositionStringA(), ImmGetCompositionStringW(), ImmGetGuideLineAW(), ImmGetIMCLockCount(), ImmSetActiveContext(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), and ImmUnlockIMC().

◆ ImmLockIMC()

◆ ImmRegisterClient()

BOOL WINAPI ImmRegisterClient ( PSHAREDINFO  ptr,
HINSTANCE  hMod 
)

Definition at line 44 of file imm.c.

45 {
46  g_SharedInfo = *ptr;
48  return Imm32InitInstance(hMod);
49 }
PSERVERINFO g_psi
Definition: imm.c:18
static BOOL APIENTRY Imm32InitInstance(HMODULE hMod)
Definition: imm.c:22
static PVOID ptr
Definition: dispmode.c:27
PSERVERINFO psi
Definition: ntuser.h:1088
SHAREDINFO g_SharedInfo
Definition: imm.c:19

Referenced by DllMain(), and User32InitializeImmEntryTable().

◆ ImmReleaseContext()

◆ ImmSetActiveContext()

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

Definition at line 1135 of file imm.c.

1136 {
1137  PCLIENTIMC pClientImc;
1138  LPINPUTCONTEXTDX pIC;
1139  PIMEDPI pImeDpi;
1140  HKL hKL;
1141  BOOL fOpen = FALSE;
1142  DWORD dwConversion = 0, iShow = ISC_SHOWUIALL;
1143  HWND hwndDefIME;
1144 
1145  TRACE("(%p, %p, %d)\n", hWnd, hIMC, fActive);
1146 
1147  if (!Imm32IsImmMode())
1148  return FALSE;
1149 
1150  pClientImc = ImmLockClientImc(hIMC);
1151 
1152  if (!fActive)
1153  {
1154  if (pClientImc)
1155  pClientImc->dwFlags &= ~CLIENTIMC_UNKNOWN4;
1156  }
1157  else if (hIMC)
1158  {
1159  if (!pClientImc)
1160  return FALSE;
1161 
1162  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1163  if (!pIC)
1164  {
1165  ImmUnlockClientImc(pClientImc);
1166  return FALSE;
1167  }
1168 
1169  pIC->hWnd = hWnd;
1170  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN5;
1171 
1172  if (pIC->dwUIFlags & 2)
1174 
1175  fOpen = pIC->fOpen;
1176  dwConversion = pIC->fdwConversion;
1177 
1178  ImmUnlockIMC(hIMC);
1179  }
1180  else
1181  {
1182  hIMC = Imm32GetContextEx(hWnd, TRUE);
1183  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1184  if (pIC)
1185  {
1186  pIC->hWnd = hWnd;
1187  ImmUnlockIMC(hIMC);
1188  }
1189  hIMC = NULL;
1190  }
1191 
1192  hKL = GetKeyboardLayout(0);
1193 
1194  if (Imm32IsCiceroMode() && !Imm32Is16BitMode())
1195  {
1196  Imm32CiceroSetActiveContext(hIMC, fActive, hWnd, hKL);
1197  hKL = GetKeyboardLayout(0);
1198  }
1199 
1200  pImeDpi = ImmLockImeDpi(hKL);
1201  if (pImeDpi)
1202  {
1203  if (IS_IME_HKL(hKL))
1204  pImeDpi->ImeSetActiveContext(hIMC, fActive);
1205  ImmUnlockImeDpi(pImeDpi);
1206  }
1207 
1208  if (IsWindow(hWnd))
1209  {
1210  SendMessageW(hWnd, WM_IME_SETCONTEXT, fActive, iShow);
1211  if (fActive)
1212  NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion);
1213  }
1214  else if (!fActive)
1215  {
1216  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
1217  if (hwndDefIME)
1218  SendMessageW(hwndDefIME, WM_IME_SETCONTEXT, 0, iShow);
1219  }
1220 
1221  if (pClientImc)
1222  ImmUnlockClientImc(pClientImc);
1223 
1224  return TRUE;
1225 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:755
DWORD dwUIFlags
Definition: imm.h:98
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1029
HWND hWnd
Definition: settings.c:17
#define ISC_SHOWUIGUIDELINE
Definition: imm.h:309
DWORD NTAPI NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
Definition: ime.c:52
static VOID APIENTRY Imm32CiceroSetActiveContext(HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL)
Definition: imm.c:489
#define CLIENTIMC_UNKNOWN5
Definition: ntuser.h:1315
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_IME_SETCONTEXT
Definition: winuser.h:1812
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
unsigned long DWORD
Definition: ntddk_ex.h:95
static HIMC APIENTRY Imm32GetContextEx(HWND hWnd, DWORD dwContextFlags)
Definition: imm.c:971
UINT_PTR HKL
Definition: msctf.idl:101
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:633
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define Imm32IsImmMode()
Definition: precomp.h:114
#define NULL
Definition: types.h:112
#define ISC_SHOWUIALL
Definition: imm.h:311
#define Imm32Is16BitMode()
Definition: precomp.h:116
DWORD dwFlags
Definition: ntuser.h:1295
#define ISC_SHOWUIALLCANDIDATEWINDOW
Definition: imm.h:310
#define CLIENTIMC_UNKNOWN4
Definition: ntuser.h:1316
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1038
#define Imm32IsCiceroMode()
Definition: precomp.h:115
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX

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

◆ ImmSetActiveContextConsoleIME()

BOOL WINAPI ImmSetActiveContextConsoleIME ( HWND  hwnd,
BOOL  fFlag 
)

Definition at line 1230 of file imm.c.

1231 {
1232  HIMC hIMC;
1233  TRACE("(%p, %d)\n", hwnd, fFlag);
1234 
1235  hIMC = ImmGetContext(hwnd);
1236  if (hIMC)
1237  return ImmSetActiveContext(hwnd, hIMC, fFlag);
1238  return FALSE;
1239 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1135
#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:1008

◆ ImmShowSoftKeyboard()

BOOL WINAPI ImmShowSoftKeyboard ( HWND  hSoftWnd,
int  nCmdShow 
)

Definition at line 1087 of file imm.c.

1088 {
1089  TRACE("(%p, %d)\n", hSoftWnd, nCmdShow);
1090  if (hSoftWnd)
1091  return ShowWindow(hSoftWnd, nCmdShow);
1092  return FALSE;
1093 }
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 952 of file imm.c.

953 {
954  LONG cLocks;
955  HANDLE hInputContext;
956 
957  TRACE("(%p)\n", pClientImc);
958 
959  cLocks = InterlockedDecrement(&pClientImc->cLockObj);
960  if (cLocks != 0 || !(pClientImc->dwFlags & CLIENTIMC_UNKNOWN1))
961  return;
962 
963  hInputContext = pClientImc->hInputContext;
964  if (hInputContext)
965  LocalFree(hInputContext);
966 
967  RtlDeleteCriticalSection(&pClientImc->cs);
968  Imm32HeapFree(pClientImc);
969 }
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
LONG cLockObj
Definition: ntuser.h:1294
static LONG cLocks
Definition: compobj.c:119
long LONG
Definition: pedump.c:60
#define CLIENTIMC_UNKNOWN1
Definition: ntuser.h:1317
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE hInputContext
Definition: ntuser.h:1293
#define InterlockedDecrement
Definition: armddk.h:52
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1297
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
DWORD dwFlags
Definition: ntuser.h:1295
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by Imm32CleanupContext(), Imm32GetContextEx(), Imm32IsImcAnsi(), Imm32LockIMCEx(), Imm32PostMessages(), Imm32ProcessRequest(), Imm32SelectLayout(), ImmGenerateMessage(), ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetCompositionFontA(), ImmGetCompositionFontW(), ImmGetCompositionStringA(), ImmGetCompositionStringW(), ImmGetGuideLineAW(), ImmGetIMCLockCount(), ImmSetActiveContext(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), ImmUnlockIMC(), and START_TEST().

◆ ImmUnlockIMC()

BOOL WINAPI ImmUnlockIMC ( HIMC  hIMC)

Definition at line 1038 of file imm.c.

1039 {
1040  PCLIENTIMC pClientImc;
1041 
1042  pClientImc = ImmLockClientImc(hIMC);
1043  if (pClientImc == NULL)
1044  return FALSE;
1045 
1046  if (pClientImc->hInputContext)
1047  LocalUnlock(pClientImc->hInputContext);
1048 
1049  InterlockedDecrement(&pClientImc->cLockObj);
1050  ImmUnlockClientImc(pClientImc);
1051  return TRUE;
1052 }
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
#define TRUE
Definition: types.h:120
LONG cLockObj
Definition: ntuser.h:1294
#define FALSE
Definition: types.h:117
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
HANDLE hInputContext
Definition: ntuser.h:1293
#define InterlockedDecrement
Definition: armddk.h:52
#define NULL
Definition: types.h:112
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952

Referenced by Imm32CleanupContext(), Imm32CShapeToggle(), Imm32CSymbolToggle(), Imm32GetImeMenuItemsAW(), Imm32ImeNonImeToggle(), Imm32KEnglish(), Imm32KHanjaConvert(), Imm32KShapeToggle(), Imm32OpenICAndCS(), Imm32RequestMessageAW(), Imm32SelectLayout(), Imm32SendChangeProc(), Imm32SetCompositionStringAW(), ImmGenerateMessage(), ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetCandidateWindow(), ImmGetCompositionFontA(), ImmGetCompositionFontW(), ImmGetCompositionStringA(), ImmGetCompositionStringW(), ImmGetCompositionWindow(), ImmGetConversionStatus(), ImmGetGuideLineAW(), ImmGetOpenStatus(), ImmGetStatusWindowPos(), ImmGetVirtualKey(), ImmProcessKey(), ImmSetActiveContext(), ImmSetCandidateWindow(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), ImmSetCompositionWindow(), ImmSetConversionStatus(), ImmSetOpenStatus(), ImmSetStatusWindowPos(), ImmTranslateMessage(), START_TEST(), test_ImmDestroyContext(), test_ImmGetIMCLockCount(), test_ImmMessages(), and test_InvalidIMC().

◆ User32InitializeImmEntryTable()

BOOL WINAPI User32InitializeImmEntryTable ( DWORD  )

Definition at line 108 of file imm.c.

109 {
110  TRACE("Imm (%x)\n", magic);
111 
112  if (magic != IMM_INIT_MAGIC)
113  return FALSE;
114 
115  /* Check whether the IMM table has already been initialized */
116  if (IMM_FN(ImmWINNLSEnableIME) != IMMSTUB_ImmWINNLSEnableIME)
117  return TRUE;
118 
120 
121  if (ghImm32 == NULL && !bImmInitializing)
122  {
123  WCHAR ImmFile[MAX_PATH];
124  GetImmFileName(ImmFile, _countof(ImmFile));
125  ghImm32 = LoadLibraryW(ImmFile);
126  if (ghImm32 == NULL)
127  {
128  ERR("Did not load imm32.dll!\n");
129  return FALSE;
130  }
131  }
132 
134 }
HRESULT GetImmFileName(_Out_ LPWSTR lpBuffer, _In_ size_t cchBuffer)
Definition: imm.c:39
#define TRUE
Definition: types.h:120
u32_t magic(void)
BOOL WINAPI ImmRegisterClient(PSHAREDINFO ptr, HINSTANCE hMod)
Definition: imm.c:44
#define FALSE
Definition: types.h:117
#define LoadLibraryW(x)
Definition: compat.h:606
#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
static BOOL IntInitializeImmEntryTable(VOID)
Definition: imm.c:54
#define ERR(fmt,...)
Definition: debug.h:110
HINSTANCE ghImm32
Definition: imm.c:20
SHAREDINFO gSharedInfo
Definition: dllmain.c:30
#define NULL
Definition: types.h:112
BOOL bImmInitializing
Definition: imm.c:22
#define IMM_INIT_MAGIC
Definition: imm.c:17
#define IMM_FN(name)
Definition: user32p.h:56

Referenced by DllMain().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( imm  )

Variable Documentation

◆ g_bClientRegd

BYTE g_bClientRegd = FALSE

Definition at line 20 of file imm.c.

Referenced by Imm32InitInstance().

◆ g_hImm32Inst

HMODULE g_hImm32Inst = NULL

Definition at line 17 of file imm.c.

Referenced by Imm32InitInstance().

◆ g_psi

PSERVERINFO g_psi = NULL

Definition at line 18 of file imm.c.

Referenced by Imm32UnknownProcess1(), and ImmRegisterClient().

◆ g_SharedInfo

SHAREDINFO g_SharedInfo = { NULL }

Definition at line 19 of file imm.c.

Referenced by ImmRegisterClient(), and ValidateHandleNoErr().