Aric Stewart : ole32: CoGetTreatAsClass should return S_FALSE if it cannot even find the key for the requested CLSID .

Alexandre Julliard julliard at winehq.org
Fri Apr 24 10:00:08 CDT 2009


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

Author: Aric Stewart <aric at codeweavers.com>
Date:   Thu Apr 23 10:19:33 2009 -0500

ole32: CoGetTreatAsClass should return S_FALSE if it cannot even find the key for the requested CLSID.

---

 dlls/ole32/compobj.c       |    3 +++
 dlls/ole32/tests/compobj.c |   19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 3eb0182..4a57009 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -2922,7 +2922,10 @@ HRESULT WINAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID clsidNew)
 
     res = COM_OpenKeyForCLSID(clsidOld, wszTreatAs, KEY_READ, &hkey);
     if (FAILED(res))
+    {
+        res = S_FALSE;
         goto done;
+    }
     if (RegQueryValueW(hkey, NULL, szClsidNew, &len))
     {
         res = S_FALSE;
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index a332d27..d0c6281 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -38,6 +38,7 @@
 HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit);
 HRESULT (WINAPI * pCoGetObjectContext)(REFIID riid, LPVOID *ppv);
 HRESULT (WINAPI * pCoSwitchCallContext)(IUnknown *pObject, IUnknown **ppOldObject);
+HRESULT (WINAPI * pCoGetTreatAsClass)(REFCLSID clsidOld, LPCLSID pClsidNew);
 
 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
 #define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
@@ -1141,6 +1142,22 @@ static void test_CoGetCallContext(void)
     CoUninitialize();
 }
 
+static void test_CoGetTreatAsClass(void)
+{
+    HRESULT hr;
+    CLSID out;
+    static GUID deadbeef = {0xdeadbeef,0xdead,0xbeef,{0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef}};
+
+    if (!pCoGetTreatAsClass)
+    {
+        win_skip("CoGetTreatAsClass not present\n");
+        return;
+    }
+    hr = pCoGetTreatAsClass(&deadbeef,&out);
+    ok (hr == S_FALSE, "expected S_FALSE got %x\n",hr);
+    ok (IsEqualGUID(&out,&deadbeef), "expected to get same clsid back\n");
+}
+
 static void test_CoInitializeEx(void)
 {
     HRESULT hr;
@@ -1167,6 +1184,7 @@ START_TEST(compobj)
     HMODULE hOle32 = GetModuleHandle("ole32");
     pCoGetObjectContext = (void*)GetProcAddress(hOle32, "CoGetObjectContext");
     pCoSwitchCallContext = (void*)GetProcAddress(hOle32, "CoSwitchCallContext");
+    pCoGetTreatAsClass = (void*)GetProcAddress(hOle32,"CoGetTreatAsClass");
     if (!(pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx")))
     {
         trace("You need DCOM95 installed to run this test\n");
@@ -1192,5 +1210,6 @@ START_TEST(compobj)
     test_CoFreeUnusedLibraries();
     test_CoGetObjectContext();
     test_CoGetCallContext();
+    test_CoGetTreatAsClass();
     test_CoInitializeEx();
 }




More information about the wine-cvs mailing list