ReactOS 0.4.16-dev-136-g52192f1
utils.cpp File Reference
#include <stdlib.h>
#include <windows.h>
#include <sddl.h>
#include <imm.h>
#include <cguid.h>
#include <tchar.h>
#include <msctf.h>
#include <ctffunc.h>
#include <shlwapi.h>
#include <strsafe.h>
#include <cicarray.h>
#include <cicreg.h>
#include <cicmutex.h>
#include <cicfmap.h>
#include "mlng.h"
#include <wine/debug.h>
Include dependency graph for utils.cpp:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define WIN32_NO_STATUS
 
#define COBJMACROS
 
#define INITGUID
 
#define _EXTYPES_H
 
#define StringFromGUID2T   StringFromGUID2A
 
#define debugstr_t   debugstr_a
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msctf)
 
LPTSTR GetUserSIDString (void)
 
BOOL InitUserSidString (void)
 
BOOL InitUniqueString (void)
 
void GetDesktopUniqueName (_In_ LPCTSTR pszName, _Out_ LPTSTR pszBuff, _In_ UINT cchBuff)
 
BOOL StringFromGUID2A (REFGUID rguid, LPSTR pszGUID, INT cchGUID)
 
BOOL FullPathExec (LPCTSTR pszExeFile, LPCTSTR pszCmdLine, UINT nCmdShow, BOOL bSysWinDir)
 
static BOOL RunCPLSetting (LPCTSTR pszCmdLine)
 
EXTERN_C HRESULT WINAPI TF_RegisterLangBarAddIn (_In_ REFGUID rguid, _In_ LPCWSTR pszFilePath, _In_ DWORD dwFlags)
 
EXTERN_C HRESULT WINAPI TF_UnregisterLangBarAddIn (_In_ REFGUID rguid, _In_ DWORD dwFlags)
 
EXTERN_C HRESULT WINAPI TF_RunInputCPL (VOID)
 
EXTERN_C BOOL WINAPI TF_IsCtfmonRunning (VOID)
 
BOOL InitLangChangeHotKey (VOID)
 
VOID CheckAnchorStores (VOID)
 
VOID InitCUASFlag (VOID)
 
EXTERN_C VOID TFUninitLib (VOID)
 
BOOL ProcessAttach (HINSTANCE hinstDLL)
 
VOID ProcessDetach (HINSTANCE hinstDLL)
 

Variables

BOOL gf_CRT_INIT = FALSE
 
BOOL g_fDllProcessDetached = FALSE
 
CRITICAL_SECTION g_cs
 
CRITICAL_SECTION g_csInDllMain
 
CRITICAL_SECTION g_csDelayLoad
 
HINSTANCE g_hInst = NULL
 
BOOL g_bOnWow64 = FALSE
 
UINT g_uACP = CP_ACP
 
DWORD g_dwOSInfo = 0
 
HKL g_hklDefault = NULL
 
DWORD g_dwTLSIndex = (DWORD)-1
 
BOOL gfSharedMemory = FALSE
 
LONG g_cRefDll = -1
 
BOOL g_fCUAS = FALSE
 
TCHAR g_szCUASImeFile [16] = { 0 }
 
UINT g_msgPrivate = 0
 
UINT g_msgSetFocus = 0
 
UINT g_msgThreadTerminate = 0
 
UINT g_msgThreadItemChange = 0
 
UINT g_msgLBarModal = 0
 
UINT g_msgRpcSendReceive = 0
 
UINT g_msgThreadMarshal = 0
 
UINT g_msgCheckThreadInputIdel = 0
 
UINT g_msgStubCleanUp = 0
 
UINT g_msgShowFloating = 0
 
UINT g_msgLBUpdate = 0
 
UINT g_msgNuiMgrDirtyUpdate = 0
 
BOOL g_fUserSidString = FALSE
 
TCHAR g_szUserSidString [MAX_PATH] = { 0 }
 
TCHAR g_szUserUnique [MAX_PATH] = { 0 }
 
TCHAR g_szAsmListCache [MAX_PATH] = { 0 }
 
TCHAR g_szTimListCache [MAX_PATH] = { 0 }
 
TCHAR g_szLayoutsCache [MAX_PATH] = { 0 }
 
CicMutex g_mutexLBES
 
CicMutex g_mutexCompart
 
CicMutex g_mutexAsm
 
CicMutex g_mutexLayouts
 
CicMutex g_mutexTMD
 
CicFileMappingStatic g_SharedMemory
 
UINT g_uLangHotKeyModifiers = 0
 
