https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0233bb72b30c12ed7ebb0…
commit 0233bb72b30c12ed7ebb02c4a1a4f45164d309e8
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Sep 7 22:05:54 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Sep 9 16:15:13 2021 +0200
[IMM32] ValidateHwndNoErr(): Apply ReactOS-specific handle table array fixup. (#3937)
CORE-17741
This function (which should belong to the user32 helpers) depends on the
internal format of the USER handles table, that is ReactOS-specific. Its
pointer value is stored in the win32k/user32 shared info section, and
thus cannot be converted to user-space and stored back into that section.
Therefore it needs to be retrieved and manually converted when the function
is called.
---
dll/win32/imm32/imm.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 9f32bcc5d5d..1dc41f8e362 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -66,6 +66,7 @@ static PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
PCLIENTINFO ClientInfo = GetWin32ClientInfo();
INT index;
PUSER_HANDLE_TABLE ht;
+ PUSER_HANDLE_ENTRY he;
WORD generation;
/* See if the window is cached */
@@ -76,15 +77,20 @@ static PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
return NULL;
ht = g_SharedInfo.aheList; /* handle table */
+ ASSERT(ht);
+ /* ReactOS-Specific! */
+ ASSERT(g_SharedInfo.ulSharedDelta != 0);
+ he = (PUSER_HANDLE_ENTRY)((ULONG_PTR)ht->handles - g_SharedInfo.ulSharedDelta);
+
index = (LOWORD(hwnd) - FIRST_USER_HANDLE) >> 1;
- if (index < 0 || index >= ht->nb_handles || ht->handles[index].type !=
TYPE_WINDOW)
+ if (index < 0 || index >= ht->nb_handles || he[index].type != TYPE_WINDOW)
return NULL;
generation = HIWORD(hwnd);
- if (generation != ht->handles[index].generation && generation &&
generation != 0xFFFF)
+ if (generation != he[index].generation && generation && generation !=
0xFFFF)
return NULL;
- return (PWND)&ht->handles[index];
+ return (PWND)&he[index];
}
static BOOL APIENTRY Imm32InitInstance(HMODULE hMod)