Aric Stewart : msctf: Make use of generated cookies in sinks to allow 64 bit compatibility.

Alexandre Julliard julliard at winehq.org
Thu Apr 23 11:27:24 CDT 2009


Module: wine
Branch: master
Commit: d7c154a8db0d743340eb210a8715eb2b8dfed8b3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d7c154a8db0d743340eb210a8715eb2b8dfed8b3

Author: Aric Stewart <aric at codeweavers.com>
Date:   Wed Apr 22 11:14:19 2009 -0500

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 2fc651f..38d8ad6 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 06499f1..a9f7982 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 a73beee..f6f9be4 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);
 




More information about the wine-cvs mailing list