UINT g_uLangHotKeyVKey = 0
 
UINT g_uLangHotKeyVKey2 = 0
 
UINT g_uKeyTipHotKeyModifiers = 0
 
UINT g_uKeyTipHotKeyVKey = 0
 
UINT g_uKeyTipHotKeyVKey2 = 0
 

Macro Definition Documentation

◆ _EXTYPES_H

#define _EXTYPES_H

Definition at line 14 of file utils.cpp.

◆ COBJMACROS

#define COBJMACROS

Definition at line 12 of file utils.cpp.

◆ debugstr_t

#define debugstr_t   debugstr_a

Definition at line 194 of file utils.cpp.

◆ INITGUID

#define INITGUID

Definition at line 13 of file utils.cpp.

◆ StringFromGUID2T

#define StringFromGUID2T   StringFromGUID2A

Definition at line 193 of file utils.cpp.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 10 of file utils.cpp.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file utils.cpp.

Function Documentation

◆ CheckAnchorStores()

VOID CheckAnchorStores ( VOID  )

@unimplemented

Definition at line 486 of file utils.cpp.

487{
488 //FIXME
489}

Referenced by ProcessAttach().

◆ FullPathExec()

BOOL FullPathExec ( LPCTSTR  pszExeFile,
LPCTSTR  pszCmdLine,
UINT  nCmdShow,
BOOL  bSysWinDir 
)

Definition at line 197 of file utils.cpp.

198{
199 STARTUPINFO si;
201 CicSystemModulePath ModPath;
202 TCHAR szCommandLine[2 * MAX_PATH];
203
204 ModPath.Init(pszExeFile, bSysWinDir);
205 if (!ModPath.m_cchPath)
206 {
207 ERR("%s\n", debugstr_t(pszExeFile));
208 return FALSE;
209 }
210
211 StringCchCopy(szCommandLine, _countof(szCommandLine), pszCmdLine);
212
213 ZeroMemory(&si, sizeof(si));
214 si.cb = sizeof(si);
215 si.wShowWindow = nCmdShow;
217 if (!CreateProcess(ModPath.m_szPath, szCommandLine, NULL, NULL, FALSE,
219 {
220 ERR("%s, %s\n", debugstr_t(ModPath.m_szPath), debugstr_t(szCommandLine));
221 return FALSE;
222 }
223
224 CloseHandle(pi.hProcess);
225 CloseHandle(pi.hThread);
226 return TRUE;
227}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define MAX_PATH
Definition: compat.h:34
#define debugstr_t
Definition: utils.cpp:194
static refpint_t pi[]
Definition: server.c:96
#define _countof(array)
Definition: sndvol32.h:70
#define StringCchCopy
Definition: strsafe.h:139
DWORD dwFlags
Definition: winbase.h:842
DWORD cb
Definition: winbase.h:831
WORD wShowWindow
Definition: winbase.h:843
#define CreateProcess
Definition: winbase.h:3758
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:181
#define ZeroMemory
Definition: winbase.h:1712
#define STARTF_USESHOWWINDOW
Definition: winbase.h:491
char TCHAR
Definition: xmlstorage.h:189

Referenced by RunCPLSetting().

◆ GetDesktopUniqueName()

void GetDesktopUniqueName ( _In_ LPCTSTR  pszName,
_Out_ LPTSTR  pszBuff,
_In_ UINT  cchBuff 
)

Definition at line 169 of file utils.cpp.

173{
174 StringCchCopy(pszBuff, cchBuff, pszName);
175 StringCchCat(pszBuff, cchBuff, g_szUserUnique);
176}
TCHAR g_szUserUnique[MAX_PATH]
Definition: utils.cpp:70
#define StringCchCat
Definition: strsafe.h:317

Referenced by ProcessAttach(), and TF_IsCtfmonRunning().

◆ GetUserSIDString()

LPTSTR GetUserSIDString ( void  )

@implemented

Definition at line 96 of file utils.cpp.

97{
98 HANDLE hToken = NULL;
100 if (!hToken)
101 return NULL;
102
103 DWORD dwLengthNeeded = 0;
104 GetTokenInformation(hToken, TokenUser, NULL, 0, &dwLengthNeeded);
105 PTOKEN_USER pTokenUser = (PTOKEN_USER)cicMemAllocClear(dwLengthNeeded);
106 if (!pTokenUser)
107 {
108 CloseHandle(hToken);
109 return NULL;
110 }
111
112 LPTSTR StringSid = NULL;
113 if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwLengthNeeded, &dwLengthNeeded) ||
114 !ConvertSidToStringSid(pTokenUser->User.Sid, &StringSid))
115 {
116 if (StringSid)
117 {
118 LocalFree(StringSid);
119 StringSid = NULL;
120 }
121 }
122
123 cicMemFree(pTokenUser);
124 CloseHandle(hToken);
125 return StringSid;
126}
static void cicMemFree(LPVOID ptr)
Definition: cicbase.h:27
static LPVOID cicMemAllocClear(SIZE_T size)
Definition: cicbase.h:15
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define GetCurrentProcess()
Definition: compat.h:759
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define ConvertSidToStringSid
Definition: sddl.h:160
SID_AND_ATTRIBUTES User
Definition: setypes.h:1010
struct _TOKEN_USER * PTOKEN_USER
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenUser
Definition: setypes.h:966
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by InitUserSidString().

