ReactOS 0.4.16-dev-122-g325d74c
tls.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS msctfime.ime
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Thread-local storage
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "msctfime.h"
9
11
13
16{
18 return s_dwTlsIndex != (DWORD)-1;
19}
20
23{
24 if (s_dwTlsIndex != (DWORD)-1)
25 {
27 s_dwTlsIndex = (DWORD)-1;
28 }
29}
30
33{
34 if (s_dwTlsIndex == (DWORD)-1)
35 return NULL;
36
37 return InternalAllocateTLS();
38}
39
42{
44}
45
48{
49 TLS *pTLS = TLS::PeekTLS();
50 if (pTLS)
51 return pTLS;
52
54 return NULL;
55
56 pTLS = (TLS *)cicMemAllocClear(sizeof(TLS));
57 if (!pTLS)
58 return NULL;
59
60 if (!::TlsSetValue(s_dwTlsIndex, pTLS))
61 {
62 cicMemFree(pTLS);
63 return NULL;
64 }
65
66 pTLS->m_dwFlags1 |= 1;
67 pTLS->m_dwUnknown2 |= 1;
68 return pTLS;
69}
70
73{
74 TLS *pTLS = TLS::PeekTLS();
75 if (!pTLS)
76 return FALSE;
77
78 if (pTLS->m_pBridge)
79 pTLS->m_pBridge->Release();
80 if (pTLS->m_pProfile)
81 pTLS->m_pProfile->Release();
82 if (pTLS->m_pThreadMgr)
83 pTLS->m_pThreadMgr->Release();
84
85 cicMemFree(pTLS);
87 return TRUE;
88}
89
92{
94 {
95 DWORD dwValue = 1;
96
97 CicRegKey regKey;
98 LSTATUS error = regKey.Open(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\CTF\\CUAS"));
99 if (error == ERROR_SUCCESS)
100 {
101 error = regKey.QueryDword(TEXT("NonEAComposition"), &dwValue);
102 if (error != ERROR_SUCCESS)
103 dwValue = 1;
104 }
105
106 m_NonEAComposition = dwValue;
107 }
108
109 return (m_NonEAComposition == 2);
110}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void cicMemFree(LPVOID ptr)
Definition: cicbase.h:27
static LPVOID cicMemAllocClear(SIZE_T size)
Definition: cicbase.h:15
LSTATUS Open(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired=KEY_READ)
Definition: cicreg.h:51
LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue)
Definition: cicreg.h:61
Definition: tls.h:14
static TLS * PeekTLS()
@implemented
Definition: tls.cpp:41
static TLS * InternalAllocateTLS()
@implemented
Definition: tls.cpp:47
ITfThreadMgr_P * m_pThreadMgr
Definition: tls.h:21
DWORD m_dwUnknown2
Definition: tls.h:24
static DWORD s_dwTlsIndex
Definition: tls.h:16
DWORD m_dwFlags1
Definition: tls.h:22
static TLS * GetTLS()
@implemented
Definition: tls.cpp:32
BOOL NonEACompositionEnabled()
@implemented
Definition: tls.cpp:91
static BOOL InternalDestroyTLS()
@implemented
Definition: tls.cpp:72
static BOOL Initialize()
@implemented
Definition: tls.cpp:15
static VOID Uninitialize()
@implemented
Definition: tls.cpp:22
DWORD m_NonEAComposition
Definition: tls.h:27
CicProfile * m_pProfile
Definition: tls.h:20
CicBridge * m_pBridge
Definition: tls.h:19
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN DllShutdownInProgress(VOID)
Definition: misc.cpp:42
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG Release()
#define TEXT(s)
Definition: k32.h:26
#define error(str)
Definition: mkdosfs.c:1605
#define DWORD
Definition: nt_native.h:44
#define HKEY_CURRENT_USER
Definition: winreg.h:11