https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d78601f39369fecb3773…
commit 3d78601f39369fecb3773fba181049f2ef01ef8c
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Nov 1 15:20:42 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Nov 1 15:20:42 2021 +0900
[WIN32SS][NTUSER] Implement NtUserDestroyInputContext (#4063)
CORE-11700
---
win32ss/user/ntuser/ime.c | 80 ++++++++++++++++++++++++++++++++++++++++-
win32ss/user/ntuser/ntstubs.c | 8 -----
win32ss/user/ntuser/object.c | 2 +-
win32ss/user/ntuser/userfuncs.h | 6 ++++
4 files changed, 86 insertions(+), 10 deletions(-)
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index 1d84609186c..12914ccb171 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -3,7 +3,8 @@
* PROJECT: ReactOS Win32k subsystem
* PURPOSE: Input Method Editor and Input Method Manager support
* FILE: win32ss/user/ntuser/ime.c
- * PROGRAMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
+ * PROGRAMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
+ * Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com)
*/
#include <win32k.h>
@@ -134,5 +135,82 @@ NtUserSetImeOwnerWindow(PIMEINFOEX pImeInfoEx, BOOL fFlag)
return 0;
}
+PVOID
+AllocInputContextObject(PDESKTOP pDesk,
+ PTHREADINFO pti,
+ SIZE_T Size,
+ PVOID* HandleOwner)
+{
+ PTHRDESKHEAD ObjHead;
+
+ ASSERT(Size > sizeof(*ObjHead));
+ ASSERT(pti != NULL);
+
+ ObjHead = UserHeapAlloc(Size);
+ if (!ObjHead)
+ return NULL;
+
+ RtlZeroMemory(ObjHead, Size);
+
+ ObjHead->pSelf = ObjHead;
+ ObjHead->rpdesk = pDesk;
+ ObjHead->pti = pti;
+ IntReferenceThreadInfo(pti);
+ *HandleOwner = pti;
+ pti->ppi->UserHandleCount++;
+
+ return ObjHead;
+}
+
+VOID UserFreeInputContext(PVOID Object)
+{
+ PIMC pIMC = Object, pImc0;
+ PTHREADINFO pti = pIMC->head.pti;
+
+ UserMarkObjectDestroy(Object);
+
+ for (pImc0 = pti->spDefaultImc; pImc0; pImc0 = pImc0->pImcNext)
+ {
+ if (pImc0->pImcNext == pIMC)
+ {
+ pImc0->pImcNext = pIMC->pImcNext;
+ break;
+ }
+ }
+
+ UserHeapFree(Object);
+
+ pti->ppi->UserHandleCount--;
+ IntDereferenceThreadInfo(pti);
+}
+
+BOOLEAN UserDestroyInputContext(PVOID Object)
+{
+ PIMC pIMC = Object;
+ UserDeleteObject(pIMC->head.h, TYPE_INPUTCONTEXT);
+ return TRUE;
+}
+
+BOOL APIENTRY NtUserDestroyInputContext(HIMC hIMC)
+{
+ PIMC pIMC;
+ BOOL ret = FALSE;
+
+ UserEnterExclusive();
+
+ if (!(gpsi->dwSRVIFlags & SRVINFO_IMM32))
+ {
+ EngSetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ UserLeave();
+ return FALSE;
+ }
+
+ pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
+ if (pIMC)
+ ret = UserDereferenceObject(pIMC);
+
+ UserLeave();
+ return ret;
+}
/* EOF */
diff --git a/win32ss/user/ntuser/ntstubs.c b/win32ss/user/ntuser/ntstubs.c
index e3de96b1d51..9d7b624151b 100644
--- a/win32ss/user/ntuser/ntstubs.c
+++ b/win32ss/user/ntuser/ntstubs.c
@@ -424,14 +424,6 @@ NtUserCreateInputContext(PCLIENTIMC pClientImc)
return NULL;
}
-BOOL
-APIENTRY
-NtUserDestroyInputContext(HIMC hIMC)
-{
- STUB;
- return FALSE;
-}
-
DWORD
APIENTRY
NtUserGetRawInputBuffer(
diff --git a/win32ss/user/ntuser/object.c b/win32ss/user/ntuser/object.c
index 05ed7eebd5c..cc2bebdb8bc 100644
--- a/win32ss/user/ntuser/object.c
+++ b/win32ss/user/ntuser/object.c
@@ -237,7 +237,7 @@ static const struct
{ AllocSysObject, /*UserKbdFileCleanup*/NULL, FreeSysObject }, /*
TYPE_KBDFILE */
{ AllocThreadObject, IntRemoveEvent, FreeThreadObject }, /*
TYPE_WINEVENTHOOK */
{ AllocSysObject, /*UserTimerCleanup*/NULL, FreeSysObject }, /*
TYPE_TIMER */
- { NULL, NULL, NULL }, /*
TYPE_INPUTCONTEXT */
+ { AllocInputContextObject, UserDestroyInputContext, UserFreeInputContext }, /*
TYPE_INPUTCONTEXT */
{ NULL, NULL, NULL }, /*
TYPE_HIDDATA */
{ NULL, NULL, NULL }, /*
TYPE_DEVICEINFO */
{ NULL, NULL, NULL }, /*
TYPE_TOUCHINPUTINFO */
diff --git a/win32ss/user/ntuser/userfuncs.h b/win32ss/user/ntuser/userfuncs.h
index 29ae2394dd8..6fb86e64d71 100644
--- a/win32ss/user/ntuser/userfuncs.h
+++ b/win32ss/user/ntuser/userfuncs.h
@@ -163,4 +163,10 @@ BOOL UserPaintCaption(PWND pWnd, INT Flags);
BOOL FASTCALL SetLayeredStatus(PWND pWnd, BYTE set);
BOOL FASTCALL GetLayeredStatus(PWND pWnd);
+/************** INPUT CONTEXT **************/
+
+VOID UserFreeInputContext(PVOID Object);
+BOOLEAN UserDestroyInputContext(PVOID Object);
+PVOID AllocInputContextObject(PDESKTOP pDesk, PTHREADINFO pti, SIZE_T Size, PVOID*
HandleOwner);
+
/* EOF */