[SDK:LIB] Introduce Cicero static library (#6492)

Refactoring and reduce binary size.
JIRA issue: CORE-19268
- Add cicero static library in sdk/lib/cicero folder.
- Delete sdk/include/reactos/cicero folder.
- Adapt the dependencies to these changes.
- Make ctfmon, msutb, and msctf modules UNICODE.
This commit is contained in:
Katayama Hirofumi MZ 2024-02-17 09:53:50 +09:00 committed by GitHub
parent 21e139d1d1
commit fc3eeb61f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 2270 additions and 2112 deletions

View file

@ -6,9 +6,9 @@ list(APPEND SOURCE
add_rc_deps(ctfmon.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/ctfmon.ico)
add_executable(ctfmon ${SOURCE} ctfmon.rc)
set_module_type(ctfmon win32gui)
set_module_type(ctfmon win32gui UNICODE)
add_dependencies(ctfmon msctf msutb)
target_link_libraries(ctfmon uuid)
target_link_libraries(ctfmon uuid cicero)
add_importlibs(ctfmon msctf msutb advapi32 shell32 user32 msvcrt kernel32)
add_pch(ctfmon precomp.h SOURCE)
add_cd_file(TARGET ctfmon DESTINATION reactos/system32 FOR all)

View file

@ -17,8 +17,8 @@
#include <msctf.h>
#include <ctfutb.h>
#include <ctffunc.h>
#include <cicero/cicbase.h>
#include <cicero/cicutb.h>
#include <cicbase.h>
#include <cicutb.h>
#include "resource.h"

View file

@ -16,7 +16,7 @@ add_library(msctfime MODULE
${CMAKE_CURRENT_BINARY_DIR}/msctfime.def)
set_module_type(msctfime win32dll UNICODE)
set_target_properties(msctfime PROPERTIES SUFFIX ".ime")
target_link_libraries(msctfime wine uuid)
target_link_libraries(msctfime wine uuid cicero)
add_importlibs(msctfime user32 gdi32 advapi32 msvcrt kernel32 ntdll)
add_delay_importlibs(msctfime comctl32 msctf oleaut32 imm32)
add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all)

View file

@ -24,12 +24,13 @@
#include <shlwapi.h>
#include <strsafe.h>
#include <cicero/cicbase.h>
#include <cicero/cicarray.h>
#include <cicero/cicimc.h>
#include <cicero/cictf.h>
#include <cicero/ciccaret.h>
#include <cicero/cicuif.h>
#include <cicbase.h>
#include <cicarray.h>
#include <cicimc.h>
#include <cictf.h>
#include <ciccaret.h>
#include <cicuif.h>
#include <cicutb.h>
#include <wine/debug.h>

View file

@ -29,8 +29,8 @@ add_library(msctf MODULE
version.rc
${CMAKE_CURRENT_BINARY_DIR}/msctf.def)
set_module_type(msctf win32dll)
target_link_libraries(msctf uuid wine)
set_module_type(msctf win32dll UNICODE)
target_link_libraries(msctf uuid wine cicero)
add_importlibs(msctf user32 advapi32 advapi32_vista msvcrt kernel32 ntdll)
add_delay_importlibs(msctf ole32 oleaut32)
add_pch(msctf precomp.h SOURCE)

View file

@ -23,9 +23,9 @@
#include <shlwapi.h>
#include <strsafe.h>
#include <cicero/cicreg.h>
#include <cicero/cicmutex.h>
#include <cicero/cicfmap.h>
#include <cicreg.h>
#include <cicmutex.h>
#include <cicfmap.h>
#include <wine/debug.h>
@ -366,7 +366,7 @@ BOOL InitLangChangeHotKey(VOID)
szLanguage[0] = szLayout[0] = TEXT('3');
szLanguage[1] = szLayout[1] = TEXT('\0');
error = regKey.Open(HKEY_CURRENT_USER, "Keyboard Layout\\Toggle");
error = regKey.Open(HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Toggle"));
if (error == ERROR_SUCCESS)
{
error = regKey.QuerySz(TEXT("Language Hotkey"), szLanguage, _countof(szLanguage));

View file

@ -11,9 +11,9 @@ add_library(msutb MODULE
${SOURCE}
msutb.rc
${CMAKE_CURRENT_BINARY_DIR}/msutb.def)
set_module_type(msutb win32dll)
set_module_type(msutb win32dll UNICODE)
add_dependencies(msutb msctf psdk)
target_link_libraries(msutb wine uuid atl_classes)
target_link_libraries(msutb wine uuid atl_classes cicero)
add_importlibs(msutb user32 gdi32 advapi32 msvcrt kernel32 ntdll)
add_delay_importlibs(msutb uxtheme imm32 comctl32 msctf ole32 oleacc oleaut32 shell32)
add_cd_file(TARGET msutb DESTINATION reactos/system32 FOR all)

View file

@ -20,7 +20,7 @@ LONG g_DllRefCount = 0;
BOOL g_bWinLogon = FALSE;
BOOL g_fInClosePopupTipbar = FALSE;
HWND g_hwndParent = NULL;
LIBTHREAD g_libTLS = { NULL, NULL };
CIC_LIBTHREAD g_libTLS = { NULL, NULL };
#ifdef ENABLE_DESKBAND
BOOL g_bEnableDeskBand = TRUE;
#else
@ -77,23 +77,6 @@ class CMsUtbModule : public CComModule
CMsUtbModule gModule;
void TFUninitLib_Thread(LIBTHREAD *libThread)
{
if (!libThread)
return;
if (libThread->m_pUnknown1)
{
libThread->m_pUnknown1->Release();
libThread->m_pUnknown1 = NULL;
}
if (libThread->m_pDisplayAttrMgr)
{
libThread->m_pDisplayAttrMgr->Release();
libThread->m_pDisplayAttrMgr = NULL;
}
}
class CCicLibMenuItem;
class CTipbarAccItem;
class CUTBMenuItem;
@ -6075,7 +6058,7 @@ BOOL GetTipbarInternal(HWND hWnd, DWORD dwFlags, CDeskBand *pDeskBand)
*
* @implemented
*/
EXTERN_C PLIBTHREAD WINAPI
EXTERN_C PCIC_LIBTHREAD WINAPI
GetLibTls(VOID)
{
TRACE("()\n");

View file

@ -9,7 +9,6 @@
#include <stdlib.h>
#define WIN32_NO_STATUS
#define COBJMACROS
#define INITGUID
@ -25,11 +24,10 @@
#include <atlbase.h>
#include <atlcom.h>
#include <strsafe.h>
#undef STATUS_NO_MEMORY
#include "resource.h"
#include <cicero/cicreg.h>
#include <cicero/cicutb.h>
#include <cicero/cicuif.h>
#include <cicreg.h>
#include <cicutb.h>
#include <cicuif.h>
#include <wine/debug.h>

View file

@ -1,177 +0,0 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Cicero registry handling
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
#include "cicbase.h"
class CicRegKey
{
public:
HKEY m_hKey;
CicRegKey() : m_hKey(NULL) { }
virtual ~CicRegKey() { Close(); }
operator HKEY() { return m_hKey; }
void Close();
LSTATUS Open(
HKEY hKey,
LPCTSTR lpSubKey,
REGSAM samDesired = KEY_READ);
LSTATUS Create(
HKEY hKey,
LPCTSTR lpSubKey,
LPTSTR lpClass = NULL,
DWORD dwOptions = REG_OPTION_NON_VOLATILE,
REGSAM samDesired = KEY_ALL_ACCESS,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL,
LPDWORD pdwDisposition = NULL);
LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue)
{
DWORD cbData = sizeof(DWORD);
return ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData);
}
LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue)
{
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
}
LSTATUS QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax);
LSTATUS SetSz(LPCTSTR pszValueName, LPCTSTR pszValue)
{
DWORD cbValue = (lstrlen(pszValue) + 1) * sizeof(TCHAR);
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
LSTATUS SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue)
{
DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
LSTATUS DeleteSubKey(LPCTSTR lpSubKey)
{
return ::RegDeleteKey(m_hKey, lpSubKey);
}
LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey);
LSTATUS EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName);
};
/******************************************************************************/
inline void
CicRegKey::Close()
{
if (!m_hKey)
return;
::RegCloseKey(m_hKey);
m_hKey = NULL;
}
inline LSTATUS
CicRegKey::Open(
HKEY hKey,
LPCTSTR lpSubKey,
REGSAM samDesired)
{
HKEY hNewKey = NULL;
LSTATUS error = ::RegOpenKeyEx(hKey, lpSubKey, 0, samDesired, &hNewKey);
if (error != ERROR_SUCCESS)
return error;
Close();
m_hKey = hNewKey;
return error;
}
inline LSTATUS
CicRegKey::Create(
HKEY hKey,
LPCTSTR lpSubKey,
LPTSTR lpClass,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
LPDWORD pdwDisposition)
{
HKEY hNewKey = NULL;
LSTATUS error = ::RegCreateKeyEx(hKey,
lpSubKey,
0,
lpClass,
dwOptions,
samDesired,
lpSecurityAttributes,
&hNewKey,
pdwDisposition);
if (error != ERROR_SUCCESS)
return error;
Close();
m_hKey = hNewKey;
return error;
}
inline LSTATUS
CicRegKey::QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax)
{
DWORD cchSaveMax = cchValueMax;
cchValueMax *= sizeof(TCHAR);
LSTATUS error = ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL,
(LPBYTE)pszValue, &cchValueMax);
if (cchSaveMax > 0)
pszValue[(error == ERROR_SUCCESS) ? (cchSaveMax - 1) : 0] = UNICODE_NULL;
return error;
}
inline LSTATUS
CicRegKey::RecurseDeleteKey(LPCTSTR lpSubKey)
{
CicRegKey regKey;
LSTATUS error = regKey.Open(m_hKey, lpSubKey, KEY_READ | KEY_WRITE);
if (error != ERROR_SUCCESS)
return error;
TCHAR szName[MAX_PATH];
DWORD cchName;
do
{
cchName = _countof(szName);
error = ::RegEnumKeyEx(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL);
if (error != ERROR_SUCCESS)
break;
szName[_countof(szName) - 1] = UNICODE_NULL;
error = regKey.RecurseDeleteKey(szName);
} while (error == ERROR_SUCCESS);
regKey.Close();
return DeleteSubKey(lpSubKey);
}
inline LSTATUS
CicRegKey::EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName)
{
DWORD dwSaveLen = cchValueName;
LSTATUS error = ::RegEnumValue(m_hKey, dwIndex, lpValueName, &cchValueName,
NULL, NULL, NULL, NULL);
if (dwSaveLen)
lpValueName[error == ERROR_SUCCESS ? dwSaveLen - 1 : 0] = 0;
return error;
}

