From: Aric Stewart Subject: (Retry)[6/6]imm32: limit cross thread access to ImmSet* functions Message-Id: <53D95664.8030908@codeweavers.com> Date: Wed, 30 Jul 2014 15:32:36 -0500 Resolves bug 35361 --- dlls/imm32/imm.c | 21 +++++++++++++++++++++ dlls/imm32/tests/imm32.c | 28 ++++++++++++++-------------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index 85e3052..ba4a823 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -2282,6 +2282,9 @@ BOOL WINAPI ImmSetCandidateWindow( if (!data || !lpCandidate) return FALSE; + if (IMM_IsCrossThreadAccess(NULL, hIMC)) + return FALSE; + TRACE("\t%x, %x, (%i,%i), (%i,%i - %i,%i)\n", lpCandidate->dwIndex, lpCandidate->dwStyle, lpCandidate->ptCurrentPos.x, lpCandidate->ptCurrentPos.y, @@ -2312,6 +2315,9 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) return FALSE; } + if (IMM_IsCrossThreadAccess(NULL, hIMC)) + return FALSE; + memcpy(&data->IMC.lfFont.W,lplf,sizeof(LOGFONTA)); MultiByteToWideChar(CP_ACP, 0, lplf->lfFaceName, -1, data->IMC.lfFont.W.lfFaceName, LF_FACESIZE); @@ -2335,6 +2341,9 @@ BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) return FALSE; } + if (IMM_IsCrossThreadAccess(NULL, hIMC)) + return FALSE; + data->IMC.lfFont.W = *lplf; ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCOMPOSITIONFONT); ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONFONT, 0); @@ -2476,6 +2485,9 @@ BOOL WINAPI ImmSetCompositionWindow( return FALSE; } + if (IMM_IsCrossThreadAccess(NULL, hIMC)) + return FALSE; + data->IMC.cfCompForm = *lpCompForm; if (IsWindowVisible(data->immKbd->UIWnd)) @@ -2510,6 +2522,9 @@ BOOL WINAPI ImmSetConversionStatus( return FALSE; } + if (IMM_IsCrossThreadAccess(NULL, hIMC)) + return FALSE; + if ( fdwConversion != data->IMC.fdwConversion ) { oldConversion = data->IMC.fdwConversion; @@ -2543,6 +2558,9 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) return FALSE; } + if (IMM_IsCrossThreadAccess(NULL, hIMC)) + return FALSE; + if (data->immKbd->UIWnd == NULL) { /* create the ime window */ @@ -2579,6 +2597,9 @@ BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) return FALSE; } + if (IMM_IsCrossThreadAccess(NULL, hIMC)) + return FALSE; + TRACE("\t(%i,%i)\n", lpptPos->x, lpptPos->y); data->IMC.ptStatusWndPos = *lpptPos; diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c index 164be08..f5dec61 100644 --- a/dlls/imm32/tests/imm32.c +++ b/dlls/imm32/tests/imm32.c @@ -525,15 +525,15 @@ static void test_ImmThreads(void) ok(rc == 0, "ImmGetOpenStatus failed\n"); rc = ImmSetOpenStatus(otherHimc, TRUE); - todo_wine ok(rc == 0, "ImmSetOpenStatus should fail\n"); + ok(rc == 0, "ImmSetOpenStatus should fail\n"); rc = ImmSetOpenStatus(threadinfo.u_himc, TRUE); - todo_wine ok(rc == 0, "ImmSetOpenStatus should fail\n"); + ok(rc == 0, "ImmSetOpenStatus should fail\n"); rc = ImmGetOpenStatus(otherHimc); - todo_wine ok(rc == 0, "ImmGetOpenStatus failed\n"); + ok(rc == 0, "ImmGetOpenStatus failed\n"); rc = ImmGetOpenStatus(threadinfo.u_himc); ok (rc == 1 || broken(rc == 0), "ImmGetOpenStatus should return 1\n"); rc = ImmSetOpenStatus(otherHimc, FALSE); - todo_wine ok(rc == 0, "ImmSetOpenStatus should fail\n"); + ok(rc == 0, "ImmSetOpenStatus should fail\n"); rc = ImmGetOpenStatus(otherHimc); ok(rc == 0, "ImmGetOpenStatus failed\n"); @@ -548,9 +548,9 @@ static void test_ImmThreads(void) rc = ImmGetCompositionFontA(threadinfo.u_himc, &lf); ok(rc != 0 || broken(rc == 0), "ImmGetCompositionFont user himc failed\n"); rc = ImmSetCompositionFontA(otherHimc, &lf); - todo_wine ok(rc == 0, "ImmSetCompositionFont should fail\n"); + ok(rc == 0, "ImmSetCompositionFont should fail\n"); rc = ImmSetCompositionFontA(threadinfo.u_himc, &lf); - todo_wine ok(rc == 0, "ImmSetCompositionFont should fail\n"); + ok(rc == 0, "ImmSetCompositionFont should fail\n"); /* CompositionWindow */ rc = ImmSetCompositionWindow(himc, &cf); @@ -559,9 +559,9 @@ static void test_ImmThreads(void) ok(rc != 0, "ImmGetCompositionWindow failed\n"); rc = ImmSetCompositionWindow(otherHimc, &cf); - todo_wine ok(rc == 0, "ImmSetCompositionWindow should fail\n"); + ok(rc == 0, "ImmSetCompositionWindow should fail\n"); rc = ImmSetCompositionWindow(threadinfo.u_himc, &cf); - todo_wine ok(rc == 0, "ImmSetCompositionWindow should fail\n"); + ok(rc == 0, "ImmSetCompositionWindow should fail\n"); rc = ImmGetCompositionWindow(otherHimc, &cf); ok(rc != 0 || broken(rc == 0), "ImmGetCompositionWindow failed\n"); rc = ImmGetCompositionWindow(threadinfo.u_himc, &cf); @@ -578,9 +578,9 @@ static void test_ImmThreads(void) rc = ImmGetConversionStatus(threadinfo.u_himc, &status, &sentence); ok(rc != 0 || broken(rc == 0), "ImmGetConversionStatus failed\n"); rc = ImmSetConversionStatus(otherHimc, status, sentence); - todo_wine ok(rc == 0, "ImmSetConversionStatus should fail\n"); + ok(rc == 0, "ImmSetConversionStatus should fail\n"); rc = ImmSetConversionStatus(threadinfo.u_himc, status, sentence); - todo_wine ok(rc == 0, "ImmSetConversionStatus should fail\n"); + ok(rc == 0, "ImmSetConversionStatus should fail\n"); /* StatusWindowPos */ rc = ImmSetStatusWindowPos(himc, &pt); @@ -589,9 +589,9 @@ static void test_ImmThreads(void) ok(rc != 0, "ImmGetStatusWindowPos failed\n"); rc = ImmSetStatusWindowPos(otherHimc, &pt); - todo_wine ok(rc == 0, "ImmSetStatusWindowPos should fail\n"); + ok(rc == 0, "ImmSetStatusWindowPos should fail\n"); rc = ImmSetStatusWindowPos(threadinfo.u_himc, &pt); - todo_wine ok(rc == 0, "ImmSetStatusWindowPos should fail\n"); + ok(rc == 0, "ImmSetStatusWindowPos should fail\n"); rc = ImmGetStatusWindowPos(otherHimc, &pt); ok(rc != 0 || broken(rc == 0), "ImmGetStatusWindowPos failed\n"); rc = ImmGetStatusWindowPos(threadinfo.u_himc, &pt); @@ -624,11 +624,11 @@ static void test_ImmThreads(void) rc = ImmGetCandidateWindow(otherHimc, 0, &cdf); ok (rc == 0, "ImmGetCandidateWindow should fail\n"); rc = ImmSetCandidateWindow(otherHimc, &cdf); - todo_wine ok (rc == 0, "ImmSetCandidateWindow should fail\n"); + ok (rc == 0, "ImmSetCandidateWindow should fail\n"); rc = ImmGetCandidateWindow(threadinfo.u_himc, 0, &cdf); ok (rc == 1, "ImmGetCandidateWindow should succeed\n"); rc = ImmSetCandidateWindow(threadinfo.u_himc, &cdf); - todo_wine ok (rc == 0, "ImmSetCandidateWindow should fail\n"); + ok (rc == 0, "ImmSetCandidateWindow should fail\n"); ImmReleaseContext(threadinfo.hwnd,otherHimc); ImmReleaseContext(hwnd,himc);