Author: akhaldi
Date: Sun Sep 28 18:27:58 2014
New Revision: 64371
URL:
http://svn.reactos.org/svn/reactos?rev=64371&view=rev
Log:
[IMM32]
* Sync with Wine 1.7.27.
CORE-8540
Modified:
trunk/reactos/dll/win32/imm32/imm.c
trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/imm32/imm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/imm32/imm.c?rev=…
==============================================================================
--- trunk/reactos/dll/win32/imm32/imm.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/imm32/imm.c [iso-8859-1] Sun Sep 28 18:27:58 2014
@@ -35,6 +35,7 @@
#include <winnls.h>
#include <winreg.h>
#include <wine/list.h>
+#include <wine/unicode.h>
WINE_DEFAULT_DEBUG_CHANNEL(imm);
@@ -75,7 +76,10 @@
ImmHkl *immKbd;
UINT lastVK;
+ DWORD magic;
} InputContextData;
+
+#define WINE_IMC_VALID_MAGIC 0x56434D49
typedef struct _tagTRANSMSG {
UINT message;
@@ -243,35 +247,36 @@
}
}
-static HMODULE LoadDefaultWineIME(void)
-{
- char buffer[MAX_PATH], libname[32], *name, *next;
- HMODULE module = 0;
+static HMODULE load_graphics_driver(void)
+{
+ static const WCHAR display_device_guid_propW[] = {
+
'_','_','w','i','n','e','_','d','i','s','p','l','a','y','_',
+
'd','e','v','i','c','e','_','g','u','i','d',0
};
+ static const WCHAR key_pathW[] = {
+
'S','y','s','t','e','m','\\',
+
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
+
'C','o','n','t','r','o','l','\\',
+
'V','i','d','e','o','\\','{',0};
+ static const WCHAR displayW[] =
{'}','\\','0','0','0','0',0};
+ static const WCHAR driverW[] =
{'G','r','a','p','h','i','c','s','D','r','i','v','e','r',0};
+
+ HMODULE ret = 0;
HKEY hkey;
-
- TRACE("Attempting to fall back to wine default IME\n");
-
- strcpy( buffer, "x11" ); /* default value */
- /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
- if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey
))
- {
- DWORD type, count = sizeof(buffer);
- RegQueryValueExA( hkey, "Ime", 0, &type, (LPBYTE) buffer,
&count );
- RegCloseKey( hkey );
- }
-
- name = buffer;
- while (name)
- {
- next = strchr( name, ',' );
- if (next) *next++ = 0;
-
- snprintf( libname, sizeof(libname), "wine%s.drv", name );
- if ((module = LoadLibraryA( libname )) != 0) break;
- name = next;
- }
-
- return module;
+ DWORD size;
+ WCHAR path[MAX_PATH];
+ WCHAR key[(sizeof(key_pathW) + sizeof(displayW)) / sizeof(WCHAR) + 40];
+ UINT guid_atom = HandleToULong( GetPropW( GetDesktopWindow(),
display_device_guid_propW ));
+
+ if (!guid_atom) return 0;
+ memcpy( key, key_pathW, sizeof(key_pathW) );
+ if (!GlobalGetAtomNameW( guid_atom, key + strlenW(key), 40 )) return 0;
+ strcatW( key, displayW );
+ if (RegOpenKeyW( HKEY_LOCAL_MACHINE, key, &hkey )) return 0;
+ size = sizeof(path);
+ if (!RegQueryValueExW( hkey, driverW, NULL, NULL, (BYTE *)path, &size )) ret =
LoadLibraryW( path );
+ RegCloseKey( hkey );
+ TRACE( "%s %p\n", debugstr_w(path), ret );
+ return ret;
}
/* ImmHkl loading and freeing */
@@ -294,8 +299,7 @@
ptr->hkl = hkl;
if (ImmGetIMEFileNameW(hkl, filename, MAX_PATH)) ptr->hIME =
LoadLibraryW(filename);
- if (!ptr->hIME)
- ptr->hIME = LoadDefaultWineIME();
+ if (!ptr->hIME) ptr->hIME = load_graphics_driver();
if (ptr->hIME)
{
LOAD_FUNCPTR(ImeInquire);
@@ -452,15 +456,33 @@
return rc;
}
+static InputContextData* get_imc_data(HIMC hIMC)
+{
+ InputContextData *data = hIMC;
+
+ if (hIMC == NULL)
+ return NULL;
+
+ if(IsBadReadPtr(data, sizeof(InputContextData)) || data->magic !=
WINE_IMC_VALID_MAGIC)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+ return data;
+}
+
/***********************************************************************
* ImmAssociateContext (IMM32.@)
*/
HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
{
HIMC old = NULL;
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p):\n", hWnd, hIMC);
+
+ if(hIMC && !data)
+ return NULL;
if (!IMM_GetThreadData()->defaultContext)
IMM_GetThreadData()->defaultContext = ImmCreateContext();
@@ -642,6 +664,7 @@
InputContextData *new_context;
LPGUIDELINE gl;
LPCANDIDATEINFO ci;
+ int i;
new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData));
@@ -669,8 +692,14 @@
gl->dwSize = sizeof(GUIDELINE);
ImmUnlockIMCC(new_context->IMC.hGuideLine);
+ for (i = 0; i < sizeof(new_context->IMC.cfCandForm) / sizeof(CANDIDATEFORM);
i++)
+ new_context->IMC.cfCandForm[i].dwIndex = ~0u;
+
/* Initialize the IME Private */
new_context->IMC.hPrivate =
ImmCreateIMCC(new_context->immKbd->imeInfo.dwPrivateDataSize);
+
+ new_context->IMC.fdwConversion =
new_context->immKbd->imeInfo.fdwConversionCaps;
+ new_context->IMC.fdwSentence =
new_context->immKbd->imeInfo.fdwSentenceCaps;
if (!new_context->immKbd->pImeSelect(new_context, TRUE))
{
@@ -683,29 +712,32 @@
new_context->immKbd->uSelected++;
TRACE("Created context %p\n",new_context);
+ new_context->magic = WINE_IMC_VALID_MAGIC;
return new_context;
}
static BOOL IMM_DestroyContext(HIMC hIMC)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("Destroying %p\n",hIMC);
- if (hIMC)
- {
- data->immKbd->uSelected --;
- data->immKbd->pImeSelect(hIMC, FALSE);
- SendMessageW(data->IMC.hWnd, WM_IME_SELECT, FALSE,
(LPARAM)GetKeyboardLayout(0));
-
- ImmDestroyIMCC(data->IMC.hCompStr);
- ImmDestroyIMCC(data->IMC.hCandInfo);
- ImmDestroyIMCC(data->IMC.hGuideLine);
- ImmDestroyIMCC(data->IMC.hPrivate);
- ImmDestroyIMCC(data->IMC.hMsgBuf);
-
- HeapFree(GetProcessHeap(),0,data);
- }
+ if (!data)
+ return FALSE;
+
+ data->immKbd->uSelected --;
+ data->immKbd->pImeSelect(hIMC, FALSE);
+ SendMessageW(data->IMC.hWnd, WM_IME_SELECT, FALSE, (LPARAM)GetKeyboardLayout(0));
+
+ ImmDestroyIMCC(data->IMC.hCompStr);
+ ImmDestroyIMCC(data->IMC.hCandInfo);
+ ImmDestroyIMCC(data->IMC.hGuideLine);
+ ImmDestroyIMCC(data->IMC.hPrivate);
+ ImmDestroyIMCC(data->IMC.hMsgBuf);
+
+ data->magic = 0;
+ HeapFree(GetProcessHeap(),0,data);
+
return TRUE;
}
@@ -885,7 +917,7 @@
HIMC hIMC, DWORD dwIndex,
LPCANDIDATELIST lpCandList, DWORD dwBufLen)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
LPCANDIDATEINFO candinfo;
LPCANDIDATELIST candlist;
DWORD ret = 0;
@@ -924,7 +956,7 @@
DWORD WINAPI ImmGetCandidateListCountA(
HIMC hIMC, LPDWORD lpdwListCount)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
LPCANDIDATEINFO candinfo;
DWORD ret, count;
@@ -956,7 +988,7 @@
DWORD WINAPI ImmGetCandidateListCountW(
HIMC hIMC, LPDWORD lpdwListCount)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
LPCANDIDATEINFO candinfo;
DWORD ret, count;
@@ -989,7 +1021,7 @@
HIMC hIMC, DWORD dwIndex,
LPCANDIDATELIST lpCandList, DWORD dwBufLen)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
LPCANDIDATEINFO candinfo;
LPCANDIDATELIST candlist;
DWORD ret = 0;
@@ -1028,7 +1060,7 @@
BOOL WINAPI ImmGetCandidateWindow(
HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM lpCandidate)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("%p, %d, %p\n", hIMC, dwIndex, lpCandidate);
@@ -1036,6 +1068,9 @@
return FALSE;
if ( dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) )
+ return FALSE;
+
+ if (data->IMC.cfCandForm[dwIndex].dwIndex != dwIndex)
return FALSE;
*lpCandidate = data->IMC.cfCandForm[dwIndex];
@@ -1068,7 +1103,7 @@
*/
BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p):\n", hIMC, lplf);
@@ -1247,7 +1282,7 @@
DWORD dwBufLen, BOOL unicode)
{
LONG rc = 0;
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
LPCOMPOSITIONSTRING compstr;
LPBYTE compdata;
@@ -1359,7 +1394,7 @@
*/
BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p)\n", hIMC, lpCompForm);
@@ -1367,7 +1402,7 @@
return FALSE;
*lpCompForm = data->IMC.cfCompForm;
- return 1;
+ return TRUE;
}
/***********************************************************************
@@ -1486,7 +1521,7 @@
BOOL WINAPI ImmGetConversionStatus(
HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("%p %p %p\n", hIMC, lpfdwConversion, lpfdwSentence);
@@ -1526,6 +1561,8 @@
/* find out how many characters in the unicode buffer */
len = ImmGetDescriptionW( hKL, NULL, 0 );
+ if (!len)
+ return 0;
/* allocate a buffer of that size */
buf = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR) );
@@ -1541,7 +1578,10 @@
HeapFree( GetProcessHeap(), 0, buf );
- return len;
+ if (len == 0)
+ return 0;
+
+ return len - 1;
}
/***********************************************************************
@@ -1553,6 +1593,7 @@
FIXME("(%p, %p, %d): semi stub\n", hKL, lpszDescription, uBufLen);
+ if (!hKL) return 0;
if (!uBufLen) return lstrlenW( name );
lstrcpynW( lpszDescription, name, uBufLen );
return lstrlenW( lpszDescription );
@@ -1667,7 +1708,7 @@
*/
BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
static int i;
if (!data)
@@ -1770,7 +1811,7 @@
*/
BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p)\n", hIMC, lpptPos);
@@ -1966,13 +2007,21 @@
BOOL WINAPI ImmNotifyIME(
HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %d, %d, %d)\n",
hIMC, dwAction, dwIndex, dwValue);
+ if (hIMC == NULL)
+ {
+ SetLastError(ERROR_SUCCESS);
+ return FALSE;
+ }
+
if (!data || ! data->immKbd->pNotifyIME)
- return FALSE;
+ {
+ return FALSE;
+ }
return data->immKbd->pNotifyIME(hIMC,dwAction,dwIndex,dwValue);
}
@@ -2042,11 +2091,11 @@
*/
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
{
- static int shown = 0;
+ static BOOL shown = FALSE;
if (!shown) {
FIXME("(%p, %p): stub\n", hWnd, hIMC);
- shown = 1;
+ shown = TRUE;
}
return TRUE;
}
@@ -2056,9 +2105,11 @@
*/
LRESULT WINAPI ImmRequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("%p %ld %ld\n", hIMC, wParam, wParam);
+ if (!data)
+ SetLastError(ERROR_INVALID_HANDLE);
if (data && IsWindow(data->IMC.hWnd))
return SendMessageA(data->IMC.hWnd, WM_IME_REQUEST, wParam, lParam);
@@ -2071,9 +2122,12 @@
*/
LRESULT WINAPI ImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("%p %ld %ld\n", hIMC, wParam, wParam);
+
+ if (!data)
+ SetLastError(ERROR_INVALID_HANDLE);
if (data && IsWindow(data->IMC.hWnd))
return SendMessageW(data->IMC.hWnd, WM_IME_REQUEST, wParam, lParam);
@@ -2087,7 +2141,7 @@
BOOL WINAPI ImmSetCandidateWindow(
HIMC hIMC, LPCANDIDATEFORM lpCandidate)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p)\n", hIMC, lpCandidate);
@@ -2115,11 +2169,14 @@
*/
BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p)\n", hIMC, lplf);
if (!data || !lplf)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
memcpy(&data->IMC.lfFont.W,lplf,sizeof(LOGFONTA));
MultiByteToWideChar(CP_ACP, 0, lplf->lfFaceName, -1,
data->IMC.lfFont.W.lfFaceName,
@@ -2135,11 +2192,14 @@
*/
BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p)\n", hIMC, lplf);
if (!data || !lplf)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
data->IMC.lfFont.W = *lplf;
ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCOMPOSITIONFONT);
@@ -2161,7 +2221,7 @@
WCHAR *CompBuffer = NULL;
WCHAR *ReadBuffer = NULL;
BOOL rc;
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %d, %p, %d, %p, %d):\n",
hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
@@ -2216,7 +2276,7 @@
CHAR *CompBuffer = NULL;
CHAR *ReadBuffer = NULL;
BOOL rc;
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %d, %p, %d, %p, %d):\n",
hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
@@ -2269,7 +2329,7 @@
HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
{
BOOL reshow = FALSE;
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p)\n", hIMC, lpCompForm);
TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm->dwStyle,
@@ -2277,7 +2337,10 @@
lpCompForm->rcArea.left, lpCompForm->rcArea.bottom,
lpCompForm->rcArea.right);
if (!data)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
data->IMC.cfCompForm = *lpCompForm;
@@ -2303,12 +2366,15 @@
HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
{
DWORD oldConversion, oldSentence;
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("%p %d %d\n", hIMC, fdwConversion, fdwSentence);
if (!data)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
if ( fdwConversion != data->IMC.fdwConversion )
{
@@ -2333,12 +2399,15 @@
*/
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("%p %d\n", hIMC, fOpen);
if (!data)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
if (data->immKbd->UIWnd == NULL)
{
@@ -2366,12 +2435,15 @@
*/
BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %p)\n", hIMC, lpptPos);
if (!data || !lpptPos)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
TRACE("\t(%i,%i)\n", lpptPos->x, lpptPos->y);
@@ -2489,9 +2561,16 @@
LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu,
DWORD dwSize)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType,
lpImeParentMenu, lpImeMenu, dwSize);
+
+ if (!data)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return 0;
+ }
+
if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems)
{
if (!is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu))
@@ -2553,9 +2632,16 @@
LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu,
DWORD dwSize)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType,
lpImeParentMenu, lpImeMenu, dwSize);
+
+ if (!data)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return 0;
+ }
+
if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems)
{
if (is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu))
@@ -2613,7 +2699,7 @@
*/
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
if (!data)
return NULL;
@@ -2626,7 +2712,10 @@
*/
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
+
+ if (!data)
+ return FALSE;
if (data->dwLock)
data->dwLock--;
return TRUE;
@@ -2637,7 +2726,9 @@
*/
DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
+ if (!data)
+ return 0;
return data->dwLock;
}
@@ -2702,7 +2793,13 @@
*/
BOOL WINAPI ImmGenerateMessage(HIMC hIMC)
{
- InputContextData *data = hIMC;
+ InputContextData *data = get_imc_data(hIMC);
+
+ if (!data)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
TRACE("%i messages queued\n",data->IMC.dwNumMsgBuf);
if (data->IMC.dwNumMsgBuf > 0)
Modified: trunk/reactos/media/doc/README.WINE
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 28 18:27:58 2014
@@ -85,7 +85,7 @@
reactos/dll/win32/ieframe # Synced to Wine-1.7.27
reactos/dll/win32/imaadp32.acm # Synced to Wine-1.7.17
reactos/dll/win32/imagehlp # Synced to Wine-1.7.17
-reactos/dll/win32/imm32 # Synced to Wine-1.7.17
+reactos/dll/win32/imm32 # Synced to Wine-1.7.27
reactos/dll/win32/inetcomm # Synced to Wine-1.7.17
reactos/dll/win32/inetmib1 # Synced to Wine-1.7.1
reactos/dll/win32/initpki # Synced to Wine-1.7.17