View file

@ -6,6 +6,7 @@ add_subdirectory(inflib)
if(CMAKE_CROSSCOMPILING)
add_subdirectory(3rdparty)
add_subdirectory(cicero)
add_subdirectory(comsupp)
add_subdirectory(conutils)
add_subdirectory(cportlib)

View file

@ -0,0 +1,15 @@
list(APPEND SOURCE
cicarray.cpp
cicbase.cpp
ciccaret.cpp
cicfmap.cpp
cicimc.cpp
cicreg.cpp
cicuif.cpp)
add_library(cicero STATIC ${SOURCE})
target_compile_definitions(cicero PRIVATE UNICODE _UNICODE)
add_dependencies(cicero psdk)
target_include_directories(cicero INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}>)

View file

@ -0,0 +1,78 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Cicero dynamic array
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#include "precomp.h"
#include "cicarray.h"
CicArrayBase::CicArrayBase(size_t cbItem)
{
m_cbItem = cbItem;
m_pb = NULL;
m_cItems = m_cCapacity = 0;
}
CicArrayBase::~CicArrayBase()
{
cicMemFree(m_pb);
}
LPVOID CicArrayBase::Append(size_t cGrow)
{
if (!Insert(m_cItems, cGrow))
return NULL;
return &m_pb[(m_cItems - cGrow) * m_cbItem];
}
BOOL CicArrayBase::Insert(size_t iItem, size_t cGrow)
{
size_t cNewCapacity = m_cItems + cGrow;
if (m_cCapacity < cNewCapacity)
{
if (cNewCapacity <= m_cItems + m_cItems / 2)
cNewCapacity = m_cItems + m_cItems / 2;
LPBYTE pbNew = (LPBYTE)cicMemReAlloc(m_pb, cNewCapacity * m_cbItem);
if (!pbNew)
return FALSE;
m_pb = pbNew;
m_cCapacity = cNewCapacity;
}
if (iItem < m_cItems)
{
MoveMemory(&m_pb[(cGrow + iItem) * m_cbItem],
&m_pb[iItem * m_cbItem],
(m_cItems - iItem) * m_cbItem);
}
m_cItems += cGrow;
return TRUE;
}
void CicArrayBase::Remove(size_t iItem, size_t cRemove)
{
if (iItem + cRemove < m_cItems)
{
MoveMemory(&m_pb[iItem * m_cbItem],
&m_pb[(iItem + cRemove) * m_cbItem],
(m_cItems - iItem - cRemove) * m_cbItem);
}
m_cItems -= cRemove;
size_t cHalfCapacity = m_cCapacity / 2;
if (cHalfCapacity <= m_cItems)
return;
LPBYTE pb = (LPBYTE)cicMemReAlloc(m_pb, cHalfCapacity * m_cbItem);
if (pb)
{
m_pb = pb;
m_cCapacity = cHalfCapacity;
}
}