◆ InitCUASFlag()

VOID InitCUASFlag ( VOID  )

Definition at line 491 of file utils.cpp.

492{
493 CicRegKey regKey1;
495
496 error = regKey1.Open(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\CTF\\SystemShared\\"));
497 if (error == ERROR_SUCCESS)
498 {
499 DWORD dwValue;
500 error = regKey1.QueryDword(TEXT("CUAS"), &dwValue);
501 if (error == ERROR_SUCCESS)
502 g_fCUAS = !!dwValue;
503 }
504
505 g_szCUASImeFile[0] = TEXT('\0');
506
507 if (!g_fCUAS)
508 return;
509
510 TCHAR szImeFile[16];
511 CicRegKey regKey2;
512 error = regKey2.Open(HKEY_LOCAL_MACHINE,
513 TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"));
514 if (error == ERROR_SUCCESS)
515 {
516 error = regKey2.QuerySz(TEXT("IME File"), szImeFile, _countof(szImeFile));
517 if (error == ERROR_SUCCESS)
518 {
519 g_szCUASImeFile[_countof(g_szCUASImeFile) - 1] = TEXT('\0'); // Avoid buffer overrun
521 }
522 }
523}
LSTATUS QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax)
Definition: cicreg.h:84
LSTATUS Open(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired=KEY_READ)
Definition: cicreg.h:51
LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue)
Definition: cicreg.h:61
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
TCHAR g_szCUASImeFile[16]
Definition: utils.cpp:51
BOOL g_fCUAS
Definition: utils.cpp:50
#define TEXT(s)
Definition: k32.h:26
#define error(str)
Definition: mkdosfs.c:1605
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ProcessAttach().

◆ InitLangChangeHotKey()

BOOL InitLangChangeHotKey ( VOID  )

@implemented

Definition at line 363 of file utils.cpp.

