mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 10:20:03 +00:00
[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:
parent
21e139d1d1
commit
fc3eeb61f3
|
@ -6,9 +6,9 @@ list(APPEND SOURCE
|
||||||
|
|
||||||
add_rc_deps(ctfmon.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/ctfmon.ico)
|
add_rc_deps(ctfmon.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/ctfmon.ico)
|
||||||
add_executable(ctfmon ${SOURCE} ctfmon.rc)
|
add_executable(ctfmon ${SOURCE} ctfmon.rc)
|
||||||
set_module_type(ctfmon win32gui)
|
set_module_type(ctfmon win32gui UNICODE)
|
||||||
add_dependencies(ctfmon msctf msutb)
|
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_importlibs(ctfmon msctf msutb advapi32 shell32 user32 msvcrt kernel32)
|
||||||
add_pch(ctfmon precomp.h SOURCE)
|
add_pch(ctfmon precomp.h SOURCE)
|
||||||
add_cd_file(TARGET ctfmon DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET ctfmon DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include <msctf.h>
|
#include <msctf.h>
|
||||||
#include <ctfutb.h>
|
#include <ctfutb.h>
|
||||||
#include <ctffunc.h>
|
#include <ctffunc.h>
|
||||||
#include <cicero/cicbase.h>
|
#include <cicbase.h>
|
||||||
#include <cicero/cicutb.h>
|
#include <cicutb.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ add_library(msctfime MODULE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/msctfime.def)
|
${CMAKE_CURRENT_BINARY_DIR}/msctfime.def)
|
||||||
set_module_type(msctfime win32dll UNICODE)
|
set_module_type(msctfime win32dll UNICODE)
|
||||||
set_target_properties(msctfime PROPERTIES SUFFIX ".ime")
|
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_importlibs(msctfime user32 gdi32 advapi32 msvcrt kernel32 ntdll)
|
||||||
add_delay_importlibs(msctfime comctl32 msctf oleaut32 imm32)
|
add_delay_importlibs(msctfime comctl32 msctf oleaut32 imm32)
|
||||||
add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -24,12 +24,13 @@
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
|
||||||
#include <cicero/cicbase.h>
|
#include <cicbase.h>
|
||||||
#include <cicero/cicarray.h>
|
#include <cicarray.h>
|
||||||
#include <cicero/cicimc.h>
|
#include <cicimc.h>
|
||||||
#include <cicero/cictf.h>
|
#include <cictf.h>
|
||||||
#include <cicero/ciccaret.h>
|
#include <ciccaret.h>
|
||||||
#include <cicero/cicuif.h>
|
#include <cicuif.h>
|
||||||
|
#include <cicutb.h>
|
||||||
|
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ add_library(msctf MODULE
|
||||||
version.rc
|
version.rc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/msctf.def)
|
${CMAKE_CURRENT_BINARY_DIR}/msctf.def)
|
||||||
|
|
||||||
set_module_type(msctf win32dll)
|
set_module_type(msctf win32dll UNICODE)
|
||||||
target_link_libraries(msctf uuid wine)
|
target_link_libraries(msctf uuid wine cicero)
|
||||||
add_importlibs(msctf user32 advapi32 advapi32_vista msvcrt kernel32 ntdll)
|
add_importlibs(msctf user32 advapi32 advapi32_vista msvcrt kernel32 ntdll)
|
||||||
add_delay_importlibs(msctf ole32 oleaut32)
|
add_delay_importlibs(msctf ole32 oleaut32)
|
||||||
add_pch(msctf precomp.h SOURCE)
|
add_pch(msctf precomp.h SOURCE)
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
|
||||||
#include <cicero/cicreg.h>
|
#include <cicreg.h>
|
||||||
#include <cicero/cicmutex.h>
|
#include <cicmutex.h>
|
||||||
#include <cicero/cicfmap.h>
|
#include <cicfmap.h>
|
||||||
|
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ BOOL InitLangChangeHotKey(VOID)
|
||||||
szLanguage[0] = szLayout[0] = TEXT('3');
|
szLanguage[0] = szLayout[0] = TEXT('3');
|
||||||
szLanguage[1] = szLayout[1] = TEXT('\0');
|
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)
|
if (error == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
error = regKey.QuerySz(TEXT("Language Hotkey"), szLanguage, _countof(szLanguage));
|
error = regKey.QuerySz(TEXT("Language Hotkey"), szLanguage, _countof(szLanguage));
|
||||||
|
|
|
@ -11,9 +11,9 @@ add_library(msutb MODULE
|
||||||
${SOURCE}
|
${SOURCE}
|
||||||
msutb.rc
|
msutb.rc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/msutb.def)
|
${CMAKE_CURRENT_BINARY_DIR}/msutb.def)
|
||||||
set_module_type(msutb win32dll)
|
set_module_type(msutb win32dll UNICODE)
|
||||||
add_dependencies(msutb msctf psdk)
|
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_importlibs(msutb user32 gdi32 advapi32 msvcrt kernel32 ntdll)
|
||||||
add_delay_importlibs(msutb uxtheme imm32 comctl32 msctf ole32 oleacc oleaut32 shell32)
|
add_delay_importlibs(msutb uxtheme imm32 comctl32 msctf ole32 oleacc oleaut32 shell32)
|
||||||
add_cd_file(TARGET msutb DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET msutb DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -20,7 +20,7 @@ LONG g_DllRefCount = 0;
|
||||||
BOOL g_bWinLogon = FALSE;
|
BOOL g_bWinLogon = FALSE;
|
||||||
BOOL g_fInClosePopupTipbar = FALSE;
|
BOOL g_fInClosePopupTipbar = FALSE;
|
||||||
HWND g_hwndParent = NULL;
|
HWND g_hwndParent = NULL;
|
||||||
LIBTHREAD g_libTLS = { NULL, NULL };
|
CIC_LIBTHREAD g_libTLS = { NULL, NULL };
|
||||||
#ifdef ENABLE_DESKBAND
|
#ifdef ENABLE_DESKBAND
|
||||||
BOOL g_bEnableDeskBand = TRUE;
|
BOOL g_bEnableDeskBand = TRUE;
|
||||||
#else
|
#else
|
||||||
|
@ -77,23 +77,6 @@ class CMsUtbModule : public CComModule
|
||||||
|
|
||||||
CMsUtbModule gModule;
|
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 CCicLibMenuItem;
|
||||||
class CTipbarAccItem;
|
class CTipbarAccItem;
|
||||||
class CUTBMenuItem;
|
class CUTBMenuItem;
|
||||||
|
@ -6075,7 +6058,7 @@ BOOL GetTipbarInternal(HWND hWnd, DWORD dwFlags, CDeskBand *pDeskBand)
|
||||||
*
|
*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
EXTERN_C PLIBTHREAD WINAPI
|
EXTERN_C PCIC_LIBTHREAD WINAPI
|
||||||
GetLibTls(VOID)
|
GetLibTls(VOID)
|
||||||
{
|
{
|
||||||
TRACE("()\n");
|
TRACE("()\n");
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define WIN32_NO_STATUS
|
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
|
|
||||||
|
@ -25,11 +24,10 @@
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
#include <atlcom.h>
|
#include <atlcom.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
#undef STATUS_NO_MEMORY
|
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <cicero/cicreg.h>
|
#include <cicreg.h>
|
||||||
#include <cicero/cicutb.h>
|
#include <cicutb.h>
|
||||||
#include <cicero/cicuif.h>
|
#include <cicuif.h>
|
||||||
|
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ add_subdirectory(inflib)
|
||||||
if(CMAKE_CROSSCOMPILING)
|
if(CMAKE_CROSSCOMPILING)
|
||||||
|
|
||||||
add_subdirectory(3rdparty)
|
add_subdirectory(3rdparty)
|
||||||
|
add_subdirectory(cicero)
|
||||||
add_subdirectory(comsupp)
|
add_subdirectory(comsupp)
|
||||||
add_subdirectory(conutils)
|
add_subdirectory(conutils)
|
||||||
add_subdirectory(cportlib)
|
add_subdirectory(cportlib)
|
||||||
|
|
15
sdk/lib/cicero/CMakeLists.txt
Normal file
15
sdk/lib/cicero/CMakeLists.txt
Normal 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}>)
|
78
sdk/lib/cicero/cicarray.cpp
Normal file
78
sdk/lib/cicero/cicarray.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -66,7 +66,7 @@ public:
|
||||||
return TRUE;
|
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)
|
for (size_t iItem = 0; iItem < m_cItems; ++iItem)
|
||||||
{
|
{
|
||||||
|
@ -76,74 +76,3 @@ public:
|
||||||
return -1;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,84 +2,84 @@
|
||||||
* PROJECT: ReactOS Cicero
|
* PROJECT: ReactOS Cicero
|
||||||
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||||
* PURPOSE: Cicero base
|
* 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
|
void* operator new(size_t size, const CicNoThrow&) noexcept
|
||||||
#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
|
|
||||||
{
|
{
|
||||||
return cicMemAllocClear(size);
|
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);
|
return cicMemAllocClear(size);
|
||||||
}
|
}
|
||||||
inline void operator delete(void* ptr) noexcept
|
void operator delete(void* ptr) noexcept
|
||||||
{
|
{
|
||||||
cicMemFree(ptr);
|
cicMemFree(ptr);
|
||||||
}
|
}
|
||||||
inline void operator delete[](void* ptr) noexcept
|
void operator delete[](void* ptr) noexcept
|
||||||
{
|
{
|
||||||
cicMemFree(ptr);
|
cicMemFree(ptr);
|
||||||
}
|
}
|
||||||
inline void operator delete(void* ptr, size_t size) noexcept
|
void operator delete(void* ptr, size_t size) noexcept
|
||||||
{
|
{
|
||||||
cicMemFree(ptr);
|
cicMemFree(ptr);
|
||||||
}
|
}
|
||||||
inline void operator delete[](void* ptr, size_t size) noexcept
|
void operator delete[](void* ptr, size_t size) noexcept
|
||||||
{
|
{
|
||||||
cicMemFree(ptr);
|
cicMemFree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct CIC_LIBTHREAD
|
// FIXME
|
||||||
|
typedef enum _PROCESSINFOCLASS
|
||||||
{
|
{
|
||||||
IUnknown *m_pUnknown1;
|
ProcessBasicInformation = 0,
|
||||||
ITfDisplayAttributeMgr *m_pDisplayAttrMgr;
|
ProcessDebugPort = 7,
|
||||||
} CIC_LIBTHREAD, *PCIC_LIBTHREAD;
|
ProcessWow64Information = 26,
|
||||||
|
ProcessImageFileName = 27,
|
||||||
|
ProcessBreakOnTermination = 29
|
||||||
|
} PROCESSINFOCLASS;
|
||||||
|
|
||||||
/* The flags of cicGetOSInfo() */
|
// FIXME
|
||||||
#define CIC_OSINFO_NT 0x01
|
typedef LONG NTSTATUS;
|
||||||
#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
|
|
||||||
|
|
||||||
static inline void
|
/* ntdll!NtQueryInformationProcess */
|
||||||
cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
|
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;
|
*pdwOSInfo = 0;
|
||||||
|
|
||||||
|
@ -124,22 +124,9 @@ cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
|
||||||
*pdwOSInfo |= CIC_OSINFO_DBCS;
|
*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
|
// Get an instance handle that is already loaded
|
||||||
static inline HINSTANCE
|
EXTERN_C
|
||||||
|
HINSTANCE
|
||||||
cicGetSystemModuleHandle(
|
cicGetSystemModuleHandle(
|
||||||
_In_ LPCTSTR pszFileName,
|
_In_ LPCTSTR pszFileName,
|
||||||
_In_ BOOL bSysWinDir)
|
_In_ BOOL bSysWinDir)
|
||||||
|
@ -151,7 +138,8 @@ cicGetSystemModuleHandle(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load a system library
|
// Load a system library
|
||||||
static inline HINSTANCE
|
EXTERN_C
|
||||||
|
HINSTANCE
|
||||||
cicLoadSystemLibrary(
|
cicLoadSystemLibrary(
|
||||||
_In_ LPCTSTR pszFileName,
|
_In_ LPCTSTR pszFileName,
|
||||||
_In_ BOOL bSysWinDir)
|
_In_ BOOL bSysWinDir)
|
||||||
|
@ -162,54 +150,7 @@ cicLoadSystemLibrary(
|
||||||
return ::LoadLibrary(ModPath.m_szPath);
|
return ::LoadLibrary(ModPath.m_szPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T_FN>
|
BOOL
|
||||||
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
|
|
||||||
CicSystemModulePath::Init(
|
CicSystemModulePath::Init(
|
||||||
_In_ LPCTSTR pszFileName,
|
_In_ LPCTSTR pszFileName,
|
||||||
_In_ BOOL bSysWinDir)
|
_In_ BOOL bSysWinDir)
|
||||||
|
@ -251,15 +192,7 @@ Failure:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ole32!CoCreateInstance
|
static FN_CoCreateInstance
|
||||||
typedef HRESULT (WINAPI *FN_CoCreateInstance)(
|
|
||||||
REFCLSID rclsid,
|
|
||||||
LPUNKNOWN pUnkOuter,
|
|
||||||
DWORD dwClsContext,
|
|
||||||
REFIID iid,
|
|
||||||
LPVOID *ppv);
|
|
||||||
|
|
||||||
static inline FN_CoCreateInstance
|
|
||||||
_cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance)
|
_cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance)
|
||||||
{
|
{
|
||||||
static FN_CoCreateInstance s_fn = NULL;
|
static FN_CoCreateInstance s_fn = NULL;
|
||||||
|
@ -268,13 +201,14 @@ _cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance)
|
||||||
return s_fn;
|
return s_fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HRESULT
|
EXTERN_C
|
||||||
|
HRESULT
|
||||||
cicRealCoCreateInstance(
|
cicRealCoCreateInstance(
|
||||||
REFCLSID rclsid,
|
_In_ REFCLSID rclsid,
|
||||||
LPUNKNOWN pUnkOuter,
|
_In_ LPUNKNOWN pUnkOuter,
|
||||||
DWORD dwClsContext,
|
_In_ DWORD dwClsContext,
|
||||||
REFIID iid,
|
_In_ REFIID iid,
|
||||||
LPVOID *ppv)
|
_Out_ LPVOID *ppv)
|
||||||
{
|
{
|
||||||
static HINSTANCE s_hOle32 = NULL;
|
static HINSTANCE s_hOle32 = NULL;
|
||||||
static FN_CoCreateInstance s_fnCoCreateInstance = NULL;
|
static FN_CoCreateInstance s_fnCoCreateInstance = NULL;
|
||||||
|
@ -293,13 +227,13 @@ cicRealCoCreateInstance(
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
static inline HRESULT
|
HRESULT
|
||||||
cicCoCreateInstance(
|
cicCoCreateInstance(
|
||||||
REFCLSID rclsid,
|
_In_ REFCLSID rclsid,
|
||||||
LPUNKNOWN pUnkOuter,
|
_In_ LPUNKNOWN pUnkOuter,
|
||||||
DWORD dwClsContext,
|
_In_ DWORD dwClsContext,
|
||||||
REFIID iid,
|
_In_ REFIID iid,
|
||||||
LPVOID *ppv)
|
_Out_ LPVOID *ppv)
|
||||||
{
|
{
|
||||||
// NOTE: It looks like Cicero wants to hook CoCreateInstance
|
// NOTE: It looks like Cicero wants to hook CoCreateInstance
|
||||||
FN_CoCreateInstance fnUserCoCreateInstance = _cicGetSetUserCoCreateInstance(NULL);
|
FN_CoCreateInstance fnUserCoCreateInstance = _cicGetSetUserCoCreateInstance(NULL);
|
||||||
|
@ -312,8 +246,9 @@ cicCoCreateInstance(
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
static inline BOOL
|
EXTERN_C
|
||||||
TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL)
|
BOOL
|
||||||
|
TFInitLib(FN_CoCreateInstance fnCoCreateInstance)
|
||||||
{
|
{
|
||||||
if (fnCoCreateInstance)
|
if (fnCoCreateInstance)
|
||||||
_cicGetSetUserCoCreateInstance(fnCoCreateInstance);
|
_cicGetSetUserCoCreateInstance(fnCoCreateInstance);
|
||||||
|
@ -323,30 +258,9 @@ TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL)
|
||||||
/**
|
/**
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
static inline VOID
|
EXTERN_C
|
||||||
|
VOID
|
||||||
TFUninitLib(VOID)
|
TFUninitLib(VOID)
|
||||||
{
|
{
|
||||||
//FIXME
|
//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
133
sdk/lib/cicero/cicbase.h
Normal 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);
|
|
@ -5,38 +5,13 @@
|
||||||
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "precomp.h"
|
||||||
|
#include "ciccaret.h"
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline CicCaret::CicCaret()
|
CicCaret::CicCaret()
|
||||||
{
|
{
|
||||||
m_bCaretBlinking = FALSE;
|
m_bCaretBlinking = FALSE;
|
||||||
m_bCaretVisible = FALSE;
|
m_bCaretVisible = FALSE;
|
||||||
|
@ -48,7 +23,7 @@ inline CicCaret::CicCaret()
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline CicCaret::~CicCaret()
|
CicCaret::~CicCaret()
|
||||||
{
|
{
|
||||||
HideCaret();
|
HideCaret();
|
||||||
::KillTimer(m_hWnd, m_uCaretBlinkTimerID);
|
::KillTimer(m_hWnd, m_uCaretBlinkTimerID);
|
||||||
|
@ -58,7 +33,7 @@ inline CicCaret::~CicCaret()
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline void CicCaret::CreateCaret(HWND hWnd, SIZE size)
|
void CicCaret::CreateCaret(HWND hWnd, SIZE size)
|
||||||
{
|
{
|
||||||
m_hWnd = hWnd;
|
m_hWnd = hWnd;
|
||||||
m_size = size;
|
m_size = size;
|
||||||
|
@ -69,7 +44,7 @@ inline void CicCaret::CreateCaret(HWND hWnd, SIZE size)
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline void CicCaret::DestroyCaret()
|
void CicCaret::DestroyCaret()
|
||||||
{
|
{
|
||||||
HideCaret();
|
HideCaret();
|
||||||
::KillTimer(m_hWnd, m_uCaretBlinkTimerID);
|
::KillTimer(m_hWnd, m_uCaretBlinkTimerID);
|
||||||
|
@ -79,7 +54,7 @@ inline void CicCaret::DestroyCaret()
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline void CicCaret::HideCaret()
|
void CicCaret::HideCaret()
|
||||||
{
|
{
|
||||||
if (m_bCaretVisible)
|
if (m_bCaretVisible)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +67,7 @@ inline void CicCaret::HideCaret()
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline void CicCaret::InvertCaret()
|
void CicCaret::InvertCaret()
|
||||||
{
|
{
|
||||||
HDC hDC = ::GetDC(m_hWnd);
|
HDC hDC = ::GetDC(m_hWnd);
|
||||||
::PatBlt(hDC, m_pt.x, m_pt.y, m_size.cx, m_size.cy, DSTINVERT);
|
::PatBlt(hDC, m_pt.x, m_pt.y, m_size.cx, m_size.cy, DSTINVERT);
|
||||||
|
@ -102,7 +77,7 @@ inline void CicCaret::InvertCaret()
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline void CicCaret::OnTimer()
|
void CicCaret::OnTimer()
|
||||||
{
|
{
|
||||||
if (m_bCaretBlinking)
|
if (m_bCaretBlinking)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +89,7 @@ inline void CicCaret::OnTimer()
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline void CicCaret::SetCaretPos(POINT pt)
|
void CicCaret::SetCaretPos(POINT pt)
|
||||||
{
|
{
|
||||||
BOOL bCaretVisible = m_bCaretVisible;
|
BOOL bCaretVisible = m_bCaretVisible;
|
||||||
if (bCaretVisible)
|
if (bCaretVisible)
|
||||||
|
@ -129,7 +104,7 @@ inline void CicCaret::SetCaretPos(POINT pt)
|
||||||
/**
|
/**
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
inline void CicCaret::SetBlinking(BOOL bBlinking)
|
void CicCaret::SetBlinking(BOOL bBlinking)
|
||||||
{
|
{
|
||||||
m_bCaretBlinking = bBlinking;
|
m_bCaretBlinking = bBlinking;
|
||||||
}
|
}
|
32
sdk/lib/cicero/ciccaret.h
Normal file
32
sdk/lib/cicero/ciccaret.h
Normal 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);
|
||||||
|
};
|
|
@ -5,51 +5,9 @@
|
||||||
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
* 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)
|
CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex)
|
||||||
{
|
{
|
||||||
m_pszName = NULL;
|
m_pszName = NULL;
|
||||||
|
@ -61,7 +19,7 @@ CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex)
|
||||||
Init(pszName, pMutex);
|
Init(pszName, pMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CicFileMappingStatic::Close()
|
void CicFileMappingStatic::Close()
|
||||||
{
|
{
|
||||||
if (m_pView)
|
if (m_pView)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +36,7 @@ inline void CicFileMappingStatic::Close()
|
||||||
m_bCreated = FALSE;
|
m_bCreated = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
|
void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
|
||||||
{
|
{
|
||||||
if (pMutex)
|
if (pMutex)
|
||||||
m_pMutex = pMutex;
|
m_pMutex = pMutex;
|
||||||
|
@ -88,7 +46,7 @@ inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
|
||||||
m_bHasMutex = (pMutex != NULL);
|
m_bHasMutex = (pMutex != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline LPVOID
|
LPVOID
|
||||||
CicFileMappingStatic::Create(
|
CicFileMappingStatic::Create(
|
||||||
LPSECURITY_ATTRIBUTES pSA,
|
LPSECURITY_ATTRIBUTES pSA,
|
||||||
DWORD dwMaximumSizeLow,
|
DWORD dwMaximumSizeLow,
|
||||||
|
@ -112,7 +70,7 @@ CicFileMappingStatic::Create(
|
||||||
return _Map();
|
return _Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline LPVOID CicFileMappingStatic::Open()
|
LPVOID CicFileMappingStatic::Open()
|
||||||
{
|
{
|
||||||
if (!m_pszName)
|
if (!m_pszName)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -123,7 +81,7 @@ inline LPVOID CicFileMappingStatic::Open()
|
||||||
return _Map();
|
return _Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline LPVOID CicFileMappingStatic::_Map()
|
LPVOID CicFileMappingStatic::_Map()
|
||||||
{
|
{
|
||||||
m_pView = ::MapViewOfFile(m_hMapping, FILE_MAP_WRITE, 0, 0, 0);
|
m_pView = ::MapViewOfFile(m_hMapping, FILE_MAP_WRITE, 0, 0, 0);
|
||||||
if (!m_pView)
|
if (!m_pView)
|
||||||
|
@ -134,28 +92,28 @@ inline LPVOID CicFileMappingStatic::_Map()
|
||||||
return m_pView;
|
return m_pView;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL CicFileMappingStatic::Enter()
|
BOOL CicFileMappingStatic::Enter()
|
||||||
{
|
{
|
||||||
if (!m_bHasMutex)
|
if (!m_bHasMutex)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return m_pMutex->Enter();
|
return m_pMutex->Enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CicFileMappingStatic::Leave()
|
void CicFileMappingStatic::Leave()
|
||||||
{
|
{
|
||||||
if (!m_bHasMutex)
|
if (!m_bHasMutex)
|
||||||
return;
|
return;
|
||||||
m_pMutex->Leave();
|
m_pMutex->Leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL CicFileMappingStatic::Flush(SIZE_T dwNumberOfBytesToFlush)
|
BOOL CicFileMappingStatic::Flush(SIZE_T dwNumberOfBytesToFlush)
|
||||||
{
|
{
|
||||||
if (!m_pView)
|
if (!m_pView)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return ::FlushViewOfFile(m_pView, dwNumberOfBytesToFlush);
|
return ::FlushViewOfFile(m_pView, dwNumberOfBytesToFlush);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CicFileMappingStatic::Finalize()
|
void CicFileMappingStatic::Finalize()
|
||||||
{
|
{
|
||||||
if (!m_bHasMutex)
|
if (!m_bHasMutex)
|
||||||
return;
|
return;
|
48
sdk/lib/cicero/cicfmap.h
Normal file
48
sdk/lib/cicero/cicfmap.h
Normal 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
53
sdk/lib/cicero/cicimc.cpp
Normal 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;
|
||||||
|
}
|
|
@ -183,44 +183,3 @@ protected:
|
||||||
return ::ImmUnlockIMC(hIMC) ? S_OK : E_FAIL;
|
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
83
sdk/lib/cicero/cicreg.cpp
Normal 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
116
sdk/lib/cicero/cicreg.h
Normal 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);
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
1088
sdk/lib/cicero/cicuif.h
Normal file
1088
sdk/lib/cicero/cicuif.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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(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);
|
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;
|
IUnknown *m_pUnknown1;
|
||||||
ITfDisplayAttributeMgr *m_pDisplayAttrMgr;
|
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 BOOL WINAPI GetPopupTipbar(HWND hWnd, BOOL fWinLogon);
|
||||||
EXTERN_C HRESULT WINAPI SetRegisterLangBand(BOOL bRegister);
|
EXTERN_C HRESULT WINAPI SetRegisterLangBand(BOOL bRegister);
|
||||||
EXTERN_C VOID WINAPI ClosePopupTipbar(VOID);
|
EXTERN_C VOID WINAPI ClosePopupTipbar(VOID);
|
||||||
|
@ -38,3 +38,20 @@ struct ITfLangBarEventSink_P : IUnknown
|
||||||
{
|
{
|
||||||
STDMETHOD(OnLangBarUpdate)(TfLBIClick click, BOOL bFlag) = 0;
|
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
6
sdk/lib/cicero/precomp.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <unknwn.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
Loading…
Reference in a new issue