View file

@ -66,7 +66,7 @@ public:
return TRUE;
}
ssize_t Find(const T_ITEM& item) const
ptrdiff_t Find(const T_ITEM& item) const
{
for (size_t iItem = 0; iItem < m_cItems; ++iItem)
{
@ -76,74 +76,3 @@ public:
return -1;
}
};
/******************************************************************************/
inline CicArrayBase::CicArrayBase(size_t cbItem)
{
m_cbItem = cbItem;
m_pb = NULL;
m_cItems = m_cCapacity = 0;
}
inline CicArrayBase::~CicArrayBase()
{
cicMemFree(m_pb);
}
inline LPVOID CicArrayBase::Append(size_t cGrow)
{
if (!Insert(m_cItems, cGrow))
return NULL;
return &m_pb[(m_cItems - cGrow) * m_cbItem];
}
inline BOOL CicArrayBase::Insert(size_t iItem, size_t cGrow)
{
size_t cNewCapacity = m_cItems + cGrow;
if (m_cCapacity < cNewCapacity)
{
if (cNewCapacity <= m_cItems + m_cItems / 2)
cNewCapacity = m_cItems + m_cItems / 2;
LPBYTE pbNew = (LPBYTE)cicMemReAlloc(m_pb, cNewCapacity * m_cbItem);
if (!pbNew)
return FALSE;
m_pb = pbNew;
m_cCapacity = cNewCapacity;
}
if (iItem < m_cItems)
{
MoveMemory(&m_pb[(cGrow + iItem) * m_cbItem],
&m_pb[iItem * m_cbItem],
(m_cItems - iItem) * m_cbItem);
}
m_cItems += cGrow;
return TRUE;
}
inline void CicArrayBase::Remove(size_t iItem, size_t cRemove)
{
if (iItem + cRemove < m_cItems)
{
MoveMemory(&m_pb[iItem * m_cbItem],
&m_pb[(iItem + cRemove) * m_cbItem],
(m_cItems - iItem - cRemove) * m_cbItem);
}
m_cItems -= cRemove;
size_t cHalfCapacity = m_cCapacity / 2;
if (cHalfCapacity <= m_cItems)
return;
LPBYTE pb = (LPBYTE)cicMemReAlloc(m_pb, cHalfCapacity * m_cbItem);
if (pb)
{
m_pb = pb;
m_cCapacity = cHalfCapacity;
}
}

View file