364{
365 CicRegKey regKey;
366 TCHAR szLanguage[2], szLayout[2];
368
369 szLanguage[0] = szLayout[0] = TEXT('3');
370 szLanguage[1] = szLayout[1] = TEXT('\0');
371
372 error = regKey.Open(HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Toggle"));
373 if (error == ERROR_SUCCESS)
374 {
375 error = regKey.QuerySz(TEXT("Language Hotkey"), szLanguage, _countof(szLanguage));
376 if (error != ERROR_SUCCESS)
377 {
379 {
380 error = regKey.QuerySz(TEXT("Hotkey"), szLanguage, _countof(szLanguage));
381 if (error != ERROR_SUCCESS)
382 szLanguage[0] = TEXT('1');
383 }
384 else
385 {
386 error = regKey.QuerySz(NULL, szLanguage, _countof(szLanguage));
387 if (error != ERROR_SUCCESS)
388 szLanguage[0] = TEXT('1');
389 }
390
392 szLanguage[0] = TEXT('1');
393 }
394
395 error = regKey.QuerySz(TEXT("Layout Hotkey"), szLayout, _countof(szLayout));
396 if (error != ERROR_SUCCESS)
397 {
398 szLayout[0] = TEXT('1');
399 if (szLanguage[0] != TEXT('2'))
400 szLayout[0] = TEXT('2');
402 szLayout[0] = TEXT('3');
403 }
404
405 szLanguage[1] = TEXT('\0');
406 szLayout[1] = TEXT('\0');
407 }
408
409 if (szLanguage[0] == szLayout[0])
410 {
411 if (szLanguage[0] == TEXT('1'))
412 szLayout[0] = TEXT('2');
413 else if (szLanguage[0] == TEXT('2'))
414 szLayout[0] = TEXT('1');
415 else
416 szLayout[0] = TEXT('3');
417 }
418
420
421 switch (szLanguage[0])
422 {
423 case TEXT('2'):
427 break;
428
429 case TEXT('3'):
433 break;
434
435 case TEXT('4'):
439 break;
440
441 case TEXT('1'):
442 default:
446 break;
447 }
448
449 switch (szLayout[0])
450 {
451 case TEXT('2'):
455 break;
456
457 case TEXT('3'):
461 break;
462
463 case TEXT('4'):
467 break;
468
469 case TEXT('1'):
470 default:
474 break;
475 }
476
478
479 TRACE("HotKey: %c, %c\n", szLanguage[0], szLayout[0]);
480 return TRUE;
481}
#define CIC_OSINFO_NT
Definition: cicbase.h:44
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1229
DWORD g_dwOSInfo
Definition: utils.cpp:45
UINT g_uKeyTipHotKeyVKey
Definition: utils.cpp:90
UINT g_uLangHotKeyVKey2
Definition: utils.cpp:88
UINT g_uLangHotKeyModifiers
Definition: utils.cpp:86
UINT g_uKeyTipHotKeyVKey2
Definition: utils.cpp:91
UINT g_uKeyTipHotKeyModifiers
Definition: utils.cpp:89
UINT g_uLangHotKeyVKey
Definition: utils.cpp:87
CRITICAL_SECTION g_csInDllMain
Definition: utils.cpp:40
#define MOD_ALT
Definition: imm.h:184
#define MOD_SHIFT
Definition: imm.h:186
#define MOD_CONTROL
Definition: imm.h:185
#define LANG_CHINESE
Definition: nls.h:42
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SM_MIDEASTENABLED
Definition: winuser.h:1037
#define VK_CONTROL
Definition: winuser.h:2206
#define VK_NUMPAD0
Definition: winuser.h:2242
#define VK_SHIFT
Definition: winuser.h:2205
#define VK_OEM_3
Definition: winuser.h:2319
int WINAPI GetSystemMetrics(_In_ int)
#define VK_MENU
Definition: winuser.h:2207

Referenced by ProcessAttach().

◆ InitUniqueString()

BOOL InitUniqueString ( void  )

@implemented

Definition at line 149 of file utils.cpp.

150{
151 g_szUserUnique[0] = TEXT('\0');
152
154 HDESK hDesk = GetThreadDesktop(dwThreadId);
155
156 DWORD nLengthNeeded;
158 if (hDesk && GetUserObjectInformation(hDesk, UOI_NAME, szName, _countof(szName), &nLengthNeeded))
160
161 if (!InitUserSidString())
162 return FALSE;
163
165 return TRUE;
166}
BOOL InitUserSidString(void)
Definition: utils.cpp:131
TCHAR g_szUserSidString[MAX_PATH]
Definition: utils.cpp:69
DWORD dwThreadId
Definition: fdebug.c:31
static const WCHAR szName[]
Definition: powrprof.c:45
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
HDESK WINAPI GetThreadDesktop(_In_ DWORD)
#define UOI_NAME
Definition: winuser.h:1087
#define GetUserObjectInformation
Definition: winuser.h:5807

Referenced by ProcessAttach().

◆ InitUserSidString()

BOOL InitUserSidString ( void  )

@implemented

Definition at line 131 of file utils.cpp.

132{
134 return TRUE;
135
136 LPTSTR pszUserSID = GetUserSIDString();
137 if (!pszUserSID)
138 return FALSE;
139
142 LocalFree(pszUserSID);
143 return TRUE;
144}
LPTSTR GetUserSIDString(void)
Definition: utils.cpp:96
BOOL g_fUserSidString
Definition: utils.cpp:68

Referenced by InitUniqueString().

◆ ProcessAttach()

BOOL ProcessAttach ( HINSTANCE  hinstDLL)

@unimplemented

Definition at line 533 of file utils.cpp.

534{
536
540
542 g_hInst = hinstDLL;
545 if (g_dwTLSIndex == (DWORD)-1)
546 return FALSE;
547
548 g_msgPrivate = ::RegisterWindowMessageA("MSUIM.Msg.Private");
549 g_msgSetFocus = ::RegisterWindowMessageA("MSUIM.Msg.SetFocus");
550 g_msgThreadTerminate = ::RegisterWindowMessageA("MSUIM.Msg.ThreadTerminate");
551 g_msgThreadItemChange = ::RegisterWindowMessageA("MSUIM.Msg.ThreadItemChange");
552 g_msgLBarModal = ::RegisterWindowMessageA("MSUIM.Msg.LangBarModal");
553 g_msgRpcSendReceive = ::RegisterWindowMessageA("MSUIM.Msg.RpcSendReceive");
554 g_msgThreadMarshal = ::RegisterWindowMessageA("MSUIM.Msg.ThreadMarshal");
555 g_msgCheckThreadInputIdel = ::RegisterWindowMessageA("MSUIM.Msg.CheckThreadInputIdel");
556 g_msgStubCleanUp = ::RegisterWindowMessageA("MSUIM.Msg.StubCleanUp");
557 g_msgShowFloating = ::RegisterWindowMessageA("MSUIM.Msg.ShowFloating");
558 g_msgLBUpdate = ::RegisterWindowMessageA("MSUIM.Msg.LBUpdate");
559 g_msgNuiMgrDirtyUpdate = ::RegisterWindowMessageA("MSUIM.Msg.MuiMgrDirtyUpdate");
560 if (!g_msgPrivate ||
561 !g_msgSetFocus ||
570 !g_msgLBUpdate ||
572 {
573 return FALSE;
574 }
575
577 TRACE("cicGetOSInfo: %u, 0x%lX\n", g_uACP, g_dwOSInfo);
578
580
581 //FIXME
582
584
585 //FIXME
586
587 InitCUASFlag();
588
589 //FIXME
590
594
595 //FIXME
596
598
599 //FIXME
600
602
603 return TRUE;
604}
EXTERN_C BOOL cicIsWow64(VOID)
Definition: cicbase.cpp:58
EXTERN_C void cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
Definition: cicbase.cpp:82
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
UINT g_msgPrivate
Definition: utils.cpp:54
VOID InitCUASFlag(VOID)
Definition: utils.cpp:491
VOID CheckAnchorStores(VOID)
Definition: utils.cpp:486
HKL g_hklDefault
Definition: utils.cpp:46
UINT g_msgLBUpdate
Definition: utils.cpp:64
UINT g_msgCheckThreadInputIdel
Definition: utils.cpp:61
BOOL g_bOnWow64
Definition: utils.cpp:43
UINT g_msgThreadMarshal
Definition: utils.cpp:60
BOOL gfSharedMemory
Definition: utils.cpp:48
CRITICAL_SECTION g_csDelayLoad
Definition: utils.cpp:41
CRITICAL_SECTION g_cs
Definition: utils.cpp:39
UINT g_msgStubCleanUp
Definition: utils.cpp:62
UINT g_msgShowFloating
Definition: utils.cpp:63
UINT g_msgNuiMgrDirtyUpdate
Definition: utils.cpp:65
UINT g_msgRpcSendReceive
Definition: utils.cpp:59
void GetDesktopUniqueName(_In_ LPCTSTR pszName, _Out_ LPTSTR pszBuff, _In_ UINT cchBuff)
Definition: utils.cpp:169
UINT g_uACP
Definition: utils.cpp:44
UINT g_msgThreadTerminate
Definition: utils.cpp:56
BOOL InitLangChangeHotKey(VOID)
Definition: utils.cpp:363
UINT g_msgSetFocus
Definition: utils.cpp:55
TCHAR g_szAsmListCache[MAX_PATH]
Definition: utils.cpp:71
BOOL InitUniqueString(void)
Definition: utils.cpp:149
TCHAR g_szTimListCache[MAX_PATH]
Definition: utils.cpp:72
UINT g_msgThreadItemChange
Definition: utils.cpp:57
BOOL gf_CRT_INIT
Definition: utils.cpp:37
DWORD g_dwTLSIndex
Definition: utils.cpp:47
UINT g_msgLBarModal
Definition: utils.cpp:58
HINSTANCE g_hInst
Definition: utils.cpp:42
TCHAR g_szLayoutsCache[MAX_PATH]
Definition: utils.cpp:73
BOOL WINAPI InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
Definition: synch.c:765
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)

◆ ProcessDetach()

VOID ProcessDetach ( HINSTANCE  hinstDLL)

@unimplemented

Definition at line 609 of file utils.cpp.

610{
611 if (!gf_CRT_INIT)
612 {
614 return;
615 }
616
617 if (gfSharedMemory)
618 {
619 if (g_cRefDll != -1 )
620 TFUninitLib();
621 //FIXME
622 }
623
624 UninitINAT();
625
626 //FIXME
627
628 //TF_UninitThreadSystem();
629
630 //FIXME
631
632 if (g_dwTLSIndex != (DWORD)-1)
633 {
635 g_dwTLSIndex = (DWORD)-1;
636 }
637
638 //FIXME
639
640 if (gfSharedMemory)
641 {
645 //FIXME
648 //FIXME
650 }
651
653
657
659}
void Uninit()
Definition: cicmutex.h:31
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
CicMutex g_mutexLBES
Definition: utils.cpp:76
EXTERN_C VOID TFUninitLib(VOID)
Definition: utils.cpp:525
CicMutex g_mutexLayouts
Definition: utils.cpp:79
CicMutex g_mutexAsm
Definition: utils.cpp:78
LONG g_cRefDll
Definition: utils.cpp:49
CicMutex g_mutexTMD
Definition: utils.cpp:80
CicMutex g_mutexCompart
Definition: utils.cpp:77
CicFileMappingStatic g_SharedMemory
Definition: utils.cpp:83
BOOL g_fDllProcessDetached
Definition: utils.cpp:38
VOID UninitINAT(VOID)
@implemented
Definition: mlng.cpp:354
#define DWORD
Definition: nt_native.h:44
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ RunCPLSetting()

static BOOL RunCPLSetting ( LPCTSTR  pszCmdLine)
inlinestatic

Definition at line 230 of file utils.cpp.

231{
232 if (!pszCmdLine)
233 return FALSE;
234
235 return FullPathExec(TEXT("rundll32.exe"), pszCmdLine, SW_SHOWMINNOACTIVE, FALSE);
236}
BOOL FullPathExec(LPCTSTR pszExeFile, LPCTSTR pszCmdLine, UINT nCmdShow, BOOL bSysWinDir)
Definition: utils.cpp:197
#define SW_SHOWMINNOACTIVE
Definition: winuser.h:780

Referenced by TF_RunInputCPL().

◆ StringFromGUID2A()

BOOL StringFromGUID2A ( REFGUID  rguid,
LPSTR  pszGUID,
INT  cchGUID 
)

Definition at line 178 of file utils.cpp.

179{
180 pszGUID[0] = ANSI_NULL;
181
182 WCHAR szWide[40];
183 szWide[0] = UNICODE_NULL;
184 BOOL ret = StringFromGUID2(rguid, szWide, _countof(szWide));
185 ::WideCharToMultiByte(CP_ACP, 0, szWide, -1, pszGUID, cchGUID, NULL, NULL);
186 return ret;
187}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
unsigned int BOOL
Definition: ntddk_ex.h:94
#define UNICODE_NULL
#define ANSI_NULL
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ TF_IsCtfmonRunning()

EXTERN_C BOOL WINAPI TF_IsCtfmonRunning ( VOID  )

Definition at line 347 of file utils.cpp.

348{
350 GetDesktopUniqueName(TEXT("CtfmonInstMutex"), szName, _countof(szName));
351
353 if (!hMutex)
354 return FALSE;
355
357 return TRUE;
358}
HANDLE hMutex
Definition: mutex.c:11
#define MUTEX_ALL_ACCESS
Definition: winbase.h:158
#define OpenMutex
Definition: winbase.h:3888

◆ TF_RegisterLangBarAddIn()

EXTERN_C HRESULT WINAPI TF_RegisterLangBarAddIn ( _In_ REFGUID  rguid,
_In_ LPCWSTR  pszFilePath,
_In_ DWORD  dwFlags 
)

Definition at line 244 of file utils.cpp.

248{
249 TRACE("(%s, %s, 0x%lX)\n", debugstr_guid(&rguid), debugstr_w(pszFilePath), dwFlags);
250
251 if (!pszFilePath || IsEqualGUID(rguid, GUID_NULL))
252 {
253 ERR("E_INVALIDARG\n");
254 return E_INVALIDARG;
255 }
256
257 TCHAR szBuff[MAX_PATH], szGUID[40];
258 StringCchCopy(szBuff, _countof(szBuff), TEXT("SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"));
259 StringFromGUID2T(rguid, szGUID, _countof(szGUID));
260 StringCchCat(szBuff, _countof(szBuff), szGUID);
261
262 CicRegKey regKey;
263 HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER);
264 LSTATUS error = regKey.Create(hBaseKey, szBuff);
265 if (error == ERROR_SUCCESS)
266 {
267 error = regKey.SetSzW(L"FilePath", pszFilePath);
268 if (error == ERROR_SUCCESS)
269 error = regKey.SetDword(TEXT("Enable"), !!(dwFlags & 4));
270 }
271
272 return ((error == ERROR_SUCCESS) ? S_OK : E_FAIL);
273}
LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue)
Definition: cicreg.h:67
LSTATUS Create(HKEY hKey, LPCTSTR lpSubKey)
Definition: cicreg.h:56
LSTATUS SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue)
Definition: cicreg.h:78
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define StringFromGUID2T
Definition: utils.cpp:193
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define GUID_NULL
Definition: ks.h:106
#define L(x)
Definition: ntvdm.h:50
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ TF_RunInputCPL()

