xref: /reactos/sdk/lib/cicero/cicimc.cpp (revision de5c4720)
1 /*
2  * PROJECT:     ReactOS Cicero
3  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE:     Locking and Unlocking IMC and IMCC handles
5  * COPYRIGHT:   Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  */
7 
8 #include "precomp.h"
9 #include <imm.h>
10 #include <immdev.h>
11 #include <imm32_undoc.h>
12 #include "cicimc.h"
13 
14 #define CUSTOM_CAND_INFO_SIZE 1964
15 
16 BOOL CicIMCLock::ClearCand()
17 {
18     HIMCC hNewCandInfo, hCandInfo = m_pIC->hCandInfo;
19     if (hCandInfo)
20     {
21         hNewCandInfo = ImmReSizeIMCC(hCandInfo, CUSTOM_CAND_INFO_SIZE);
22         if (!hNewCandInfo)
23         {
24             ImmDestroyIMCC(m_pIC->hCandInfo);
25             m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
26             return FALSE;
27         }
28     }
29     else
30     {
31         hNewCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
32     }
33 
34     m_pIC->hCandInfo = hNewCandInfo;
35     if (!m_pIC->hCandInfo)
36         return FALSE;
37 
38     CicIMCCLock<CANDIDATEINFO> candInfo(m_pIC->hCandInfo);
39     if (!candInfo)
40     {
41         ImmDestroyIMCC(m_pIC->hCandInfo);
42         m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
43         return FALSE;
44     }
45 
46     candInfo.get().dwSize = CUSTOM_CAND_INFO_SIZE;
47     candInfo.get().dwCount = 0;
48     candInfo.get().dwOffset[0] = sizeof(CANDIDATEINFO);
49 
50     // FIXME: Something is trailing after CANDIDATEINFO...
51 
52     return TRUE;
53 }
54