2004-12-21 15:51:27 +01:00
|
|
|
/*
|
|
|
|
* Marshaling Tests
|
|
|
|
*
|
|
|
|
* Copyright 2004 Robert Shearman
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-12-21 15:51:27 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define _WIN32_DCOM
|
|
|
|
#define COBJMACROS
|
2006-09-29 12:45:44 +02:00
|
|
|
#define CONST_VTABLE
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
2007-03-09 18:51:36 +01:00
|
|
|
#include <stdio.h>
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "objbase.h"
|
2008-07-08 16:17:17 +02:00
|
|
|
#include "olectl.h"
|
2006-06-28 22:24:58 +02:00
|
|
|
#include "shlguid.h"
|
2008-03-23 11:04:04 +01:00
|
|
|
#include "shobjidl.h"
|
2009-06-23 09:37:30 +02:00
|
|
|
#include "initguid.h"
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2008-07-08 16:17:17 +02:00
|
|
|
DEFINE_GUID(CLSID_StdGlobalInterfaceTable,0x00000323,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
|
2011-05-30 12:45:31 +02:00
|
|
|
DEFINE_GUID(CLSID_ManualResetEvent, 0x0000032c,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
|
2008-07-08 16:17:17 +02:00
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* functions that are not present on all versions of Windows */
|
2010-10-01 13:37:14 +02:00
|
|
|
static HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit);
|
2013-08-21 22:00:39 +02:00
|
|
|
static HRESULT (WINAPI *pDllGetClassObject)(REFCLSID,REFIID,LPVOID);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
/* helper macros to make tests a bit leaner */
|
2006-10-14 04:54:46 +02:00
|
|
|
#define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
|
|
|
|
#define ok_no_locks() ok(cLocks == 0, "Number of locks should be 0, but actually is %d\n", cLocks)
|
|
|
|
#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
|
2013-10-24 17:16:47 +02:00
|
|
|
#define ok_non_zero_external_conn() do {if (with_external_conn) ok(external_connections, "got no external connections\n");} while(0);
|
|
|
|
#define ok_zero_external_conn() do {if (with_external_conn) ok(!external_connections, "got %d external connections\n", external_connections);} while(0);
|
|
|
|
#define ok_last_release_closes(b) do {if (with_external_conn) ok(last_release_closes == b, "got %d expected %d\n", last_release_closes, b);} while(0);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2006-01-20 16:14:32 +01:00
|
|
|
static const IID IID_IWineTest =
|
|
|
|
{
|
|
|
|
0x5201163f,
|
|
|
|
0x8164,
|
|
|
|
0x4fd0,
|
|
|
|
{0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd}
|
|
|
|
}; /* 5201163f-8164-4fd0-a1a2-5d5a3654d3bd */
|
|
|
|
|
2007-03-27 19:18:05 +02:00
|
|
|
static const IID IID_IRemUnknown =
|
|
|
|
{
|
|
|
|
0x00000131,
|
|
|
|
0x0000,
|
|
|
|
0x0000,
|
|
|
|
{0xc0,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
|
|
|
|
};
|
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
#define EXTENTID_WineTest IID_IWineTest
|
2007-02-23 20:38:11 +01:00
|
|
|
#define CLSID_WineTest IID_IWineTest
|
2006-12-29 15:44:14 +01:00
|
|
|
|
2007-03-09 18:51:36 +01:00
|
|
|
static const CLSID CLSID_WineOOPTest =
|
|
|
|
{
|
|
|
|
0x5201163f,
|
|
|
|
0x8164,
|
|
|
|
0x4fd0,
|
|
|
|
{0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd}
|
|
|
|
}; /* 5201163f-8164-4fd0-a1a2-5d5a3654d3bd */
|
|
|
|
|
2006-06-28 22:24:58 +02:00
|
|
|
static void test_cocreateinstance_proxy(void)
|
|
|
|
{
|
|
|
|
IUnknown *pProxy;
|
|
|
|
IMultiQI *pMQI;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_ShellDesktop, NULL, CLSCTX_INPROC, &IID_IUnknown, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoCreateInstance);
|
|
|
|
hr = IUnknown_QueryInterface(pProxy, &IID_IMultiQI, (void **)&pMQI);
|
|
|
|
ok(hr == S_OK, "created object is not a proxy, so was created in the wrong apartment\n");
|
|
|
|
if (hr == S_OK)
|
|
|
|
IMultiQI_Release(pMQI);
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
static const LARGE_INTEGER ullZero;
|
|
|
|
static LONG cLocks;
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void LockModule(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
InterlockedIncrement(&cLocks);
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void UnlockModule(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
InterlockedDecrement(&cLocks);
|
|
|
|
}
|
|
|
|
|
2013-10-18 13:52:46 +02:00
|
|
|
static BOOL with_external_conn;
|
|
|
|
static DWORD external_connections;
|
|
|
|
static BOOL last_release_closes;
|
|
|
|
|
|
|
|
static HRESULT WINAPI ExternalConnection_QueryInterface(IExternalConnection *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2015-08-17 15:11:55 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2013-10-18 13:52:46 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ExternalConnection_AddRef(IExternalConnection *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ExternalConnection_Release(IExternalConnection *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI ExternalConnection_AddConnection(IExternalConnection *iface, DWORD extconn, DWORD reserved)
|
|
|
|
{
|
|
|
|
trace("add connection\n");
|
|
|
|
return ++external_connections;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DWORD WINAPI ExternalConnection_ReleaseConnection(IExternalConnection *iface, DWORD extconn,
|
|
|
|
DWORD reserved, BOOL fLastReleaseCloses)
|
|
|
|
{
|
|
|
|
trace("release connection %d\n", fLastReleaseCloses);
|
|
|
|
last_release_closes = fLastReleaseCloses;
|
|
|
|
return --external_connections;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IExternalConnectionVtbl ExternalConnectionVtbl = {
|
|
|
|
ExternalConnection_QueryInterface,
|
|
|
|
ExternalConnection_AddRef,
|
|
|
|
ExternalConnection_Release,
|
|
|
|
ExternalConnection_AddConnection,
|
|
|
|
ExternalConnection_ReleaseConnection
|
|
|
|
};
|
|
|
|
|
|
|
|
static IExternalConnection ExternalConnection = { &ExternalConnectionVtbl };
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2005-01-19 18:00:20 +01:00
|
|
|
static HRESULT WINAPI Test_IUnknown_QueryInterface(
|
|
|
|
LPUNKNOWN iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
*ppvObj = iface;
|
2005-01-19 18:00:20 +01:00
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-01-26 21:42:30 +01:00
|
|
|
*ppvObj = NULL;
|
2005-01-19 18:00:20 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Test_IUnknown_AddRef(LPUNKNOWN iface)
|
|
|
|
{
|
|
|
|
LockModule();
|
|
|
|
return 2; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Test_IUnknown_Release(LPUNKNOWN iface)
|
|
|
|
{
|
|
|
|
UnlockModule();
|
|
|
|
return 1; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IUnknownVtbl TestUnknown_Vtbl =
|
2005-01-19 18:00:20 +01:00
|
|
|
{
|
|
|
|
Test_IUnknown_QueryInterface,
|
|
|
|
Test_IUnknown_AddRef,
|
|
|
|
Test_IUnknown_Release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static IUnknown Test_Unknown = { &TestUnknown_Vtbl };
|
|
|
|
|
2015-09-02 11:21:16 +02:00
|
|
|
static ULONG WINAPI TestCrash_IUnknown_Release(LPUNKNOWN iface)
|
|
|
|
{
|
|
|
|
UnlockModule();
|
|
|
|
if(!cLocks) {
|
|
|
|
trace("crashing...\n");
|
|
|
|
*(int**)0xc = 0;
|
|
|
|
}
|
|
|
|
return 1; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl TestCrashUnknown_Vtbl =
|
|
|
|
{
|
|
|
|
Test_IUnknown_QueryInterface,
|
|
|
|
Test_IUnknown_AddRef,
|
|
|
|
TestCrash_IUnknown_Release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static IUnknown TestCrash_Unknown = { &TestCrashUnknown_Vtbl };
|
2005-01-19 18:00:20 +01:00
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
2007-03-27 19:18:05 +02:00
|
|
|
IsEqualGUID(riid, &IID_IClassFactory) ||
|
|
|
|
/* the only other interface Wine is currently able to marshal (for testing two proxies) */
|
|
|
|
IsEqualGUID(riid, &IID_IRemUnknown))
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
*ppvObj = iface;
|
2004-12-21 15:51:27 +01:00
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 13:52:46 +02:00
|
|
|
if (with_external_conn && IsEqualGUID(riid, &IID_IExternalConnection))
|
|
|
|
{
|
|
|
|
*ppvObj = &ExternalConnection;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-01-26 21:42:30 +01:00
|
|
|
*ppvObj = NULL;
|
2004-12-21 15:51:27 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Test_IClassFactory_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
LockModule();
|
|
|
|
return 2; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Test_IClassFactory_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
UnlockModule();
|
|
|
|
return 1; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Test_IClassFactory_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2005-01-19 18:00:20 +01:00
|
|
|
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
|
|
|
|
return IUnknown_QueryInterface((IUnknown*)&Test_Unknown, riid, ppvObj);
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Test_IClassFactory_LockServer(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
BOOL fLock)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IClassFactoryVtbl TestClassFactory_Vtbl =
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
Test_IClassFactory_QueryInterface,
|
|
|
|
Test_IClassFactory_AddRef,
|
|
|
|
Test_IClassFactory_Release,
|
|
|
|
Test_IClassFactory_CreateInstance,
|
|
|
|
Test_IClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static IClassFactory Test_ClassFactory = { &TestClassFactory_Vtbl };
|
|
|
|
|
|
|
|
#define RELEASEMARSHALDATA WM_USER
|
|
|
|
|
|
|
|
struct host_object_data
|
|
|
|
{
|
|
|
|
IStream *stream;
|
|
|
|
IID iid;
|
|
|
|
IUnknown *object;
|
|
|
|
MSHLFLAGS marshal_flags;
|
|
|
|
HANDLE marshal_event;
|
|
|
|
IMessageFilter *filter;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD CALLBACK host_object_proc(LPVOID p)
|
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
struct host_object_data *data = p;
|
2004-12-21 15:51:27 +01:00
|
|
|
HRESULT hr;
|
|
|
|
MSG msg;
|
|
|
|
|
2005-02-01 15:18:10 +01:00
|
|
|
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
if (data->filter)
|
|
|
|
{
|
|
|
|
IMessageFilter * prev_filter = NULL;
|
|
|
|
hr = CoRegisterMessageFilter(data->filter, &prev_filter);
|
|
|
|
if (prev_filter) IMessageFilter_Release(prev_filter);
|
|
|
|
ok_ole_success(hr, CoRegisterMessageFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoMarshalInterface(data->stream, &data->iid, data->object, MSHCTX_INPROC, NULL, data->marshal_flags);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
2005-01-12 20:28:37 +01:00
|
|
|
/* force the message queue to be created before signaling parent thread */
|
2013-10-15 20:37:46 +02:00
|
|
|
PeekMessageA(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
2005-01-12 20:28:37 +01:00
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
SetEvent(data->marshal_event);
|
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
while (GetMessageA(&msg, NULL, 0, 0))
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
if (msg.hwnd == NULL && msg.message == RELEASEMARSHALDATA)
|
|
|
|
{
|
|
|
|
CoReleaseMarshalData(data->stream);
|
|
|
|
SetEvent((HANDLE)msg.lParam);
|
|
|
|
}
|
|
|
|
else
|
2013-10-15 20:37:46 +02:00
|
|
|
DispatchMessageA(&msg);
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD start_host_object2(IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, IMessageFilter *filter, HANDLE *thread)
|
|
|
|
{
|
|
|
|
DWORD tid = 0;
|
2013-10-15 20:37:46 +02:00
|
|
|
HANDLE marshal_event = CreateEventA(NULL, FALSE, FALSE, NULL);
|
2005-03-22 19:26:06 +01:00
|
|
|
struct host_object_data *data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
data->stream = stream;
|
|
|
|
data->iid = *riid;
|
|
|
|
data->object = object;
|
|
|
|
data->marshal_flags = marshal_flags;
|
|
|
|
data->marshal_event = marshal_event;
|
|
|
|
data->filter = filter;
|
|
|
|
|
|
|
|
*thread = CreateThread(NULL, 0, host_object_proc, data, 0, &tid);
|
|
|
|
|
|
|
|
/* wait for marshaling to complete before returning */
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(marshal_event, 10000), "wait timed out\n" );
|
2004-12-21 15:51:27 +01:00
|
|
|
CloseHandle(marshal_event);
|
|
|
|
|
|
|
|
return tid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD start_host_object(IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, HANDLE *thread)
|
|
|
|
{
|
|
|
|
return start_host_object2(stream, riid, object, marshal_flags, NULL, thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* asks thread to release the marshal data because it has to be done by the
|
|
|
|
* same thread that marshaled the interface in the first place. */
|
2013-10-24 17:16:48 +02:00
|
|
|
static void release_host_object(DWORD tid, WPARAM wp)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
HANDLE event = CreateEventA(NULL, FALSE, FALSE, NULL);
|
2013-10-24 17:16:48 +02:00
|
|
|
PostThreadMessageA(tid, RELEASEMARSHALDATA, wp, (LPARAM)event);
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(event, 10000), "wait timed out\n" );
|
2004-12-21 15:51:27 +01:00
|
|
|
CloseHandle(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void end_host_object(DWORD tid, HANDLE thread)
|
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
BOOL ret = PostThreadMessageA(tid, WM_QUIT, 0, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(ret, "PostThreadMessage failed with error %d\n", GetLastError());
|
2004-12-21 15:51:27 +01:00
|
|
|
/* be careful of races - don't return until hosting thread has terminated */
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
|
2004-12-21 15:51:27 +01:00
|
|
|
CloseHandle(thread);
|
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
/* tests failure case of interface not having a marshaler specified in the
|
|
|
|
* registry */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_no_marshaler(void)
|
2005-01-28 13:39:13 +01:00
|
|
|
{
|
|
|
|
IStream *pStream;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IWineTest, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_NOINTERFACE, "CoMarshalInterface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
IStream_Release(pStream);
|
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* tests normal marshal and then release without unmarshaling */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_normal_marshal_and_release(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoReleaseMarshalData(pStream);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
2004-12-27 20:21:47 +01:00
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tests success case of a same-thread marshal and unmarshal */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_normal_marshal_and_unmarshal(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
}
|
|
|
|
|
2005-03-30 19:08:31 +02:00
|
|
|
/* tests failure case of unmarshaling a freed object */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_marshal_and_unmarshal_invalid(void)
|
2005-01-28 13:39:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IClassFactory *pProxy = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
void * dummy;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoReleaseMarshalData(pStream);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
todo_wine { ok_ole_success(hr, CoUnmarshalInterface); }
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
if (pProxy)
|
|
|
|
{
|
|
|
|
hr = IClassFactory_CreateInstance(pProxy, NULL, &IID_IUnknown, &dummy);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == RPC_E_DISCONNECTED, "Remote call should have returned RPC_E_DISCONNECTED, instead of 0x%08x\n", hr);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
IClassFactory_Release(pProxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:18:12 +01:00
|
|
|
static void test_same_apartment_unmarshal_failure(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream;
|
|
|
|
IUnknown *pProxy;
|
|
|
|
static const LARGE_INTEGER llZero;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2007-01-09 18:18:12 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IUnknown, (IUnknown *)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-01-09 18:18:12 +01:00
|
|
|
|
|
|
|
hr = IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
ok_ole_success(hr, IStream_Seek);
|
|
|
|
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IParseDisplayName, (void **)&pProxy);
|
|
|
|
ok(hr == E_NOINTERFACE, "CoUnmarshalInterface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
2007-11-10 17:04:30 +01:00
|
|
|
|
|
|
|
IStream_Release(pStream);
|
2007-01-09 18:18:12 +01:00
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* tests success case of an interthread marshal */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_interthread_marshal_and_unmarshal(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
2005-01-17 14:39:40 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2006-06-28 22:25:14 +02:00
|
|
|
/* the number of external references that Wine's proxy manager normally gives
|
|
|
|
* out, so we can test the border case of running out of references */
|
|
|
|
#define NORMALEXTREFS 5
|
|
|
|
|
2005-08-27 11:25:16 +02:00
|
|
|
/* tests success case of an interthread marshal and then marshaling the proxy */
|
|
|
|
static void test_proxy_marshal_and_unmarshal(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
2006-06-28 22:25:14 +02:00
|
|
|
int i;
|
2005-08-27 11:25:16 +02:00
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2005-08-27 11:25:16 +02:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-08-27 11:25:16 +02:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
/* marshal the proxy */
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, pProxy, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
2006-06-28 22:25:14 +02:00
|
|
|
/* marshal 5 more times to exhaust the normal external references of 5 */
|
|
|
|
for (i = 0; i < NORMALEXTREFS; i++)
|
|
|
|
{
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, pProxy, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
/* release the original proxy to test that we successfully keep the
|
|
|
|
* original object alive */
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
2005-08-27 11:25:16 +02:00
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2006-06-28 22:25:14 +02:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-08-27 11:25:16 +02:00
|
|
|
|
2006-06-28 22:25:14 +02:00
|
|
|
IUnknown_Release(pProxy2);
|
2005-08-27 11:25:16 +02:00
|
|
|
|
2006-06-28 22:25:14 +02:00
|
|
|
/* unmarshal all of the proxies to check that the object stub still exists */
|
|
|
|
for (i = 0; i < NORMALEXTREFS; i++)
|
|
|
|
{
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2005-08-27 11:25:16 +02:00
|
|
|
|
2006-06-28 22:25:14 +02:00
|
|
|
IUnknown_Release(pProxy2);
|
|
|
|
}
|
2005-08-27 11:25:16 +02:00
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2005-08-27 11:25:16 +02:00
|
|
|
|
2006-06-28 22:25:14 +02:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
2005-08-27 11:25:16 +02:00
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2006-03-01 13:18:14 +01:00
|
|
|
/* tests success case of an interthread marshal and then marshaling the proxy
|
|
|
|
* using an iid that hasn't previously been unmarshaled */
|
|
|
|
static void test_proxy_marshal_and_unmarshal2(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2006-03-01 13:18:14 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IUnknown, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2006-03-01 13:18:14 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IUnknown, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
/* marshal the proxy */
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, pProxy, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
/* unmarshal the second proxy to the object */
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
/* now the proxies should be as follows:
|
|
|
|
* pProxy -> &Test_ClassFactory
|
|
|
|
* pProxy2 -> &Test_ClassFactory
|
|
|
|
* they should NOT be as follows:
|
|
|
|
* pProxy -> &Test_ClassFactory
|
|
|
|
* pProxy2 -> pProxy
|
|
|
|
* the above can only really be tested by looking in +ole traces
|
|
|
|
*/
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2006-03-01 13:18:14 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy2);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2006-03-01 13:18:14 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2007-05-21 17:43:09 +02:00
|
|
|
/* tests success case of an interthread marshal and then table-weak-marshaling the proxy */
|
|
|
|
static void test_proxy_marshal_and_unmarshal_weak(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
/* marshal the proxy */
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, pProxy, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLEWEAK);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
/* release the original proxy to test that we successfully keep the
|
|
|
|
* original object alive */
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == CO_E_OBJNOTREG, "CoUnmarshalInterface should return CO_E_OBJNOTREG instead of 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests success case of an interthread marshal and then table-strong-marshaling the proxy */
|
|
|
|
static void test_proxy_marshal_and_unmarshal_strong(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
/* marshal the proxy */
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, pProxy, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLESTRONG);
|
|
|
|
ok(hr == S_OK /* WinNT */ || hr == E_INVALIDARG /* Win9x */,
|
|
|
|
"CoMarshalInterface should have return S_OK or E_INVALIDARG instead of 0x%08x\n", hr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
/* release the original proxy to test that we successfully keep the
|
|
|
|
* original object alive */
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy2);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2007-05-21 17:43:09 +02:00
|
|
|
|
|
|
|
end:
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
todo_wine {
|
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
|
|
|
}
|
2007-05-21 17:43:09 +02:00
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* tests that stubs are released when the containing apartment is destroyed */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_marshal_stub_apartment_shutdown(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
2005-02-01 15:18:10 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
2005-01-14 17:48:34 +01:00
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
todo_wine {
|
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
|
|
|
}
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests that proxies are released when the containing apartment is destroyed */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_marshal_proxy_apartment_shutdown(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
2005-02-01 15:18:10 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
2005-01-14 18:20:13 +01:00
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
2005-02-01 15:18:10 +01:00
|
|
|
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
/* tests that proxies are released when the containing mta apartment is destroyed */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_marshal_proxy_mta_apartment_shutdown(void)
|
2005-01-28 13:39:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
CoUninitialize();
|
2005-02-14 12:01:51 +01:00
|
|
|
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-02-14 12:01:51 +01:00
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
2005-02-01 15:18:10 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2005-01-28 13:39:13 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
2005-02-14 12:01:51 +01:00
|
|
|
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
2005-01-28 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ncu_params
|
|
|
|
{
|
2005-07-19 21:12:47 +02:00
|
|
|
LPSTREAM stream;
|
|
|
|
HANDLE marshal_event;
|
|
|
|
HANDLE unmarshal_event;
|
2005-01-28 13:39:13 +01:00
|
|
|
};
|
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
/* helper for test_no_couninitialize_server */
|
|
|
|
static DWORD CALLBACK no_couninitialize_server_proc(LPVOID p)
|
2005-01-28 13:39:13 +01:00
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
struct ncu_params *ncu_params = p;
|
2005-07-19 21:12:47 +02:00
|
|
|
HRESULT hr;
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
hr = CoMarshalInterface(ncu_params->stream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
SetEvent(ncu_params->marshal_event);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(ncu_params->unmarshal_event, 10000), "wait timed out\n" );
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
/* die without calling CoUninitialize */
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
return 0;
|
2005-01-28 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
/* tests apartment that an apartment with a stub is released without deadlock
|
|
|
|
* if the owning thread exits */
|
2006-01-12 11:53:19 +01:00
|
|
|
static void test_no_couninitialize_server(void)
|
2005-01-28 13:39:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
struct ncu_params ncu_params;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
ncu_params.marshal_event = CreateEventA(NULL, TRUE, FALSE, NULL);
|
|
|
|
ncu_params.unmarshal_event = CreateEventA(NULL, TRUE, FALSE, NULL);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
ncu_params.stream = pStream;
|
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
thread = CreateThread(NULL, 0, no_couninitialize_server_proc, &ncu_params, 0, &tid);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(ncu_params.marshal_event, 10000), "wait timed out\n" );
|
2005-01-28 13:39:13 +01:00
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-07-19 21:12:47 +02:00
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
SetEvent(ncu_params.unmarshal_event);
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2005-02-08 14:42:15 +01:00
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
todo_wine {
|
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
|
|
|
}
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
CloseHandle(thread);
|
|
|
|
CloseHandle(ncu_params.marshal_event);
|
|
|
|
CloseHandle(ncu_params.unmarshal_event);
|
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
}
|
|
|
|
|
2005-07-19 21:12:47 +02:00
|
|
|
/* STA -> STA call during DLL_THREAD_DETACH */
|
|
|
|
static DWORD CALLBACK no_couninitialize_client_proc(LPVOID p)
|
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
struct ncu_params *ncu_params = p;
|
2005-07-19 21:12:47 +02:00
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
|
|
|
|
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
|
|
|
|
|
|
|
hr = CoUnmarshalInterface(ncu_params->stream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2006-10-23 12:28:58 +02:00
|
|
|
IStream_Release(ncu_params->stream);
|
2005-07-19 21:12:47 +02:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
/* die without calling CoUninitialize */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests STA -> STA call during DLL_THREAD_DETACH doesn't deadlock */
|
2006-01-12 11:53:19 +01:00
|
|
|
static void test_no_couninitialize_client(void)
|
2005-07-19 21:12:47 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
DWORD host_tid;
|
|
|
|
HANDLE thread;
|
|
|
|
HANDLE host_thread;
|
|
|
|
struct ncu_params ncu_params;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2005-07-19 21:12:47 +02:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
ncu_params.stream = pStream;
|
|
|
|
|
|
|
|
/* NOTE: assumes start_host_object uses an STA to host the object, as MTAs
|
|
|
|
* always deadlock when called from within DllMain */
|
|
|
|
host_tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown *)&Test_ClassFactory, MSHLFLAGS_NORMAL, &host_thread);
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-07-19 21:12:47 +02:00
|
|
|
|
|
|
|
thread = CreateThread(NULL, 0, no_couninitialize_client_proc, &ncu_params, 0, &tid);
|
|
|
|
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
|
2005-07-19 21:12:47 +02:00
|
|
|
CloseHandle(thread);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2005-07-19 21:12:47 +02:00
|
|
|
|
|
|
|
end_host_object(host_tid, host_thread);
|
|
|
|
}
|
|
|
|
|
2015-09-02 11:21:16 +02:00
|
|
|
static BOOL crash_thread_success;
|
|
|
|
|
|
|
|
static DWORD CALLBACK crash_couninitialize_proc(void *p)
|
|
|
|
{
|
|
|
|
IStream *stream;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
|
|
|
|
hr = CoMarshalInterface(stream, &IID_IUnknown, &TestCrash_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
|
|
|
|
hr = CoReleaseMarshalData(stream);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
hr = CoMarshalInterface(stream, &IID_IUnknown, &TestCrash_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
trace("CoUninitialize >>>\n");
|
|
|
|
CoUninitialize();
|
|
|
|
trace("CoUninitialize <<<\n");
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
crash_thread_success = TRUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_crash_couninitialize(void)
|
|
|
|
{
|
|
|
|
HANDLE thread;
|
|
|
|
DWORD tid;
|
|
|
|
|
|
|
|
if(!GetProcAddress(GetModuleHandleA("kernel32.dll"), "CreateActCtxW")) {
|
|
|
|
win_skip("Skipping crash tests on win2k.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
crash_thread_success = FALSE;
|
|
|
|
thread = CreateThread(NULL, 0, crash_couninitialize_proc, NULL, 0, &tid);
|
|
|
|
ok(!WaitForSingleObject(thread, 10000), "wait timed out\n");
|
|
|
|
CloseHandle(thread);
|
|
|
|
ok(crash_thread_success, "Crash thread failed\n");
|
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* tests success case of a same-thread table-weak marshal, unmarshal, unmarshal */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_tableweak_marshal_and_unmarshal_twice(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy1 = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_TABLEWEAK, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy1);
|
2005-02-01 15:18:10 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
2004-12-27 20:21:47 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IUnknown_Release(pProxy1);
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
IUnknown_Release(pProxy2);
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2013-10-24 17:16:47 +02:00
|
|
|
/* When IExternalConnection is present COM's lifetime management
|
|
|
|
* behaviour is altered; the remaining weak ref prevents stub shutdown. */
|
|
|
|
if (with_external_conn)
|
|
|
|
{
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
2013-10-24 17:16:48 +02:00
|
|
|
release_host_object(tid, 0);
|
2013-10-24 17:16:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Without IExternalConnection this line is shows the difference between weak and strong table marshaling
|
|
|
|
* weak has cLocks == 0, strong has cLocks > 0. */
|
2005-01-17 14:39:40 +01:00
|
|
|
ok_no_locks();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2013-10-24 17:16:47 +02:00
|
|
|
IStream_Release(pStream);
|
2004-12-21 15:51:27 +01:00
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
/* tests releasing after unmarshaling one object */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_tableweak_marshal_releasedata1(void)
|
2005-01-28 13:39:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy1 = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_TABLEWEAK, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy1);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
/* release the remaining reference on the object by calling
|
|
|
|
* CoReleaseMarshalData in the hosting thread */
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
2013-10-24 17:16:48 +02:00
|
|
|
release_host_object(tid, 0);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
2005-02-18 21:03:23 +01:00
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
2005-02-18 21:03:23 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2005-01-28 13:39:13 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
2005-02-18 21:03:23 +01:00
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy1);
|
2013-10-24 17:16:47 +02:00
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
if (pProxy2)
|
2013-10-24 17:16:47 +02:00
|
|
|
{
|
|
|
|
ok_non_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
IUnknown_Release(pProxy2);
|
2013-10-24 17:16:47 +02:00
|
|
|
}
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
/* this line is shows the difference between weak and strong table marshaling:
|
|
|
|
* weak has cLocks == 0
|
|
|
|
* strong has cLocks > 0 */
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests releasing after unmarshaling one object */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_tableweak_marshal_releasedata2(void)
|
2005-01-28 13:39:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_TABLEWEAK, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
/* release the remaining reference on the object by calling
|
|
|
|
* CoReleaseMarshalData in the hosting thread */
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
2013-10-24 17:16:48 +02:00
|
|
|
release_host_object(tid, 0);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
2005-02-18 21:03:23 +01:00
|
|
|
todo_wine
|
|
|
|
{
|
2005-01-28 13:39:13 +01:00
|
|
|
ok(hr == CO_E_OBJNOTREG,
|
2006-10-14 04:54:46 +02:00
|
|
|
"CoUnmarshalInterface should have failed with CO_E_OBJNOTREG, but returned 0x%08x instead\n",
|
2005-01-28 13:39:13 +01:00
|
|
|
hr);
|
2005-02-18 21:03:23 +01:00
|
|
|
}
|
2005-01-28 13:39:13 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
struct duo_marshal_data
|
2008-04-28 20:42:22 +02:00
|
|
|
{
|
2013-10-24 17:16:48 +02:00
|
|
|
MSHLFLAGS marshal_flags1, marshal_flags2;
|
|
|
|
IStream *pStream1, *pStream2;
|
2008-04-28 20:42:22 +02:00
|
|
|
HANDLE hReadyEvent;
|
|
|
|
HANDLE hQuitEvent;
|
|
|
|
};
|
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
static DWORD CALLBACK duo_marshal_thread_proc(void *p)
|
2008-04-28 20:42:22 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2013-10-24 17:16:48 +02:00
|
|
|
struct duo_marshal_data *data = p;
|
2008-04-28 20:42:22 +02:00
|
|
|
HANDLE hQuitEvent = data->hQuitEvent;
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
hr = CoMarshalInterface(data->pStream1, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, data->marshal_flags1);
|
2008-04-28 20:42:22 +02:00
|
|
|
ok_ole_success(hr, "CoMarshalInterface");
|
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
hr = CoMarshalInterface(data->pStream2, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, data->marshal_flags2);
|
2008-04-28 20:42:22 +02:00
|
|
|
ok_ole_success(hr, "CoMarshalInterface");
|
|
|
|
|
|
|
|
/* force the message queue to be created before signaling parent thread */
|
2013-10-15 20:37:46 +02:00
|
|
|
PeekMessageA(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
2008-04-28 20:42:22 +02:00
|
|
|
|
|
|
|
SetEvent(data->hReadyEvent);
|
|
|
|
|
2009-08-18 12:48:57 +02:00
|
|
|
while (WAIT_OBJECT_0 + 1 == MsgWaitForMultipleObjects(1, &hQuitEvent, FALSE, 10000, QS_ALLINPUT))
|
2008-04-28 20:42:22 +02:00
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
2013-10-24 17:16:47 +02:00
|
|
|
{
|
|
|
|
if (msg.hwnd == NULL && msg.message == RELEASEMARSHALDATA)
|
|
|
|
{
|
2013-10-24 17:16:48 +02:00
|
|
|
CoReleaseMarshalData(msg.wParam == 1 ? data->pStream1 : data->pStream2);
|
2013-10-24 17:16:47 +02:00
|
|
|
SetEvent((HANDLE)msg.lParam);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DispatchMessageA(&msg);
|
|
|
|
}
|
2008-04-28 20:42:22 +02:00
|
|
|
}
|
|
|
|
CloseHandle(hQuitEvent);
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests interaction between table-weak and normal marshalling of an object */
|
|
|
|
static void test_tableweak_and_normal_marshal_and_unmarshal(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *pProxyWeak = NULL;
|
|
|
|
IUnknown *pProxyNormal = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
2013-10-24 17:16:48 +02:00
|
|
|
struct duo_marshal_data data;
|
2008-04-28 20:42:22 +02:00
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2008-04-28 20:42:22 +02:00
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
data.hReadyEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
|
|
|
data.hQuitEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
2013-10-24 17:16:48 +02:00
|
|
|
data.marshal_flags1 = MSHLFLAGS_TABLEWEAK;
|
|
|
|
data.marshal_flags2 = MSHLFLAGS_NORMAL;
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &data.pStream1);
|
2008-04-28 20:42:22 +02:00
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
2013-10-24 17:16:48 +02:00
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &data.pStream2);
|
2008-04-28 20:42:22 +02:00
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
thread = CreateThread(NULL, 0, duo_marshal_thread_proc, &data, 0, &tid);
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(data.hReadyEvent, 10000), "wait timed out\n" );
|
2008-04-28 20:42:22 +02:00
|
|
|
CloseHandle(data.hReadyEvent);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2008-04-28 20:42:22 +02:00
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
/* weak */
|
|
|
|
IStream_Seek(data.pStream1, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(data.pStream1, &IID_IClassFactory, (void **)&pProxyWeak);
|
2008-04-28 20:42:22 +02:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
/* normal */
|
|
|
|
IStream_Seek(data.pStream2, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(data.pStream2, &IID_IClassFactory, (void **)&pProxyNormal);
|
2008-04-28 20:42:22 +02:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IUnknown_Release(pProxyNormal);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2008-04-28 20:42:22 +02:00
|
|
|
|
|
|
|
IUnknown_Release(pProxyWeak);
|
|
|
|
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
|
|
|
|
|
|
|
/* When IExternalConnection is present COM's lifetime management
|
|
|
|
* behaviour is altered; the remaining weak ref prevents stub shutdown. */
|
|
|
|
if (with_external_conn)
|
|
|
|
{
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:48 +02:00
|
|
|
IStream_Seek(data.pStream1, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
release_host_object(tid, 1);
|
2013-10-24 17:16:47 +02:00
|
|
|
}
|
2008-04-28 20:42:22 +02:00
|
|
|
ok_no_locks();
|
|
|
|
|
2013-10-24 17:16:48 +02:00
|
|
|
IStream_Release(data.pStream1);
|
|
|
|
IStream_Release(data.pStream2);
|
2008-04-28 20:42:22 +02:00
|
|
|
|
|
|
|
SetEvent(data.hQuitEvent);
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
|
2008-04-28 20:42:22 +02:00
|
|
|
CloseHandle(thread);
|
|
|
|
}
|
|
|
|
|
2013-10-24 17:16:49 +02:00
|
|
|
static void test_tableweak_and_normal_marshal_and_releasedata(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
struct duo_marshal_data data;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
external_connections = 0;
|
|
|
|
|
|
|
|
data.hReadyEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
|
|
|
data.hQuitEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
|
|
|
data.marshal_flags1 = MSHLFLAGS_TABLEWEAK;
|
|
|
|
data.marshal_flags2 = MSHLFLAGS_NORMAL;
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &data.pStream1);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &data.pStream2);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
|
|
|
|
thread = CreateThread(NULL, 0, duo_marshal_thread_proc, &data, 0, &tid);
|
|
|
|
ok( !WaitForSingleObject(data.hReadyEvent, 10000), "wait timed out\n" );
|
|
|
|
CloseHandle(data.hReadyEvent);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
ok_non_zero_external_conn();
|
|
|
|
|
|
|
|
/* release normal - which in the non-external conn case will free the object despite the weak ref. */
|
|
|
|
IStream_Seek(data.pStream2, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
release_host_object(tid, 2);
|
|
|
|
|
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
|
|
|
|
|
|
|
if (with_external_conn)
|
|
|
|
{
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
IStream_Seek(data.pStream1, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
release_host_object(tid, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
IStream_Release(data.pStream1);
|
|
|
|
IStream_Release(data.pStream2);
|
|
|
|
|
|
|
|
SetEvent(data.hQuitEvent);
|
|
|
|
ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
|
|
|
|
CloseHandle(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_two_tableweak_marshal_and_releasedata(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
struct duo_marshal_data data;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
external_connections = 0;
|
|
|
|
|
|
|
|
data.hReadyEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
|
|
|
data.hQuitEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
|
|
|
data.marshal_flags1 = MSHLFLAGS_TABLEWEAK;
|
|
|
|
data.marshal_flags2 = MSHLFLAGS_TABLEWEAK;
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &data.pStream1);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &data.pStream2);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
|
|
|
|
thread = CreateThread(NULL, 0, duo_marshal_thread_proc, &data, 0, &tid);
|
|
|
|
ok( !WaitForSingleObject(data.hReadyEvent, 10000), "wait timed out\n" );
|
|
|
|
CloseHandle(data.hReadyEvent);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
ok_zero_external_conn();
|
|
|
|
|
|
|
|
/* release one weak ref - the remaining weak ref will keep the obj alive */
|
|
|
|
IStream_Seek(data.pStream1, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
release_host_object(tid, 1);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(data.pStream2, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
release_host_object(tid, 2);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
IStream_Release(data.pStream1);
|
|
|
|
IStream_Release(data.pStream2);
|
|
|
|
|
|
|
|
SetEvent(data.hQuitEvent);
|
|
|
|
ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
|
|
|
|
CloseHandle(thread);
|
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* tests success case of a same-thread table-strong marshal, unmarshal, unmarshal */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_tablestrong_marshal_and_unmarshal_twice(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy1 = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_TABLESTRONG, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy1);
|
2005-02-01 15:18:10 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
2004-12-27 20:21:47 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
if (pProxy1) IUnknown_Release(pProxy1);
|
|
|
|
if (pProxy2) IUnknown_Release(pProxy2);
|
|
|
|
|
|
|
|
/* this line is shows the difference between weak and strong table marshaling:
|
|
|
|
* weak has cLocks == 0
|
|
|
|
* strong has cLocks > 0 */
|
2004-12-27 20:21:47 +01:00
|
|
|
ok_more_than_one_lock();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
/* release the remaining reference on the object by calling
|
|
|
|
* CoReleaseMarshalData in the hosting thread */
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
2013-10-24 17:16:48 +02:00
|
|
|
release_host_object(tid, 0);
|
2004-12-21 15:51:27 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
2005-01-17 14:39:40 +01:00
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests CoLockObjectExternal */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_lock_object_external(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2006-06-30 12:07:43 +02:00
|
|
|
/* test the stub manager creation aspect of CoLockObjectExternal when the
|
|
|
|
* object hasn't been marshaled yet */
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, TRUE);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2006-06-30 12:07:43 +02:00
|
|
|
|
|
|
|
CoDisconnectObject((IUnknown*)&Test_ClassFactory, 0);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
|
|
|
external_connections = 0;
|
2006-06-30 12:07:43 +02:00
|
|
|
|
|
|
|
/* test our empty stub manager being handled correctly in
|
|
|
|
* CoMarshalInterface */
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, TRUE);
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, TRUE);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2006-06-30 12:07:43 +02:00
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoReleaseMarshalData(pStream);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
2009-11-23 16:07:20 +01:00
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, FALSE, TRUE);
|
|
|
|
|
2006-06-30 12:07:43 +02:00
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2006-06-30 12:07:43 +02:00
|
|
|
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, FALSE, TRUE);
|
|
|
|
|
2004-12-27 20:21:47 +01:00
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(TRUE);
|
2009-11-23 16:07:20 +01:00
|
|
|
|
|
|
|
/* test CoLockObjectExternal releases reference to object with
|
|
|
|
* fLastUnlockReleases as TRUE and there are only strong references on
|
|
|
|
* the object */
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, FALSE);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2009-11-23 16:07:20 +01:00
|
|
|
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, FALSE, FALSE);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
2009-11-23 16:07:20 +01:00
|
|
|
|
|
|
|
/* test CoLockObjectExternal doesn't release the last reference to an
|
|
|
|
* object with fLastUnlockReleases as TRUE and there is a weak reference
|
|
|
|
* on the object */
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLEWEAK);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
2009-11-23 16:07:20 +01:00
|
|
|
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, FALSE);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2009-11-23 16:07:20 +01:00
|
|
|
|
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, FALSE, FALSE);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
2009-11-23 16:07:20 +01:00
|
|
|
|
|
|
|
CoDisconnectObject((IUnknown*)&Test_ClassFactory, 0);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
IStream_Release(pStream);
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tests disconnecting stubs */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_disconnect_stub(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, TRUE);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoReleaseMarshalData(pStream);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
CoDisconnectObject((IUnknown*)&Test_ClassFactory, 0);
|
|
|
|
|
2005-02-08 17:51:22 +01:00
|
|
|
ok_no_locks();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2012-05-14 18:24:19 +02:00
|
|
|
|
|
|
|
hr = CoDisconnectObject(NULL, 0);
|
|
|
|
ok( hr == E_INVALIDARG, "wrong status %x\n", hr );
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tests failure case of a same-thread marshal and unmarshal twice */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_normal_marshal_and_unmarshal_twice(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy1 = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
|
|
|
|
cLocks = 0;
|
2013-10-24 17:16:47 +02:00
|
|
|
external_connections = 0;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_non_zero_external_conn();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy1);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
2013-10-24 17:16:47 +02:00
|
|
|
ok_zero_external_conn();
|
|
|
|
ok_last_release_closes(FALSE);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy2);
|
|
|
|
ok(hr == CO_E_OBJNOTCONNECTED,
|
2006-10-14 04:54:46 +02:00
|
|
|
"CoUnmarshalInterface should have failed with error CO_E_OBJNOTCONNECTED for double unmarshal, instead of 0x%08x\n", hr);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IUnknown_Release(pProxy1);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests success case of marshaling and unmarshaling an HRESULT */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_hresult_marshaling(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HRESULT hr_marshaled = 0;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
static const HRESULT E_DEADBEEF = 0xdeadbeef;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
|
|
|
|
hr = CoMarshalHresult(pStream, E_DEADBEEF);
|
|
|
|
ok_ole_success(hr, CoMarshalHresult);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IStream_Read(pStream, &hr_marshaled, sizeof(HRESULT), NULL);
|
|
|
|
ok_ole_success(hr, IStream_Read);
|
|
|
|
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr_marshaled == E_DEADBEEF, "Didn't marshal HRESULT as expected: got value 0x%08x instead\n", hr_marshaled);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr_marshaled = 0;
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalHresult(pStream, &hr_marshaled);
|
|
|
|
ok_ole_success(hr, CoUnmarshalHresult);
|
|
|
|
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr_marshaled == E_DEADBEEF, "Didn't marshal HRESULT as expected: got value 0x%08x instead\n", hr_marshaled);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IStream_Release(pStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* helper for test_proxy_used_in_wrong_thread */
|
|
|
|
static DWORD CALLBACK bad_thread_proc(LPVOID p)
|
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
IClassFactory * cf = p;
|
2004-12-21 15:51:27 +01:00
|
|
|
HRESULT hr;
|
2005-01-19 18:00:20 +01:00
|
|
|
IUnknown * proxy = NULL;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2007-05-21 17:45:17 +02:00
|
|
|
hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == CO_E_NOTINITIALIZED,
|
|
|
|
"COM should have failed with CO_E_NOTINITIALIZED on using proxy without apartment, but instead returned 0x%08x\n",
|
|
|
|
hr);
|
|
|
|
|
|
|
|
hr = IClassFactory_QueryInterface(cf, &IID_IMultiQI, (LPVOID *)&proxy);
|
|
|
|
/* Win9x returns S_OK, whilst NT returns RPC_E_WRONG_THREAD */
|
|
|
|
trace("call to proxy's QueryInterface for local interface without apartment returned 0x%08x\n", hr);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
IUnknown_Release(proxy);
|
|
|
|
|
|
|
|
hr = IClassFactory_QueryInterface(cf, &IID_IStream, (LPVOID *)&proxy);
|
|
|
|
/* Win9x returns E_NOINTERFACE, whilst NT returns RPC_E_WRONG_THREAD */
|
|
|
|
trace("call to proxy's QueryInterface without apartment returned 0x%08x\n", hr);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
IUnknown_Release(proxy);
|
|
|
|
|
2005-02-14 12:01:51 +01:00
|
|
|
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
2006-01-20 16:16:08 +01:00
|
|
|
|
2005-01-19 18:00:20 +01:00
|
|
|
hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
|
|
|
|
if (proxy) IUnknown_Release(proxy);
|
2004-12-21 15:51:27 +01:00
|
|
|
ok(hr == RPC_E_WRONG_THREAD,
|
2006-10-14 04:54:46 +02:00
|
|
|
"COM should have failed with RPC_E_WRONG_THREAD on using proxy from wrong apartment, but instead returned 0x%08x\n",
|
2004-12-21 15:51:27 +01:00
|
|
|
hr);
|
|
|
|
|
2007-05-21 17:45:17 +02:00
|
|
|
hr = IClassFactory_QueryInterface(cf, &IID_IStream, (LPVOID *)&proxy);
|
|
|
|
/* Win9x returns E_NOINTERFACE, whilst NT returns RPC_E_WRONG_THREAD */
|
|
|
|
trace("call to proxy's QueryInterface from wrong apartment returned 0x%08x\n", hr);
|
|
|
|
|
2010-11-16 13:39:11 +01:00
|
|
|
/* now be really bad and release the proxy from the wrong apartment */
|
2012-08-13 11:40:46 +02:00
|
|
|
IClassFactory_Release(cf);
|
2007-05-21 17:45:17 +02:00
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests failure case of a using a proxy in the wrong apartment */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_proxy_used_in_wrong_thread(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
DWORD tid, tid2;
|
|
|
|
HANDLE thread;
|
|
|
|
HANDLE host_thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &host_thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
2005-02-01 15:18:10 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
2007-05-21 17:45:17 +02:00
|
|
|
/* do a call that will fail, but result in IRemUnknown being used by the proxy */
|
2012-08-13 11:40:46 +02:00
|
|
|
IUnknown_QueryInterface(pProxy, &IID_IStream, (LPVOID *)&pStream);
|
2007-05-21 17:45:17 +02:00
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* create a thread that we can misbehave in */
|
2009-01-20 11:21:23 +01:00
|
|
|
thread = CreateThread(NULL, 0, bad_thread_proc, pProxy, 0, &tid2);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
|
2004-12-21 15:51:27 +01:00
|
|
|
CloseHandle(thread);
|
|
|
|
|
2007-05-21 17:45:17 +02:00
|
|
|
/* do release statement on Win9x that we should have done above */
|
2013-10-15 20:37:46 +02:00
|
|
|
if (!GetProcAddress(GetModuleHandleA("ole32"), "CoRegisterSurrogateEx"))
|
2007-05-21 17:45:17 +02:00
|
|
|
IUnknown_Release(pProxy);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, host_thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MessageFilter_QueryInterface(IMessageFilter *iface, REFIID riid, void ** ppvObj)
|
|
|
|
{
|
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IClassFactory))
|
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
*ppvObj = iface;
|
2012-08-13 11:40:46 +02:00
|
|
|
IMessageFilter_AddRef(iface);
|
2004-12-21 15:51:27 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MessageFilter_AddRef(IMessageFilter *iface)
|
|
|
|
{
|
|
|
|
return 2; /* non-heap object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MessageFilter_Release(IMessageFilter *iface)
|
|
|
|
{
|
|
|
|
return 1; /* non-heap object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI MessageFilter_HandleInComingCall(
|
|
|
|
IMessageFilter *iface,
|
|
|
|
DWORD dwCallType,
|
|
|
|
HTASK threadIDCaller,
|
|
|
|
DWORD dwTickCount,
|
|
|
|
LPINTERFACEINFO lpInterfaceInfo)
|
|
|
|
{
|
|
|
|
static int callcount = 0;
|
|
|
|
DWORD ret;
|
|
|
|
trace("HandleInComingCall\n");
|
|
|
|
switch (callcount)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ret = SERVERCALL_REJECTED;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ret = SERVERCALL_RETRYLATER;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = SERVERCALL_ISHANDLED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
callcount++;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI MessageFilter_RetryRejectedCall(
|
|
|
|
IMessageFilter *iface,
|
|
|
|
HTASK threadIDCallee,
|
|
|
|
DWORD dwTickCount,
|
|
|
|
DWORD dwRejectType)
|
|
|
|
{
|
|
|
|
trace("RetryRejectedCall\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI MessageFilter_MessagePending(
|
|
|
|
IMessageFilter *iface,
|
|
|
|
HTASK threadIDCallee,
|
|
|
|
DWORD dwTickCount,
|
|
|
|
DWORD dwPendingType)
|
|
|
|
{
|
|
|
|
trace("MessagePending\n");
|
|
|
|
return PENDINGMSG_WAITNOPROCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IMessageFilterVtbl MessageFilter_Vtbl =
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
MessageFilter_QueryInterface,
|
|
|
|
MessageFilter_AddRef,
|
|
|
|
MessageFilter_Release,
|
|
|
|
MessageFilter_HandleInComingCall,
|
|
|
|
MessageFilter_RetryRejectedCall,
|
|
|
|
MessageFilter_MessagePending
|
|
|
|
};
|
|
|
|
|
|
|
|
static IMessageFilter MessageFilter = { &MessageFilter_Vtbl };
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_message_filter(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IClassFactory *cf = NULL;
|
|
|
|
DWORD tid;
|
2005-01-19 18:00:20 +01:00
|
|
|
IUnknown *proxy = NULL;
|
2004-12-21 15:51:27 +01:00
|
|
|
IMessageFilter *prev_filter = NULL;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object2(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &MessageFilter, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&cf);
|
2005-01-19 18:00:20 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2004-12-21 15:51:27 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
2005-01-19 18:00:20 +01:00
|
|
|
hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
|
2006-12-19 20:37:09 +01:00
|
|
|
ok(hr == RPC_E_CALL_REJECTED, "Call should have returned RPC_E_CALL_REJECTED, but return 0x%08x instead\n", hr);
|
2005-01-19 18:00:20 +01:00
|
|
|
if (proxy) IUnknown_Release(proxy);
|
|
|
|
proxy = NULL;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CoRegisterMessageFilter(&MessageFilter, &prev_filter);
|
|
|
|
ok_ole_success(hr, CoRegisterMessageFilter);
|
|
|
|
|
2005-01-19 18:00:20 +01:00
|
|
|
hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
|
|
|
|
ok_ole_success(hr, IClassFactory_CreateInstance);
|
|
|
|
|
|
|
|
IUnknown_Release(proxy);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
IClassFactory_Release(cf);
|
|
|
|
|
2005-01-27 11:39:44 +01:00
|
|
|
ok_no_locks();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
2006-12-19 20:37:29 +01:00
|
|
|
|
|
|
|
hr = CoRegisterMessageFilter(prev_filter, NULL);
|
|
|
|
ok_ole_success(hr, CoRegisterMessageFilter);
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
2005-01-11 11:45:52 +01:00
|
|
|
/* test failure case of trying to unmarshal from bad stream */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_bad_marshal_stream(void)
|
2005-01-11 11:45:52 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
|
|
|
ok_ole_success(hr, CoMarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
/* try to read beyond end of stream */
|
|
|
|
hr = CoReleaseMarshalData(pStream);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == STG_E_READFAULT, "Should have failed with STG_E_READFAULT, but returned 0x%08x instead\n", hr);
|
2005-01-11 11:45:52 +01:00
|
|
|
|
|
|
|
/* now release for real */
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoReleaseMarshalData(pStream);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
|
|
|
|
IStream_Release(pStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests that proxies implement certain interfaces */
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_proxy_interfaces(void)
|
2005-01-11 11:45:52 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
IUnknown *pOtherUnknown = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
2005-01-27 11:39:44 +01:00
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IUnknown, (void **)&pProxy);
|
2005-02-01 15:18:10 +01:00
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
2005-01-11 11:45:52 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(pProxy, &IID_IUnknown, (LPVOID*)&pOtherUnknown);
|
|
|
|
ok_ole_success(hr, IUnknown_QueryInterface IID_IUnknown);
|
|
|
|
if (hr == S_OK) IUnknown_Release(pOtherUnknown);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(pProxy, &IID_IClientSecurity, (LPVOID*)&pOtherUnknown);
|
2007-03-26 19:15:04 +02:00
|
|
|
ok_ole_success(hr, IUnknown_QueryInterface IID_IClientSecurity);
|
2005-01-11 11:45:52 +01:00
|
|
|
if (hr == S_OK) IUnknown_Release(pOtherUnknown);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(pProxy, &IID_IMultiQI, (LPVOID*)&pOtherUnknown);
|
2005-01-26 22:07:05 +01:00
|
|
|
ok_ole_success(hr, IUnknown_QueryInterface IID_IMultiQI);
|
2005-01-11 11:45:52 +01:00
|
|
|
if (hr == S_OK) IUnknown_Release(pOtherUnknown);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(pProxy, &IID_IMarshal, (LPVOID*)&pOtherUnknown);
|
2005-08-27 11:25:16 +02:00
|
|
|
ok_ole_success(hr, IUnknown_QueryInterface IID_IMarshal);
|
2005-01-11 11:45:52 +01:00
|
|
|
if (hr == S_OK) IUnknown_Release(pOtherUnknown);
|
|
|
|
|
2005-01-31 12:29:41 +01:00
|
|
|
/* IMarshal2 is also supported on NT-based systems, but is pretty much
|
|
|
|
* useless as it has no more methods over IMarshal that it inherits from. */
|
2005-01-11 11:45:52 +01:00
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2005-09-18 13:10:37 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-12-04 22:14:56 +01:00
|
|
|
IUnknown IUnknown_iface;
|
2005-09-18 13:10:37 +02:00
|
|
|
ULONG refs;
|
|
|
|
} HeapUnknown;
|
|
|
|
|
2010-12-04 22:14:56 +01:00
|
|
|
static inline HeapUnknown *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HeapUnknown, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
2005-09-18 13:10:37 +02:00
|
|
|
static HRESULT WINAPI HeapUnknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
2009-01-20 11:21:23 +01:00
|
|
|
*ppv = iface;
|
2005-09-18 13:10:37 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HeapUnknown_AddRef(IUnknown *iface)
|
|
|
|
{
|
2010-12-04 22:14:56 +01:00
|
|
|
HeapUnknown *This = impl_from_IUnknown(iface);
|
2005-09-18 13:10:37 +02:00
|
|
|
return InterlockedIncrement((LONG*)&This->refs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HeapUnknown_Release(IUnknown *iface)
|
|
|
|
{
|
2010-12-04 22:14:56 +01:00
|
|
|
HeapUnknown *This = impl_from_IUnknown(iface);
|
2005-09-18 13:10:37 +02:00
|
|
|
ULONG refs = InterlockedDecrement((LONG*)&This->refs);
|
|
|
|
if (!refs) HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl HeapUnknown_Vtbl =
|
|
|
|
{
|
|
|
|
HeapUnknown_QueryInterface,
|
|
|
|
HeapUnknown_AddRef,
|
|
|
|
HeapUnknown_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_proxybuffer(REFIID riid)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IPSFactoryBuffer *psfb;
|
|
|
|
IRpcProxyBuffer *proxy;
|
|
|
|
LPVOID lpvtbl;
|
|
|
|
ULONG refs;
|
|
|
|
CLSID clsid;
|
2007-06-27 00:12:36 +02:00
|
|
|
HeapUnknown *pUnkOuter = HeapAlloc(GetProcessHeap(), 0, sizeof(*pUnkOuter));
|
2005-09-18 13:10:37 +02:00
|
|
|
|
2010-12-04 22:14:56 +01:00
|
|
|
pUnkOuter->IUnknown_iface.lpVtbl = &HeapUnknown_Vtbl;
|
2005-09-18 13:10:37 +02:00
|
|
|
pUnkOuter->refs = 1;
|
|
|
|
|
|
|
|
hr = CoGetPSClsid(riid, &clsid);
|
|
|
|
ok_ole_success(hr, CoGetPSClsid);
|
|
|
|
|
|
|
|
hr = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (LPVOID*)&psfb);
|
|
|
|
ok_ole_success(hr, CoGetClassObject);
|
|
|
|
|
2010-12-04 22:14:56 +01:00
|
|
|
hr = IPSFactoryBuffer_CreateProxy(psfb, &pUnkOuter->IUnknown_iface, riid, &proxy, &lpvtbl);
|
2005-09-18 13:10:37 +02:00
|
|
|
ok_ole_success(hr, IPSFactoryBuffer_CreateProxy);
|
|
|
|
ok(lpvtbl != NULL, "IPSFactoryBuffer_CreateProxy succeeded, but returned a NULL vtable!\n");
|
|
|
|
|
2006-05-22 23:17:53 +02:00
|
|
|
/* release our reference to the outer unknown object - the PS factory
|
|
|
|
* buffer will have AddRef's it in the CreateProxy call */
|
2010-12-04 22:14:56 +01:00
|
|
|
refs = IUnknown_Release(&pUnkOuter->IUnknown_iface);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(refs == 1, "Ref count of outer unknown should have been 1 instead of %d\n", refs);
|
2006-05-22 23:17:53 +02:00
|
|
|
|
2011-02-09 22:44:25 +01:00
|
|
|
/* Not checking return, unreliable on native. Maybe it leaks references? */
|
|
|
|
IPSFactoryBuffer_Release(psfb);
|
2005-09-18 13:10:37 +02:00
|
|
|
|
|
|
|
refs = IUnknown_Release((IUnknown *)lpvtbl);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(refs == 0, "Ref-count leak of %d on IRpcProxyBuffer\n", refs);
|
2005-09-18 13:10:37 +02:00
|
|
|
|
|
|
|
refs = IRpcProxyBuffer_Release(proxy);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(refs == 0, "Ref-count leak of %d on IRpcProxyBuffer\n", refs);
|
2005-09-18 13:10:37 +02:00
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:13 +01:00
|
|
|
static void test_stubbuffer(REFIID riid)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IPSFactoryBuffer *psfb;
|
|
|
|
IRpcStubBuffer *stub;
|
|
|
|
ULONG refs;
|
|
|
|
CLSID clsid;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CoGetPSClsid(riid, &clsid);
|
|
|
|
ok_ole_success(hr, CoGetPSClsid);
|
|
|
|
|
|
|
|
hr = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (LPVOID*)&psfb);
|
|
|
|
ok_ole_success(hr, CoGetClassObject);
|
|
|
|
|
|
|
|
hr = IPSFactoryBuffer_CreateStub(psfb, riid, (IUnknown*)&Test_ClassFactory, &stub);
|
|
|
|
ok_ole_success(hr, IPSFactoryBuffer_CreateStub);
|
|
|
|
|
2011-02-09 22:44:25 +01:00
|
|
|
/* Not checking return, unreliable on native. Maybe it leaks references? */
|
|
|
|
IPSFactoryBuffer_Release(psfb);
|
2005-01-28 13:39:13 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IRpcStubBuffer_Disconnect(stub);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
refs = IRpcStubBuffer_Release(stub);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(refs == 0, "Ref-count leak of %d on IRpcProxyBuffer\n", refs);
|
2005-01-28 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
2005-03-04 13:30:47 +01:00
|
|
|
static HWND hwnd_app;
|
|
|
|
|
|
|
|
static HRESULT WINAPI TestRE_IClassFactory_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2005-09-12 22:43:32 +02:00
|
|
|
DWORD_PTR res;
|
2006-01-20 16:14:32 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IWineTest))
|
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
BOOL ret = SendMessageTimeoutA(hwnd_app, WM_NULL, 0, 0, SMTO_BLOCK, 5000, &res);
|
2006-01-20 16:14:32 +01:00
|
|
|
ok(ret, "Timed out sending a message to originating window during RPC call\n");
|
|
|
|
}
|
2009-10-22 13:04:30 +02:00
|
|
|
*ppvObj = NULL;
|
2005-03-04 13:30:47 +01:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IClassFactoryVtbl TestREClassFactory_Vtbl =
|
2005-03-04 13:30:47 +01:00
|
|
|
{
|
|
|
|
Test_IClassFactory_QueryInterface,
|
|
|
|
Test_IClassFactory_AddRef,
|
|
|
|
Test_IClassFactory_Release,
|
|
|
|
TestRE_IClassFactory_CreateInstance,
|
|
|
|
Test_IClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
2010-10-01 13:37:14 +02:00
|
|
|
static IClassFactory TestRE_ClassFactory = { &TestREClassFactory_Vtbl };
|
2005-03-04 13:30:47 +01:00
|
|
|
|
|
|
|
static LRESULT CALLBACK window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_USER:
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IClassFactory *proxy = NULL;
|
|
|
|
IUnknown *object;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&TestRE_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&proxy);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
2006-01-20 16:14:32 +01:00
|
|
|
/* note the use of the magic IID_IWineTest value to tell remote thread
|
|
|
|
* to try to send a message back to us */
|
|
|
|
hr = IClassFactory_CreateInstance(proxy, NULL, &IID_IWineTest, (void **)&object);
|
2011-07-26 04:28:13 +02:00
|
|
|
ok(hr == S_FALSE, "expected S_FALSE, got %d\n", hr);
|
2005-03-04 13:30:47 +01:00
|
|
|
|
|
|
|
IClassFactory_Release(proxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
PostMessageA(hwnd, WM_QUIT, 0, 0);
|
2005-03-04 13:30:47 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-01-20 16:14:32 +01:00
|
|
|
case WM_USER+1:
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IClassFactory *proxy = NULL;
|
|
|
|
IUnknown *object;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&TestRE_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&proxy);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
/* post quit message before a doing a COM call to show that a pending
|
|
|
|
* WM_QUIT message doesn't stop the call from succeeding */
|
2013-10-15 20:37:46 +02:00
|
|
|
PostMessageA(hwnd, WM_QUIT, 0, 0);
|
2006-01-20 16:14:32 +01:00
|
|
|
hr = IClassFactory_CreateInstance(proxy, NULL, &IID_IUnknown, (void **)&object);
|
2011-02-09 22:44:25 +01:00
|
|
|
ok(hr == S_FALSE, "IClassFactory_CreateInstance returned 0x%08x, expected S_FALSE\n", hr);
|
2006-01-20 16:14:32 +01:00
|
|
|
|
|
|
|
IClassFactory_Release(proxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-12-23 16:51:27 +01:00
|
|
|
case WM_USER+2:
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IClassFactory *proxy = NULL;
|
|
|
|
IUnknown *object;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&proxy);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
/* shows that COM calls executed during the processing of sent
|
|
|
|
* messages should fail */
|
|
|
|
hr = IClassFactory_CreateInstance(proxy, NULL, &IID_IUnknown, (void **)&object);
|
|
|
|
ok(hr == RPC_E_CANTCALLOUT_ININPUTSYNCCALL,
|
|
|
|
"COM call during processing of sent message should return RPC_E_CANTCALLOUT_ININPUTSYNCCALL instead of 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IClassFactory_Release(proxy);
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
|
|
|
PostQuitMessage(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2005-03-04 13:30:47 +01:00
|
|
|
default:
|
2013-10-15 20:37:46 +02:00
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
2005-03-04 13:30:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-07 15:14:25 +01:00
|
|
|
static void register_test_window(void)
|
2005-03-04 13:30:47 +01:00
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
WNDCLASSA wndclass;
|
2005-03-04 13:30:47 +01:00
|
|
|
|
|
|
|
memset(&wndclass, 0, sizeof(wndclass));
|
|
|
|
wndclass.lpfnWndProc = window_proc;
|
|
|
|
wndclass.lpszClassName = "WineCOMTest";
|
2013-10-15 20:37:46 +02:00
|
|
|
RegisterClassA(&wndclass);
|
2007-12-07 15:14:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_message_reentrancy(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
2005-03-04 13:30:47 +01:00
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
hwnd_app = CreateWindowA("WineCOMTest", NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, 0);
|
2005-03-04 13:30:47 +01:00
|
|
|
ok(hwnd_app != NULL, "Window creation failed\n");
|
|
|
|
|
2006-01-20 16:14:32 +01:00
|
|
|
/* start message re-entrancy test */
|
2013-10-15 20:37:46 +02:00
|
|
|
PostMessageA(hwnd_app, WM_USER, 0, 0);
|
2005-03-04 13:30:47 +01:00
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
while (GetMessageA(&msg, NULL, 0, 0))
|
2005-03-04 13:30:47 +01:00
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
2013-10-15 20:37:46 +02:00
|
|
|
DispatchMessageA(&msg);
|
2005-03-04 13:30:47 +01:00
|
|
|
}
|
2007-12-07 15:14:25 +01:00
|
|
|
DestroyWindow(hwnd_app);
|
2005-03-04 13:30:47 +01:00
|
|
|
}
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2006-12-23 16:51:27 +01:00
|
|
|
static HRESULT WINAPI TestMsg_IClassFactory_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
*ppvObj = NULL;
|
2013-10-15 20:37:46 +02:00
|
|
|
SendMessageA(hwnd_app, WM_USER+2, 0, 0);
|
2006-12-23 16:51:27 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IClassFactoryVtbl TestMsgClassFactory_Vtbl =
|
|
|
|
{
|
|
|
|
Test_IClassFactory_QueryInterface,
|
|
|
|
Test_IClassFactory_AddRef,
|
|
|
|
Test_IClassFactory_Release,
|
|
|
|
TestMsg_IClassFactory_CreateInstance,
|
|
|
|
Test_IClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
2010-10-01 13:37:14 +02:00
|
|
|
static IClassFactory TestMsg_ClassFactory = { &TestMsgClassFactory_Vtbl };
|
2006-12-23 16:51:27 +01:00
|
|
|
|
|
|
|
static void test_call_from_message(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
IStream *pStream;
|
|
|
|
HRESULT hr;
|
|
|
|
IClassFactory *proxy;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
IUnknown *object;
|
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
hwnd_app = CreateWindowA("WineCOMTest", NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, 0);
|
2006-12-23 16:51:27 +01:00
|
|
|
ok(hwnd_app != NULL, "Window creation failed\n");
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&TestMsg_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&proxy);
|
|
|
|
ok_ole_success(hr, CoReleaseMarshalData);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
/* start message re-entrancy test */
|
|
|
|
hr = IClassFactory_CreateInstance(proxy, NULL, &IID_IUnknown, (void **)&object);
|
|
|
|
ok_ole_success(hr, IClassFactory_CreateInstance);
|
|
|
|
|
|
|
|
IClassFactory_Release(proxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
while (GetMessageA(&msg, NULL, 0, 0))
|
2006-12-23 16:51:27 +01:00
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
2013-10-15 20:37:46 +02:00
|
|
|
DispatchMessageA(&msg);
|
2006-12-23 16:51:27 +01:00
|
|
|
}
|
2007-12-07 15:14:25 +01:00
|
|
|
DestroyWindow(hwnd_app);
|
2006-12-23 16:51:27 +01:00
|
|
|
}
|
|
|
|
|
2006-01-20 16:14:32 +01:00
|
|
|
static void test_WM_QUIT_handling(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
hwnd_app = CreateWindowA("WineCOMTest", NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, 0);
|
2006-01-20 16:14:32 +01:00
|
|
|
ok(hwnd_app != NULL, "Window creation failed\n");
|
|
|
|
|
|
|
|
/* start WM_QUIT handling test */
|
2013-10-15 20:37:46 +02:00
|
|
|
PostMessageA(hwnd_app, WM_USER+1, 0, 0);
|
2006-01-20 16:14:32 +01:00
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
while (GetMessageA(&msg, NULL, 0, 0))
|
2006-01-20 16:14:32 +01:00
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
2013-10-15 20:37:46 +02:00
|
|
|
DispatchMessageA(&msg);
|
2006-01-20 16:14:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-17 10:48:25 +01:00
|
|
|
static SIZE_T round_global_size(SIZE_T size)
|
2009-01-28 13:48:40 +01:00
|
|
|
{
|
2009-02-17 10:48:25 +01:00
|
|
|
static SIZE_T global_size_alignment = -1;
|
|
|
|
if (global_size_alignment == -1)
|
2009-01-28 13:48:40 +01:00
|
|
|
{
|
2009-02-17 10:48:25 +01:00
|
|
|
void *p = GlobalAlloc(GMEM_FIXED, 1);
|
|
|
|
global_size_alignment = GlobalSize(p);
|
|
|
|
GlobalFree(p);
|
2009-01-28 13:48:40 +01:00
|
|
|
}
|
|
|
|
|
2009-02-17 10:48:25 +01:00
|
|
|
return ((size + global_size_alignment - 1) & ~(global_size_alignment - 1));
|
2009-01-28 13:48:40 +01:00
|
|
|
}
|
|
|
|
|
2006-05-25 00:01:41 +02:00
|
|
|
static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *ptr, DWORD mshlflags)
|
|
|
|
{
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
DWORD size;
|
|
|
|
char *marshal_data;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = GetHGlobalFromStream(pStream, &hglobal);
|
|
|
|
ok_ole_success(hr, GetHGlobalFromStream);
|
|
|
|
|
|
|
|
size = GlobalSize(hglobal);
|
|
|
|
|
2008-11-05 23:04:10 +01:00
|
|
|
marshal_data = GlobalLock(hglobal);
|
2006-05-25 00:01:41 +02:00
|
|
|
|
|
|
|
if (mshctx == MSHCTX_INPROC)
|
|
|
|
{
|
2009-02-17 10:48:25 +01:00
|
|
|
DWORD expected_size = round_global_size(3*sizeof(DWORD) + sizeof(GUID));
|
2009-02-10 16:32:01 +01:00
|
|
|
ok(size == expected_size ||
|
2009-07-02 14:00:05 +02:00
|
|
|
broken(size == (2*sizeof(DWORD))) /* Win9x & NT4 */,
|
2009-02-10 16:32:01 +01:00
|
|
|
"size should have been %d instead of %d\n", expected_size, size);
|
2006-05-25 00:01:41 +02:00
|
|
|
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(*(DWORD *)marshal_data == mshlflags, "expected 0x%x, but got 0x%x for mshctx\n", mshlflags, *(DWORD *)marshal_data);
|
2006-05-25 00:01:41 +02:00
|
|
|
marshal_data += sizeof(DWORD);
|
|
|
|
ok(*(void **)marshal_data == ptr, "expected %p, but got %p for mshctx\n", ptr, *(void **)marshal_data);
|
|
|
|
marshal_data += sizeof(void *);
|
2009-02-10 16:32:01 +01:00
|
|
|
if (sizeof(void*) == 4 && size >= 3*sizeof(DWORD))
|
2009-01-10 21:06:09 +01:00
|
|
|
{
|
|
|
|
ok(*(DWORD *)marshal_data == 0, "expected 0x0, but got 0x%x\n", *(DWORD *)marshal_data);
|
|
|
|
marshal_data += sizeof(DWORD);
|
|
|
|
}
|
2009-02-10 16:32:01 +01:00
|
|
|
if (size >= 3*sizeof(DWORD) + sizeof(GUID))
|
|
|
|
{
|
2014-02-12 12:10:46 +01:00
|
|
|
trace("got guid data: %s\n", wine_dbgstr_guid((GUID *)marshal_data));
|
2009-02-10 16:32:01 +01:00
|
|
|
}
|
2006-05-25 00:01:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(size > sizeof(DWORD), "size should have been > sizeof(DWORD), not %d\n", size);
|
2006-05-25 00:01:41 +02:00
|
|
|
ok(*(DWORD *)marshal_data == 0x574f454d /* MEOW */,
|
|
|
|
"marshal data should be filled by standard marshal and start with MEOW signature\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_freethreadedmarshaler(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *pFTUnknown;
|
|
|
|
IMarshal *pFTMarshal;
|
|
|
|
IStream *pStream;
|
|
|
|
IUnknown *pProxy;
|
|
|
|
static const LARGE_INTEGER llZero;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
hr = CoCreateFreeThreadedMarshaler(NULL, &pFTUnknown);
|
|
|
|
ok_ole_success(hr, CoCreateFreeThreadedMarshaler);
|
|
|
|
hr = IUnknown_QueryInterface(pFTUnknown, &IID_IMarshal, (void **)&pFTMarshal);
|
|
|
|
ok_ole_success(hr, IUnknown_QueryInterface);
|
|
|
|
IUnknown_Release(pFTUnknown);
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
|
|
|
|
/* inproc normal marshaling */
|
|
|
|
|
|
|
|
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
|
2009-01-20 11:21:23 +01:00
|
|
|
&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
2006-05-25 00:01:41 +02:00
|
|
|
ok_ole_success(hr, IMarshal_MarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
test_freethreadedmarshaldata(pStream, MSHCTX_INPROC, &Test_ClassFactory, MSHLFLAGS_NORMAL);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, IMarshal_UnmarshalInterface);
|
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
/* native doesn't allow us to unmarshal or release the stream data,
|
|
|
|
* presumably because it wants us to call CoMarshalInterface instead */
|
2006-12-14 18:11:28 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2006-05-25 00:01:41 +02:00
|
|
|
/* local normal marshaling */
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
2009-01-20 11:21:23 +01:00
|
|
|
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory, &Test_ClassFactory, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
|
2006-05-25 00:01:41 +02:00
|
|
|
ok_ole_success(hr, IMarshal_MarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
test_freethreadedmarshaldata(pStream, MSHCTX_LOCAL, &Test_ClassFactory, MSHLFLAGS_NORMAL);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_ReleaseMarshalData(pFTMarshal, pStream);
|
|
|
|
ok_ole_success(hr, IMarshal_ReleaseMarshalData);
|
|
|
|
|
|
|
|
ok_no_locks();
|
2006-12-14 18:11:28 +01:00
|
|
|
}
|
2006-05-25 00:01:41 +02:00
|
|
|
|
|
|
|
/* inproc table-strong marshaling */
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
|
|
|
|
(IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, (void *)0xdeadbeef,
|
|
|
|
MSHLFLAGS_TABLESTRONG);
|
|
|
|
ok_ole_success(hr, IMarshal_MarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
test_freethreadedmarshaldata(pStream, MSHCTX_INPROC, &Test_ClassFactory, MSHLFLAGS_TABLESTRONG);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, IMarshal_UnmarshalInterface);
|
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
2006-05-25 00:02:14 +02:00
|
|
|
ok_more_than_one_lock();
|
2006-05-25 00:01:41 +02:00
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_ReleaseMarshalData(pFTMarshal, pStream);
|
|
|
|
ok_ole_success(hr, IMarshal_ReleaseMarshalData);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
/* inproc table-weak marshaling */
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
|
|
|
|
(IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, (void *)0xdeadbeef,
|
|
|
|
MSHLFLAGS_TABLEWEAK);
|
|
|
|
ok_ole_success(hr, IMarshal_MarshalInterface);
|
|
|
|
|
2006-05-25 00:01:53 +02:00
|
|
|
ok_no_locks();
|
2006-05-25 00:01:41 +02:00
|
|
|
|
|
|
|
test_freethreadedmarshaldata(pStream, MSHCTX_INPROC, &Test_ClassFactory, MSHLFLAGS_TABLEWEAK);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, IMarshal_UnmarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IUnknown_Release(pProxy);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
/* inproc normal marshaling (for extraordinary cases) */
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
|
2009-01-20 11:21:23 +01:00
|
|
|
&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
2006-05-25 00:01:41 +02:00
|
|
|
ok_ole_success(hr, IMarshal_MarshalInterface);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
/* this call shows that DisconnectObject does nothing */
|
|
|
|
hr = IMarshal_DisconnectObject(pFTMarshal, 0);
|
|
|
|
ok_ole_success(hr, IMarshal_DisconnectObject);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_ReleaseMarshalData(pFTMarshal, pStream);
|
|
|
|
ok_ole_success(hr, IMarshal_ReleaseMarshalData);
|
|
|
|
|
2006-05-25 00:02:14 +02:00
|
|
|
ok_no_locks();
|
2006-05-25 00:01:41 +02:00
|
|
|
|
|
|
|
/* doesn't enforce marshaling rules here and allows us to unmarshal the
|
|
|
|
* interface, even though it was freed above */
|
|
|
|
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, IMarshal_UnmarshalInterface);
|
|
|
|
|
2006-05-25 00:02:14 +02:00
|
|
|
ok_no_locks();
|
2006-05-25 00:01:41 +02:00
|
|
|
|
|
|
|
IStream_Release(pStream);
|
|
|
|
IMarshal_Release(pFTMarshal);
|
|
|
|
}
|
|
|
|
|
2011-09-21 00:42:06 +02:00
|
|
|
static HRESULT reg_unreg_wine_test_class(BOOL Register)
|
2007-02-23 20:38:11 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
char buffer[256];
|
|
|
|
LPOLESTR pszClsid;
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD dwDisposition;
|
|
|
|
DWORD error;
|
|
|
|
|
|
|
|
hr = StringFromCLSID(&CLSID_WineTest, &pszClsid);
|
|
|
|
ok_ole_success(hr, "StringFromCLSID");
|
2009-01-29 15:33:02 +01:00
|
|
|
strcpy(buffer, "CLSID\\");
|
2007-02-23 20:38:11 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, pszClsid, -1, buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), NULL, NULL);
|
|
|
|
CoTaskMemFree(pszClsid);
|
|
|
|
strcat(buffer, "\\InprocHandler32");
|
2009-01-25 20:01:54 +01:00
|
|
|
if (Register)
|
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
error = RegCreateKeyExA(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey, &dwDisposition);
|
2011-09-21 00:42:06 +02:00
|
|
|
if (error == ERROR_ACCESS_DENIED)
|
|
|
|
{
|
|
|
|
skip("Not authorized to modify the Classes key\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2009-01-25 20:01:54 +01:00
|
|
|
ok(error == ERROR_SUCCESS, "RegCreateKeyEx failed with error %d\n", error);
|
2011-09-21 00:42:06 +02:00
|
|
|
if (error != ERROR_SUCCESS) hr = E_FAIL;
|
2013-10-15 20:37:46 +02:00
|
|
|
error = RegSetValueExA(hkey, NULL, 0, REG_SZ, (const unsigned char *)"\"ole32.dll\"", strlen("\"ole32.dll\"") + 1);
|
2009-01-25 20:01:54 +01:00
|
|
|
ok(error == ERROR_SUCCESS, "RegSetValueEx failed with error %d\n", error);
|
2011-09-21 00:42:06 +02:00
|
|
|
if (error != ERROR_SUCCESS) hr = E_FAIL;
|
2009-01-25 20:01:54 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
RegDeleteKeyA(HKEY_CLASSES_ROOT, buffer);
|
2009-01-25 20:01:54 +01:00
|
|
|
*strrchr(buffer, '\\') = '\0';
|
2013-10-15 20:37:46 +02:00
|
|
|
RegDeleteKeyA(HKEY_CLASSES_ROOT, buffer);
|
2009-01-25 20:01:54 +01:00
|
|
|
}
|
2011-09-21 00:42:06 +02:00
|
|
|
return hr;
|
2009-01-25 20:01:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_inproc_handler(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *pObject;
|
|
|
|
IUnknown *pObject2;
|
|
|
|
|
2011-09-21 00:42:06 +02:00
|
|
|
if (FAILED(reg_unreg_wine_test_class(TRUE)))
|
|
|
|
return;
|
2007-02-23 20:38:11 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_WineTest, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&pObject);
|
|
|
|
ok_ole_success(hr, "CoCreateInstance");
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(pObject, &IID_IWineTest, (void **)&pObject2);
|
|
|
|
ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface on handler for invalid interface returned 0x%08x instead of E_NOINTERFACE\n", hr);
|
|
|
|
|
|
|
|
/* it's a handler as it supports IOleObject */
|
|
|
|
hr = IUnknown_QueryInterface(pObject, &IID_IOleObject, (void **)&pObject2);
|
|
|
|
ok_ole_success(hr, "IUnknown_QueryInterface(&IID_IOleObject)");
|
|
|
|
IUnknown_Release(pObject2);
|
|
|
|
|
|
|
|
IUnknown_Release(pObject);
|
|
|
|
}
|
|
|
|
|
2009-01-25 20:01:54 +01:00
|
|
|
reg_unreg_wine_test_class(FALSE);
|
2007-02-23 20:38:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Test_SMI_QueryInterface(
|
|
|
|
IStdMarshalInfo *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IStdMarshalInfo))
|
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
*ppvObj = iface;
|
2012-08-13 11:40:46 +02:00
|
|
|
IStdMarshalInfo_AddRef(iface);
|
2007-02-23 20:38:11 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Test_SMI_AddRef(IStdMarshalInfo *iface)
|
|
|
|
{
|
|
|
|
LockModule();
|
|
|
|
return 2; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Test_SMI_Release(IStdMarshalInfo *iface)
|
|
|
|
{
|
|
|
|
UnlockModule();
|
|
|
|
return 1; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Test_SMI_GetClassForHandler(
|
|
|
|
IStdMarshalInfo *iface,
|
|
|
|
DWORD dwDestContext,
|
|
|
|
void *pvDestContext,
|
|
|
|
CLSID *pClsid)
|
|
|
|
{
|
|
|
|
*pClsid = CLSID_WineTest;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IStdMarshalInfoVtbl Test_SMI_Vtbl =
|
|
|
|
{
|
|
|
|
Test_SMI_QueryInterface,
|
|
|
|
Test_SMI_AddRef,
|
|
|
|
Test_SMI_Release,
|
|
|
|
Test_SMI_GetClassForHandler
|
|
|
|
};
|
|
|
|
|
|
|
|
static IStdMarshalInfo Test_SMI = {&Test_SMI_Vtbl};
|
|
|
|
|
|
|
|
static void test_handler_marshaling(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IUnknown *pProxy = NULL;
|
|
|
|
IUnknown *pObject;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
static const LARGE_INTEGER ullZero;
|
|
|
|
|
2011-09-21 00:42:06 +02:00
|
|
|
if (FAILED(reg_unreg_wine_test_class(TRUE)))
|
|
|
|
return;
|
2007-02-23 20:38:11 +01:00
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, "CreateStreamOnHGlobal");
|
|
|
|
tid = start_host_object(pStream, &IID_IUnknown, (IUnknown*)&Test_SMI, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IUnknown, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, "CoUnmarshalInterface");
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
2008-08-06 06:51:03 +02:00
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
ok_more_than_one_lock();
|
2007-02-23 20:38:11 +01:00
|
|
|
|
2008-08-06 06:51:03 +02:00
|
|
|
hr = IUnknown_QueryInterface(pProxy, &IID_IWineTest, (void **)&pObject);
|
|
|
|
ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface with unknown IID should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
|
2007-02-23 20:38:11 +01:00
|
|
|
|
2008-08-06 06:51:03 +02:00
|
|
|
/* it's a handler as it supports IOleObject */
|
|
|
|
hr = IUnknown_QueryInterface(pProxy, &IID_IOleObject, (void **)&pObject);
|
|
|
|
todo_wine
|
|
|
|
ok_ole_success(hr, "IUnknown_QueryInterface(&IID_IOleObject)");
|
|
|
|
if (SUCCEEDED(hr)) IUnknown_Release(pObject);
|
2007-02-23 20:38:11 +01:00
|
|
|
|
2008-08-06 06:51:03 +02:00
|
|
|
IUnknown_Release(pProxy);
|
2007-02-23 20:38:11 +01:00
|
|
|
|
2008-08-06 06:51:03 +02:00
|
|
|
ok_no_locks();
|
|
|
|
}
|
2007-02-23 20:38:11 +01:00
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
2009-01-25 20:01:54 +01:00
|
|
|
reg_unreg_wine_test_class(FALSE);
|
2007-02-23 20:38:11 +01:00
|
|
|
|
|
|
|
/* FIXME: test IPersist interface has the same effect as IStdMarshalInfo */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-27 19:18:05 +02:00
|
|
|
static void test_client_security(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IClassFactory *pProxy = NULL;
|
|
|
|
IUnknown *pProxy2 = NULL;
|
|
|
|
IUnknown *pUnknown1 = NULL;
|
|
|
|
IUnknown *pUnknown2 = NULL;
|
|
|
|
IClientSecurity *pCliSec = NULL;
|
|
|
|
IMarshal *pMarshal;
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE thread;
|
|
|
|
static const LARGE_INTEGER ullZero;
|
|
|
|
DWORD dwAuthnSvc;
|
|
|
|
DWORD dwAuthzSvc;
|
|
|
|
OLECHAR *pServerPrincName;
|
|
|
|
DWORD dwAuthnLevel;
|
|
|
|
DWORD dwImpLevel;
|
|
|
|
void *pAuthInfo;
|
|
|
|
DWORD dwCapabilities;
|
|
|
|
void *pv;
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, "CreateStreamOnHGlobal");
|
|
|
|
tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
|
|
|
|
ok_ole_success(hr, "CoUnmarshalInterface");
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
2012-08-13 11:40:46 +02:00
|
|
|
hr = IClassFactory_QueryInterface(pProxy, &IID_IUnknown, (LPVOID*)&pUnknown1);
|
2007-03-27 19:18:05 +02:00
|
|
|
ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown");
|
|
|
|
|
2012-08-13 11:40:46 +02:00
|
|
|
hr = IClassFactory_QueryInterface(pProxy, &IID_IRemUnknown, (LPVOID*)&pProxy2);
|
2007-03-27 19:18:05 +02:00
|
|
|
ok_ole_success(hr, "IUnknown_QueryInterface IID_IStream");
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(pProxy2, &IID_IUnknown, (LPVOID*)&pUnknown2);
|
|
|
|
ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown");
|
|
|
|
|
|
|
|
ok(pUnknown1 == pUnknown2, "both proxy's IUnknowns should be the same - %p, %p\n", pUnknown1, pUnknown2);
|
|
|
|
|
2012-08-13 11:40:46 +02:00
|
|
|
hr = IClassFactory_QueryInterface(pProxy, &IID_IMarshal, (LPVOID*)&pMarshal);
|
2007-03-27 19:18:05 +02:00
|
|
|
ok_ole_success(hr, "IUnknown_QueryInterface IID_IMarshal");
|
|
|
|
|
2012-08-13 11:40:46 +02:00
|
|
|
hr = IClassFactory_QueryInterface(pProxy, &IID_IClientSecurity, (LPVOID*)&pCliSec);
|
2007-03-27 19:18:05 +02:00
|
|
|
ok_ole_success(hr, "IUnknown_QueryInterface IID_IClientSecurity");
|
|
|
|
|
|
|
|
hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pProxy, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket (all NULLs)");
|
|
|
|
|
|
|
|
hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pMarshal, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
todo_wine ok(hr == E_NOINTERFACE, "IClientSecurity_QueryBlanket with local interface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pProxy, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
|
|
|
|
todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket");
|
|
|
|
|
|
|
|
hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pProxy, dwAuthnSvc, dwAuthzSvc, pServerPrincName, dwAuthnLevel, RPC_C_IMP_LEVEL_IMPERSONATE, pAuthInfo, dwCapabilities);
|
|
|
|
todo_wine ok_ole_success(hr, "IClientSecurity_SetBlanket");
|
|
|
|
|
|
|
|
hr = IClassFactory_CreateInstance(pProxy, NULL, &IID_IWineTest, &pv);
|
|
|
|
ok(hr == E_NOINTERFACE, "COM call should have succeeded instead of returning 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pMarshal, dwAuthnSvc, dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities);
|
|
|
|
todo_wine ok(hr == E_NOINTERFACE, "IClientSecurity_SetBlanket with local interface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pProxy, 0xdeadbeef, dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities);
|
|
|
|
todo_wine ok(hr == E_INVALIDARG, "IClientSecurity_SetBlanke with invalid dwAuthnSvc should have returned E_INVALIDARG instead of 0x%08x\n", hr);
|
|
|
|
|
|
|
|
CoTaskMemFree(pServerPrincName);
|
|
|
|
|
2009-01-20 11:21:23 +01:00
|
|
|
hr = IClientSecurity_QueryBlanket(pCliSec, pUnknown1, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
|
2007-03-27 19:18:05 +02:00
|
|
|
todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket(IUnknown)");
|
|
|
|
|
|
|
|
CoTaskMemFree(pServerPrincName);
|
|
|
|
|
|
|
|
IClassFactory_Release(pProxy);
|
|
|
|
IUnknown_Release(pProxy2);
|
|
|
|
IUnknown_Release(pUnknown1);
|
|
|
|
IUnknown_Release(pUnknown2);
|
|
|
|
IMarshal_Release(pMarshal);
|
|
|
|
IClientSecurity_Release(pCliSec);
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
static HANDLE heventShutdown;
|
|
|
|
|
2006-04-18 10:18:03 +02:00
|
|
|
static void LockModuleOOP(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
InterlockedIncrement(&cLocks); /* for test purposes only */
|
|
|
|
CoAddRefServerProcess();
|
|
|
|
}
|
|
|
|
|
2006-04-18 10:18:03 +02:00
|
|
|
static void UnlockModuleOOP(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
InterlockedDecrement(&cLocks); /* for test purposes only */
|
|
|
|
if (!CoReleaseServerProcess())
|
|
|
|
SetEvent(heventShutdown);
|
|
|
|
}
|
|
|
|
|
2005-03-04 13:30:47 +01:00
|
|
|
static HWND hwnd_app;
|
|
|
|
|
2015-10-13 15:49:16 +02:00
|
|
|
struct local_server
|
|
|
|
{
|
|
|
|
IPersist IPersist_iface; /* a nice short interface */
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI local_server_QueryInterface(IPersist *iface, REFIID iid, void **obj)
|
|
|
|
{
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(iid, &IID_IPersist))
|
|
|
|
*obj = iface;
|
|
|
|
|
|
|
|
if (*obj)
|
|
|
|
{
|
|
|
|
IPersist_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI local_server_AddRef(IPersist *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI local_server_Release(IPersist *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI local_server_GetClassID(IPersist *iface, CLSID *clsid)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*clsid = IID_IUnknown;
|
|
|
|
|
|
|
|
/* Test calling CoDisconnectObject within a COM call */
|
|
|
|
hr = CoDisconnectObject((IUnknown *)iface, 0);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
2017-11-10 13:56:05 +01:00
|
|
|
/* Initialize and uninitialize the apartment to show that we
|
|
|
|
* remain in the autojoined mta */
|
|
|
|
hr = pCoInitializeEx( NULL, COINIT_MULTITHREADED );
|
|
|
|
ok( hr == S_FALSE, "got %08x\n", hr );
|
|
|
|
CoUninitialize();
|
|
|
|
|
2015-10-13 15:49:16 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPersistVtbl local_server_persist_vtbl =
|
|
|
|
{
|
|
|
|
local_server_QueryInterface,
|
|
|
|
local_server_AddRef,
|
|
|
|
local_server_Release,
|
|
|
|
local_server_GetClassID
|
|
|
|
};
|
|
|
|
|
|
|
|
struct local_server local_server_class =
|
|
|
|
{
|
|
|
|
{&local_server_persist_vtbl}
|
|
|
|
};
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
static HRESULT WINAPI TestOOP_IClassFactory_QueryInterface(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IClassFactory))
|
|
|
|
{
|
2009-01-20 11:21:23 +01:00
|
|
|
*ppvObj = iface;
|
2004-12-21 15:51:27 +01:00
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TestOOP_IClassFactory_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 2; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TestOOP_IClassFactory_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 1; /* non-heap-based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TestOOP_IClassFactory_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2015-10-13 15:49:16 +02:00
|
|
|
IPersist *persist = &local_server_class.IPersist_iface;
|
|
|
|
HRESULT hr;
|
|
|
|
IPersist_AddRef( persist );
|
|
|
|
hr = IPersist_QueryInterface( persist, riid, ppvObj );
|
|
|
|
IPersist_Release( persist );
|
|
|
|
return hr;
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TestOOP_IClassFactory_LockServer(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
BOOL fLock)
|
|
|
|
{
|
|
|
|
if (fLock)
|
|
|
|
LockModuleOOP();
|
|
|
|
else
|
|
|
|
UnlockModuleOOP();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IClassFactoryVtbl TestClassFactoryOOP_Vtbl =
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
TestOOP_IClassFactory_QueryInterface,
|
|
|
|
TestOOP_IClassFactory_AddRef,
|
|
|
|
TestOOP_IClassFactory_Release,
|
|
|
|
TestOOP_IClassFactory_CreateInstance,
|
|
|
|
TestOOP_IClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static IClassFactory TestOOP_ClassFactory = { &TestClassFactoryOOP_Vtbl };
|
|
|
|
|
2007-03-09 18:51:36 +01:00
|
|
|
static void test_register_local_server(void)
|
|
|
|
{
|
|
|
|
DWORD cookie;
|
|
|
|
HRESULT hr;
|
|
|
|
HANDLE ready_event;
|
|
|
|
DWORD wait;
|
2015-10-13 15:49:16 +02:00
|
|
|
HANDLE handles[2];
|
2007-03-09 18:51:36 +01:00
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
heventShutdown = CreateEventA(NULL, TRUE, FALSE, NULL);
|
2015-10-13 15:49:16 +02:00
|
|
|
ready_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Ready Event");
|
|
|
|
handles[0] = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Quit Event");
|
|
|
|
handles[1] = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Repeat Event");
|
2007-03-09 18:51:36 +01:00
|
|
|
|
2015-10-13 15:49:16 +02:00
|
|
|
again:
|
2007-03-09 18:51:36 +01:00
|
|
|
hr = CoRegisterClassObject(&CLSID_WineOOPTest, (IUnknown *)&TestOOP_ClassFactory,
|
|
|
|
CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &cookie);
|
|
|
|
ok_ole_success(hr, CoRegisterClassObject);
|
|
|
|
|
|
|
|
SetEvent(ready_event);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2015-10-13 15:49:16 +02:00
|
|
|
wait = MsgWaitForMultipleObjects(2, handles, FALSE, 30000, QS_ALLINPUT);
|
|
|
|
if (wait == WAIT_OBJECT_0+2)
|
2007-03-09 18:51:36 +01:00
|
|
|
{
|
|
|
|
MSG msg;
|
2013-10-15 20:37:46 +02:00
|
|
|
|
|
|
|
if (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
2007-03-09 18:51:36 +01:00
|
|
|
{
|
|
|
|
trace("Message 0x%x\n", msg.message);
|
|
|
|
TranslateMessage(&msg);
|
2013-10-15 20:37:46 +02:00
|
|
|
DispatchMessageA(&msg);
|
2007-03-09 18:51:36 +01:00
|
|
|
}
|
|
|
|
}
|
2015-10-13 15:49:16 +02:00
|
|
|
else if (wait == WAIT_OBJECT_0+1)
|
|
|
|
{
|
|
|
|
hr = CoRevokeClassObject(cookie);
|
|
|
|
ok_ole_success(hr, CoRevokeClassObject);
|
|
|
|
goto again;
|
|
|
|
}
|
2007-03-09 18:51:36 +01:00
|
|
|
}
|
2015-10-13 15:49:16 +02:00
|
|
|
while (wait == WAIT_OBJECT_0+2);
|
2007-03-09 18:51:36 +01:00
|
|
|
|
2009-02-17 14:58:11 +01:00
|
|
|
ok( wait == WAIT_OBJECT_0, "quit event wait timed out\n" );
|
2007-03-09 18:51:36 +01:00
|
|
|
hr = CoRevokeClassObject(cookie);
|
|
|
|
ok_ole_success(hr, CoRevokeClassObject);
|
2015-10-13 15:49:16 +02:00
|
|
|
CloseHandle(handles[0]);
|
|
|
|
CloseHandle(handles[1]);
|
2007-03-09 18:51:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HANDLE create_target_process(const char *arg)
|
|
|
|
{
|
|
|
|
char **argv;
|
|
|
|
char cmdline[MAX_PATH];
|
2010-12-30 20:02:00 +01:00
|
|
|
BOOL ret;
|
2007-03-09 18:51:36 +01:00
|
|
|
PROCESS_INFORMATION pi;
|
2013-10-15 20:37:46 +02:00
|
|
|
STARTUPINFOA si = { 0 };
|
2007-03-09 18:51:36 +01:00
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
2007-11-01 14:26:33 +01:00
|
|
|
pi.hThread = NULL;
|
|
|
|
pi.hProcess = NULL;
|
2007-03-09 18:51:36 +01:00
|
|
|
winetest_get_mainargs( &argv );
|
2015-09-02 11:20:08 +02:00
|
|
|
sprintf(cmdline, "\"%s\" %s %s", argv[0], argv[1], arg);
|
2013-10-15 20:37:46 +02:00
|
|
|
ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
2010-12-30 20:02:00 +01:00
|
|
|
ok(ret, "CreateProcess failed with error: %u\n", GetLastError());
|
2007-11-01 14:26:33 +01:00
|
|
|
if (pi.hThread) CloseHandle(pi.hThread);
|
2007-03-09 18:51:36 +01:00
|
|
|
return pi.hProcess;
|
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
/* tests functions commonly used by out of process COM servers */
|
2007-03-09 18:40:40 +01:00
|
|
|
static void test_local_server(void)
|
2004-12-21 15:51:27 +01:00
|
|
|
{
|
|
|
|
DWORD cookie;
|
|
|
|
HRESULT hr;
|
|
|
|
IClassFactory * cf;
|
2015-10-13 15:49:16 +02:00
|
|
|
IPersist *persist;
|
2004-12-21 15:51:27 +01:00
|
|
|
DWORD ret;
|
2007-03-09 18:51:36 +01:00
|
|
|
HANDLE process;
|
|
|
|
HANDLE quit_event;
|
|
|
|
HANDLE ready_event;
|
2015-10-13 15:49:16 +02:00
|
|
|
HANDLE repeat_event;
|
|
|
|
CLSID clsid;
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
heventShutdown = CreateEventA(NULL, TRUE, FALSE, NULL);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
/* Start the object suspended */
|
|
|
|
hr = CoRegisterClassObject(&CLSID_WineOOPTest, (IUnknown *)&TestOOP_ClassFactory,
|
|
|
|
CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED, &cookie);
|
|
|
|
ok_ole_success(hr, CoRegisterClassObject);
|
|
|
|
|
|
|
|
/* ... and CoGetClassObject does not find it and fails when it looks for the
|
|
|
|
* class in the registry */
|
|
|
|
hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER,
|
|
|
|
NULL, &IID_IClassFactory, (LPVOID*)&cf);
|
2007-03-09 18:40:40 +01:00
|
|
|
ok(hr == REGDB_E_CLASSNOTREG || /* NT */
|
|
|
|
hr == S_OK /* Win9x */,
|
2006-10-14 04:54:46 +02:00
|
|
|
"CoGetClassObject should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
/* Resume the object suspended above ... */
|
|
|
|
hr = CoResumeClassObjects();
|
|
|
|
ok_ole_success(hr, CoResumeClassObjects);
|
|
|
|
|
|
|
|
/* ... and now it should succeed */
|
|
|
|
hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER,
|
|
|
|
NULL, &IID_IClassFactory, (LPVOID*)&cf);
|
|
|
|
ok_ole_success(hr, CoGetClassObject);
|
|
|
|
|
|
|
|
/* Now check the locking is working */
|
|
|
|
/* NOTE: we are accessing the class directly, not through a proxy */
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
hr = IClassFactory_LockServer(cf, TRUE);
|
2007-03-09 18:40:40 +01:00
|
|
|
ok_ole_success(hr, IClassFactory_LockServer);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IClassFactory_LockServer(cf, FALSE);
|
2007-03-09 18:40:40 +01:00
|
|
|
ok_ole_success(hr, IClassFactory_LockServer);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
IClassFactory_Release(cf);
|
|
|
|
|
|
|
|
/* wait for shutdown signal */
|
2007-03-09 18:40:40 +01:00
|
|
|
ret = WaitForSingleObject(heventShutdown, 0);
|
2007-03-09 19:55:13 +01:00
|
|
|
ok(ret != WAIT_TIMEOUT, "Server didn't shut down\n");
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
/* try to connect again after SCM has suspended registered class objects */
|
|
|
|
hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, NULL,
|
|
|
|
&IID_IClassFactory, (LPVOID*)&cf);
|
2007-03-09 18:40:40 +01:00
|
|
|
ok(hr == CO_E_SERVER_STOPPING || /* NT */
|
2008-04-16 23:39:45 +02:00
|
|
|
hr == REGDB_E_CLASSNOTREG || /* win2k */
|
2007-03-09 18:40:40 +01:00
|
|
|
hr == S_OK /* Win9x */,
|
2008-04-16 23:39:45 +02:00
|
|
|
"CoGetClassObject should have returned CO_E_SERVER_STOPPING or REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
|
2004-12-21 15:51:27 +01:00
|
|
|
|
|
|
|
hr = CoRevokeClassObject(cookie);
|
|
|
|
ok_ole_success(hr, CoRevokeClassObject);
|
|
|
|
|
|
|
|
CloseHandle(heventShutdown);
|
2007-03-09 18:51:36 +01:00
|
|
|
|
|
|
|
process = create_target_process("-Embedding");
|
|
|
|
ok(process != NULL, "couldn't start local server process, error was %d\n", GetLastError());
|
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
ready_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Ready Event");
|
2009-08-18 12:48:57 +02:00
|
|
|
ok( !WaitForSingleObject(ready_event, 10000), "wait timed out\n" );
|
2007-03-09 18:51:36 +01:00
|
|
|
|
2015-10-13 15:49:16 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_LOCAL_SERVER, &IID_IPersist, (void **)&persist);
|
2007-03-09 18:51:36 +01:00
|
|
|
ok_ole_success(hr, CoCreateInstance);
|
|
|
|
|
2015-10-13 15:49:16 +02:00
|
|
|
IPersist_Release(persist);
|
2007-03-09 18:51:36 +01:00
|
|
|
|
2015-10-13 15:49:16 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_LOCAL_SERVER, &IID_IPersist, (void **)&persist);
|
2007-03-09 18:51:36 +01:00
|
|
|
ok(hr == REGDB_E_CLASSNOTREG, "Second CoCreateInstance on REGCLS_SINGLEUSE object should have failed\n");
|
|
|
|
|
2015-10-13 15:49:16 +02:00
|
|
|
/* Re-register the class and try calling CoDisconnectObject from within a call to that object */
|
|
|
|
repeat_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Repeat Event");
|
|
|
|
SetEvent(repeat_event);
|
|
|
|
CloseHandle(repeat_event);
|
|
|
|
|
|
|
|
ok( !WaitForSingleObject(ready_event, 10000), "wait timed out\n" );
|
|
|
|
CloseHandle(ready_event);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_LOCAL_SERVER, &IID_IPersist, (void **)&persist);
|
|
|
|
ok_ole_success(hr, CoCreateInstance);
|
|
|
|
|
|
|
|
/* GetClassID will call CoDisconnectObject */
|
|
|
|
IPersist_GetClassID(persist, &clsid);
|
|
|
|
IPersist_Release(persist);
|
|
|
|
|
2013-10-15 20:37:46 +02:00
|
|
|
quit_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Quit Event");
|
2007-03-09 18:51:36 +01:00
|
|
|
SetEvent(quit_event);
|
|
|
|
|
2008-02-07 12:56:00 +01:00
|
|
|
winetest_wait_child_process( process );
|
2007-03-09 18:51:36 +01:00
|
|
|
CloseHandle(quit_event);
|
|
|
|
CloseHandle(process);
|
2004-12-21 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
2006-06-14 14:20:01 +02:00
|
|
|
struct git_params
|
|
|
|
{
|
|
|
|
DWORD cookie;
|
|
|
|
IGlobalInterfaceTable *git;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD CALLBACK get_global_interface_proc(LPVOID pv)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
2009-01-20 11:21:23 +01:00
|
|
|
struct git_params *params = pv;
|
2006-06-14 14:20:01 +02:00
|
|
|
IClassFactory *cf;
|
|
|
|
|
|
|
|
hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
|
2008-04-16 23:39:45 +02:00
|
|
|
ok(hr == CO_E_NOTINITIALIZED ||
|
2009-01-28 13:48:40 +01:00
|
|
|
broken(hr == E_UNEXPECTED) /* win2k */ ||
|
|
|
|
broken(hr == S_OK) /* NT 4 */,
|
2008-04-16 23:39:45 +02:00
|
|
|
"IGlobalInterfaceTable_GetInterfaceFromGlobal should have failed with error CO_E_NOTINITIALIZED or E_UNEXPECTED instead of 0x%08x\n",
|
2006-06-14 14:20:01 +02:00
|
|
|
hr);
|
2009-01-28 13:48:40 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
IClassFactory_Release(cf);
|
2006-06-14 14:20:01 +02:00
|
|
|
|
|
|
|
CoInitialize(NULL);
|
2007-05-22 11:31:45 +02:00
|
|
|
|
2006-06-14 14:20:01 +02:00
|
|
|
hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
|
2006-06-14 14:20:14 +02:00
|
|
|
ok_ole_success(hr, IGlobalInterfaceTable_GetInterfaceFromGlobal);
|
2007-01-07 13:15:54 +01:00
|
|
|
|
2007-05-22 11:31:45 +02:00
|
|
|
IClassFactory_Release(cf);
|
2007-01-07 13:15:54 +01:00
|
|
|
|
2006-06-14 14:20:01 +02:00
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_globalinterfacetable(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IGlobalInterfaceTable *git;
|
|
|
|
DWORD cookie;
|
|
|
|
HANDLE thread;
|
|
|
|
DWORD tid;
|
|
|
|
struct git_params params;
|
|
|
|
DWORD ret;
|
2007-05-22 11:31:45 +02:00
|
|
|
IUnknown *object;
|
2013-08-21 22:00:39 +02:00
|
|
|
IClassFactory *cf;
|
2013-08-23 08:34:48 +02:00
|
|
|
ULONG ref;
|
2007-05-22 11:31:45 +02:00
|
|
|
|
|
|
|
trace("test_globalinterfacetable\n");
|
|
|
|
cLocks = 0;
|
2006-06-14 14:20:01 +02:00
|
|
|
|
2013-08-21 22:00:39 +02:00
|
|
|
hr = pDllGetClassObject(&CLSID_StdGlobalInterfaceTable, &IID_IClassFactory, (void**)&cf);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IClassFactory_QueryInterface(cf, &IID_IGlobalInterfaceTable, (void**)&object);
|
|
|
|
ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IClassFactory_Release(cf);
|
|
|
|
|
2006-06-14 14:20:01 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, &IID_IGlobalInterfaceTable, (void **)&git);
|
|
|
|
ok_ole_success(hr, CoCreateInstance);
|
|
|
|
|
2013-08-23 08:34:48 +02:00
|
|
|
ref = IGlobalInterfaceTable_AddRef(git);
|
|
|
|
ok(ref == 1, "ref=%d\n", ref);
|
|
|
|
ref = IGlobalInterfaceTable_AddRef(git);
|
|
|
|
ok(ref == 1, "ref=%d\n", ref);
|
|
|
|
|
|
|
|
ref = IGlobalInterfaceTable_Release(git);
|
|
|
|
ok(ref == 1, "ref=%d\n", ref);
|
|
|
|
ref = IGlobalInterfaceTable_Release(git);
|
|
|
|
ok(ref == 1, "ref=%d\n", ref);
|
|
|
|
|
2006-06-14 14:20:01 +02:00
|
|
|
hr = IGlobalInterfaceTable_RegisterInterfaceInGlobal(git, (IUnknown *)&Test_ClassFactory, &IID_IClassFactory, &cookie);
|
|
|
|
ok_ole_success(hr, IGlobalInterfaceTable_RegisterInterfaceInGlobal);
|
|
|
|
|
2007-05-22 11:31:45 +02:00
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
2006-06-14 14:20:01 +02:00
|
|
|
params.cookie = cookie;
|
|
|
|
params.git = git;
|
|
|
|
/* note: params is on stack so we MUST wait for get_global_interface_proc
|
|
|
|
* to exit before we can return */
|
|
|
|
thread = CreateThread(NULL, 0, get_global_interface_proc, ¶ms, 0, &tid);
|
|
|
|
|
2009-08-18 12:48:57 +02:00
|
|
|
ret = MsgWaitForMultipleObjects(1, &thread, FALSE, 10000, QS_ALLINPUT);
|
2006-06-14 14:20:01 +02:00
|
|
|
while (ret == WAIT_OBJECT_0 + 1)
|
|
|
|
{
|
|
|
|
MSG msg;
|
2013-10-15 20:37:46 +02:00
|
|
|
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
|
|
|
DispatchMessageA(&msg);
|
2009-08-18 12:48:57 +02:00
|
|
|
ret = MsgWaitForMultipleObjects(1, &thread, FALSE, 10000, QS_ALLINPUT);
|
2006-06-14 14:20:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(thread);
|
2007-05-22 11:31:45 +02:00
|
|
|
|
|
|
|
/* test getting interface from global with different iid */
|
|
|
|
hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(git, cookie, &IID_IUnknown, (void **)&object);
|
|
|
|
ok_ole_success(hr, IGlobalInterfaceTable_GetInterfaceFromGlobal);
|
2007-05-22 11:32:19 +02:00
|
|
|
IUnknown_Release(object);
|
2007-05-22 11:31:45 +02:00
|
|
|
|
|
|
|
/* test getting interface from global with same iid */
|
|
|
|
hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(git, cookie, &IID_IClassFactory, (void **)&object);
|
|
|
|
ok_ole_success(hr, IGlobalInterfaceTable_GetInterfaceFromGlobal);
|
|
|
|
IUnknown_Release(object);
|
|
|
|
|
|
|
|
hr = IGlobalInterfaceTable_RevokeInterfaceFromGlobal(git, cookie);
|
|
|
|
ok_ole_success(hr, IGlobalInterfaceTable_RevokeInterfaceFromGlobal);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
IGlobalInterfaceTable_Release(git);
|
2006-06-14 14:20:01 +02:00
|
|
|
}
|
|
|
|
|
2011-05-30 12:45:31 +02:00
|
|
|
static void test_manualresetevent(void)
|
|
|
|
{
|
2012-08-13 11:41:12 +02:00
|
|
|
ISynchronizeHandle *sync_handle;
|
2011-05-30 12:45:31 +02:00
|
|
|
ISynchronize *psync1, *psync2;
|
|
|
|
IUnknown *punk;
|
2012-08-13 11:41:12 +02:00
|
|
|
HANDLE handle;
|
2011-05-30 12:45:31 +02:00
|
|
|
LONG ref;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_ManualResetEvent, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(!!punk, "Got NULL.\n");
|
|
|
|
IUnknown_Release(punk);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_ManualResetEvent, NULL, CLSCTX_INPROC_SERVER, &IID_ISynchronize, (void**)&psync1);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(!!psync1, "Got NULL.\n");
|
|
|
|
|
|
|
|
hr = ISynchronize_Wait(psync1, 0, 5);
|
|
|
|
ok(hr == RPC_S_CALLPENDING, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISynchronize_Reset(psync1);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Signal(psync1);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Wait(psync1, 0, 5);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Wait(psync1, 0, 5);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Reset(psync1);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Wait(psync1, 0, 5);
|
|
|
|
ok(hr == RPC_S_CALLPENDING, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_ManualResetEvent, NULL, CLSCTX_INPROC_SERVER, &IID_ISynchronize, (void**)&psync2);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(!!psync2, "Got NULL.\n");
|
|
|
|
ok(psync1 != psync2, "psync1 == psync2.\n");
|
2012-08-13 11:41:12 +02:00
|
|
|
|
|
|
|
hr = ISynchronize_QueryInterface(psync2, &IID_ISynchronizeHandle, (void**)&sync_handle);
|
|
|
|
ok(hr == S_OK, "QueryInterface(IID_ISynchronizeHandle) failed: %08x\n", hr);
|
|
|
|
|
|
|
|
handle = NULL;
|
|
|
|
hr = ISynchronizeHandle_GetHandle(sync_handle, &handle);
|
|
|
|
ok(hr == S_OK, "GetHandle failed: %08x\n", hr);
|
|
|
|
ok(handle != NULL && handle != INVALID_HANDLE_VALUE, "handle = %p\n", handle);
|
|
|
|
|
|
|
|
ISynchronizeHandle_Release(sync_handle);
|
|
|
|
|
2011-05-30 12:45:31 +02:00
|
|
|
hr = ISynchronize_Wait(psync2, 0, 5);
|
|
|
|
ok(hr == RPC_S_CALLPENDING, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISynchronize_Reset(psync1);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Reset(psync2);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Signal(psync1);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
hr = ISynchronize_Wait(psync2, 0, 5);
|
|
|
|
ok(hr == RPC_S_CALLPENDING, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ref = ISynchronize_AddRef(psync1);
|
|
|
|
ok(ref == 2, "Got ref: %d\n", ref);
|
|
|
|
ref = ISynchronize_AddRef(psync1);
|
|
|
|
ok(ref == 3, "Got ref: %d\n", ref);
|
|
|
|
ref = ISynchronize_Release(psync1);
|
|
|
|
ok(ref == 2, "Got nonzero ref: %d\n", ref);
|
|
|
|
ref = ISynchronize_Release(psync2);
|
|
|
|
ok(!ref, "Got nonzero ref: %d\n", ref);
|
|
|
|
ref = ISynchronize_Release(psync1);
|
|
|
|
ok(ref == 1, "Got nonzero ref: %d\n", ref);
|
|
|
|
ref = ISynchronize_Release(psync1);
|
|
|
|
ok(!ref, "Got nonzero ref: %d\n", ref);
|
|
|
|
}
|
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
static const char *debugstr_iid(REFIID riid)
|
|
|
|
{
|
|
|
|
static char name[256];
|
|
|
|
HKEY hkeyInterface;
|
|
|
|
WCHAR bufferW[39];
|
|
|
|
char buffer[39];
|
|
|
|
LONG name_size = sizeof(name);
|
|
|
|
StringFromGUID2(riid, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer, sizeof(buffer), NULL, NULL);
|
2013-10-15 20:37:46 +02:00
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_QUERY_VALUE, &hkeyInterface) != ERROR_SUCCESS)
|
2006-12-29 15:44:14 +01:00
|
|
|
{
|
|
|
|
memcpy(name, buffer, sizeof(buffer));
|
|
|
|
goto done;
|
|
|
|
}
|
2013-10-15 20:37:46 +02:00
|
|
|
if (RegQueryValueA(hkeyInterface, buffer, name, &name_size) != ERROR_SUCCESS)
|
2006-12-29 15:44:14 +01:00
|
|
|
{
|
|
|
|
memcpy(name, buffer, sizeof(buffer));
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkeyInterface);
|
|
|
|
done:
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TestChannelHook_QueryInterface(IChannelHook *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IChannelHook))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
2012-08-13 11:40:46 +02:00
|
|
|
IChannelHook_AddRef(iface);
|
2006-12-29 15:44:14 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TestChannelHook_AddRef(IChannelHook *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TestChannelHook_Release(IChannelHook *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-09-02 12:41:05 +02:00
|
|
|
static BOOL new_hook_struct;
|
|
|
|
static int method, server_tid;
|
|
|
|
static GUID causality;
|
|
|
|
|
|
|
|
struct new_hook_info
|
|
|
|
{
|
|
|
|
IID iid;
|
|
|
|
GUID causality;
|
|
|
|
DWORD server_pid;
|
|
|
|
DWORD server_tid;
|
|
|
|
WORD method;
|
|
|
|
};
|
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
static void WINAPI TestChannelHook_ClientGetSize(
|
|
|
|
IChannelHook *iface,
|
|
|
|
REFGUID uExtent,
|
|
|
|
REFIID riid,
|
|
|
|
ULONG *pDataSize )
|
|
|
|
{
|
|
|
|
SChannelHookCallInfo *info = (SChannelHookCallInfo *)riid;
|
2016-09-02 12:41:05 +02:00
|
|
|
trace("TestChannelHook_ClientGetSize\n");
|
|
|
|
trace("\t%s\n", debugstr_iid(riid));
|
|
|
|
if (info->cbSize != sizeof(*info))
|
|
|
|
new_hook_struct = TRUE;
|
|
|
|
|
|
|
|
if (!new_hook_struct)
|
|
|
|
{
|
|
|
|
ok(info->cbSize == sizeof(*info), "cbSize was %d instead of %d\n", info->cbSize, (int)sizeof(*info));
|
|
|
|
ok(info->dwServerPid == GetCurrentProcessId(), "dwServerPid was 0x%x instead of 0x%x\n", info->dwServerPid, GetCurrentProcessId());
|
|
|
|
ok(info->iMethod == method, "iMethod was %d should be %d\n", info->iMethod, method);
|
|
|
|
ok(!info->pObject, "pObject should be NULL\n");
|
|
|
|
if (method == 3)
|
|
|
|
causality = info->uCausality;
|
|
|
|
else
|
|
|
|
ok(IsEqualGUID(&info->uCausality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct new_hook_info *new_info = (struct new_hook_info *)riid;
|
|
|
|
ok(new_info->server_pid == GetCurrentProcessId(), "server pid was 0x%x instead of 0x%x\n", new_info->server_pid,
|
|
|
|
GetCurrentProcessId());
|
|
|
|
ok(new_info->server_tid == server_tid, "server tid was 0x%x instead of 0x%x\n", new_info->server_tid,
|
|
|
|
server_tid);
|
|
|
|
ok(new_info->method == method, "method was %d instead of %d\n", new_info->method, method);
|
|
|
|
if (method == 3)
|
|
|
|
causality = new_info->causality;
|
|
|
|
else
|
|
|
|
ok(IsEqualGUID(&new_info->causality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
ok(IsEqualGUID(uExtent, &EXTENTID_WineTest), "uExtent wasn't correct\n");
|
|
|
|
|
|
|
|
*pDataSize = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI TestChannelHook_ClientFillBuffer(
|
|
|
|
IChannelHook *iface,
|
|
|
|
REFGUID uExtent,
|
|
|
|
REFIID riid,
|
|
|
|
ULONG *pDataSize,
|
|
|
|
void *pDataBuffer )
|
|
|
|
{
|
|
|
|
SChannelHookCallInfo *info = (SChannelHookCallInfo *)riid;
|
|
|
|
trace("TestChannelHook_ClientFillBuffer\n");
|
2016-09-02 12:41:05 +02:00
|
|
|
|
|
|
|
if (!new_hook_struct)
|
|
|
|
{
|
|
|
|
ok(info->cbSize == sizeof(*info), "cbSize was %d instead of %d\n", info->cbSize, (int)sizeof(*info));
|
|
|
|
ok(info->dwServerPid == GetCurrentProcessId(), "dwServerPid was 0x%x instead of 0x%x\n", info->dwServerPid, GetCurrentProcessId());
|
|
|
|
ok(info->iMethod == method, "iMethod was %d should be %d\n", info->iMethod, method);
|
|
|
|
ok(!info->pObject, "pObject should be NULL\n");
|
|
|
|
ok(IsEqualGUID(&info->uCausality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct new_hook_info *new_info = (struct new_hook_info *)riid;
|
|
|
|
ok(new_info->server_pid == GetCurrentProcessId(), "server pid was 0x%x instead of 0x%x\n", new_info->server_pid,
|
|
|
|
GetCurrentProcessId());
|
|
|
|
ok(new_info->server_tid == server_tid, "server tid was 0x%x instead of 0x%x\n", new_info->server_tid,
|
|
|
|
server_tid);
|
|
|
|
ok(new_info->method == method, "method was %d instead of %d\n", new_info->method, method);
|
|
|
|
ok(IsEqualGUID(&new_info->causality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
ok(IsEqualGUID(uExtent, &EXTENTID_WineTest), "uExtent wasn't correct\n");
|
|
|
|
|
|
|
|
*(unsigned char *)pDataBuffer = 0xcc;
|
|
|
|
*pDataSize = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI TestChannelHook_ClientNotify(
|
|
|
|
IChannelHook *iface,
|
|
|
|
REFGUID uExtent,
|
|
|
|
REFIID riid,
|
|
|
|
ULONG cbDataSize,
|
|
|
|
void *pDataBuffer,
|
|
|
|
DWORD lDataRep,
|
|
|
|
HRESULT hrFault )
|
|
|
|
{
|
|
|
|
SChannelHookCallInfo *info = (SChannelHookCallInfo *)riid;
|
|
|
|
trace("TestChannelHook_ClientNotify hrFault = 0x%08x\n", hrFault);
|
2016-09-02 12:41:05 +02:00
|
|
|
|
|
|
|
if (!new_hook_struct)
|
|
|
|
{
|
|
|
|
ok(info->cbSize == sizeof(*info), "cbSize was %d instead of %d\n", info->cbSize, (int)sizeof(*info));
|
|
|
|
ok(info->dwServerPid == GetCurrentProcessId(), "dwServerPid was 0x%x instead of 0x%x\n", info->dwServerPid, GetCurrentProcessId());
|
|
|
|
ok(info->iMethod == method, "iMethod was %d should be %d\n", info->iMethod, method);
|
|
|
|
todo_wine {
|
|
|
|
ok(info->pObject != NULL, "pObject shouldn't be NULL\n");
|
|
|
|
}
|
|
|
|
ok(IsEqualGUID(&info->uCausality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct new_hook_info *new_info = (struct new_hook_info *)riid;
|
|
|
|
ok(new_info->server_pid == GetCurrentProcessId(), "server pid was 0x%x instead of 0x%x\n", new_info->server_pid,
|
|
|
|
GetCurrentProcessId());
|
|
|
|
ok(new_info->server_tid == server_tid, "server tid was 0x%x instead of 0x%x\n", new_info->server_tid,
|
|
|
|
server_tid);
|
|
|
|
ok(new_info->method == method, "method was %d instead of %d\n", new_info->method, method);
|
|
|
|
ok(IsEqualGUID(&new_info->causality, &causality), "causality wasn't correct\n");
|
2006-12-29 15:44:14 +01:00
|
|
|
}
|
2016-09-02 12:41:05 +02:00
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
ok(IsEqualGUID(uExtent, &EXTENTID_WineTest), "uExtent wasn't correct\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI TestChannelHook_ServerNotify(
|
|
|
|
IChannelHook *iface,
|
|
|
|
REFGUID uExtent,
|
|
|
|
REFIID riid,
|
|
|
|
ULONG cbDataSize,
|
|
|
|
void *pDataBuffer,
|
|
|
|
DWORD lDataRep )
|
|
|
|
{
|
|
|
|
SChannelHookCallInfo *info = (SChannelHookCallInfo *)riid;
|
|
|
|
trace("TestChannelHook_ServerNotify\n");
|
2016-09-02 12:41:05 +02:00
|
|
|
|
|
|
|
if (!new_hook_struct)
|
|
|
|
{
|
|
|
|
ok(info->cbSize == sizeof(*info), "cbSize was %d instead of %d\n", info->cbSize, (int)sizeof(*info));
|
|
|
|
ok(info->dwServerPid == GetCurrentProcessId(), "dwServerPid was 0x%x instead of 0x%x\n", info->dwServerPid, GetCurrentProcessId());
|
|
|
|
ok(info->iMethod == method, "iMethod was %d should be %d\n", info->iMethod, method);
|
|
|
|
ok(info->pObject != NULL, "pObject shouldn't be NULL\n");
|
|
|
|
ok(IsEqualGUID(&info->uCausality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct new_hook_info *new_info = (struct new_hook_info *)riid;
|
|
|
|
ok(new_info->server_pid == GetCurrentProcessId(), "server pid was 0x%x instead of 0x%x\n", new_info->server_pid,
|
|
|
|
GetCurrentProcessId());
|
|
|
|
ok(new_info->server_tid == server_tid, "server tid was 0x%x instead of 0x%x\n", new_info->server_tid,
|
|
|
|
server_tid);
|
|
|
|
ok(new_info->method == method, "method was %d instead of %d\n", new_info->method, method);
|
|
|
|
ok(IsEqualGUID(&new_info->causality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
ok(cbDataSize == 1, "cbDataSize should have been 1 instead of %d\n", cbDataSize);
|
|
|
|
ok(*(unsigned char *)pDataBuffer == 0xcc, "pDataBuffer should have contained 0xcc instead of 0x%x\n", *(unsigned char *)pDataBuffer);
|
|
|
|
ok(IsEqualGUID(uExtent, &EXTENTID_WineTest), "uExtent wasn't correct\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI TestChannelHook_ServerGetSize(
|
|
|
|
IChannelHook *iface,
|
|
|
|
REFGUID uExtent,
|
|
|
|
REFIID riid,
|
|
|
|
HRESULT hrFault,
|
|
|
|
ULONG *pDataSize )
|
|
|
|
{
|
|
|
|
SChannelHookCallInfo *info = (SChannelHookCallInfo *)riid;
|
|
|
|
trace("TestChannelHook_ServerGetSize\n");
|
2016-09-02 12:41:05 +02:00
|
|
|
trace("\t%s\n", debugstr_iid(riid));
|
|
|
|
if (!new_hook_struct)
|
|
|
|
{
|
|
|
|
ok(info->cbSize == sizeof(*info), "cbSize was %d instead of %d\n", info->cbSize, (int)sizeof(*info));
|
|
|
|
ok(info->dwServerPid == GetCurrentProcessId(), "dwServerPid was 0x%x instead of 0x%x\n", info->dwServerPid, GetCurrentProcessId());
|
|
|
|
ok(info->iMethod == method, "iMethod was %d should be %d\n", info->iMethod, method);
|
|
|
|
ok(info->pObject != NULL, "pObject shouldn't be NULL\n");
|
|
|
|
ok(IsEqualGUID(&info->uCausality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct new_hook_info *new_info = (struct new_hook_info *)riid;
|
|
|
|
ok(new_info->server_pid == GetCurrentProcessId(), "server pid was 0x%x instead of 0x%x\n", new_info->server_pid,
|
|
|
|
GetCurrentProcessId());
|
|
|
|
ok(new_info->server_tid == server_tid, "server tid was 0x%x instead of 0x%x\n", new_info->server_tid,
|
|
|
|
server_tid);
|
|
|
|
ok(new_info->method == method, "method was %d instead of %d\n", new_info->method, method);
|
|
|
|
ok(IsEqualGUID(&new_info->causality, &causality), "causality wasn't correct\n");
|
|
|
|
}
|
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
ok(IsEqualGUID(uExtent, &EXTENTID_WineTest), "uExtent wasn't correct\n");
|
|
|
|
if (hrFault != S_OK)
|
|
|
|
trace("\thrFault = 0x%08x\n", hrFault);
|
|
|
|
|
|
|
|
*pDataSize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI TestChannelHook_ServerFillBuffer(
|
|
|
|
IChannelHook *iface,
|
|
|
|
REFGUID uExtent,
|
|
|
|
REFIID riid,
|
|
|
|
ULONG *pDataSize,
|
|
|
|
void *pDataBuffer,
|
|
|
|
HRESULT hrFault )
|
|
|
|
{
|
|
|
|
trace("TestChannelHook_ServerFillBuffer\n");
|
|
|
|
ok(0, "TestChannelHook_ServerFillBuffer shouldn't be called\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IChannelHookVtbl TestChannelHookVtbl =
|
|
|
|
{
|
|
|
|
TestChannelHook_QueryInterface,
|
|
|
|
TestChannelHook_AddRef,
|
|
|
|
TestChannelHook_Release,
|
|
|
|
TestChannelHook_ClientGetSize,
|
|
|
|
TestChannelHook_ClientFillBuffer,
|
|
|
|
TestChannelHook_ClientNotify,
|
|
|
|
TestChannelHook_ServerNotify,
|
|
|
|
TestChannelHook_ServerGetSize,
|
|
|
|
TestChannelHook_ServerFillBuffer,
|
|
|
|
};
|
|
|
|
|
|
|
|
static IChannelHook TestChannelHook = { &TestChannelHookVtbl };
|
|
|
|
|
|
|
|
static void test_channel_hook(void)
|
|
|
|
{
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
IClassFactory *cf = NULL;
|
|
|
|
DWORD tid;
|
|
|
|
IUnknown *proxy = NULL;
|
|
|
|
HANDLE thread;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoRegisterChannelHook(&EXTENTID_WineTest, &TestChannelHook);
|
|
|
|
ok_ole_success(hr, CoRegisterChannelHook);
|
|
|
|
|
|
|
|
hr = CoRegisterMessageFilter(&MessageFilter, NULL);
|
|
|
|
ok_ole_success(hr, CoRegisterMessageFilter);
|
|
|
|
|
|
|
|
cLocks = 0;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
ok_ole_success(hr, CreateStreamOnHGlobal);
|
|
|
|
tid = start_host_object2(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &MessageFilter, &thread);
|
2016-09-02 12:41:05 +02:00
|
|
|
server_tid = tid;
|
2006-12-29 15:44:14 +01:00
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
|
|
|
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&cf);
|
|
|
|
ok_ole_success(hr, CoUnmarshalInterface);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
ok_more_than_one_lock();
|
|
|
|
|
2016-09-02 12:41:05 +02:00
|
|
|
method = 3;
|
2006-12-29 15:44:14 +01:00
|
|
|
hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
|
|
|
|
ok_ole_success(hr, IClassFactory_CreateInstance);
|
2016-09-02 12:41:05 +02:00
|
|
|
|
|
|
|
method = 5;
|
2006-12-29 15:44:14 +01:00
|
|
|
IUnknown_Release(proxy);
|
|
|
|
|
|
|
|
IClassFactory_Release(cf);
|
|
|
|
|
|
|
|
ok_no_locks();
|
|
|
|
|
|
|
|
end_host_object(tid, thread);
|
|
|
|
|
|
|
|
hr = CoRegisterMessageFilter(NULL, NULL);
|
|
|
|
ok_ole_success(hr, CoRegisterMessageFilter);
|
|
|
|
}
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
START_TEST(marshal)
|
|
|
|
{
|
2013-10-15 20:37:46 +02:00
|
|
|
HMODULE hOle32 = GetModuleHandleA("ole32");
|
2007-03-09 18:51:36 +01:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
|
2010-11-16 13:39:11 +01:00
|
|
|
if (!GetProcAddress(hOle32, "CoRegisterSurrogateEx")) {
|
|
|
|
win_skip("skipping test on win9x\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx");
|
2013-08-21 22:00:39 +02:00
|
|
|
pDllGetClassObject = (void*)GetProcAddress(hOle32, "DllGetClassObject");
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2007-03-09 18:51:36 +01:00
|
|
|
argc = winetest_get_mainargs( &argv );
|
|
|
|
if (argc > 2 && (!strcmp(argv[2], "-Embedding")))
|
|
|
|
{
|
2017-11-10 13:56:05 +01:00
|
|
|
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
2007-03-09 18:51:36 +01:00
|
|
|
test_register_local_server();
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-07 15:14:25 +01:00
|
|
|
register_test_window();
|
2006-01-20 16:14:32 +01:00
|
|
|
|
2006-06-28 22:24:58 +02:00
|
|
|
test_cocreateinstance_proxy();
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
|
|
|
|
|
|
|
/* FIXME: test CoCreateInstanceEx */
|
|
|
|
|
|
|
|
/* lifecycle management and marshaling tests */
|
2013-10-24 17:16:47 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
test_no_marshaler();
|
|
|
|
test_normal_marshal_and_release();
|
|
|
|
test_normal_marshal_and_unmarshal();
|
|
|
|
test_marshal_and_unmarshal_invalid();
|
|
|
|
test_same_apartment_unmarshal_failure();
|
|
|
|
test_interthread_marshal_and_unmarshal();
|
|
|
|
test_proxy_marshal_and_unmarshal();
|
|
|
|
test_proxy_marshal_and_unmarshal2();
|
|
|
|
test_proxy_marshal_and_unmarshal_weak();
|
|
|
|
test_proxy_marshal_and_unmarshal_strong();
|
|
|
|
test_marshal_stub_apartment_shutdown();
|
|
|
|
test_marshal_proxy_apartment_shutdown();
|
|
|
|
test_marshal_proxy_mta_apartment_shutdown();
|
|
|
|
test_no_couninitialize_server();
|
|
|
|
test_no_couninitialize_client();
|
|
|
|
test_tableweak_marshal_and_unmarshal_twice();
|
|
|
|
test_tableweak_marshal_releasedata1();
|
|
|
|
test_tableweak_marshal_releasedata2();
|
|
|
|
test_tableweak_and_normal_marshal_and_unmarshal();
|
2013-10-24 17:16:49 +02:00
|
|
|
test_tableweak_and_normal_marshal_and_releasedata();
|
|
|
|
test_two_tableweak_marshal_and_releasedata();
|
2013-10-24 17:16:47 +02:00
|
|
|
test_tablestrong_marshal_and_unmarshal_twice();
|
|
|
|
test_lock_object_external();
|
|
|
|
test_disconnect_stub();
|
|
|
|
test_normal_marshal_and_unmarshal_twice();
|
|
|
|
|
|
|
|
with_external_conn = !with_external_conn;
|
|
|
|
} while (with_external_conn);
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
test_hresult_marshaling();
|
|
|
|
test_proxy_used_in_wrong_thread();
|
|
|
|
test_message_filter();
|
2005-01-11 11:45:52 +01:00
|
|
|
test_bad_marshal_stream();
|
|
|
|
test_proxy_interfaces();
|
2005-01-28 13:39:13 +01:00
|
|
|
test_stubbuffer(&IID_IClassFactory);
|
2005-09-18 13:10:37 +02:00
|
|
|
test_proxybuffer(&IID_IClassFactory);
|
2005-03-04 13:30:47 +01:00
|
|
|
test_message_reentrancy();
|
2006-12-23 16:51:27 +01:00
|
|
|
test_call_from_message();
|
2006-01-20 16:14:32 +01:00
|
|
|
test_WM_QUIT_handling();
|
2006-05-25 00:01:41 +02:00
|
|
|
test_freethreadedmarshaler();
|
2007-02-23 20:38:11 +01:00
|
|
|
test_inproc_handler();
|
|
|
|
test_handler_marshaling();
|
2007-03-27 19:18:05 +02:00
|
|
|
test_client_security();
|
2004-12-21 15:51:27 +01:00
|
|
|
|
2007-03-09 18:40:40 +01:00
|
|
|
test_local_server();
|
2005-05-23 11:54:53 +02:00
|
|
|
|
2006-06-14 14:20:01 +02:00
|
|
|
test_globalinterfacetable();
|
2011-05-30 12:45:31 +02:00
|
|
|
test_manualresetevent();
|
2015-09-02 11:21:16 +02:00
|
|
|
test_crash_couninitialize();
|
2005-05-23 11:54:53 +02:00
|
|
|
|
2006-12-29 15:44:14 +01:00
|
|
|
/* must be last test as channel hooks can't be unregistered */
|
|
|
|
test_channel_hook();
|
|
|
|
|
2004-12-21 15:51:27 +01:00
|
|
|
CoUninitialize();
|
|
|
|
}
|