https://git.reactos.org/?p=reactos.git;a=commitdiff;h=69a925cae88e520f03535b25cff47937a647a443

commit 69a925cae88e520f03535b25cff47937a647a443
Author:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
AuthorDate: Tue Dec 26 13:39:56 2023 +0900
Commit:     GitHub <nore...@github.com>
CommitDate: Tue Dec 26 13:39:56 2023 +0900

    [MSCTF] Implement TF_RunInputCPL (#6231)
    
    - Add FullPathExec, and RunCPLSetting
      helper functions.
    - Implement TF_RunInputCPL function
      by using them.
    - Modify msctf.spec.
    CORE-19361
---
 dll/win32/msctf/msctf.spec |  2 +-
 dll/win32/msctf/utils.cpp  | 75 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/dll/win32/msctf/msctf.spec b/dll/win32/msctf/msctf.spec
index 186e1cadac2..7f90b05c2b2 100644
--- a/dll/win32/msctf/msctf.spec
+++ b/dll/win32/msctf/msctf.spec
@@ -32,7 +32,7 @@
 @ stub TF_IsCtfmonRunning
 @ stub TF_IsInMarshaling
 @ stub TF_MlngInfoCount
-@ stub TF_RunInputCPL
+@ stdcall TF_RunInputCPL()
 @ stdcall -stub TF_PostAllThreadMsg(long long)
 @ stdcall TF_RegisterLangBarAddIn(ptr wstr long)
 @ stdcall TF_UnregisterLangBarAddIn(ptr long)
diff --git a/dll/win32/msctf/utils.cpp b/dll/win32/msctf/utils.cpp
index 944d3d1c063..79371ed1e2f 100644
--- a/dll/win32/msctf/utils.cpp
+++ b/dll/win32/msctf/utils.cpp
@@ -29,6 +29,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
 
+DWORD g_dwOSInfo = 0; // See cicGetOSInfo
+
 BOOL StringFromGUID2A(REFGUID rguid, LPSTR pszGUID, INT cchGUID)
 {
     pszGUID[0] = ANSI_NULL;
@@ -42,10 +44,53 @@ BOOL StringFromGUID2A(REFGUID rguid, LPSTR pszGUID, INT 
cchGUID)
 
 #ifdef UNICODE
     #define StringFromGUID2T StringFromGUID2
+    #define debugstr_t debugstr_w
 #else
     #define StringFromGUID2T StringFromGUID2A
+    #define debugstr_t debugstr_a
 #endif
 
+BOOL FullPathExec(LPCTSTR pszExeFile, LPCTSTR pszCmdLine, UINT nCmdShow, BOOL 
bSysWinDir)
+{
+    STARTUPINFO si;
+    PROCESS_INFORMATION pi;
+    CicSystemModulePath ModPath;
+    TCHAR szCommandLine[2 * MAX_PATH];
+
+    ModPath.Init(pszExeFile, bSysWinDir);
+    if (!ModPath.m_cchPath)
+    {
+        ERR("%s\n", debugstr_t(pszExeFile));
+        return FALSE;
+    }
+
+    StringCchCopy(szCommandLine, _countof(szCommandLine), pszCmdLine);
+
+    ZeroMemory(&si, sizeof(si));
+    si.cb = sizeof(si);
+    si.wShowWindow = nCmdShow;
+    si.dwFlags = STARTF_USESHOWWINDOW;
+    if (!CreateProcess(ModPath.m_szPath, szCommandLine, NULL, NULL, FALSE,
+                       NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
+    {
+        ERR("%s, %s\n", debugstr_t(ModPath.m_szPath), 
debugstr_t(szCommandLine));
+        return FALSE;
+    }
+
+    CloseHandle(pi.hProcess);
+    CloseHandle(pi.hThread);
+    return TRUE;
+}
+
+static inline BOOL
+RunCPLSetting(LPCTSTR pszCmdLine)
+{
+    if (!pszCmdLine)
+        return FALSE;
+
+    return FullPathExec(TEXT("rundll32.exe"), pszCmdLine, SW_SHOWMINNOACTIVE, 
FALSE);
+}
+
 /***********************************************************************
  *      TF_RegisterLangBarAddIn (MSCTF.@)
  *
@@ -118,3 +163,33 @@ TF_UnregisterLangBarAddIn(
 
     return hr;
 }
+
+/***********************************************************************
+ *      TF_RunInputCPL (MSCTF.@)
+ *
+ * @implemented
+ */
+EXTERN_C HRESULT WINAPI
+TF_RunInputCPL(VOID)
+{
+    CicSystemModulePath ModPath;
+    TCHAR szCmdLine[2 * MAX_PATH];
+
+    TRACE("()\n");
+
+    // NOTE: We don't support Win95/98/Me
+    if (g_dwOSInfo & CIC_OSINFO_XPPLUS)
+        ModPath.Init(TEXT("input.dll"), FALSE);
+    else
+        ModPath.Init(TEXT("input.cpl"), FALSE);
+
+    if (!ModPath.m_cchPath)
+        return E_FAIL;
+
+    StringCchPrintf(szCmdLine, _countof(szCmdLine),
+                    TEXT("rundll32.exe shell32.dll,Control_RunDLL %s"), 
ModPath.m_szPath);
+    if (!RunCPLSetting(szCmdLine))
+        return E_FAIL;
+
+    return S_OK;
+}

Reply via email to