EXTERN_C HRESULT WINAPI TF_RunInputCPL ( VOID  )

Definition at line 317 of file utils.cpp.

318{
319 CicSystemModulePath ModPath;
320 TCHAR szCmdLine[2 * MAX_PATH];
321
322 TRACE("()\n");
323
324 // NOTE: We don't support Win95/98/Me
326 ModPath.Init(TEXT("input.dll"), FALSE);
327 else
328 ModPath.Init(TEXT("input.cpl"), FALSE);
329
330 if (!ModPath.m_cchPath)
331 return E_FAIL;
332
333 StringCchPrintf(szCmdLine, _countof(szCmdLine),
334 TEXT("rundll32.exe shell32.dll,Control_RunDLL %s"), ModPath.m_szPath);
335 if (!RunCPLSetting(szCmdLine))
336 return E_FAIL;
337
338 return S_OK;
339}
#define CIC_OSINFO_XPPLUS
Definition: cicbase.h:51
static BOOL RunCPLSetting(LPCTSTR pszCmdLine)
Definition: utils.cpp:230
#define StringCchPrintf
Definition: strsafe.h:517

Referenced by CUTBContextMenu::SelectMenuItem().

◆ TF_UnregisterLangBarAddIn()

EXTERN_C HRESULT WINAPI TF_UnregisterLangBarAddIn ( _In_ REFGUID  rguid,
_In_ DWORD  dwFlags 
)