@ -2,84 +2,84 @@
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Cicero base
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
* COPYRIGHT: Copyright 2023-2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
#include "precomp.h"
#include "cicbase.h"
#include <shlwapi.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
#include <strsafe.h>
#ifndef __cplusplus
#error Cicero needs C++.
#endif
static inline LPVOID cicMemAlloc(SIZE_T size)
{
return LocalAlloc(0, size);
}
static inline LPVOID cicMemAllocClear(SIZE_T size)
{
return LocalAlloc(LMEM_ZEROINIT, size);
}
static inline LPVOID cicMemReAlloc(LPVOID ptr, SIZE_T newSize)
{
if (!ptr)
return LocalAlloc(LMEM_ZEROINIT, newSize);
return LocalReAlloc(ptr, newSize, LMEM_ZEROINIT);
}
static inline void cicMemFree(LPVOID ptr)
{
if (ptr)
LocalFree(ptr);
}
struct CicNoThrow { };
#define cicNoThrow CicNoThrow{}
inline void* operator new(size_t size, const CicNoThrow&) noexcept
void* operator new(size_t size, const CicNoThrow&) noexcept
{
return cicMemAllocClear(size);
}
inline void* operator new[](size_t size, const CicNoThrow&) noexcept
void* operator new[](size_t size, const CicNoThrow&) noexcept
{
return cicMemAllocClear(size);
}
inline void operator delete(void* ptr) noexcept
void operator delete(void* ptr) noexcept
{
cicMemFree(ptr);
}
inline void operator delete[](void* ptr) noexcept
void operator delete[](void* ptr) noexcept
{
cicMemFree(ptr);
}
inline void operator delete(void* ptr, size_t size) noexcept
void operator delete(void* ptr, size_t size) noexcept
{
cicMemFree(ptr);
}
inline void operator delete[](void* ptr, size_t size) noexcept
void operator delete[](void* ptr, size_t size) noexcept
{
cicMemFree(ptr);
}
typedef struct CIC_LIBTHREAD
// FIXME
typedef enum _PROCESSINFOCLASS
{
IUnknown *m_pUnknown1;
ITfDisplayAttributeMgr *m_pDisplayAttrMgr;
} CIC_LIBTHREAD, *PCIC_LIBTHREAD;
ProcessBasicInformation = 0,
ProcessDebugPort = 7,
ProcessWow64Information = 26,
ProcessImageFileName = 27,
ProcessBreakOnTermination = 29
} PROCESSINFOCLASS;
/* The flags of cicGetOSInfo() */
#define CIC_OSINFO_NT 0x01
#define CIC_OSINFO_2KPLUS 0x02
#define CIC_OSINFO_95 0x04
#define CIC_OSINFO_98PLUS 0x08
#define CIC_OSINFO_CJK 0x10
#define CIC_OSINFO_IMM 0x20
#define CIC_OSINFO_DBCS 0x40
#define CIC_OSINFO_XPPLUS 0x80
// FIXME
typedef LONG NTSTATUS;
static inline void
cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
/* ntdll!NtQueryInformationProcess */
typedef NTSTATUS (WINAPI *FN_NtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
EXTERN_C
BOOL cicIsWow64(VOID)
{
static FN_NtQueryInformationProcess s_fnNtQueryInformationProcess = NULL;
ULONG_PTR Value;
if (!s_fnNtQueryInformationProcess)
{
HMODULE hNTDLL = cicGetSystemModuleHandle(TEXT("ntdll.dll"), FALSE);
if (!hNTDLL)
return FALSE;
s_fnNtQueryInformationProcess =
(FN_NtQueryInformationProcess)GetProcAddress(hNTDLL, "NtQueryInformationProcess");
if (!s_fnNtQueryInformationProcess)
return FALSE;
}
Value = 0;
s_fnNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information,
&Value, sizeof(Value), NULL);
return !!Value;
}
EXTERN_C
void cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
{
*pdwOSInfo = 0;
@ -124,22 +124,9 @@ cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
*pdwOSInfo |= CIC_OSINFO_DBCS;
}
struct CicSystemModulePath
{
TCHAR m_szPath[MAX_PATH + 2];
SIZE_T m_cchPath;
CicSystemModulePath()
{
m_szPath[0] = UNICODE_NULL;
m_cchPath = 0;
}
BOOL Init(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir);
};
// Get an instance handle that is already loaded
static inline HINSTANCE
EXTERN_C
HINSTANCE
cicGetSystemModuleHandle(
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir)
@ -151,7 +138,8 @@ cicGetSystemModuleHandle(
}
// Load a system library
static inline HINSTANCE
EXTERN_C
HINSTANCE
cicLoadSystemLibrary(
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir)
@ -162,54 +150,7 @@ cicLoadSystemLibrary(
return ::LoadLibrary(ModPath.m_szPath);
}
template <typename T_FN>
static inline BOOL
cicGetFN(HINSTANCE& hinstDLL, T_FN& fn, LPCTSTR pszDllName, LPCSTR pszFuncName)
{
if (fn)
return TRUE;
if (!hinstDLL)
hinstDLL = cicLoadSystemLibrary(pszDllName, FALSE);
if (!hinstDLL)
return FALSE;
fn = reinterpret_cast<T_FN>(GetProcAddress(hinstDLL, pszFuncName));
return !!fn;
}
#include <ndk/pstypes.h> /* for PROCESSINFOCLASS */
/* ntdll!NtQueryInformationProcess */
typedef NTSTATUS (WINAPI *FN_NtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
/* Is the current process on WoW64? */
static inline BOOL cicIsWow64(VOID)
{
static FN_NtQueryInformationProcess s_fnNtQueryInformationProcess = NULL;
ULONG_PTR Value;
NTSTATUS Status;
if (!s_fnNtQueryInformationProcess)
{
HMODULE hNTDLL = cicGetSystemModuleHandle(TEXT("ntdll.dll"), FALSE);
if (!hNTDLL)
return FALSE;
s_fnNtQueryInformationProcess =
(FN_NtQueryInformationProcess)GetProcAddress(hNTDLL, "NtQueryInformationProcess");
if (!s_fnNtQueryInformationProcess)
return FALSE;
}
Value = 0;
Status = s_fnNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information,
&Value, sizeof(Value), NULL);
if (!NT_SUCCESS(Status))
return FALSE;
return !!Value;
}
inline BOOL
BOOL
CicSystemModulePath::Init(
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir)
@ -251,15 +192,7 @@ Failure:
return FALSE;
}
// ole32!CoCreateInstance
typedef HRESULT (WINAPI *FN_CoCreateInstance)(
REFCLSID rclsid,
LPUNKNOWN pUnkOuter,
DWORD dwClsContext,
REFIID iid,
LPVOID *ppv);
static inline FN_CoCreateInstance
static FN_CoCreateInstance
_cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance)
{
static FN_CoCreateInstance s_fn = NULL;
@ -268,13 +201,14 @@ _cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance)
return s_fn;
}
static inline HRESULT
EXTERN_C
HRESULT
cicRealCoCreateInstance(
REFCLSID rclsid,
LPUNKNOWN pUnkOuter,
DWORD dwClsContext,
REFIID iid,
LPVOID *ppv)
_In_ REFCLSID rclsid,
_In_ LPUNKNOWN pUnkOuter,
_In_ DWORD dwClsContext,
_In_ REFIID iid,
_Out_ LPVOID *ppv)
{
static HINSTANCE s_hOle32 = NULL;
static FN_CoCreateInstance s_fnCoCreateInstance = NULL;
@ -293,13 +227,13 @@ cicRealCoCreateInstance(
/**
* @implemented
*/
static inline HRESULT
HRESULT
cicCoCreateInstance(
REFCLSID rclsid,
LPUNKNOWN pUnkOuter,
DWORD dwClsContext,
REFIID iid,
LPVOID *ppv)
_In_ REFCLSID rclsid,
_In_ LPUNKNOWN pUnkOuter,
_In_ DWORD dwClsContext,
_In_ REFIID iid,
_Out_ LPVOID *ppv)
{
// NOTE: It looks like Cicero wants to hook CoCreateInstance
FN_CoCreateInstance fnUserCoCreateInstance = _cicGetSetUserCoCreateInstance(NULL);
@ -312,8 +246,9 @@ cicCoCreateInstance(
/**
* @implemented
*/
static inline BOOL
TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL)
EXTERN_C
BOOL
TFInitLib(FN_CoCreateInstance fnCoCreateInstance)
{
if (fnCoCreateInstance)
_cicGetSetUserCoCreateInstance(fnCoCreateInstance);
@ -323,30 +258,9 @@ TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL)
/**
* @unimplemented
*/
static inline VOID
EXTERN_C
VOID
TFUninitLib(VOID)
{
//FIXME
}
/**
* @implemented
*/
static inline VOID
TFUninitLib_Thread(PCIC_LIBTHREAD pLibThread)
{
if (!pLibThread)
return;
if (pLibThread->m_pUnknown1)
{
pLibThread->m_pUnknown1->Release();
pLibThread->m_pUnknown1 = NULL;
}
if (pLibThread->m_pDisplayAttrMgr)
{
pLibThread->m_pDisplayAttrMgr->Release();
pLibThread->m_pDisplayAttrMgr = NULL;
}
}

133
sdk/lib/cicero/cicbase.h Normal file
View file

@ -0,0 +1,133 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Cicero base
* COPYRIGHT: Copyright 2023-2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
static inline LPVOID cicMemAlloc(SIZE_T size)
{
return LocalAlloc(0, size);
}
static inline LPVOID cicMemAllocClear(SIZE_T size)
{
return LocalAlloc(LMEM_ZEROINIT, size);
}
static inline LPVOID cicMemReAlloc(LPVOID ptr, SIZE_T newSize)
{
if (!ptr)
return LocalAlloc(LMEM_ZEROINIT, newSize);
return LocalReAlloc(ptr, newSize, LMEM_ZEROINIT);
}
static inline void cicMemFree(LPVOID ptr)
{
if (ptr)
LocalFree(ptr);
}
struct CicNoThrow { };
#define cicNoThrow CicNoThrow{}
void* operator new(size_t size, const CicNoThrow&) noexcept;
void* operator new[](size_t size, const CicNoThrow&) noexcept;
void operator delete(void* ptr) noexcept;
void operator delete[](void* ptr) noexcept;
void operator delete(void* ptr, size_t size) noexcept;
void operator delete[](void* ptr, size_t size) noexcept;
/* The flags of cicGetOSInfo() */
#define CIC_OSINFO_NT 0x01
#define CIC_OSINFO_2KPLUS 0x02
#define CIC_OSINFO_95 0x04
#define CIC_OSINFO_98PLUS 0x08
#define CIC_OSINFO_CJK 0x10
#define CIC_OSINFO_IMM 0x20
#define CIC_OSINFO_DBCS 0x40
#define CIC_OSINFO_XPPLUS 0x80
EXTERN_C
void cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo);
#ifdef __cplusplus
struct CicSystemModulePath
{
TCHAR m_szPath[MAX_PATH + 2];
SIZE_T m_cchPath;
CicSystemModulePath()
{
m_szPath[0] = UNICODE_NULL;
m_cchPath = 0;
}
BOOL Init(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir);
};
#endif
// Get an instance handle that is already loaded
EXTERN_C
HINSTANCE
cicGetSystemModuleHandle(
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir);
// Load a system library
EXTERN_C
HINSTANCE
cicLoadSystemLibrary(
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir);
#ifdef __cplusplus
template <typename T_FN>
static inline BOOL
cicGetFN(HINSTANCE& hinstDLL, T_FN& fn, LPCTSTR pszDllName, LPCSTR pszFuncName)
{
if (fn)
return TRUE;
if (!hinstDLL)
hinstDLL = cicLoadSystemLibrary(pszDllName, FALSE);
if (!hinstDLL)
return FALSE;
fn = reinterpret_cast<T_FN>(GetProcAddress(hinstDLL, pszFuncName));
return !!fn;
}
#endif
/* Is the current process on WoW64? */
EXTERN_C
BOOL cicIsWow64(VOID);
EXTERN_C
HRESULT
cicRealCoCreateInstance(
_In_ REFCLSID rclsid,
_In_ LPUNKNOWN pUnkOuter,
_In_ DWORD dwClsContext,
_In_ REFIID iid,
_Out_ LPVOID *ppv);
EXTERN_C
HRESULT
cicCoCreateInstance(
_In_ REFCLSID rclsid,
_In_ LPUNKNOWN pUnkOuter,
_In_ DWORD dwClsContext,
_In_ REFIID iid,
_Out_ LPVOID *ppv);
// ole32!CoCreateInstance
typedef HRESULT (WINAPI *FN_CoCreateInstance)(
REFCLSID rclsid,
LPUNKNOWN pUnkOuter,
DWORD dwClsContext,
REFIID iid,
LPVOID *ppv);
EXTERN_C BOOL TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL);
EXTERN_C VOID TFUninitLib(VOID);

