[NTUSER] Implement NtUserGetAppImeLevel and NtUserSetAppImeLevel (#4313)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Wed, 26 Jan 2022 22:29:19 +0000 (07:29 +0900)
committerGitHub <noreply@github.com>
Wed, 26 Jan 2022 22:29:19 +0000 (07:29 +0900)
- Add AtomImeLevel atom.
- Modify NtUserSetAppImeLevel prototype.
- Implement NtUserGetAppImeLevel and NtUserSetAppImeLevel functions.
CORE-11700

win32ss/include/ntuser.h
win32ss/user/ntuser/ime.c
win32ss/user/ntuser/ntuser.c
win32ss/user/ntuser/ntuser.h

index dab6b26..400830a 100644 (file)
@@ -3084,11 +3084,11 @@ NTAPI
 NtUserSetActiveWindow(
     HWND Wnd);
 
-DWORD
+BOOL
 NTAPI
 NtUserSetAppImeLevel(
-    DWORD dwUnknown1,
-    DWORD dwUnknown2);
+    HWND hWnd,
+    DWORD dwLevel);
 
 HWND
 NTAPI
index 3a8af9d..18806d6 100644 (file)
@@ -238,8 +238,29 @@ DWORD
 APIENTRY
 NtUserGetAppImeLevel(HWND hWnd)
 {
-    STUB;
-    return 0;
+    DWORD ret = 0;
+    PWND pWnd;
+    PTHREADINFO pti;
+
+    UserEnterShared();
+
+    pWnd = ValidateHwndNoErr(hWnd);
+    if (!pWnd)
+        goto Quit;
+
+    if (!IS_IMM_MODE())
+    {
+        EngSetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+        goto Quit;
+    }
+
+    pti = PsGetCurrentThreadWin32Thread();
+    if (pWnd->head.pti->ppi == pti->ppi)
+        ret = (DWORD)(ULONG_PTR)UserGetProp(pWnd, AtomImeLevel, TRUE);
+
+Quit:
+    UserLeave();
+    return ret;
 }
 
 BOOL FASTCALL UserGetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pInfoEx, IMEINFOEXCLASS SearchType)
@@ -335,14 +356,33 @@ Quit:
     return ret;
 }
 
-DWORD
+BOOL
 APIENTRY
-NtUserSetAppImeLevel(
-    DWORD dwUnknown1,
-    DWORD dwUnknown2)
+NtUserSetAppImeLevel(HWND hWnd, DWORD dwLevel)
 {
-    STUB;
-    return 0;
+    BOOL ret = FALSE;
+    PWND pWnd;
+    PTHREADINFO pti;
+
+    UserEnterExclusive();
+
+    pWnd = ValidateHwndNoErr(hWnd);
+    if (!pWnd)
+        goto Quit;
+
+    if (!IS_IMM_MODE())
+    {
+        EngSetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+        goto Quit;
+    }
+
+    pti = PsGetCurrentThreadWin32Thread();
+    if (pWnd->head.pti->ppi == pti->ppi)
+        ret = UserSetProp(pWnd, AtomImeLevel, (HANDLE)(ULONG_PTR)dwLevel, TRUE);
+
+Quit:
+    UserLeave();
+    return ret;
 }
 
 BOOL FASTCALL UserSetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pImeInfoEx)
index 3280590..220ed8d 100644 (file)
@@ -25,6 +25,7 @@ ATOM AtomQOS;           // Window DDE Quality of Service atom.
 HINSTANCE hModClient = NULL;
 BOOL ClientPfnInit = FALSE;
 ATOM gaGuiConsoleWndClass;
+ATOM AtomImeLevel;
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
@@ -55,6 +56,7 @@ InitUserAtoms(VOID)
 
     AtomDDETrack = IntAddGlobalAtom(L"SysDT", TRUE);
     AtomQOS      = IntAddGlobalAtom(L"SysQOS", TRUE);
+    AtomImeLevel = IntAddGlobalAtom(L"SysIMEL", TRUE);
 
     /*
      * FIXME: AddPropW uses the global kernel atom table, thus leading to conflicts if we use
index 29ee2fa..090a797 100644 (file)
@@ -18,6 +18,7 @@ extern BOOL g_AlwaysDisplayVersion;
 extern ATOM gaGuiConsoleWndClass;
 extern ATOM AtomDDETrack;
 extern ATOM AtomQOS;
+extern ATOM AtomImeLevel;
 extern ERESOURCE UserLock;
 
 CODE_SEG("INIT") NTSTATUS NTAPI InitUserImpl(VOID);