Definition at line 281 of file utils.cpp.

284{
285 TRACE("(%s, 0x%lX)\n", debugstr_guid(&rguid), dwFlags);
286
287 if (IsEqualGUID(rguid, GUID_NULL))
288 {
289 ERR("E_INVALIDARG\n");
290 return E_INVALIDARG;
291 }
292
293 TCHAR szSubKey[MAX_PATH];
294 StringCchCopy(szSubKey, _countof(szSubKey), TEXT("SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"));
295
296 CicRegKey regKey;
297 HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER);
298 LSTATUS error = regKey.Open(hBaseKey, szSubKey, KEY_ALL_ACCESS);
299 HRESULT hr = E_FAIL;
300 if (error == ERROR_SUCCESS)
301 {
302 TCHAR szGUID[40];
303 StringFromGUID2T(rguid, szGUID, _countof(szGUID));
304 regKey.RecurseDeleteKey(szGUID);
305 hr = S_OK;
306 }
307
308 return hr;
309}
LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey)
Definition: cicreg.h:113
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
HRESULT hr
Definition: shlfolder.c:183

◆ TFUninitLib()

EXTERN_C VOID TFUninitLib ( VOID  )

Definition at line 525 of file utils.cpp.

526{
527 // Do nothing
528}

Referenced by ProcessDetach().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msctf  )

