From d7c154a8db0d743340eb210a8715eb2b8dfed8b3 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Wed, 22 Apr 2009 11:14:19 -0500 Subject: [PATCH] msctf: Make use of generated cookies in sinks to allow 64 bit compatibility. --- dlls/msctf/context.c | 12 ++++++++++-- dlls/msctf/msctf_internal.h | 4 ++++ dlls/msctf/threadmgr.c | 12 ++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c index 2fc651f101b..38d8ad6218c 100644 --- a/dlls/msctf/context.c +++ b/dlls/msctf/context.c @@ -382,7 +382,7 @@ static WINAPI HRESULT ContextSource_AdviseSink(ITfSource *iface, return CONNECT_E_CANNOTCONNECT; } list_add_head(&This->pTextEditSink ,&es->entry); - *pdwCookie = (DWORD)es; + *pdwCookie = generate_Cookie(COOKIE_MAGIC_CONTEXTSINK, es); } else { @@ -396,10 +396,18 @@ static WINAPI HRESULT ContextSource_AdviseSink(ITfSource *iface, static WINAPI HRESULT ContextSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie) { - ContextSink *sink = (ContextSink*)pdwCookie; + ContextSink *sink; Context *This = impl_from_ITfSourceVtbl(iface); + TRACE("(%p) %x\n",This,pdwCookie); + if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_CONTEXTSINK) + return E_INVALIDARG; + + sink = (ContextSink*)remove_Cookie(pdwCookie); + if (!sink) + return CONNECT_E_NOCONNECTION; + list_remove(&sink->entry); free_sink(sink); diff --git a/dlls/msctf/msctf_internal.h b/dlls/msctf/msctf_internal.h index 06499f10cc6..a9f79827855 100644 --- a/dlls/msctf/msctf_internal.h +++ b/dlls/msctf/msctf_internal.h @@ -20,6 +20,10 @@ #ifndef __WINE_MSCTF_I_H #define __WINE_MSCTF_I_H + +#define COOKIE_MAGIC_TMSINK 0x0010 +#define COOKIE_MAGIC_CONTEXTSINK 0x0020 + extern DWORD tlsIndex; extern HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut); diff --git a/dlls/msctf/threadmgr.c b/dlls/msctf/threadmgr.c index a73beee86ef..f6f9be485ca 100644 --- a/dlls/msctf/threadmgr.c +++ b/dlls/msctf/threadmgr.c @@ -365,7 +365,7 @@ static WINAPI HRESULT ThreadMgrSource_AdviseSink(ITfSource *iface, return CONNECT_E_CANNOTCONNECT; } list_add_head(&This->ThreadMgrEventSink,&tms->entry); - *pdwCookie = (DWORD)tms; + *pdwCookie = generate_Cookie(COOKIE_MAGIC_TMSINK, tms); } else { @@ -380,10 +380,18 @@ static WINAPI HRESULT ThreadMgrSource_AdviseSink(ITfSource *iface, static WINAPI HRESULT ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie) { - ThreadMgrSink *sink = (ThreadMgrSink*)pdwCookie; + ThreadMgrSink *sink; ThreadMgr *This = impl_from_ITfSourceVtbl(iface); + TRACE("(%p) %x\n",This,pdwCookie); + if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_TMSINK) + return E_INVALIDARG; + + sink = (ThreadMgrSink*)remove_Cookie(pdwCookie); + if (!sink) + return CONNECT_E_NOCONNECTION; + list_remove(&sink->entry); free_sink(sink);