https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7d6fc57ec96e2ff6bbd49ea5c943704224224a7b

commit 7d6fc57ec96e2ff6bbd49ea5c943704224224a7b
Author:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
AuthorDate: Thu Dec 21 19:05:33 2023 +0900
Commit:     GitHub <nore...@github.com>
CommitDate: Thu Dec 21 19:05:33 2023 +0900

    [CTFMON][MSCTFIME][SDK] Renaming for Cicero (#6216)
    
    Keep consistency with Cicero naming rule.
    - s/CModulePath/CicSystemModulePath/.
    - s/GetOSInfo/cicGetOSInfo/.
    - s/IsWow64/cicIsWow64/.
    - s/GetSystemModuleHandle/cicGetSystemModuleHandle/.
    - s/LoadSystemLibrary/cicLoadSystemLibrary/.
    - Move cicGetOSInfo and cicIsWow64
      to <cicero/cicbase.h>.
    - Delete some Cicero headers.
    - Adapt ctfmon and msctfime to
      these changes.
    CORE-19360
---
 base/applications/ctfmon/CRegWatcher.cpp           |   2 +-
 base/applications/ctfmon/ctfmon.cpp                |  38 +----
 base/applications/ctfmon/precomp.h                 |   4 -
 dll/ime/msctfime/msctfime.cpp                      |   4 +-
 dll/ime/msctfime/msctfime.h                        |   4 +-
 sdk/include/reactos/cicero/CModulePath.h           |  90 ------------
 sdk/include/reactos/cicero/cicbase.h               | 158 ++++++++++++++++++++-
 sdk/include/reactos/cicero/{imclock.h => cicimc.h} |   0
 sdk/include/reactos/cicero/osinfo.h                |  47 ------
 9 files changed, 166 insertions(+), 181 deletions(-)

diff --git a/base/applications/ctfmon/CRegWatcher.cpp 
b/base/applications/ctfmon/CRegWatcher.cpp
index 7782b5c096d..f27ab57895c 100644
--- a/base/applications/ctfmon/CRegWatcher.cpp
+++ b/base/applications/ctfmon/CRegWatcher.cpp
@@ -138,7 +138,7 @@ CRegWatcher::UpdateSpTip()
     }
 
     // Get %WINDIR%/IME/sptip.dll!TF_CreateLangProfileUtil function
-    HINSTANCE hSPTIP = LoadSystemLibrary(L"IME\\sptip.dll", TRUE);
+    HINSTANCE hSPTIP = cicLoadSystemLibrary(L"IME\\sptip.dll", TRUE);
     FN_TF_CreateLangProfileUtil fnTF_CreateLangProfileUtil =
         (FN_TF_CreateLangProfileUtil)::GetProcAddress(hSPTIP, 
"TF_CreateLangProfileUtil");
     if (fnTF_CreateLangProfileUtil)
diff --git a/base/applications/ctfmon/ctfmon.cpp 
b/base/applications/ctfmon/ctfmon.cpp
index ebeae0fd933..676c0657289 100644
--- a/base/applications/ctfmon/ctfmon.cpp
+++ b/base/applications/ctfmon/ctfmon.cpp
@@ -9,10 +9,6 @@
 #include "CRegWatcher.h"
 #include "CLoaderWnd.h"
 
-// ntdll!NtQueryInformationProcess
-typedef NTSTATUS (WINAPI *FN_NtQueryInformationProcess)(HANDLE, 
PROCESSINFOCLASS, PVOID, ULONG, PULONG);
-FN_NtQueryInformationProcess g_fnNtQueryInformationProcess = NULL;
-
 // kernel32!SetProcessShutdownParameters
 typedef BOOL (WINAPI *FN_SetProcessShutdownParameters)(DWORD, DWORD);
 FN_SetProcessShutdownParameters g_fnSetProcessShutdownParameters = NULL;
@@ -29,31 +25,9 @@ HANDLE      g_hCicMutex     = NULL;     // The Cicero mutex
 BOOL        g_bOnWow64      = FALSE;    // Is the app running on WoW64?
 BOOL        g_fNoRunKey     = FALSE;    // Don't write registry key "Run"?
 BOOL        g_fJustRunKey   = FALSE;    // Just write registry key "Run"?
-DWORD       g_dwOsInfo      = 0;        // The OS version info. See GetOSInfo
+DWORD       g_dwOsInfo      = 0;        // The OS version info. See 
cicGetOSInfo
 CLoaderWnd* g_pLoaderWnd    = NULL;     // TIP Bar loader window
 