Variable Documentation

◆ g_bOnWow64

BOOL g_bOnWow64 = FALSE

Definition at line 43 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_cRefDll

LONG g_cRefDll = -1

Definition at line 49 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_cs

Definition at line 39 of file utils.cpp.

Referenced by ProcessAttach(), and ProcessDetach().

◆ g_csDelayLoad

CRITICAL_SECTION g_csDelayLoad

Definition at line 41 of file utils.cpp.

Referenced by ProcessAttach(), and ProcessDetach().

◆ g_csInDllMain

CRITICAL_SECTION g_csInDllMain

Definition at line 40 of file utils.cpp.

Referenced by InitLangChangeHotKey(), ProcessAttach(), and ProcessDetach().

◆ g_dwOSInfo

DWORD g_dwOSInfo = 0

Definition at line 45 of file utils.cpp.

Referenced by InitLangChangeHotKey(), ProcessAttach(), and TF_RunInputCPL().

◆ g_dwTLSIndex

DWORD g_dwTLSIndex = (DWORD)-1

Definition at line 47 of file utils.cpp.

Referenced by ProcessAttach(), and ProcessDetach().

◆ g_fCUAS

BOOL g_fCUAS = FALSE

Definition at line 50 of file utils.cpp.

Referenced by InitCUASFlag().

◆ g_fDllProcessDetached

BOOL g_fDllProcessDetached = FALSE

Definition at line 38 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_fUserSidString

BOOL g_fUserSidString = FALSE