View file

@ -5,38 +5,13 @@
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
class CicCaret
{
protected:
HWND m_hWnd;
UINT m_uCaretBlinkTimerID;
POINT m_pt;
SIZE m_size;
BOOL m_bCaretBlinking;
BOOL m_bCaretVisible;
public:
enum { TIMER_ID = 0x4F83AF91 };
CicCaret();
virtual ~CicCaret();
void CreateCaret(HWND hWnd, SIZE size);
void DestroyCaret();
void HideCaret();
void InvertCaret();
void OnTimer();
void SetCaretPos(POINT pt);
void SetBlinking(BOOL bBlinking);
};
/***********************************************************************/
#include "precomp.h"
#include "ciccaret.h"
/**
* @implemented
*/
inline CicCaret::CicCaret()
CicCaret::CicCaret()
{
m_bCaretBlinking = FALSE;
m_bCaretVisible = FALSE;
@ -48,7 +23,7 @@ inline CicCaret::CicCaret()
/**
* @implemented
*/
inline CicCaret::~CicCaret()
CicCaret::~CicCaret()
{
HideCaret();
::KillTimer(m_hWnd, m_uCaretBlinkTimerID);
@ -58,7 +33,7 @@ inline CicCaret::~CicCaret()
/**
* @implemented
*/
inline void CicCaret::CreateCaret(HWND hWnd, SIZE size)
void CicCaret::CreateCaret(HWND hWnd, SIZE size)
{
m_hWnd = hWnd;
m_size = size;
@ -69,7 +44,7 @@ inline void CicCaret::CreateCaret(HWND hWnd, SIZE size)
/**
* @implemented
*/
inline void CicCaret::DestroyCaret()
void CicCaret::DestroyCaret()
{
HideCaret();
::KillTimer(m_hWnd, m_uCaretBlinkTimerID);
@ -79,7 +54,7 @@ inline void CicCaret::DestroyCaret()
/**
* @implemented
*/
inline void CicCaret::HideCaret()
void CicCaret::HideCaret()
{
if (m_bCaretVisible)
{
@ -92,7 +67,7 @@ inline void CicCaret::HideCaret()
/**
* @implemented
*/
inline void CicCaret::InvertCaret()
void CicCaret::InvertCaret()
{
HDC hDC = ::GetDC(m_hWnd);
::PatBlt(hDC, m_pt.x, m_pt.y, m_size.cx, m_size.cy, DSTINVERT);
@ -102,7 +77,7 @@ inline void CicCaret::InvertCaret()
/**
* @implemented
*/
inline void CicCaret::OnTimer()
void CicCaret::OnTimer()
{
if (m_bCaretBlinking)
{
@ -114,7 +89,7 @@ inline void CicCaret::OnTimer()
/**
* @implemented
*/
inline void CicCaret::SetCaretPos(POINT pt)
void CicCaret::SetCaretPos(POINT pt)
{
BOOL bCaretVisible = m_bCaretVisible;
if (bCaretVisible)
@ -129,7 +104,7 @@ inline void CicCaret::SetCaretPos(POINT pt)
/**
* @implemented
*/
inline void CicCaret::SetBlinking(BOOL bBlinking)
void CicCaret::SetBlinking(BOOL bBlinking)
{
m_bCaretBlinking = bBlinking;
}

32
sdk/lib/cicero/ciccaret.h Normal file
View file

@ -0,0 +1,32 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Displaying Cicero caret
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
class CicCaret
{
protected:
HWND m_hWnd;
UINT m_uCaretBlinkTimerID;
POINT m_pt;
SIZE m_size;
BOOL m_bCaretBlinking;
BOOL m_bCaretVisible;
public:
enum { TIMER_ID = 0x4F83AF91 };
CicCaret();
virtual ~CicCaret();
void CreateCaret(HWND hWnd, SIZE size);
void DestroyCaret();
void HideCaret();
void InvertCaret();
void OnTimer();
void SetCaretPos(POINT pt);
void SetBlinking(BOOL bBlinking);
};

View file

@ -5,51 +5,9 @@
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
#include "precomp.h"
#include "cicfmap.h"
#include "cicmutex.h"
// class CicFileMappingStatic;
// class CicFileMapping;
class CicFileMappingStatic
{
protected:
LPCTSTR m_pszName;
LPVOID m_pView;
HANDLE m_hMapping;
BOOL m_bCreated;
BOOL m_bHasMutex;
CicMutex *m_pMutex;
LPVOID _Map();
public:
CicFileMappingStatic() { }
~CicFileMappingStatic() { }
void Init(LPCTSTR pszName, CicMutex *pMutex);
LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists);
LPVOID Open();
void Close();
BOOL Enter();
void Leave();
BOOL Flush(SIZE_T dwNumberOfBytesToFlush);
void Finalize();
};
class CicFileMapping : public CicFileMappingStatic
{
public:
CicFileMapping(LPCTSTR pszName, CicMutex *pMutex);
virtual ~CicFileMapping() { Finalize(); }
};
/******************************************************************************/
inline
CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex)
{
m_pszName = NULL;
@ -61,7 +19,7 @@ CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex)
Init(pszName, pMutex);
}
inline void CicFileMappingStatic::Close()
void CicFileMappingStatic::Close()
{
if (m_pView)
{
@ -78,7 +36,7 @@ inline void CicFileMappingStatic::Close()
m_bCreated = FALSE;
}
inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
{
if (pMutex)
m_pMutex = pMutex;
@ -88,7 +46,7 @@ inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
m_bHasMutex = (pMutex != NULL);
}
inline LPVOID
LPVOID
CicFileMappingStatic::Create(
LPSECURITY_ATTRIBUTES pSA,
DWORD dwMaximumSizeLow,
@ -112,7 +70,7 @@ CicFileMappingStatic::Create(
return _Map();
}
inline LPVOID CicFileMappingStatic::Open()
LPVOID CicFileMappingStatic::Open()
{
if (!m_pszName)
return NULL;
@ -123,7 +81,7 @@ inline LPVOID CicFileMappingStatic::Open()
return _Map();
}
inline LPVOID CicFileMappingStatic::_Map()
LPVOID CicFileMappingStatic::_Map()
{
m_pView = ::MapViewOfFile(m_hMapping, FILE_MAP_WRITE, 0, 0, 0);
if (!m_pView)
@ -134,28 +92,28 @@ inline LPVOID CicFileMappingStatic::_Map()
return m_pView;
}
inline BOOL CicFileMappingStatic::Enter()
BOOL CicFileMappingStatic::Enter()
{
if (!m_bHasMutex)
return TRUE;
return m_pMutex->Enter();
}
inline void CicFileMappingStatic::Leave()
void CicFileMappingStatic::Leave()
{
if (!m_bHasMutex)
return;
m_pMutex->Leave();
}
inline BOOL CicFileMappingStatic::Flush(SIZE_T dwNumberOfBytesToFlush)
BOOL CicFileMappingStatic::Flush(SIZE_T dwNumberOfBytesToFlush)
{
if (!m_pView)
return FALSE;
return ::FlushViewOfFile(m_pView, dwNumberOfBytesToFlush);
}
inline void CicFileMappingStatic::Finalize()
void CicFileMappingStatic::Finalize()
{
if (!m_bHasMutex)
return;

48
sdk/lib/cicero/cicfmap.h Normal file
View file

@ -0,0 +1,48 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Cicero file mapping
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
#include "cicmutex.h"
// class CicFileMappingStatic;
// class CicFileMapping;
class CicFileMappingStatic
{
protected:
LPCTSTR m_pszName;
LPVOID m_pView;
HANDLE m_hMapping;
BOOL m_bCreated;
BOOL m_bHasMutex;
CicMutex *m_pMutex;
LPVOID _Map();
public:
CicFileMappingStatic() { }
~CicFileMappingStatic() { }
void Init(LPCTSTR pszName, CicMutex *pMutex);
LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists);
LPVOID Open();
void Close();
BOOL Enter();
void Leave();
BOOL Flush(SIZE_T dwNumberOfBytesToFlush);
void Finalize();
};
class CicFileMapping : public CicFileMappingStatic
{
public:
CicFileMapping(LPCTSTR pszName, CicMutex *pMutex);
virtual ~CicFileMapping() { Finalize(); }
};

53
sdk/lib/cicero/cicimc.cpp Normal file
View file

@ -0,0 +1,53 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Locking and Unlocking IMC and IMCC handles
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#include "precomp.h"
#include <imm.h>
#include <immdev.h>
#include <imm32_undoc.h>
#include "cicimc.h"
#define CUSTOM_CAND_INFO_SIZE 1964
BOOL CicIMCLock::ClearCand()
{
HIMCC hNewCandInfo, hCandInfo = m_pIC->hCandInfo;
if (hCandInfo)
{
hNewCandInfo = ImmReSizeIMCC(hCandInfo, CUSTOM_CAND_INFO_SIZE);
if (!hNewCandInfo)
{
ImmDestroyIMCC(m_pIC->hCandInfo);
m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
return FALSE;
}
}
else
{
hNewCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
}
m_pIC->hCandInfo = hNewCandInfo;
if (!m_pIC->hCandInfo)
return FALSE;
CicIMCCLock<CANDIDATEINFO> candInfo(m_pIC->hCandInfo);
if (!candInfo)
{
ImmDestroyIMCC(m_pIC->hCandInfo);
m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
return FALSE;
}
candInfo.get().dwSize = CUSTOM_CAND_INFO_SIZE;
candInfo.get().dwCount = 0;
candInfo.get().dwOffset[0] = sizeof(CANDIDATEINFO);
// FIXME: Something is trailing after CANDIDATEINFO...
return TRUE;
}

View file

@ -183,44 +183,3 @@ protected:
return ::ImmUnlockIMC(hIMC) ? S_OK : E_FAIL;
}
};
#define CUSTOM_CAND_INFO_SIZE 1964
inline BOOL CicIMCLock::ClearCand()
{
HIMCC hNewCandInfo, hCandInfo = m_pIC->hCandInfo;
if (hCandInfo)
{
hNewCandInfo = ImmReSizeIMCC(hCandInfo, CUSTOM_CAND_INFO_SIZE);
if (!hNewCandInfo)
{
ImmDestroyIMCC(m_pIC->hCandInfo);
m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
return FALSE;
}
}
else
{
hNewCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
}
m_pIC->hCandInfo = hNewCandInfo;
if (!m_pIC->hCandInfo)
return FALSE;
CicIMCCLock<CANDIDATEINFO> candInfo(m_pIC->hCandInfo);
if (!candInfo)
{
ImmDestroyIMCC(m_pIC->hCandInfo);
m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE);
return FALSE;
}
candInfo.get().dwSize = CUSTOM_CAND_INFO_SIZE;
candInfo.get().dwCount = 0;
candInfo.get().dwOffset[0] = sizeof(CANDIDATEINFO);
// FIXME: Something is trailing after CANDIDATEINFO...
return TRUE;
}

83
sdk/lib/cicero/cicreg.cpp Normal file
View file

@ -0,0 +1,83 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Cicero registry handling
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#include "precomp.h"
#include <cicreg.h>
EXTERN_C LSTATUS
_cicRegKey_Open(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired)
{
HKEY hNewKey;
LSTATUS error = ::RegOpenKeyEx(hKey, lpSubKey, 0, samDesired, &hNewKey);
if (error != ERROR_SUCCESS)
return error;
self.Close();
self.m_hKey = hNewKey;
return error;
}
EXTERN_C LSTATUS
_cicRegKey_Create(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey)
{
HKEY hNewKey;
LSTATUS error = ::RegCreateKeyEx(hKey, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hNewKey, NULL);
if (error != ERROR_SUCCESS)
return error;
self.Close();
self.m_hKey = hNewKey;
return error;
}
EXTERN_C LSTATUS
_cicRegKey_EnumValue(CicRegKey& self, DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName)
{
DWORD dwSaveLen = cchValueName;
LSTATUS error = ::RegEnumValue(self.m_hKey, dwIndex, lpValueName, &cchValueName,
NULL, NULL, NULL, NULL);
if (dwSaveLen)
lpValueName[error == ERROR_SUCCESS ? dwSaveLen - 1 : 0] = 0;
return error;
}
EXTERN_C LSTATUS
_cicRegKey_QuerySz(CicRegKey& self, LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax)
{
DWORD cbValueMax = cchValueMax * sizeof(TCHAR);
LSTATUS error = ::RegQueryValueEx(self.m_hKey, pszValueName, 0, NULL, (LPBYTE)pszValue, &cbValueMax);
if (cchValueMax > 0)
pszValue[(error == ERROR_SUCCESS) ? (cchValueMax - 1) : 0] = UNICODE_NULL;
return error;
}
EXTERN_C LSTATUS
_cicRegKey_RecurseDeleteKey(CicRegKey& self, LPCTSTR lpSubKey)
{
CicRegKey regKey;
LSTATUS error = regKey.Open(self.m_hKey, lpSubKey, KEY_READ | KEY_WRITE);
if (error != ERROR_SUCCESS)
return error;
TCHAR szName[MAX_PATH];
DWORD cchName;
do
{
cchName = _countof(szName);
error = ::RegEnumKeyEx(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL);
if (error != ERROR_SUCCESS)
break;
szName[_countof(szName) - 1] = UNICODE_NULL;
error = regKey.RecurseDeleteKey(szName);
} while (error == ERROR_SUCCESS);
regKey.Close();
return self.DeleteSubKey(lpSubKey);
}

116
sdk/lib/cicero/cicreg.h Normal file
View file

@ -0,0 +1,116 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Cicero registry handling
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
class CicRegKey
{
public:
HKEY m_hKey;
CicRegKey() : m_hKey(NULL) { }
~CicRegKey() { Close(); }
operator HKEY() { return m_hKey; }
LSTATUS Open(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired = KEY_READ);
LSTATUS Create(HKEY hKey, LPCTSTR lpSubKey);
void Close();
LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue);
LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue);
LSTATUS QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax);
LSTATUS SetSz(LPCTSTR pszValueName, LPCTSTR pszValue);
LSTATUS SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue);
LSTATUS DeleteValue(LPCTSTR pszValueName);
LSTATUS DeleteSubKey(LPCTSTR lpSubKey);
LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey);
LSTATUS EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName);
};
/***********************************************************************/
// FIXME: Here, directly using C++ methods causes compile errors... Why?
EXTERN_C LSTATUS _cicRegKey_Open(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired);
EXTERN_C LSTATUS _cicRegKey_Create(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey);
EXTERN_C LSTATUS _cicRegKey_RecurseDeleteKey(CicRegKey& self, LPCTSTR lpSubKey);
EXTERN_C LSTATUS
_cicRegKey_EnumValue(CicRegKey& self, DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName);
EXTERN_C LSTATUS
_cicRegKey_QuerySz(CicRegKey& self, LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax);
inline LSTATUS CicRegKey::Open(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired)
{
return _cicRegKey_Open(*this, hKey, lpSubKey, samDesired);
}
inline LSTATUS CicRegKey::Create(HKEY hKey, LPCTSTR lpSubKey)
{
return _cicRegKey_Create(*this, hKey, lpSubKey);
}
inline LSTATUS CicRegKey::QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue)
{
DWORD cbData = sizeof(DWORD);
return ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData);
}
inline LSTATUS CicRegKey::SetDword(LPCTSTR pszValueName, DWORD dwValue)
{
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
}
inline LSTATUS CicRegKey::SetSz(LPCTSTR pszValueName, LPCTSTR pszValue)
{
DWORD cbValue = (lstrlen(pszValue) + 1) * sizeof(TCHAR);
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
inline LSTATUS CicRegKey::SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue)
{
DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
inline LSTATUS CicRegKey::QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax)
{
return _cicRegKey_QuerySz(*this, pszValueName, pszValue, cchValueMax);
}
inline void CicRegKey::Close()
{
if (!m_hKey)
return;
::RegCloseKey(m_hKey);
m_hKey = NULL;
}
inline LSTATUS CicRegKey::DeleteValue(LPCTSTR pszValueName)
{
return ::RegDeleteValue(m_hKey, pszValueName);
}
inline LSTATUS CicRegKey::DeleteSubKey(LPCTSTR lpSubKey)
{
return ::RegDeleteKey(m_hKey, lpSubKey);
}
inline LSTATUS CicRegKey::EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName)
{
return _cicRegKey_EnumValue(*this, dwIndex, lpValueName, cchValueName);
}
inline LSTATUS CicRegKey::RecurseDeleteKey(LPCTSTR lpSubKey)
{
return _cicRegKey_RecurseDeleteKey(*this, lpSubKey);
}

