[CTFMON][SDK] Add ctfmon.exe (#6149)

ctfmon.exe will be a replacement of our
kbswitch.exe in the future. That is the
front-end of Language Bar. It is needed
to support TIPs.
- Add ctfmon.exe at base/applications/ctfmon.
- Add <cicero/cicbase.h>,
  <cicero/CModulePath.h>, and
  <cicero/osinfo.h> headers and use them.
CORE-19362
This commit is contained in:
Katayama Hirofumi MZ 2023-12-13 21:37:15 +09:00 committed by GitHub
parent a19ba4760e
commit 079b36542c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 1156 additions and 0 deletions

View file

@ -0,0 +1,90 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Manipulate module path
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
struct CModulePath
{
WCHAR m_szPath[MAX_PATH];
SIZE_T m_cchPath;
CModulePath()
{
m_szPath[0] = UNICODE_NULL;
m_cchPath = 0;
}
BOOL Init(_In_ LPCWSTR pszFileName, _In_ BOOL bSysWinDir);
};
// Get an instance handle that is already loaded
static inline HINSTANCE
GetSystemModuleHandle(
_In_ LPCWSTR pszFileName,
_In_ BOOL bSysWinDir)
{
CModulePath ModPath;
if (!ModPath.Init(pszFileName, bSysWinDir))
return NULL;
return GetModuleHandleW(ModPath.m_szPath);
}
// Load a system library
static inline HINSTANCE
LoadSystemLibrary(
_In_ LPCWSTR pszFileName,
_In_ BOOL bSysWinDir)
{
CModulePath ModPath;
if (!ModPath.Init(pszFileName, bSysWinDir))
return NULL;
return ::LoadLibraryW(ModPath.m_szPath);
}
/******************************************************************************/
inline BOOL
CModulePath::Init(
_In_ LPCWSTR pszFileName,
_In_ BOOL bSysWinDir)
{
SIZE_T cchPath;
if (bSysWinDir)
{
// Usually C:\Windows or C:\ReactOS
cchPath = ::GetSystemWindowsDirectory(m_szPath, _countof(m_szPath));
}
else
{
// Usually C:\Windows\system32 or C:\ReactOS\system32
cchPath = ::GetSystemDirectoryW(m_szPath, _countof(m_szPath));
}
m_szPath[_countof(m_szPath) - 1] = UNICODE_NULL; // Avoid buffer overrun
if ((cchPath == 0) || (cchPath > _countof(m_szPath) - 2))
goto Failure;
// Add backslash if necessary
if ((cchPath > 0) && (m_szPath[cchPath - 1] != L'\\'))
{
m_szPath[cchPath + 0] = L'\\';
m_szPath[cchPath + 1] = UNICODE_NULL;
}
// Append pszFileName
if (FAILED(StringCchCatW(m_szPath, _countof(m_szPath), pszFileName)))
goto Failure;
m_cchPath = wcslen(m_szPath);
return TRUE;
Failure:
m_szPath[0] = UNICODE_NULL;
m_cchPath = 0;
return FALSE;
}

View file

@ -0,0 +1,44 @@
/*
* 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>
*/
static inline LPVOID cicMemAllocClear(SIZE_T size)
{
return LocalAlloc(LMEM_ZEROINIT, size);
}
static inline void cicMemFree(LPVOID ptr)
{
if (ptr)
LocalFree(ptr);
}
#ifdef __cplusplus
inline void* __cdecl operator new(size_t size) noexcept
{
return cicMemAllocClear(size);
}
inline void __cdecl operator delete(void* ptr) noexcept
{
cicMemFree(ptr);
}
inline void __cdecl operator delete(void* ptr, size_t size) noexcept
{
cicMemFree(ptr);
}
#endif // __cplusplus
// FIXME: Use msutb.dll and header
static inline void ClosePopupTipbar(void)
{
}
// FIXME: Use msutb.dll and header
static inline void GetPopupTipbar(HWND hwnd, BOOL fWinLogon)
{
}

View file

@ -0,0 +1,47 @@
/*
* PROJECT: ReactOS Cicero
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Getting OS information
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
/* The flags of GetOSInfo() */
#define OSINFO_NT 0x01
#define OSINFO_CJK 0x10
#define OSINFO_IMM 0x20
#define OSINFO_DBCS 0x40
static inline DWORD
GetOSInfo(VOID)
{
DWORD dwOsInfo = 0;
/* Check OS version info */
OSVERSIONINFOW VerInfo = { sizeof(VerInfo) };
GetVersionExW(&VerInfo);
if (VerInfo.dwPlatformId == DLLVER_PLATFORM_NT)
dwOsInfo |= OSINFO_NT;
/* Check codepage */
switch (GetACP())
{
case 932: /* Japanese (Japan) */
case 936: /* Chinese (PRC, Singapore) */
case 949: /* Korean (Korea) */
case 950: /* Chinese (Taiwan, Hong Kong) */
dwOsInfo |= OSINFO_CJK;
break;
}
if (GetSystemMetrics(SM_IMMENABLED))
dwOsInfo |= OSINFO_IMM;
if (GetSystemMetrics(SM_DBCSENABLED))
dwOsInfo |= OSINFO_DBCS;
/* I'm not interested in other flags */
return dwOsInfo;
}