Definition at line 68 of file utils.cpp.

Referenced by InitUserSidString().

◆ g_hInst

HINSTANCE g_hInst = NULL

Definition at line 42 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_hklDefault

HKL g_hklDefault = NULL

Definition at line 46 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgCheckThreadInputIdel

UINT g_msgCheckThreadInputIdel = 0

Definition at line 61 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgLBarModal

UINT g_msgLBarModal = 0

Definition at line 58 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgLBUpdate

UINT g_msgLBUpdate = 0

Definition at line 64 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgNuiMgrDirtyUpdate

UINT g_msgNuiMgrDirtyUpdate = 0

Definition at line 65 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgPrivate

UINT g_msgPrivate = 0

Definition at line 54 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgRpcSendReceive

UINT g_msgRpcSendReceive = 0

Definition at line 59 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgSetFocus

UINT g_msgSetFocus = 0

Definition at line 55 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgShowFloating

UINT g_msgShowFloating = 0

Definition at line 63 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgStubCleanUp

UINT g_msgStubCleanUp = 0

Definition at line 62 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgThreadItemChange

UINT g_msgThreadItemChange = 0

Definition at line 57 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgThreadMarshal

UINT g_msgThreadMarshal = 0

Definition at line 60 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_msgThreadTerminate

UINT g_msgThreadTerminate = 0

Definition at line 56 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_mutexAsm

CicMutex g_mutexAsm

Definition at line 78 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_mutexCompart

CicMutex g_mutexCompart

Definition at line 77 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_mutexLayouts

CicMutex g_mutexLayouts

Definition at line 79 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_mutexLBES

CicMutex g_mutexLBES

Definition at line 76 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_mutexTMD

CicMutex g_mutexTMD

Definition at line 80 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_SharedMemory

CicFileMappingStatic g_SharedMemory

Definition at line 83 of file utils.cpp.

Referenced by ProcessDetach().

◆ g_szAsmListCache

TCHAR g_szAsmListCache[MAX_PATH] = { 0 }

Definition at line 71 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_szCUASImeFile

TCHAR g_szCUASImeFile[16] = { 0 }

Definition at line 51 of file utils.cpp.

Referenced by InitCUASFlag().

◆ g_szLayoutsCache

TCHAR g_szLayoutsCache[MAX_PATH] = { 0 }

Definition at line 73 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_szTimListCache

TCHAR g_szTimListCache[MAX_PATH] = { 0 }

Definition at line 72 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_szUserSidString

TCHAR g_szUserSidString[MAX_PATH] = { 0 }

Definition at line 69 of file utils.cpp.

Referenced by InitUniqueString(), and InitUserSidString().

◆ g_szUserUnique

TCHAR g_szUserUnique[MAX_PATH] = { 0 }

Definition at line 70 of file utils.cpp.

Referenced by GetDesktopUniqueName(), and InitUniqueString().

◆ g_uACP

UINT g_uACP = CP_ACP

Definition at line 44 of file utils.cpp.

Referenced by ProcessAttach().

◆ g_uKeyTipHotKeyModifiers

UINT g_uKeyTipHotKeyModifiers = 0

Definition at line 89 of file utils.cpp.

Referenced by InitLangChangeHotKey().

◆ g_uKeyTipHotKeyVKey

UINT g_uKeyTipHotKeyVKey = 0

Definition at line 90 of file utils.cpp.

Referenced by InitLangChangeHotKey().

◆ g_uKeyTipHotKeyVKey2

UINT g_uKeyTipHotKeyVKey2 = 0

Definition at line 91 of file utils.cpp.

Referenced by InitLangChangeHotKey().

◆ g_uLangHotKeyModifiers

UINT g_uLangHotKeyModifiers = 0

Definition at line 86 of file utils.cpp.

Referenced by InitLangChangeHotKey().

◆ g_uLangHotKeyVKey

UINT g_uLangHotKeyVKey = 0

Definition at line 87 of file utils.cpp.

Referenced by InitLangChangeHotKey().

◆ g_uLangHotKeyVKey2

UINT g_uLangHotKeyVKey2 = 0

Definition at line 88 of file utils.cpp.

Referenced by InitLangChangeHotKey().

◆ gf_CRT_INIT

BOOL gf_CRT_INIT = FALSE

Definition at line 37 of file utils.cpp.

Referenced by ProcessAttach(), and ProcessDetach().

◆ gfSharedMemory

BOOL gfSharedMemory = FALSE

Definition at line 48 of file utils.cpp.

Referenced by ProcessAttach(), and ProcessDetach().