-// Is the current process on WoW64?
-static BOOL
-IsWow64(VOID)
-{
-    HMODULE hNTDLL = GetSystemModuleHandle(L"ntdll.dll", FALSE);
-    if (!hNTDLL)
-        return FALSE;
-
-    g_fnNtQueryInformationProcess =
-        (FN_NtQueryInformationProcess)::GetProcAddress(hNTDLL, 
"NtQueryInformationProcess");
-    if (!g_fnNtQueryInformationProcess)
-        return FALSE;
-
-    ULONG_PTR Value = 0;
-    NTSTATUS Status = g_fnNtQueryInformationProcess(::GetCurrentProcess(), 
ProcessWow64Information,
-                                                    &Value, sizeof(Value), 
NULL);
-    if (!NT_SUCCESS(Status))
-        return FALSE;
-
-    return !!Value;
-}
-
 static VOID
 ParseCommandLine(
     _In_ LPCWSTR pszCmdLine)
@@ -107,7 +81,7 @@ WriteRegRun(VOID)
         return;
 
     // Write the module path
-    CModulePath ModPath;
+    CicSystemModulePath ModPath;
     if (ModPath.Init(L"ctfmon.exe", FALSE))
     {
         DWORD cbData = (ModPath.m_cchPath + 1) * sizeof(WCHAR);
@@ -172,7 +146,7 @@ CheckX64System(
     }
 
     // Get GetSystemWow64DirectoryW function
-    g_hKernel32 = GetSystemModuleHandle(L"kernel32.dll", FALSE);
+    g_hKernel32 = cicGetSystemModuleHandle(L"kernel32.dll", FALSE);
     g_fnGetSystemWow64DirectoryW =
         (FN_GetSystemWow64DirectoryW)::GetProcAddress(g_hKernel32, 
"GetSystemWow64DirectoryW");
     if (!g_fnGetSystemWow64DirectoryW)
@@ -204,8 +178,8 @@ InitApp(
     g_hInst     = hInstance;    // Save the instance handle
 
     g_uACP      = ::GetACP();   // Save the active codepage
-    g_bOnWow64  = IsWow64();    // Is the current process on WoW64?
-    g_dwOsInfo  = GetOSInfo();  // Get OS info
+    g_bOnWow64  = cicIsWow64();   // Is the current process on WoW64?
+    g_dwOsInfo  = cicGetOSInfo(); // Get OS info
 
     // Create a mutex for Cicero
     g_hCicMutex = TF_CreateCicLoadMutex(&g_fWinLogon);
@@ -218,7 +192,7 @@ InitApp(
     // Call SetProcessShutdownParameters if possible
     if (g_dwOsInfo & OSINFO_NT)
     {
-        g_hKernel32 = GetSystemModuleHandle(L"kernel32.dll", FALSE);
+        g_hKernel32 = cicGetSystemModuleHandle(L"kernel32.dll", FALSE);
         g_fnSetProcessShutdownParameters =
             (FN_SetProcessShutdownParameters)
                 ::GetProcAddress(g_hKernel32, "SetProcessShutdownParameters");
diff --git a/base/applications/ctfmon/precomp.h 
b/base/applications/ctfmon/precomp.h
index 636739eb9e1..541e1d6833a 100644
--- a/base/applications/ctfmon/precomp.h
+++ b/base/applications/ctfmon/precomp.h
@@ -9,7 +9,6 @@
 
 #define WIN32_NO_STATUS
 #include <windows.h>
-#include <ndk/pstypes.h>
 #include <shellapi.h>
 #include <shlwapi.h>
 #include <stdlib.h>
@@ -17,10 +16,7 @@
 #include <msctf.h>
 #include <ctfutb.h>
 #include <ctffunc.h>
-
 #include <cicero/cicbase.h>
-#include <cicero/osinfo.h>
-#include <cicero/CModulePath.h>
 
 #include "resource.h"
 
diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp
index 86a7ddc325a..bfe55ed615f 100644
--- a/dll/ime/msctfime/msctfime.cpp
+++ b/dll/ime/msctfime/msctfime.cpp
@@ -88,7 +88,7 @@ DllShutDownInProgress(VOID)
     if (s_fnDllShutDownInProgress)
         return s_fnDllShutDownInProgress();
 
-    hNTDLL = GetSystemModuleHandle(L"ntdll.dll", FALSE);
+    hNTDLL = cicGetSystemModuleHandle(L"ntdll.dll", FALSE);
     s_fnDllShutDownInProgress =
         (FN_DllShutDownInProgress)GetProcAddress(hNTDLL, 
"RtlDllShutdownInProgress");
     if (!s_fnDllShutDownInProgress)
@@ -2841,7 +2841,7 @@ BOOL ProcessAttach(HINSTANCE hinstDLL)
     if (!TLS::Initialize())
         return FALSE;
 
-    g_dwOSInfo = GetOSInfo();
+    g_dwOSInfo = cicGetOSInfo();
 
     // FIXME
 
diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h
index daa9f74c66f..5fce8fb5c42 100644
--- a/dll/ime/msctfime/msctfime.h
+++ b/dll/ime/msctfime/msctfime.h
@@ -24,9 +24,7 @@
 
 #include <cicero/cicbase.h>
 #include <cicero/cicarray.h>
-#include <cicero/osinfo.h>
-#include <cicero/CModulePath.h>
-#include <cicero/imclock.h>
+#include <cicero/cicimc.h>
 
 class CicInputContext;
 
diff --git a/sdk/include/reactos/cicero/CModulePath.h 
b/sdk/include/reactos/cicero/CModulePath.h
deleted file mode 100644
index 2418b157cdd..00000000000
--- a/sdk/include/reactos/cicero/CModulePath.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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...@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;
-}
diff --git a/sdk/include/reactos/cicero/cicbase.h 
b/sdk/include/reactos/cicero/cicbase.h
index 3e4184ac7fc..ff18ce94f72 100644
--- a/sdk/include/reactos/cicero/cicbase.h
+++ b/sdk/include/reactos/cicero/cicbase.h
@@ -7,6 +7,10 @@
 
 #pragma once
 
+#ifndef __cplusplus
+    #error Cicero needs C++.
+#endif
+
 static inline LPVOID cicMemAlloc(SIZE_T size)
 {
     return LocalAlloc(0, size);
@@ -30,7 +34,6 @@ static inline void cicMemFree(LPVOID ptr)
         LocalFree(ptr);
 }
 
-#ifdef __cplusplus
 inline void* __cdecl operator new(size_t size) noexcept
 {
     return cicMemAllocClear(size);
@@ -45,7 +48,6 @@ 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)
@@ -56,3 +58,155 @@ static inline void ClosePopupTipbar(void)
 static inline void GetPopupTipbar(HWND hwnd, BOOL fWinLogon)
 {
 }
+
+/* The flags of cicGetOSInfo() */
+#define OSINFO_NT    0x01
+#define OSINFO_CJK   0x10
+#define OSINFO_IMM   0x20
+#define OSINFO_DBCS  0x40
+
+static inline DWORD
+cicGetOSInfo(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;
+}
+
+struct CicSystemModulePath
+{
+    WCHAR m_szPath[MAX_PATH];
+    SIZE_T m_cchPath;
+
+    CicSystemModulePath()
+    {
+        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
+cicGetSystemModuleHandle(
+    _In_ LPCWSTR pszFileName,
+    _In_ BOOL bSysWinDir)
+{
+    CicSystemModulePath ModPath;
+    if (!ModPath.Init(pszFileName, bSysWinDir))
+        return NULL;
+    return GetModuleHandleW(ModPath.m_szPath);
+}
+
+// Load a system library
+static inline HINSTANCE
+cicLoadSystemLibrary(
+    _In_ LPCWSTR pszFileName,
+    _In_ BOOL bSysWinDir)
+{
+    CicSystemModulePath ModPath;
+    if (!ModPath.Init(pszFileName, bSysWinDir))
+        return NULL;
+    return ::LoadLibraryW(ModPath.m_szPath);
+}
+
+#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(L"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(
+    _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;
+}
diff --git a/sdk/include/reactos/cicero/imclock.h 
b/sdk/include/reactos/cicero/cicimc.h
similarity index 100%
rename from sdk/include/reactos/cicero/imclock.h
rename to sdk/include/reactos/cicero/cicimc.h
diff --git a/sdk/include/reactos/cicero/osinfo.h 
b/sdk/include/reactos/cicero/osinfo.h
deleted file mode 100644
index b260000dfbc..00000000000
--- a/sdk/include/reactos/cicero/osinfo.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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...@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;
-}

Reply via email to