1088
sdk/lib/cicero/cicuif.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -18,13 +18,13 @@ DEFINE_GUID(IID_ITfLangBarEventSink_P, 0x7A460360, 0xDA21, 0x4B09, 0xA8,
DEFINE_GUID(CLSID_MSUTBDeskBand, 0x540D8A8B, 0x1C3F, 0x4E32, 0x81, 0x32, 0x53, 0x0F, 0x6A, 0x50, 0x20, 0x90);
DEFINE_GUID(CATID_DeskBand, 0x00021492, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
typedef struct LIBTHREAD
typedef struct CIC_LIBTHREAD
{
IUnknown *m_pUnknown1;
ITfDisplayAttributeMgr *m_pDisplayAttrMgr;
} LIBTHREAD, *PLIBTHREAD;
} CIC_LIBTHREAD, *PCIC_LIBTHREAD;
EXTERN_C PLIBTHREAD WINAPI GetLibTls(VOID);
EXTERN_C PCIC_LIBTHREAD WINAPI GetLibTls(VOID);
EXTERN_C BOOL WINAPI GetPopupTipbar(HWND hWnd, BOOL fWinLogon);
EXTERN_C HRESULT WINAPI SetRegisterLangBand(BOOL bRegister);
EXTERN_C VOID WINAPI ClosePopupTipbar(VOID);
@ -38,3 +38,20 @@ struct ITfLangBarEventSink_P : IUnknown
{
STDMETHOD(OnLangBarUpdate)(TfLBIClick click, BOOL bFlag) = 0;
};
inline void TFUninitLib_Thread(PCIC_LIBTHREAD pLibThread)
{
if (!pLibThread)
return;
if (pLibThread->m_pUnknown1)
{
pLibThread->m_pUnknown1->Release();
pLibThread->m_pUnknown1 = NULL;
}
if (pLibThread->m_pDisplayAttrMgr)
{
pLibThread->m_pDisplayAttrMgr->Release();
pLibThread->m_pDisplayAttrMgr = NULL;
}
}

6
sdk/lib/cicero/precomp.h Normal file
View file

@ -0,0 +1,6 @@
#pragma once
#include <windows.h>
#include <unknwn.h>
#include <stddef.h>
#include <stdlib.h>