Rob Shearman : ole32: Fix CoRevokeClassObject to return RPC_E_WRONG_THREAD if it was called from a different apartment than the one that called CoRegisterClassObject .

Alexandre Julliard julliard at wine.codeweavers.com
Tue May 8 06:59:40 CDT 2007


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Tue May  8 00:00:41 2007 +0100

ole32: Fix CoRevokeClassObject to return RPC_E_WRONG_THREAD if it was called from a different apartment than the one that called CoRegisterClassObject.

---

 dlls/ole32/compobj.c       |   21 +++++++++++++++++++--
 dlls/ole32/tests/compobj.c |    2 --
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 808d94e..5ba74d7 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -1809,9 +1809,17 @@ HRESULT WINAPI CoRevokeClassObject(
 {
   HRESULT hr = E_INVALIDARG;
   RegisteredClass *curClass;
+  APARTMENT *apt;
 
   TRACE("(%08x)\n",dwRegister);
 
+  apt = COM_CurrentApt();
+  if (!apt)
+  {
+    ERR("COM was not initialized\n");
+    return CO_E_NOTINITIALIZED;
+  }
+
   EnterCriticalSection( &csRegisteredClassList );
 
   LIST_FOR_EACH_ENTRY(curClass, &RegisteredClassList, RegisteredClass, entry)
@@ -1821,8 +1829,17 @@ HRESULT WINAPI CoRevokeClassObject(
      */
     if (curClass->dwCookie == dwRegister)
     {
-      COM_RevokeRegisteredClassObject(curClass);
-      hr = S_OK;
+      if (curClass->apartment_id == apt->oxid)
+      {
+          COM_RevokeRegisteredClassObject(curClass);
+          hr = S_OK;
+      }
+      else
+      {
+          ERR("called from wrong apartment, should be called from %s\n",
+              wine_dbgstr_longlong(curClass->apartment_id));
+          hr = RPC_E_WRONG_THREAD;
+      }
       break;
     }
   }
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index d9d93a5..739dec1 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -847,7 +847,6 @@ static void test_registered_object_thread_affinity(void)
     WaitForSingleObject(thread, INFINITE);
     GetExitCodeThread(thread, &exitcode);
     hr = exitcode;
-    todo_wine
     ok(hr == RPC_E_WRONG_THREAD, "CoRevokeClassObject called from different "
        "thread to where registered should return RPC_E_WRONG_THREAD instead of 0x%08x\n", hr);
 
@@ -860,7 +859,6 @@ static void test_registered_object_thread_affinity(void)
         "thread should return S_OK instead of 0x%08x\n", hr);
 
     hr = CoRevokeClassObject(cookie);
-    todo_wine
     ok_ole_success(hr, "CoRevokeClassObject");
 
     CoUninitialize();




More information about the wine-cvs mailing list