ReactOS 0.4.16-dev-122-g325d74c
marshal.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "olectl.h"
#include "shlguid.h"
#include "shobjidl.h"
#include "wine/test.h"
#include "wine/heap.h"
Include dependency graph for marshal.c:

Go to the source code of this file.

Classes

struct  tagDUALSTRINGARRAY
 
struct  tagSTDOBJREF
 
struct  tagOBJREF
 
struct  StubBufferWrapper
 
struct  host_object_data
 
struct  ncu_params
 
struct  duo_marshal_data
 
struct  HeapUnknown
 
struct  local_server
 
struct  git_params
 
struct  implicit_mta_marshal_data
 
struct  new_hook_info
 

Macros

#define _WIN32_DCOM
 
#define COBJMACROS
 
#define CONST_VTABLE
 
#define DEFINE_EXPECT(func)    static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
 
#define SET_EXPECT(func)    expect_ ## func = TRUE
 
#define CHECK_EXPECT2(func)
 
#define CHECK_EXPECT(func)
 
#define CHECK_CALLED(func)
 
#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)
 
#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);
 
#define OBJREF_SIGNATURE   (0x574f454d)
 
#define OBJREF_STANDARD   (0x1)
 
#define OBJREF_CUSTOM   (0x4)
 
#define EXTENTID_WineTest   IID_IWineTest
 
#define CLSID_WineTest   IID_IWineTest
 
#define RELEASEMARSHALDATA   WM_USER
 
#define NORMALEXTREFS   5
 

Typedefs

typedef struct tagDUALSTRINGARRAY DUALSTRINGARRAY
 
typedef UINT64 OXID
 
typedef UINT64 OID
 
typedef GUID IPID
 
typedef struct tagSTDOBJREF STDOBJREF
 
typedef struct tagOBJREF OBJREF
 

Functions

static HRESULT (WINAPI *pCoInitializeEx)(LPVOID lpReserved
 
static void test_cocreateinstance_proxy (void)
 
static void LockModule (void)
 
static void UnlockModule (void)
 
static HRESULT WINAPI ExternalConnection_QueryInterface (IExternalConnection *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ExternalConnection_AddRef (IExternalConnection *iface)
 
static ULONG WINAPI ExternalConnection_Release (IExternalConnection *iface)
 
static DWORD WINAPI ExternalConnection_AddConnection (IExternalConnection *iface, DWORD extconn, DWORD reserved)
 
static DWORD WINAPI ExternalConnection_ReleaseConnection (IExternalConnection *iface, DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses)
 
static HRESULT WINAPI Test_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
 
static ULONG WINAPI Test_IUnknown_AddRef (LPUNKNOWN iface)
 
static ULONG WINAPI Test_IUnknown_Release (LPUNKNOWN iface)
 
static ULONG WINAPI TestCrash_IUnknown_Release (LPUNKNOWN iface)
 
static HRESULT WINAPI Test_IClassFactory_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
 
static ULONG WINAPI Test_IClassFactory_AddRef (LPCLASSFACTORY iface)
 
static ULONG WINAPI Test_IClassFactory_Release (LPCLASSFACTORY iface)
 
static HRESULT WINAPI Test_IClassFactory_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
 
static HRESULT WINAPI Test_IClassFactory_LockServer (LPCLASSFACTORY iface, BOOL fLock)
 
 DEFINE_EXPECT (Invoke)
 
 DEFINE_EXPECT (CreateStub)
 
 DEFINE_EXPECT (CreateProxy)
 
 DEFINE_EXPECT (GetWindow)
 
 DEFINE_EXPECT (Disconnect)
 
static HRESULT WINAPI OleWindow_QueryInterface (IOleWindow *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleWindow_AddRef (IOleWindow *iface)
 
static ULONG WINAPI OleWindow_Release (IOleWindow *iface)
 
static HRESULT WINAPI OleWindow_GetWindow (IOleWindow *iface, HWND *hwnd)
 
static HRESULT WINAPI OleClientSite_QueryInterface (IOleClientSite *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleClientSite_AddRef (IOleClientSite *iface)
 
static ULONG WINAPI OleClientSite_Release (IOleClientSite *iface)
 
static StubBufferWrapperimpl_from_IRpcStubBuffer (IRpcStubBuffer *iface)
 
static HRESULT WINAPI RpcStubBuffer_QueryInterface (IRpcStubBuffer *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI RpcStubBuffer_AddRef (IRpcStubBuffer *iface)
 
static ULONG WINAPI RpcStubBuffer_Release (IRpcStubBuffer *iface)
 
static HRESULT WINAPI RpcStubBuffer_Connect (IRpcStubBuffer *iface, IUnknown *pUnkServer)
 
static void WINAPI RpcStubBuffer_Disconnect (IRpcStubBuffer *iface)
 
static HRESULT WINAPI RpcStubBuffer_Invoke (IRpcStubBuffer *iface, RPCOLEMESSAGE *_prpcmsg, IRpcChannelBuffer *_pRpcChannelBuffer)
 
static IRpcStubBuffer *WINAPI RpcStubBuffer_IsIIDSupported (IRpcStubBuffer *iface, REFIID riid)
 
static ULONG WINAPI RpcStubBuffer_CountRefs (IRpcStubBuffer *iface)
 
static HRESULT WINAPI RpcStubBuffer_DebugServerQueryInterface (IRpcStubBuffer *iface, void **ppv)
 
static void WINAPI RpcStubBuffer_DebugServerRelease (IRpcStubBuffer *iface, void *pv)
 
static HRESULT WINAPI PSFactoryBuffer_QueryInterface (IPSFactoryBuffer *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI PSFactoryBuffer_AddRef (IPSFactoryBuffer *iface)
 
static ULONG WINAPI PSFactoryBuffer_Release (IPSFactoryBuffer *iface)
 
static HRESULT WINAPI PSFactoryBuffer_CreateProxy (IPSFactoryBuffer *iface, IUnknown *outer, REFIID riid, IRpcProxyBuffer **ppProxy, void **ppv)
 
static HRESULT WINAPI PSFactoryBuffer_CreateStub (IPSFactoryBuffer *iface, REFIID riid, IUnknown *server, IRpcStubBuffer **ppStub)
 
static DWORD CALLBACK host_object_proc (LPVOID p)
 
static DWORD start_host_object2 (struct host_object_data *object_data, HANDLE *thread)
 
static DWORD start_host_object (IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, HANDLE *thread)
 
static void release_host_object (DWORD tid, WPARAM wp)
 
static void end_host_object (DWORD tid, HANDLE thread)
 
static void test_no_marshaler (void)
 
static void test_normal_marshal_and_release (void)
 
static void test_normal_marshal_and_unmarshal (void)
 
static void test_marshal_and_unmarshal_invalid (void)
 
static void test_same_apartment_unmarshal_failure (void)
 
static void test_interthread_marshal_and_unmarshal (void)
 
static void test_proxy_marshal_and_unmarshal (void)
 
static void test_proxy_marshal_and_unmarshal2 (void)
 
static void test_proxy_marshal_and_unmarshal_weak (void)
 
static void test_proxy_marshal_and_unmarshal_strong (void)
 
static void test_marshal_stub_apartment_shutdown (void)
 
static void test_marshal_proxy_apartment_shutdown (void)
 
static void test_marshal_proxy_mta_apartment_shutdown (void)
 
static void test_marshal_channel_buffer (void)
 
 DEFINE_EXPECT (CustomMarshal_GetUnmarshalClass)
 
 DEFINE_EXPECT (CustomMarshal_GetMarshalSizeMax)
 
 DEFINE_EXPECT (CustomMarshal_MarshalInterface)
 
static HRESULT WINAPI CustomMarshal_QueryInterface (IMarshal *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI CustomMarshal_AddRef (IMarshal *iface)
 
static ULONG WINAPI CustomMarshal_Release (IMarshal *iface)
 
static HRESULT WINAPI CustomMarshal_GetUnmarshalClass (IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, CLSID *clsid)
 
static HRESULT WINAPI CustomMarshal_GetMarshalSizeMax (IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, DWORD *size)
 
static HRESULT WINAPI CustomMarshal_MarshalInterface (IMarshal *iface, IStream *stream, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags)
 
static HRESULT WINAPI CustomMarshal_UnmarshalInterface (IMarshal *iface, IStream *stream, REFIID riid, void **ppv)
 
static HRESULT WINAPI CustomMarshal_ReleaseMarshalData (IMarshal *iface, IStream *stream)
 
static HRESULT WINAPI CustomMarshal_DisconnectObject (IMarshal *iface, DWORD res)
 
static void test_StdMarshal_custom_marshaling (void)
 
static void test_DfMarshal_custom_marshaling (void)
 
static void test_CoGetStandardMarshal (void)
 
static DWORD CALLBACK no_couninitialize_server_proc (LPVOID p)
 
static void test_no_couninitialize_server (void)
 
static DWORD CALLBACK no_couninitialize_client_proc (LPVOID p)
 
static void test_no_couninitialize_client (void)
 
static DWORD CALLBACK crash_couninitialize_proc (void *p)
 
static void test_crash_couninitialize (void)
 
static void test_tableweak_marshal_and_unmarshal_twice (void)
 
static void test_tableweak_marshal_releasedata1 (void)
 
static void test_tableweak_marshal_releasedata2 (void)
 
static DWORD CALLBACK duo_marshal_thread_proc (void *p)
 
static void test_tableweak_and_normal_marshal_and_unmarshal (void)
 
static void test_tableweak_and_normal_marshal_and_releasedata (void)
 
static void test_two_tableweak_marshal_and_releasedata (void)
 
static void test_tablestrong_marshal_and_unmarshal_twice (void)
 
static void test_lock_object_external (void)
 
static void test_disconnect_stub (void)
 
static void test_normal_marshal_and_unmarshal_twice (void)
 
static void test_hresult_marshaling (void)
 
static DWORD CALLBACK bad_thread_proc (LPVOID p)
 
static void test_proxy_used_in_wrong_thread (void)
 
static HRESULT WINAPI MessageFilter_QueryInterface (IMessageFilter *iface, REFIID riid, void **ppvObj)
 
static ULONG WINAPI MessageFilter_AddRef (IMessageFilter *iface)
 
static ULONG WINAPI MessageFilter_Release (IMessageFilter *iface)
 
static DWORD WINAPI MessageFilter_HandleInComingCall (IMessageFilter *iface, DWORD dwCallType, HTASK threadIDCaller, DWORD dwTickCount, LPINTERFACEINFO lpInterfaceInfo)
 
static DWORD WINAPI MessageFilter_RetryRejectedCall (IMessageFilter *iface, HTASK threadIDCallee, DWORD dwTickCount, DWORD dwRejectType)
 
static DWORD WINAPI MessageFilter_MessagePending (IMessageFilter *iface, HTASK threadIDCallee, DWORD dwTickCount, DWORD dwPendingType)
 
static void test_message_filter (void)
 
static void test_bad_marshal_stream (void)
 
static void test_proxy_interfaces (void)
 
static HeapUnknownimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI HeapUnknown_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI HeapUnknown_AddRef (IUnknown *iface)
 
static ULONG WINAPI HeapUnknown_Release (IUnknown *iface)
 
static void test_proxybuffer (REFIID riid)
 
static void test_stubbuffer (REFIID riid)
 
static HRESULT WINAPI TestRE_IClassFactory_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
 
static LRESULT CALLBACK window_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void register_test_window (void)
 
static void test_message_reentrancy (void)
 
static HRESULT WINAPI TestMsg_IClassFactory_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
 
static void test_call_from_message (void)
 
static void test_WM_QUIT_handling (void)
 
static SIZE_T round_global_size (SIZE_T size)
 
static void test_freethreadedmarshaldata (IStream *pStream, MSHCTX mshctx, void *ptr, DWORD mshlflags)
 
static void test_freethreadedmarshaler (void)
 
static HRESULT reg_unreg_wine_test_class (BOOL Register)
 
static void test_inproc_handler (void)
 
static HRESULT WINAPI Test_SMI_QueryInterface (IStdMarshalInfo *iface, REFIID riid, LPVOID *ppvObj)
 
static ULONG WINAPI Test_SMI_AddRef (IStdMarshalInfo *iface)
 
static ULONG WINAPI Test_SMI_Release (IStdMarshalInfo *iface)
 
static HRESULT WINAPI Test_SMI_GetClassForHandler (IStdMarshalInfo *iface, DWORD dwDestContext, void *pvDestContext, CLSID *pClsid)
 
static void test_handler_marshaling (void)
 
static void test_client_security (void)
 
static void LockModuleOOP (void)
 
static void UnlockModuleOOP (void)
 
static HRESULT WINAPI local_server_QueryInterface (IPersist *iface, REFIID iid, void **obj)
 
static ULONG WINAPI local_server_AddRef (IPersist *iface)
 
static ULONG WINAPI local_server_Release (IPersist *iface)
 
static HRESULT WINAPI local_server_GetClassID (IPersist *iface, CLSID *clsid)
 
static HRESULT WINAPI TestOOP_IClassFactory_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
 
static ULONG WINAPI TestOOP_IClassFactory_AddRef (LPCLASSFACTORY iface)
 
static ULONG WINAPI TestOOP_IClassFactory_Release (LPCLASSFACTORY iface)
 
static HRESULT WINAPI TestOOP_IClassFactory_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
 
static HRESULT WINAPI TestOOP_IClassFactory_LockServer (LPCLASSFACTORY iface, BOOL fLock)
 
static void test_register_local_server (void)
 
static HANDLE create_target_process (const char *arg)
 
static void test_local_server (void)
 
static DWORD CALLBACK get_global_interface_proc (LPVOID pv)
 
static void test_globalinterfacetable (void)
 
static void test_manualresetevent (void)
 
static DWORD CALLBACK implicit_mta_unmarshal_proc (void *param)
 
static DWORD CALLBACK implicit_mta_use_proc (void *param)
 
static DWORD CALLBACK implicit_mta_marshal_proc (void *param)
 
static void test_implicit_mta (void)
 
static const chardebugstr_iid (REFIID riid)
 
static HRESULT WINAPI TestChannelHook_QueryInterface (IChannelHook *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI TestChannelHook_AddRef (IChannelHook *iface)
 
static ULONG WINAPI TestChannelHook_Release (IChannelHook *iface)
 
static void WINAPI TestChannelHook_ClientGetSize (IChannelHook *iface, REFGUID uExtent, REFIID riid, ULONG *pDataSize)
 
static void WINAPI TestChannelHook_ClientFillBuffer (IChannelHook *iface, REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer)
 
static void WINAPI TestChannelHook_ClientNotify (IChannelHook *iface, REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep, HRESULT hrFault)
 
static void WINAPI TestChannelHook_ServerNotify (IChannelHook *iface, REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep)
 
static void WINAPI TestChannelHook_ServerGetSize (IChannelHook *iface, REFGUID uExtent, REFIID riid, HRESULT hrFault, ULONG *pDataSize)
 
static void WINAPI TestChannelHook_ServerFillBuffer (IChannelHook *iface, REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer, HRESULT hrFault)
 
static void test_channel_hook (void)
 
 START_TEST (marshal)
 

Variables

static const GUID CLSID_WineTestPSFactoryBuffer = { 0x22222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } }
 
static const GUID CLSID_DfMarshal = { 0x0000030b, 0x0000, 0x0000, { 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }
 
static DWORD dwCoInit
 
static REFIID
 
static LPVOID
 
static const IID IID_IWineTest
 
static const IID IID_IRemUnknown
 
static const CLSID CLSID_WineOOPTest
 
static const LARGE_INTEGER ullZero
 
static LONG cLocks
 
static BOOL with_external_conn
 
static DWORD external_connections
 
static BOOL last_release_closes
 
static const IExternalConnectionVtbl ExternalConnectionVtbl
 
static IExternalConnection ExternalConnection = { &ExternalConnectionVtbl }
 
static const IUnknownVtbl TestUnknown_Vtbl
 
static IUnknown Test_Unknown = { &TestUnknown_Vtbl }
 
static const IUnknownVtbl TestCrashUnknown_Vtbl
 
static IUnknown TestCrash_Unknown = { &TestCrashUnknown_Vtbl }
 
static const IClassFactoryVtbl TestClassFactory_Vtbl
 
static IClassFactory Test_ClassFactory = { &TestClassFactory_Vtbl }
 
static const IOleWindowVtbl OleWindowVtbl
 
static IOleWindow Test_OleWindow = { &OleWindowVtbl }
 
static const IOleClientSiteVtbl OleClientSiteVtbl
 
static IOleClientSite Test_OleClientSite = { &OleClientSiteVtbl }
 
static const IRpcStubBufferVtbl RpcStubBufferVtbl
 
static IPSFactoryBufferps_factory_buffer
 
static IPSFactoryBufferVtbl PSFactoryBufferVtbl
 
static IPSFactoryBuffer PSFactoryBuffer = { &PSFactoryBufferVtbl }
 
static const CLSIDunmarshal_class
 
static IMarshalVtbl CustomMarshalVtbl
 
static IMarshal CustomMarshal = { &CustomMarshalVtbl }
 
static BOOL crash_thread_success
 
static const IMessageFilterVtbl MessageFilter_Vtbl
 
static IMessageFilter MessageFilter = { &MessageFilter_Vtbl }
 
static const IUnknownVtbl HeapUnknown_Vtbl
 
static HWND hwnd_app
 
static const IClassFactoryVtbl TestREClassFactory_Vtbl
 
static IClassFactory TestRE_ClassFactory = { &TestREClassFactory_Vtbl }
 
static IClassFactoryVtbl TestMsgClassFactory_Vtbl
 
static IClassFactory TestMsg_ClassFactory = { &TestMsgClassFactory_Vtbl }
 
static const IStdMarshalInfoVtbl Test_SMI_Vtbl
 
static IStdMarshalInfo Test_SMI = {&Test_SMI_Vtbl}
 
static HANDLE heventShutdown
 
static const IPersistVtbl local_server_persist_vtbl
 
struct local_server local_server_class
 
static const IClassFactoryVtbl TestClassFactoryOOP_Vtbl
 
static IClassFactory TestOOP_ClassFactory = { &TestClassFactoryOOP_Vtbl }
 
static BOOL new_hook_struct
 
static int method
 
static int server_tid
 
static GUID causality
 
static const IChannelHookVtbl TestChannelHookVtbl
 
static IChannelHook TestChannelHook = { &TestChannelHookVtbl }
 

Macro Definition Documentation

◆ _WIN32_DCOM

#define _WIN32_DCOM

Definition at line 21 of file marshal.c.

◆ CHECK_CALLED

#define CHECK_CALLED (   func)
Value:
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define FALSE
Definition: types.h:117
GLenum func
Definition: glext.h:6028
#define expect_(expected, got, precision)
Definition: font.c:29

Definition at line 56 of file marshal.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)

Definition at line 50 of file marshal.c.

◆ CHECK_EXPECT2

#define CHECK_EXPECT2 (   func)
Value:
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define TRUE
Definition: types.h:120

Definition at line 44 of file marshal.c.

◆ CLSID_WineTest

#define CLSID_WineTest   IID_IWineTest

Definition at line 139 of file marshal.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file marshal.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 23 of file marshal.c.

◆ DEFINE_EXPECT

#define DEFINE_EXPECT (   func)     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE

Definition at line 38 of file marshal.c.

◆ EXTENTID_WineTest

#define EXTENTID_WineTest   IID_IWineTest

Definition at line 138 of file marshal.c.

◆ NORMALEXTREFS

#define NORMALEXTREFS   5

Definition at line 900 of file marshal.c.

◆ OBJREF_CUSTOM

#define OBJREF_CUSTOM   (0x4)

Definition at line 79 of file marshal.c.

◆ OBJREF_SIGNATURE

#define OBJREF_SIGNATURE   (0x574f454d)

Definition at line 77 of file marshal.c.

◆ OBJREF_STANDARD

#define OBJREF_STANDARD   (0x1)

Definition at line 78 of file marshal.c.

◆ ok_last_release_closes

#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);

Definition at line 75 of file marshal.c.

◆ ok_more_than_one_lock

#define ok_more_than_one_lock ( )    ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)

Definition at line 70 of file marshal.c.

◆ ok_no_locks

#define ok_no_locks ( )    ok(cLocks == 0, "Number of locks should be 0, but actually is %d\n", cLocks)

Definition at line 71 of file marshal.c.

◆ ok_non_zero_external_conn

#define ok_non_zero_external_conn ( )    do {if (with_external_conn) ok(external_connections, "got no external connections\n");} while(0);

Definition at line 73 of file marshal.c.

◆ ok_ole_success

#define ok_ole_success (   hr,
  func 
)    ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)

Definition at line 72 of file marshal.c.

◆ ok_zero_external_conn

#define ok_zero_external_conn ( )    do {if (with_external_conn) ok(!external_connections, "got %d external connections\n", external_connections);} while(0);

Definition at line 74 of file marshal.c.

◆ RELEASEMARSHALDATA

#define RELEASEMARSHALDATA   WM_USER

Definition at line 600 of file marshal.c.

◆ SET_EXPECT

#define SET_EXPECT (   func)     expect_ ## func = TRUE

Definition at line 41 of file marshal.c.

Typedef Documentation

◆ DUALSTRINGARRAY

◆ IPID

typedef GUID IPID

Definition at line 89 of file marshal.c.

◆ OBJREF

◆ OID

typedef UINT64 OID

Definition at line 88 of file marshal.c.

◆ OXID

typedef UINT64 OXID

Definition at line 87 of file marshal.c.

◆ STDOBJREF

Function Documentation

◆ bad_thread_proc()

static DWORD CALLBACK bad_thread_proc ( LPVOID  p)
static

Definition at line 2482 of file marshal.c.

2483{
2484 IClassFactory * cf = p;
2485 HRESULT hr;
2486 IUnknown * proxy = NULL;
2487
2488 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
2489 todo_wine
2491 "COM should have failed with CO_E_NOTINITIALIZED on using proxy without apartment, but instead returned 0x%08x\n",
2492 hr);
2493
2494 hr = IClassFactory_QueryInterface(cf, &IID_IMultiQI, (LPVOID *)&proxy);
2495 /* Win9x returns S_OK, whilst NT returns RPC_E_WRONG_THREAD */
2496 trace("call to proxy's QueryInterface for local interface without apartment returned 0x%08x\n", hr);
2497 if (SUCCEEDED(hr))
2498 IUnknown_Release(proxy);
2499
2500 hr = IClassFactory_QueryInterface(cf, &IID_IStream, (LPVOID *)&proxy);
2501 /* Win9x returns E_NOINTERFACE, whilst NT returns RPC_E_WRONG_THREAD */
2502 trace("call to proxy's QueryInterface without apartment returned 0x%08x\n", hr);
2503 if (SUCCEEDED(hr))
2504 IUnknown_Release(proxy);
2505
2506 pCoInitializeEx(NULL, COINIT_MULTITHREADED);
2507
2508 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
2509 if (proxy) IUnknown_Release(proxy);
2511 "COM should have failed with RPC_E_WRONG_THREAD on using proxy from wrong apartment, but instead returned 0x%08x\n",
2512 hr);
2513
2514 hr = IClassFactory_QueryInterface(cf, &IID_IStream, (LPVOID *)&proxy);
2515 /* Win9x returns E_NOINTERFACE, whilst NT returns RPC_E_WRONG_THREAD */
2516 trace("call to proxy's QueryInterface from wrong apartment returned 0x%08x\n", hr);
2517
2518 /* now be really bad and release the proxy from the wrong apartment */
2519 IClassFactory_Release(cf);
2520
2522
2523 return 0;
2524}
#define CO_E_NOTINITIALIZED
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
int proxy
Definition: main.c:67
GLfloat GLfloat p
Definition: glext.h:8902
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define todo_wine
Definition: custom.c:89
@ COINIT_MULTITHREADED
Definition: objbase.h:279
HRESULT hr
Definition: shlfolder.c:183
#define RPC_E_WRONG_THREAD
Definition: winerror.h:2490

Referenced by test_proxy_used_in_wrong_thread().

◆ crash_couninitialize_proc()

static DWORD CALLBACK crash_couninitialize_proc ( void p)
static

Definition at line 1792 of file marshal.c.

1793{
1794 IStream *stream;
1795 HRESULT hr;
1796
1797 cLocks = 0;
1798
1800
1803
1804 hr = CoMarshalInterface(stream, &IID_IUnknown, &TestCrash_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1806
1807 IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1808
1811
1812 ok_no_locks();
1813
1814 hr = CoMarshalInterface(stream, &IID_IUnknown, &TestCrash_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1816
1818
1819 trace("CoUninitialize >>>\n");
1821 trace("CoUninitialize <<<\n");
1822
1823 ok_no_locks();
1824
1825 IStream_Release(stream);
1827 return 0;
1828}
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:2055
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1876
#define ok_more_than_one_lock()
Definition: marshal.c:70
static LONG cLocks
Definition: marshal.c:169
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok_ole_success(hr, func)
Definition: marshal.c:72
static BOOL crash_thread_success
Definition: marshal.c:1790
#define ok_no_locks()
Definition: marshal.c:71
static IUnknown TestCrash_Unknown
Definition: marshal.c:284
Definition: parse.h:23

Referenced by test_crash_couninitialize().

◆ create_target_process()

static HANDLE create_target_process ( const char arg)
static

Definition at line 3804 of file marshal.c.

3805{
3806 char **argv;
3807 char cmdline[MAX_PATH];
3808 BOOL ret;
3810 STARTUPINFOA si = { 0 };
3811 si.cb = sizeof(si);
3812
3813 pi.hThread = NULL;
3814 pi.hProcess = NULL;
3816 sprintf(cmdline, "\"%s\" %s %s", argv[0], argv[1], arg);
3817 ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
3818 ok(ret, "CreateProcess failed with error: %u\n", GetLastError());
3819 if (pi.hThread) CloseHandle(pi.hThread);
3820 return pi.hProcess;
3821}
#define CloseHandle
Definition: compat.h:739
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4747
unsigned int BOOL
Definition: ntddk_ex.h:94
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static refpint_t pi[]
Definition: server.c:96
#define argv
Definition: mplay32.c:18
int winetest_get_mainargs(char ***pargv)
TCHAR * cmdline
Definition: stretchblt.cpp:32
DWORD cb
Definition: winbase.h:831
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_local_server().

◆ CustomMarshal_AddRef()

static ULONG WINAPI CustomMarshal_AddRef ( IMarshal iface)
static

Definition at line 1384 of file marshal.c.

1385{
1386 return 2;
1387}

◆ CustomMarshal_DisconnectObject()

static HRESULT WINAPI CustomMarshal_DisconnectObject ( IMarshal iface,
DWORD  res 
)
static

Definition at line 1453 of file marshal.c.

1454{
1455 ok(0, "unexpected call\n");
1456 return E_NOTIMPL;
1457}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ CustomMarshal_GetMarshalSizeMax()

static HRESULT WINAPI CustomMarshal_GetMarshalSizeMax ( IMarshal iface,
REFIID  riid,
void pv,
DWORD  dwDestContext,
void pvDestContext,
DWORD  mshlflags,
DWORD size 
)
static

Definition at line 1402 of file marshal.c.

1404{
1406 ok(size != NULL, "size = NULL\n");
1407
1408 *size = 0;
1409 return S_OK;
1410}
GLsizeiptr size
Definition: glext.h:5919
#define S_OK
Definition: intsafe.h:52
static HRESULT WINAPI CustomMarshal_GetMarshalSizeMax(IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, DWORD *size)
Definition: marshal.c:1402
#define CHECK_EXPECT(func)
Definition: marshal.c:50

Referenced by CustomMarshal_GetMarshalSizeMax(), test_DfMarshal_custom_marshaling(), and test_StdMarshal_custom_marshaling().

◆ CustomMarshal_GetUnmarshalClass()

static HRESULT WINAPI CustomMarshal_GetUnmarshalClass ( IMarshal iface,
REFIID  riid,
void pv,
DWORD  dwDestContext,
void pvDestContext,
DWORD  mshlflags,
CLSID clsid 
)
static

Definition at line 1394 of file marshal.c.

1396{
1399 return S_OK;
1400}
static HRESULT WINAPI CustomMarshal_GetUnmarshalClass(IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, CLSID *clsid)
Definition: marshal.c:1394
static const CLSID * unmarshal_class
Definition: marshal.c:1365
REFCLSID clsid
Definition: msctf.c:82

Referenced by CustomMarshal_GetUnmarshalClass(), test_DfMarshal_custom_marshaling(), and test_StdMarshal_custom_marshaling().

◆ CustomMarshal_MarshalInterface()

static HRESULT WINAPI CustomMarshal_MarshalInterface ( IMarshal iface,
IStream stream,
REFIID  riid,
void pv,
DWORD  dwDestContext,
void pvDestContext,
DWORD  mshlflags 
)
static

Definition at line 1412 of file marshal.c.

1414{
1415 IMarshal *std_marshal;
1416 STATSTG stat;
1417 HRESULT hr;
1418
1420
1422 return S_OK;
1423
1424 hr = IStream_Stat(stream, &stat, STATFLAG_DEFAULT);
1425 ok_ole_success(hr, IStream_Stat);
1426 ok(U(stat.cbSize).LowPart == 0, "stream is not empty (%d)\n", U(stat.cbSize).LowPart);
1427 ok(U(stat.cbSize).HighPart == 0, "stream is not empty (%d)\n", U(stat.cbSize).HighPart);
1428
1430 dwDestContext, NULL, mshlflags, &std_marshal);
1432 hr = IMarshal_MarshalInterface(std_marshal, stream, riid, pv,
1433 dwDestContext, pvDestContext, mshlflags);
1434 ok_ole_success(hr, IMarshal_MarshalInterface);
1435 IMarshal_Release(std_marshal);
1436
1437 return S_OK;
1438}
#define stat
Definition: acwin.h:99
#define U(x)
Definition: wordpad.c:45
const CLSID CLSID_StdMarshal
HRESULT WINAPI CoGetStandardMarshal(REFIID riid, IUnknown *pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags, LPMARSHAL *ppMarshal)
Definition: marshal.c:1676
REFIID riid
Definition: atlbase.h:39
static HRESULT WINAPI CustomMarshal_MarshalInterface(IMarshal *iface, IStream *stream, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags)
Definition: marshal.c:1412
Definition: stat.h:55

Referenced by CustomMarshal_MarshalInterface(), test_DfMarshal_custom_marshaling(), and test_StdMarshal_custom_marshaling().

◆ CustomMarshal_QueryInterface()

static HRESULT WINAPI CustomMarshal_QueryInterface ( IMarshal iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 1370 of file marshal.c.

1371{
1372 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMarshal)) {
1373 *ppv = iface;
1374 }
1375 else
1376 {
1377 *ppv = NULL;
1378 return E_NOINTERFACE;
1379 }
1380 IUnknown_AddRef((IUnknown*)*ppv);
1381 return S_OK;
1382}
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ CustomMarshal_Release()

static ULONG WINAPI CustomMarshal_Release ( IMarshal iface)
static

Definition at line 1389 of file marshal.c.

1390{
1391 return 1;
1392}

◆ CustomMarshal_ReleaseMarshalData()

static HRESULT WINAPI CustomMarshal_ReleaseMarshalData ( IMarshal iface,
IStream stream 
)
static

Definition at line 1447 of file marshal.c.

1448{
1449 ok(0, "unexpected call\n");
1450 return E_NOTIMPL;
1451}

◆ CustomMarshal_UnmarshalInterface()

static HRESULT WINAPI CustomMarshal_UnmarshalInterface ( IMarshal iface,
IStream stream,
REFIID  riid,
void **  ppv 
)
static

Definition at line 1440 of file marshal.c.

1442{
1443 ok(0, "unexpected call\n");
1444 return E_NOTIMPL;
1445}

◆ debugstr_iid()

static const char * debugstr_iid ( REFIID  riid)
static

Definition at line 4282 of file marshal.c.

4283{
4284 static char name[256];
4285 HKEY hkeyInterface;
4286 WCHAR bufferW[39];
4287 char buffer[39];
4288 LONG name_size = sizeof(name);
4289 StringFromGUID2(riid, bufferW, ARRAY_SIZE(bufferW));
4290 WideCharToMultiByte(CP_ACP, 0, bufferW, ARRAY_SIZE(bufferW), buffer, sizeof(buffer), NULL, NULL);
4291 if (RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_QUERY_VALUE, &hkeyInterface) != ERROR_SUCCESS)
4292 {
4293 memcpy(name, buffer, sizeof(buffer));
4294 goto done;
4295 }
4296 if (RegQueryValueA(hkeyInterface, buffer, name, &name_size) != ERROR_SUCCESS)
4297 {
4298 memcpy(name, buffer, sizeof(buffer));
4299 goto done;
4300 }
4301 RegCloseKey(hkeyInterface);
4302done:
4303 return name;
4304}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LSTATUS WINAPI RegQueryValueA(HKEY hkey, LPCSTR name, LPSTR data, LPLONG count)
Definition: reg.c:4212
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
GLuint buffer
Definition: glext.h:5915
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
long LONG
Definition: pedump.c:60
Definition: name.c:39
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by TestChannelHook_ClientGetSize(), and TestChannelHook_ServerGetSize().

◆ DEFINE_EXPECT() [1/8]

DEFINE_EXPECT ( CreateProxy  )

◆ DEFINE_EXPECT() [2/8]

DEFINE_EXPECT ( CreateStub  )

◆ DEFINE_EXPECT() [3/8]

DEFINE_EXPECT ( CustomMarshal_GetMarshalSizeMax  )

◆ DEFINE_EXPECT() [4/8]

DEFINE_EXPECT ( CustomMarshal_GetUnmarshalClass  )

◆ DEFINE_EXPECT() [5/8]

DEFINE_EXPECT ( CustomMarshal_MarshalInterface  )

◆ DEFINE_EXPECT() [6/8]

DEFINE_EXPECT ( Disconnect  )

◆ DEFINE_EXPECT() [7/8]

DEFINE_EXPECT ( GetWindow  )

◆ DEFINE_EXPECT() [8/8]

DEFINE_EXPECT ( Invoke  )

◆ duo_marshal_thread_proc()

static DWORD CALLBACK duo_marshal_thread_proc ( void p)
static

Definition at line 2014 of file marshal.c.

2015{
2016 HRESULT hr;
2017 struct duo_marshal_data *data = p;
2018 HANDLE hQuitEvent = data->hQuitEvent;
2019 MSG msg;
2020
2021 pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
2022
2023 hr = CoMarshalInterface(data->pStream1, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, data->marshal_flags1);
2024 ok_ole_success(hr, "CoMarshalInterface");
2025
2026 hr = CoMarshalInterface(data->pStream2, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, data->marshal_flags2);
2027 ok_ole_success(hr, "CoMarshalInterface");
2028
2029 /* force the message queue to be created before signaling parent thread */
2031
2032 SetEvent(data->hReadyEvent);
2033
2035 {
2036 while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
2037 {
2038 if (msg.hwnd == NULL && msg.message == RELEASEMARSHALDATA)
2039 {
2040 CoReleaseMarshalData(msg.wParam == 1 ? data->pStream1 : data->pStream2);
2041 SetEvent((HANDLE)msg.lParam);
2042 }
2043 else
2045 }
2046 }
2048
2050
2051 return 0;
2052}
#define msg(x)
Definition: auth_time.c:54
const GUID IID_IClassFactory
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
#define RELEASEMARSHALDATA
Definition: marshal.c:600
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
HANDLE hQuitEvent
Definition: marshal.c:2011
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define WAIT_OBJECT_0
Definition: winbase.h:406
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define QS_ALLINPUT
Definition: winuser.h:906
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1199
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define WM_USER
Definition: winuser.h:1898
#define PM_NOREMOVE
Definition: winuser.h:1198

Referenced by test_tableweak_and_normal_marshal_and_releasedata(), test_tableweak_and_normal_marshal_and_unmarshal(), and test_two_tableweak_marshal_and_releasedata().

◆ end_host_object()

static void end_host_object ( DWORD  tid,
HANDLE  thread 
)
static

Definition at line 700 of file marshal.c.

701{
703 ok(ret, "PostThreadMessage failed with error %d\n", GetLastError());
704 /* be careful of races - don't return until hosting thread has terminated */
705 ok( !WaitForSingleObject(thread, 10000), "wait timed out\n" );
707}
static HANDLE thread
Definition: service.c:33
static TfClientId tid
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WM_QUIT
Definition: winuser.h:1626
BOOL WINAPI PostThreadMessageA(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by test_call_from_message(), test_channel_hook(), test_client_security(), test_handler_marshaling(), test_implicit_mta(), test_interthread_marshal_and_unmarshal(), test_marshal_and_unmarshal_invalid(), test_marshal_channel_buffer(), test_marshal_proxy_apartment_shutdown(), test_marshal_proxy_mta_apartment_shutdown(), test_marshal_stub_apartment_shutdown(), test_message_filter(), test_no_couninitialize_client(), test_proxy_interfaces(), test_proxy_marshal_and_unmarshal(), test_proxy_marshal_and_unmarshal2(), test_proxy_marshal_and_unmarshal_strong(), test_proxy_marshal_and_unmarshal_weak(), test_proxy_used_in_wrong_thread(), test_tablestrong_marshal_and_unmarshal_twice(), test_tableweak_marshal_and_unmarshal_twice(), test_tableweak_marshal_releasedata1(), test_tableweak_marshal_releasedata2(), and window_proc().

◆ ExternalConnection_AddConnection()

static DWORD WINAPI ExternalConnection_AddConnection ( IExternalConnection iface,
DWORD  extconn,
DWORD  reserved 
)
static

Definition at line 202 of file marshal.c.

203{
204 trace("add connection\n");
205 return ++external_connections;
206}
static DWORD external_connections
Definition: marshal.c:182

◆ ExternalConnection_AddRef()

static ULONG WINAPI ExternalConnection_AddRef ( IExternalConnection iface)
static

Definition at line 192 of file marshal.c.

193{
194 return 2;
195}

◆ ExternalConnection_QueryInterface()

static HRESULT WINAPI ExternalConnection_QueryInterface ( IExternalConnection iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 185 of file marshal.c.

186{
187 ok(0, "unexpected call\n");
188 *ppv = NULL;
189 return E_NOINTERFACE;
190}

◆ ExternalConnection_Release()

static ULONG WINAPI ExternalConnection_Release ( IExternalConnection iface)
static

Definition at line 197 of file marshal.c.

198{
199 return 1;
200}

◆ ExternalConnection_ReleaseConnection()

static DWORD WINAPI ExternalConnection_ReleaseConnection ( IExternalConnection iface,
DWORD  extconn,
DWORD  reserved,
BOOL  fLastReleaseCloses 
)
static

Definition at line 209 of file marshal.c.

211{
212 trace("release connection %d\n", fLastReleaseCloses);
213 last_release_closes = fLastReleaseCloses;
214 return --external_connections;
215}
static BOOL last_release_closes
Definition: marshal.c:183

◆ get_global_interface_proc()

static DWORD CALLBACK get_global_interface_proc ( LPVOID  pv)
static

Definition at line 3940 of file marshal.c.

3941{
3942 HRESULT hr;
3943 struct git_params *params = pv;
3945
3946 hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
3948 broken(hr == E_UNEXPECTED) /* win2k */ ||
3949 broken(hr == S_OK) /* NT 4 */,
3950 "IGlobalInterfaceTable_GetInterfaceFromGlobal should have failed with error CO_E_NOTINITIALIZED or E_UNEXPECTED instead of 0x%08x\n",
3951 hr);
3952 if (hr == S_OK)
3953 IClassFactory_Release(cf);
3954
3956
3957 hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
3958 ok_ole_success(hr, IGlobalInterfaceTable_GetInterfaceFromGlobal);
3959
3960 IClassFactory_Release(cf);
3961
3963
3964 return hr;
3965}
#define broken(x)
Definition: atltest.h:178
GLenum const GLfloat * params
Definition: glext.h:5645
#define E_UNEXPECTED
Definition: winerror.h:2456

Referenced by test_globalinterfacetable().

◆ HeapUnknown_AddRef()

static ULONG WINAPI HeapUnknown_AddRef ( IUnknown iface)
static

Definition at line 2801 of file marshal.c.

2802{
2804 return InterlockedIncrement((LONG*)&This->refs);
2805}
#define InterlockedIncrement
Definition: armddk.h:53
static HeapUnknown * impl_from_IUnknown(IUnknown *iface)
Definition: marshal.c:2784

◆ HeapUnknown_QueryInterface()

static HRESULT WINAPI HeapUnknown_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 2789 of file marshal.c.

2790{
2792 {
2793 IUnknown_AddRef(iface);
2794 *ppv = iface;
2795 return S_OK;
2796 }
2797 *ppv = NULL;
2798 return E_NOINTERFACE;
2799}

◆ HeapUnknown_Release()

static ULONG WINAPI HeapUnknown_Release ( IUnknown iface)
static

Definition at line 2807 of file marshal.c.

2808{
2810 ULONG refs = InterlockedDecrement((LONG*)&This->refs);
2811 if (!refs) HeapFree(GetProcessHeap(), 0, This);
2812 return refs;
2813}
#define InterlockedDecrement
Definition: armddk.h:52
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
uint32_t ULONG
Definition: typedefs.h:59

◆ host_object_proc()

static DWORD CALLBACK host_object_proc ( LPVOID  p)
static

Definition at line 618 of file marshal.c.

619{
620 struct host_object_data *data = p;
621 DWORD registration_key;
622 HRESULT hr;
623 MSG msg;
624
625 pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
626
627 if(data->register_object) {
628 hr = CoRegisterClassObject(data->register_clsid, data->register_object,
629 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &registration_key);
630 ok(hr == S_OK, "CoRegisterClassObject failed: %08x\n", hr);
631 }
632
633 if (data->filter)
634 {
635 IMessageFilter * prev_filter = NULL;
636 hr = CoRegisterMessageFilter(data->filter, &prev_filter);
637 if (prev_filter) IMessageFilter_Release(prev_filter);
639 }
640
641 hr = CoMarshalInterface(data->stream, data->iid, data->object, MSHCTX_INPROC, NULL, data->marshal_flags);
643
644 /* force the message queue to be created before signaling parent thread */
646
647 SetEvent(data->marshal_event);
648
649 while (GetMessageA(&msg, NULL, 0, 0))
650 {
651 if (msg.hwnd == NULL && msg.message == RELEASEMARSHALDATA)
652 {
653 CoReleaseMarshalData(data->stream);
654 SetEvent((HANDLE)msg.lParam);
655 }
656 else
658 }
659
661
663
664 return hr;
665}
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister)
Definition: compobj.c:2897
HRESULT WINAPI CoRegisterMessageFilter(LPMESSAGEFILTER lpMessageFilter, LPMESSAGEFILTER *lplpMessageFilter)
Definition: compobj.c:4046
unsigned long DWORD
Definition: ntddk_ex.h:95
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:393
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)

Referenced by start_host_object2().

◆ HRESULT()

static HRESULT ( WINAPI pCoInitializeEx)
static

◆ impl_from_IRpcStubBuffer()

static StubBufferWrapper * impl_from_IRpcStubBuffer ( IRpcStubBuffer iface)
static

Definition at line 434 of file marshal.c.

435{
436 return CONTAINING_RECORD(iface, StubBufferWrapper, IRpcStubBuffer_iface);
437}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by RpcStubBuffer_AddRef(), RpcStubBuffer_Invoke(), RpcStubBuffer_QueryInterface(), and RpcStubBuffer_Release().

◆ impl_from_IUnknown()

static HeapUnknown * impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 2784 of file marshal.c.

2785{
2786 return CONTAINING_RECORD(iface, HeapUnknown, IUnknown_iface);
2787}

Referenced by HeapUnknown_AddRef(), and HeapUnknown_Release().

◆ implicit_mta_marshal_proc()

static DWORD CALLBACK implicit_mta_marshal_proc ( void param)
static

Definition at line 4182 of file marshal.c.

4183{
4185 HRESULT hr;
4186
4188 (IUnknown *)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
4190
4191 SetEvent(data->start);
4192
4193 ok(!WaitForSingleObject(data->stop, 1000), "wait failed\n");
4194 return 0;
4195}
GLfloat param
Definition: glext.h:5796

Referenced by test_implicit_mta().

◆ implicit_mta_unmarshal_proc()

static DWORD CALLBACK implicit_mta_unmarshal_proc ( void param)
static

Definition at line 4119 of file marshal.c.

4120{
4121 IStream *stream = param;
4123 IUnknown *proxy;
4124 HRESULT hr;
4125
4126 IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
4129
4130 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4131 ok_ole_success(hr, IClassFactory_CreateInstance);
4132
4133 IUnknown_Release(proxy);
4134
4135 /* But if we initialize an STA in this apartment, it becomes the wrong one. */
4137
4138 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4139 ok(hr == RPC_E_WRONG_THREAD, "got %#x\n", hr);
4140
4142
4145
4146 IClassFactory_Release(cf);
4147
4148 ok_no_locks();
4151 return 0;
4152}
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1981
#define ok_non_zero_external_conn()
Definition: marshal.c:73
#define ok_zero_external_conn()
Definition: marshal.c:74
#define ok_last_release_closes(b)
Definition: marshal.c:75

Referenced by test_implicit_mta().

◆ implicit_mta_use_proc()

static DWORD CALLBACK implicit_mta_use_proc ( void param)
static

Definition at line 4154 of file marshal.c.

4155{
4157 IUnknown *proxy;
4158 HRESULT hr;
4159
4160 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4161 ok_ole_success(hr, IClassFactory_CreateInstance);
4162
4163 IUnknown_Release(proxy);
4164
4165 /* But if we initialize an STA in this apartment, it becomes the wrong one. */
4167
4168 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4169 ok(hr == RPC_E_WRONG_THREAD, "got %#x\n", hr);
4170
4172 return 0;
4173}

Referenced by test_implicit_mta().

◆ local_server_AddRef()

static ULONG WINAPI local_server_AddRef ( IPersist iface)
static

Definition at line 3648 of file marshal.c.

3649{
3650 return 2;
3651}

◆ local_server_GetClassID()

static HRESULT WINAPI local_server_GetClassID ( IPersist iface,
CLSID clsid 
)
static

Definition at line 3658 of file marshal.c.

3659{
3660 HRESULT hr;
3661
3663
3664 /* Test calling CoDisconnectObject within a COM call */
3665 hr = CoDisconnectObject((IUnknown *)iface, 0);
3666 ok(hr == S_OK, "got %08x\n", hr);
3667
3668 /* Initialize and uninitialize the apartment to show that we
3669 * remain in the autojoined mta */
3670 hr = pCoInitializeEx( NULL, COINIT_MULTITHREADED );
3671 ok( hr == S_FALSE, "got %08x\n", hr );
3673
3674 return S_OK;
3675}
HRESULT WINAPI CoDisconnectObject(LPUNKNOWN lpUnk, DWORD reserved)
Definition: compobj.c:2149
#define S_FALSE
Definition: winerror.h:2357

◆ local_server_QueryInterface()

static HRESULT WINAPI local_server_QueryInterface ( IPersist iface,
REFIID  iid,
void **  obj 
)
static

Definition at line 3632 of file marshal.c.

3633{
3634 *obj = NULL;
3635
3636 if (IsEqualGUID(iid, &IID_IUnknown) ||
3638 *obj = iface;
3639
3640 if (*obj)
3641 {
3642 IPersist_AddRef(iface);
3643 return S_OK;
3644 }
3645 return E_NOINTERFACE;
3646}
const GUID IID_IPersist
Definition: proxy.cpp:14
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

◆ local_server_Release()

static ULONG WINAPI local_server_Release ( IPersist iface)
static

Definition at line 3653 of file marshal.c.

3654{
3655 return 1;
3656}

◆ LockModule()

static void LockModule ( void  )
static

Definition at line 171 of file marshal.c.

172{
174}

Referenced by Test_IClassFactory_AddRef(), Test_IUnknown_AddRef(), and Test_SMI_AddRef().

◆ LockModuleOOP()

static void LockModuleOOP ( void  )
static

Definition at line 3612 of file marshal.c.

3613{
3614 InterlockedIncrement(&cLocks); /* for test purposes only */
3616}
ULONG WINAPI CoAddRefServerProcess(void)
Definition: compobj.c:4162

Referenced by TestOOP_IClassFactory_LockServer().

◆ MessageFilter_AddRef()

static ULONG WINAPI MessageFilter_AddRef ( IMessageFilter iface)
static

Definition at line 2584 of file marshal.c.

2585{
2586 return 2; /* non-heap object */
2587}

◆ MessageFilter_HandleInComingCall()

static DWORD WINAPI MessageFilter_HandleInComingCall ( IMessageFilter iface,
DWORD  dwCallType,
HTASK  threadIDCaller,
DWORD  dwTickCount,
LPINTERFACEINFO  lpInterfaceInfo 
)
static

Definition at line 2594 of file marshal.c.

2600{
2601 static int callcount = 0;
2602 DWORD ret;
2603 trace("HandleInComingCall\n");
2604 switch (callcount)
2605 {
2606 case 0:
2607 ret = SERVERCALL_REJECTED;
2608 break;
2609 case 1:
2610 ret = SERVERCALL_RETRYLATER;
2611 break;
2612 default:
2613 ret = SERVERCALL_ISHANDLED;
2614 break;
2615 }
2616 callcount++;
2617 return ret;
2618}

◆ MessageFilter_MessagePending()

static DWORD WINAPI MessageFilter_MessagePending ( IMessageFilter iface,
HTASK  threadIDCallee,
DWORD  dwTickCount,
DWORD  dwPendingType 
)
static

Definition at line 2630 of file marshal.c.

2635{
2636 trace("MessagePending\n");
2637 return PENDINGMSG_WAITNOPROCESS;
2638}

◆ MessageFilter_QueryInterface()

static HRESULT WINAPI MessageFilter_QueryInterface ( IMessageFilter iface,
REFIID  riid,
void **  ppvObj 
)
static

Definition at line 2569 of file marshal.c.

2570{
2571 if (ppvObj == NULL) return E_POINTER;
2572
2573 if (IsEqualGUID(riid, &IID_IUnknown) ||
2575 {
2576 *ppvObj = iface;
2577 IMessageFilter_AddRef(iface);
2578 return S_OK;
2579 }
2580
2581 return E_NOINTERFACE;
2582}
#define E_POINTER
Definition: winerror.h:2365

◆ MessageFilter_Release()

static ULONG WINAPI MessageFilter_Release ( IMessageFilter iface)
static

Definition at line 2589 of file marshal.c.

2590{
2591 return 1; /* non-heap object */
2592}

◆ MessageFilter_RetryRejectedCall()

static DWORD WINAPI MessageFilter_RetryRejectedCall ( IMessageFilter iface,
HTASK  threadIDCallee,
DWORD  dwTickCount,
DWORD  dwRejectType 
)
static

Definition at line 2620 of file marshal.c.

2625{
2626 trace("RetryRejectedCall\n");
2627 return 0;
2628}

◆ no_couninitialize_client_proc()

static DWORD CALLBACK no_couninitialize_client_proc ( LPVOID  p)
static

Definition at line 1733 of file marshal.c.

1734{
1735 struct ncu_params *ncu_params = p;
1736 HRESULT hr;
1737 IUnknown *pProxy = NULL;
1738
1739 pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1740
1743 IStream_Release(ncu_params->stream);
1744
1746
1747 /* die without calling CoUninitialize */
1748
1749 return 0;
1750}
LPSTREAM stream
Definition: marshal.c:1654

Referenced by test_no_couninitialize_client().

◆ no_couninitialize_server_proc()

static DWORD CALLBACK no_couninitialize_server_proc ( LPVOID  p)
static

Definition at line 1660 of file marshal.c.

1661{
1662 struct ncu_params *ncu_params = p;
1663 HRESULT hr;
1664
1665 pCoInitializeEx(NULL, COINIT_MULTITHREADED);
1666
1667 hr = CoMarshalInterface(ncu_params->stream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1669
1671
1672 ok( !WaitForSingleObject(ncu_params->unmarshal_event, 10000), "wait timed out\n" );
1673
1674 /* die without calling CoUninitialize */
1675
1676 return 0;
1677}
HANDLE unmarshal_event
Definition: marshal.c:1656
HANDLE marshal_event
Definition: marshal.c:1655

Referenced by test_no_couninitialize_server().

◆ OleClientSite_AddRef()

static ULONG WINAPI OleClientSite_AddRef ( IOleClientSite iface)
static

Definition at line 409 of file marshal.c.

410{
411 return 2;
412}

◆ OleClientSite_QueryInterface()

static HRESULT WINAPI OleClientSite_QueryInterface ( IOleClientSite iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 393 of file marshal.c.

394{
396 *ppv = iface;
397 else if (IsEqualGUID(riid, &IID_IOleWindow))
399 else
400 {
401 *ppv = NULL;
402 return E_NOINTERFACE;
403 }
404
405 IUnknown_AddRef((IUnknown*)*ppv);
406 return S_OK;
407}
static IOleWindow Test_OleWindow
Definition: marshal.c:391
const GUID IID_IOleWindow
const GUID IID_IOleClientSite

◆ OleClientSite_Release()

static ULONG WINAPI OleClientSite_Release ( IOleClientSite iface)
static

Definition at line 414 of file marshal.c.

415{
416 return 1;
417}

◆ OleWindow_AddRef()

static ULONG WINAPI OleWindow_AddRef ( IOleWindow iface)
static

Definition at line 366 of file marshal.c.

367{
368 return 2;
369}

◆ OleWindow_GetWindow()

static HRESULT WINAPI OleWindow_GetWindow ( IOleWindow iface,
HWND hwnd 
)
static

Definition at line 376 of file marshal.c.

377{
379 *hwnd = (HWND)0xdeadbeef;
380 return S_OK;
381}
HANDLE HWND
Definition: compat.h:19
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)

◆ OleWindow_QueryInterface()

static HRESULT WINAPI OleWindow_QueryInterface ( IOleWindow iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 359 of file marshal.c.

360{
361 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
362 *ppv = NULL;
363 return E_NOINTERFACE;
364}
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197

◆ OleWindow_Release()

static ULONG WINAPI OleWindow_Release ( IOleWindow iface)
static

Definition at line 371 of file marshal.c.

372{
373 return 1;
374}

◆ PSFactoryBuffer_AddRef()

static ULONG WINAPI PSFactoryBuffer_AddRef ( IPSFactoryBuffer iface)
static

Definition at line 551 of file marshal.c.

552{
553 return 2;
554}

◆ PSFactoryBuffer_CreateProxy()

static HRESULT WINAPI PSFactoryBuffer_CreateProxy ( IPSFactoryBuffer iface,
IUnknown outer,
REFIID  riid,
IRpcProxyBuffer **  ppProxy,
void **  ppv 
)
static

Definition at line 561 of file marshal.c.

563{
564 CHECK_EXPECT(CreateProxy);
565 return IPSFactoryBuffer_CreateProxy(ps_factory_buffer, outer, riid, ppProxy, ppv);
566}
static IPSFactoryBuffer * ps_factory_buffer
Definition: marshal.c:536

◆ PSFactoryBuffer_CreateStub()

static HRESULT WINAPI PSFactoryBuffer_CreateStub ( IPSFactoryBuffer iface,
REFIID  riid,
IUnknown server,
IRpcStubBuffer **  ppStub 
)
static

Definition at line 568 of file marshal.c.

570{
572 HRESULT hr;
573
574 CHECK_EXPECT(CreateStub);
575
576 ok(server == (IUnknown*)&Test_OleClientSite, "unexpected server %p\n", server);
577
578 stub = heap_alloc(sizeof(*stub));
579 stub->IRpcStubBuffer_iface.lpVtbl = &RpcStubBufferVtbl;
580 stub->ref = 1;
581
582 hr = IPSFactoryBuffer_CreateStub(ps_factory_buffer, riid, server, &stub->buffer);
583 ok(hr == S_OK, "CreateStub failed: %08x\n", hr);
584
585 *ppStub = &stub->IRpcStubBuffer_iface;
586 return S_OK;
587}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static IOleClientSite Test_OleClientSite
Definition: marshal.c:426
static const IRpcStubBufferVtbl RpcStubBufferVtbl
Definition: marshal.c:523
Definition: stubgen.c:11
struct _stub stub
static rfbScreenInfoPtr server
Definition: vnc.c:74

◆ PSFactoryBuffer_QueryInterface()

static HRESULT WINAPI PSFactoryBuffer_QueryInterface ( IPSFactoryBuffer iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 538 of file marshal.c.

539{
540 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPSFactoryBuffer))
541 *ppv = iface;
542 else
543 {
544 *ppv = NULL;
545 return E_NOINTERFACE;
546 }
547 IUnknown_AddRef((IUnknown*)*ppv);
548 return S_OK;
549}

◆ PSFactoryBuffer_Release()

static ULONG WINAPI PSFactoryBuffer_Release ( IPSFactoryBuffer iface)
static

Definition at line 556 of file marshal.c.

557{
558 return 1;
559}

◆ reg_unreg_wine_test_class()

static HRESULT reg_unreg_wine_test_class ( BOOL  Register)
static

Definition at line 3355 of file marshal.c.

3356{
3357 HRESULT hr;
3358 char buffer[256];
3359 LPOLESTR pszClsid;
3360 HKEY hkey;
3361 DWORD dwDisposition;
3362 DWORD error;
3363
3364 hr = StringFromCLSID(&CLSID_WineTest, &pszClsid);
3365 ok_ole_success(hr, "StringFromCLSID");
3366 strcpy(buffer, "CLSID\\");
3367 WideCharToMultiByte(CP_ACP, 0, pszClsid, -1, buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), NULL, NULL);
3368 CoTaskMemFree(pszClsid);
3369 strcat(buffer, "\\InprocHandler32");
3370 if (Register)
3371 {
3372 error = RegCreateKeyExA(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey, &dwDisposition);
3374 {
3375 skip("Not authorized to modify the Classes key\n");
3376 return E_FAIL;
3377 }
3378 ok(error == ERROR_SUCCESS, "RegCreateKeyEx failed with error %d\n", error);
3379 if (error != ERROR_SUCCESS) hr = E_FAIL;
3380 error = RegSetValueExA(hkey, NULL, 0, REG_SZ, (const unsigned char *)"\"ole32.dll\"", strlen("\"ole32.dll\"") + 1);
3381 ok(error == ERROR_SUCCESS, "RegSetValueEx failed with error %d\n", error);
3382 if (error != ERROR_SUCCESS) hr = E_FAIL;
3383 RegCloseKey(hkey);
3384 }
3385 else
3386 {
3388 *strrchr(buffer, '\\') = '\0';
3390 }
3391 return hr;
3392}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define skip(...)
Definition: atltest.h:64
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1034
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1224
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define REG_SZ
Definition: layer.c:22
#define error(str)
Definition: mkdosfs.c:1605
#define CLSID_WineTest
Definition: marshal.c:139
static LPOLESTR
Definition: stg_prop.c:27
#define KEY_SET_VALUE
Definition: nt_native.h:1017
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)

Referenced by test_handler_marshaling(), and test_inproc_handler().

◆ register_test_window()

static void register_test_window ( void  )
static

Definition at line 3039 of file marshal.c.

3040{
3041 WNDCLASSA wndclass;
3042
3043 memset(&wndclass, 0, sizeof(wndclass));
3044 wndclass.lpfnWndProc = window_proc;
3045 wndclass.lpszClassName = "WineCOMTest";
3046 RegisterClassA(&wndclass);
3047}
static LRESULT CALLBACK window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: marshal.c:2921
#define memset(x, y, z)
Definition: compat.h:39
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)

Referenced by START_TEST().

◆ release_host_object()

static void release_host_object ( DWORD  tid,
WPARAM  wp 
)
static

Definition at line 692 of file marshal.c.

693{
696 ok( !WaitForSingleObject(event, 10000), "wait timed out\n" );
698}
struct _cl_event * event
Definition: glext.h:7739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
LONG_PTR LPARAM
Definition: windef.h:208

Referenced by test_tablestrong_marshal_and_unmarshal_twice(), test_tableweak_and_normal_marshal_and_releasedata(), test_tableweak_and_normal_marshal_and_unmarshal(), test_tableweak_marshal_and_unmarshal_twice(), test_tableweak_marshal_releasedata1(), test_tableweak_marshal_releasedata2(), and test_two_tableweak_marshal_and_releasedata().

◆ round_global_size()

static SIZE_T round_global_size ( SIZE_T  size)
static

Definition at line 3150 of file marshal.c.

3151{
3152 static SIZE_T global_size_alignment = -1;
3153 if (global_size_alignment == -1)
3154 {
3155 void *p = GlobalAlloc(GMEM_FIXED, 1);
3156 global_size_alignment = GlobalSize(p);
3157 GlobalFree(p);
3158 }
3159
3160 return ((size + global_size_alignment - 1) & ~(global_size_alignment - 1));
3161}
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define GMEM_FIXED
Definition: winbase.h:293

Referenced by test_freethreadedmarshaldata().

◆ RpcStubBuffer_AddRef()

static ULONG WINAPI RpcStubBuffer_AddRef ( IRpcStubBuffer iface)
static

Definition at line 454 of file marshal.c.

455{
457 return InterlockedIncrement(&This->ref);
458}
static StubBufferWrapper * impl_from_IRpcStubBuffer(IRpcStubBuffer *iface)
Definition: marshal.c:434

◆ RpcStubBuffer_Connect()

static HRESULT WINAPI RpcStubBuffer_Connect ( IRpcStubBuffer iface,
IUnknown pUnkServer 
)
static

Definition at line 471 of file marshal.c.

472{
473 ok(0, "unexpected call\n");
474 return E_NOTIMPL;
475}

◆ RpcStubBuffer_CountRefs()

static ULONG WINAPI RpcStubBuffer_CountRefs ( IRpcStubBuffer iface)
static

Definition at line 506 of file marshal.c.

507{
508 ok(0, "unexpected call\n");
509 return E_NOTIMPL;
510}

◆ RpcStubBuffer_DebugServerQueryInterface()

static HRESULT WINAPI RpcStubBuffer_DebugServerQueryInterface ( IRpcStubBuffer iface,
void **  ppv 
)
static

Definition at line 512 of file marshal.c.

513{
514 ok(0, "unexpected call\n");
515 return E_NOTIMPL;
516}

◆ RpcStubBuffer_DebugServerRelease()

static void WINAPI RpcStubBuffer_DebugServerRelease ( IRpcStubBuffer iface,
void pv 
)
static

Definition at line 518 of file marshal.c.

519{
520 ok(0, "unexpected call\n");
521}

◆ RpcStubBuffer_Disconnect()

static void WINAPI RpcStubBuffer_Disconnect ( IRpcStubBuffer iface)
static

Definition at line 477 of file marshal.c.

478{
479 CHECK_EXPECT(Disconnect);
480}

◆ RpcStubBuffer_Invoke()

static HRESULT WINAPI RpcStubBuffer_Invoke ( IRpcStubBuffer iface,
RPCOLEMESSAGE *  _prpcmsg,
IRpcChannelBuffer _pRpcChannelBuffer 
)
static

Definition at line 482 of file marshal.c.

484{
486 void *dest_context_data;
487 DWORD dest_context;
488 HRESULT hr;
489
490 CHECK_EXPECT(Invoke);
491
492 hr = IRpcChannelBuffer_GetDestCtx(_pRpcChannelBuffer, &dest_context, &dest_context_data);
493 ok(hr == S_OK, "GetDestCtx failed: %08x\n", hr);
494 ok(dest_context == MSHCTX_INPROC, "desc_context = %x\n", dest_context);
495 ok(!dest_context_data, "desc_context_data = %p\n", dest_context_data);
496
497 return IRpcStubBuffer_Invoke(This->buffer, _prpcmsg, _pRpcChannelBuffer);
498}

◆ RpcStubBuffer_IsIIDSupported()

static IRpcStubBuffer *WINAPI RpcStubBuffer_IsIIDSupported ( IRpcStubBuffer iface,
REFIID  riid 
)
static

Definition at line 500 of file marshal.c.

501{
502 ok(0, "unexpected call\n");
503 return NULL;
504}

◆ RpcStubBuffer_QueryInterface()

static HRESULT WINAPI RpcStubBuffer_QueryInterface ( IRpcStubBuffer iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 439 of file marshal.c.

440{
442
443 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IRpcStubBuffer, riid)) {
444 *ppv = &This->IRpcStubBuffer_iface;
445 }else {
446 *ppv = NULL;
447 return E_NOINTERFACE;
448 }
449
450 IUnknown_AddRef((IUnknown*)*ppv);
451 return S_OK;
452}

◆ RpcStubBuffer_Release()

static ULONG WINAPI RpcStubBuffer_Release ( IRpcStubBuffer iface)
static

Definition at line 460 of file marshal.c.

461{
464 if(!ref) {
465 IRpcStubBuffer_Release(This->buffer);
467 }
468 return ref;
469}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
Definition: send.c:48

◆ start_host_object()

◆ start_host_object2()

static DWORD start_host_object2 ( struct host_object_data object_data,
HANDLE thread 
)
static

Definition at line 667 of file marshal.c.

668{
669 DWORD tid = 0;
670 struct host_object_data *data;
671
672 data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
673 *data = *object_data;
676
677 /* wait for marshaling to complete before returning */
678 ok( !WaitForSingleObject(data->marshal_event, 10000), "wait timed out\n" );
679 CloseHandle(data->marshal_event);
680
681 return tid;
682}
#define HeapAlloc
Definition: compat.h:733
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
static DWORD CALLBACK host_object_proc(LPVOID p)
Definition: marshal.c:618
HANDLE marshal_event
Definition: marshal.c:611

Referenced by start_host_object(), test_channel_hook(), test_marshal_channel_buffer(), and test_message_filter().

◆ START_TEST()

START_TEST ( marshal  )

Definition at line 4603 of file marshal.c.

4604{
4605 HMODULE hOle32 = GetModuleHandleA("ole32");
4606 int argc;
4607 char **argv;
4608
4609 if (!GetProcAddress(hOle32, "CoRegisterSurrogateEx")) {
4610 win_skip("skipping test on win9x\n");
4611 return;
4612 }
4613
4614 pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx");
4615 pDllGetClassObject = (void*)GetProcAddress(hOle32, "DllGetClassObject");
4616
4618 if (argc > 2 && (!strcmp(argv[2], "-Embedding")))
4619 {
4620 pCoInitializeEx(NULL, COINIT_MULTITHREADED);
4623
4624 return;
4625 }
4626
4628
4631
4632 pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
4633
4634 /* FIXME: test CoCreateInstanceEx */
4635
4636 /* lifecycle management and marshaling tests */
4637 do
4638 {
4664
4666 } while (with_external_conn);
4667
4686
4688
4692
4693 /* must be last test as channel hooks can't be unregistered */
4695
4697}
static int argc
Definition: ServiceArgs.c:12
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_client_security(void)
Definition: marshal.c:3522
static void test_tableweak_and_normal_marshal_and_releasedata(void)
Definition: marshal.c:2125
static void test_proxy_marshal_and_unmarshal_strong(void)
Definition: marshal.c:1095
static void test_normal_marshal_and_unmarshal(void)
Definition: marshal.c:752
static void test_interthread_marshal_and_unmarshal(void)
Definition: marshal.c:863
static void test_proxy_interfaces(void)
Definition: marshal.c:2728
static void test_proxy_marshal_and_unmarshal(void)
Definition: marshal.c:903
static void test_tableweak_marshal_and_unmarshal_twice(void)
Definition: marshal.c:1848
static void test_call_from_message(void)
Definition: marshal.c:3089
static void test_proxy_marshal_and_unmarshal_weak(void)
Definition: marshal.c:1042
static void test_no_marshaler(void)
Definition: marshal.c:711
static void test_crash_couninitialize(void)
Definition: marshal.c:1830
static void test_message_filter(void)
Definition: marshal.c:2652
static void test_proxy_used_in_wrong_thread(void)
Definition: marshal.c:2527
static void test_implicit_mta(void)
Definition: marshal.c:4197
static void test_inproc_handler(void)
Definition: marshal.c:3394
static void test_marshal_and_unmarshal_invalid(void)
Definition: marshal.c:784
static void test_register_local_server(void)
Definition: marshal.c:3754
static void test_tableweak_marshal_releasedata1(void)
Definition: marshal.c:1904
static void test_freethreadedmarshaler(void)
Definition: marshal.c:3208
static void test_tableweak_and_normal_marshal_and_unmarshal(void)
Definition: marshal.c:2055
static void test_tablestrong_marshal_and_unmarshal_twice(void)
Definition: marshal.c:2221
static void test_manualresetevent(void)
Definition: marshal.c:4044
static void test_normal_marshal_and_unmarshal_twice(void)
Definition: marshal.c:2410
static void test_cocreateinstance_proxy(void)
Definition: marshal.c:149
static void test_message_reentrancy(void)
Definition: marshal.c:3049
static void test_no_couninitialize_server(void)
Definition: marshal.c:1681
static void test_local_server(void)
Definition: marshal.c:3824
static void test_two_tableweak_marshal_and_releasedata(void)
Definition: marshal.c:2175
static void test_hresult_marshaling(void)
Definition: marshal.c:2451
static void test_marshal_stub_apartment_shutdown(void)
Definition: marshal.c:1164
static void test_proxybuffer(REFIID riid)
Definition: marshal.c:2822
static void test_globalinterfacetable(void)
Definition: marshal.c:3967
static void register_test_window(void)
Definition: marshal.c:3039
static void test_same_apartment_unmarshal_failure(void)
Definition: marshal.c:830
static void test_WM_QUIT_handling(void)
Definition: marshal.c:3133
static void test_CoGetStandardMarshal(void)
Definition: marshal.c:1575
static void test_DfMarshal_custom_marshaling(void)
Definition: marshal.c:1526
static void test_stubbuffer(REFIID riid)
Definition: marshal.c:2860
static void test_tableweak_marshal_releasedata2(void)
Definition: marshal.c:1965
static void test_proxy_marshal_and_unmarshal2(void)
Definition: marshal.c:978
static void test_channel_hook(void)
Definition: marshal.c:4553
static void test_StdMarshal_custom_marshaling(void)
Definition: marshal.c:1474
static void test_marshal_channel_buffer(void)
Definition: marshal.c:1296
static void test_disconnect_stub(void)
Definition: marshal.c:2372
static void test_no_couninitialize_client(void)
Definition: marshal.c:1753
static void test_marshal_proxy_mta_apartment_shutdown(void)
Definition: marshal.c:1252
static void test_handler_marshaling(void)
Definition: marshal.c:3472
static void test_normal_marshal_and_release(void)
Definition: marshal.c:725
static BOOL with_external_conn
Definition: marshal.c:181
static void test_marshal_proxy_apartment_shutdown(void)
Definition: marshal.c:1204
static void test_lock_object_external(void)
Definition: marshal.c:2274
static void test_bad_marshal_stream(void)
Definition: marshal.c:2703
#define win_skip
Definition: test.h:163

◆ test_bad_marshal_stream()

static void test_bad_marshal_stream ( void  )
static

Definition at line 2703 of file marshal.c.

2704{
2705 HRESULT hr;
2706 IStream *pStream = NULL;
2707
2708 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
2710 hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
2712
2714
2715 /* try to read beyond end of stream */
2716 hr = CoReleaseMarshalData(pStream);
2717 ok(hr == STG_E_READFAULT, "Should have failed with STG_E_READFAULT, but returned 0x%08x instead\n", hr);
2718
2719 /* now release for real */
2720 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2721 hr = CoReleaseMarshalData(pStream);
2723
2724 IStream_Release(pStream);
2725}
#define STG_E_READFAULT
Definition: winerror.h:2576

Referenced by START_TEST().

◆ test_call_from_message()

static void test_call_from_message ( void  )
static

Definition at line 3089 of file marshal.c.

3090{
3091 MSG msg;
3092 IStream *pStream;
3093 HRESULT hr;
3095 DWORD tid;
3096 HANDLE thread;
3098
3100 ok(hwnd_app != NULL, "Window creation failed\n");
3101
3102 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
3104 tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&TestMsg_ClassFactory, MSHLFLAGS_NORMAL, &thread);
3105
3107
3108 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
3109 hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&proxy);
3111 IStream_Release(pStream);
3112
3114
3115 /* start message re-entrancy test */
3116 hr = IClassFactory_CreateInstance(proxy, NULL, &IID_IUnknown, (void **)&object);
3117 ok_ole_success(hr, IClassFactory_CreateInstance);
3118
3119 IClassFactory_Release(proxy);
3120
3121 ok_no_locks();
3122
3124
3125 while (GetMessageA(&msg, NULL, 0, 0))
3126 {
3129 }
3131}
static IClassFactory TestMsg_ClassFactory
Definition: marshal.c:3087
static HWND hwnd_app
Definition: marshal.c:2892
static DWORD start_host_object(IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, HANDLE *thread)
Definition: marshal.c:684
static void end_host_object(DWORD tid, HANDLE thread)
Definition: marshal.c:700
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by START_TEST().

◆ test_channel_hook()

static void test_channel_hook ( void  )
static

Definition at line 4553 of file marshal.c.

4554{
4556 DWORD tid;
4557 IUnknown *proxy = NULL;
4558 HANDLE thread;
4559 HRESULT hr;
4560
4562 MSHLFLAGS_NORMAL, &MessageFilter };
4563
4566
4569
4570 cLocks = 0;
4571
4572 hr = CreateStreamOnHGlobal(NULL, TRUE, &object_data.stream);
4574 tid = start_host_object2(&object_data, &thread);
4575 server_tid = tid;
4576
4578
4579 IStream_Seek(object_data.stream, ullZero, STREAM_SEEK_SET, NULL);
4580 hr = CoUnmarshalInterface(object_data.stream, &IID_IClassFactory, (void **)&cf);
4582 IStream_Release(object_data.stream);
4583
4585
4586 method = 3;
4587 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
4588 ok_ole_success(hr, IClassFactory_CreateInstance);
4589
4590 method = 5;
4591 IUnknown_Release(proxy);
4592
4593 IClassFactory_Release(cf);
4594
4595 ok_no_locks();
4596
4598
4601}
HRESULT WINAPI CoRegisterChannelHook(REFGUID guidExtension, IChannelHook *pChannelHook)
Definition: compobj.c:4787
method
Definition: dragdrop.c:54
static int server_tid
Definition: marshal.c:4330
static IChannelHook TestChannelHook
Definition: marshal.c:4551
#define EXTENTID_WineTest
Definition: marshal.c:138
static IMessageFilter MessageFilter
Definition: marshal.c:2650

Referenced by START_TEST().

◆ test_client_security()

static void test_client_security ( void  )
static

Definition at line 3522 of file marshal.c.

3523{
3524 HRESULT hr;
3525 IStream *pStream = NULL;
3526 IClassFactory *pProxy = NULL;
3527 IUnknown *pProxy2 = NULL;
3528 IUnknown *pUnknown1 = NULL;
3529 IUnknown *pUnknown2 = NULL;
3530 IClientSecurity *pCliSec = NULL;
3531 IMarshal *pMarshal;
3532 DWORD tid;
3533 HANDLE thread;
3534 static const LARGE_INTEGER ullZero;
3535 DWORD dwAuthnSvc;
3536 DWORD dwAuthzSvc;
3537 OLECHAR *pServerPrincName;
3538 DWORD dwAuthnLevel;
3539 DWORD dwImpLevel;
3540 void *pAuthInfo;
3541 DWORD dwCapabilities;
3542 void *pv;
3543
3544 cLocks = 0;
3545
3546 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
3547 ok_ole_success(hr, "CreateStreamOnHGlobal");
3548 tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
3549
3550 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
3551 hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
3552 ok_ole_success(hr, "CoUnmarshalInterface");
3553 IStream_Release(pStream);
3554
3555 hr = IClassFactory_QueryInterface(pProxy, &IID_IUnknown, (LPVOID*)&pUnknown1);
3556 ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown");
3557
3558 hr = IClassFactory_QueryInterface(pProxy, &IID_IRemUnknown, (LPVOID*)&pProxy2);
3559 ok_ole_success(hr, "IUnknown_QueryInterface IID_IStream");
3560
3561 hr = IUnknown_QueryInterface(pProxy2, &IID_IUnknown, (LPVOID*)&pUnknown2);
3562 ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown");
3563
3564 ok(pUnknown1 == pUnknown2, "both proxy's IUnknowns should be the same - %p, %p\n", pUnknown1, pUnknown2);
3565
3566 hr = IClassFactory_QueryInterface(pProxy, &IID_IMarshal, (LPVOID*)&pMarshal);
3567 ok_ole_success(hr, "IUnknown_QueryInterface IID_IMarshal");
3568
3569 hr = IClassFactory_QueryInterface(pProxy, &IID_IClientSecurity, (LPVOID*)&pCliSec);
3570 ok_ole_success(hr, "IUnknown_QueryInterface IID_IClientSecurity");
3571
3572 hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pProxy, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3573 todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket (all NULLs)");
3574
3575 hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pMarshal, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3576 todo_wine ok(hr == E_NOINTERFACE, "IClientSecurity_QueryBlanket with local interface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
3577
3578 hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pProxy, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
3579 todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket");
3580
3581 hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pProxy, dwAuthnSvc, dwAuthzSvc, pServerPrincName, dwAuthnLevel, RPC_C_IMP_LEVEL_IMPERSONATE, pAuthInfo, dwCapabilities);
3582 todo_wine ok_ole_success(hr, "IClientSecurity_SetBlanket");
3583
3584 hr = IClassFactory_CreateInstance(pProxy, NULL, &IID_IWineTest, &pv);
3585 ok(hr == E_NOINTERFACE, "COM call should have succeeded instead of returning 0x%08x\n", hr);
3586
3587 hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pMarshal, dwAuthnSvc, dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities);
3588 todo_wine ok(hr == E_NOINTERFACE, "IClientSecurity_SetBlanket with local interface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
3589
3590 hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pProxy, 0xdeadbeef, dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities);
3591 todo_wine ok(hr == E_INVALIDARG, "IClientSecurity_SetBlanke with invalid dwAuthnSvc should have returned E_INVALIDARG instead of 0x%08x\n", hr);
3592
3593 CoTaskMemFree(pServerPrincName);
3594
3595 hr = IClientSecurity_QueryBlanket(pCliSec, pUnknown1, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
3596 todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket(IUnknown)");
3597
3598 CoTaskMemFree(pServerPrincName);
3599
3600 IClassFactory_Release(pProxy);
3601 IUnknown_Release(pProxy2);
3602 IUnknown_Release(pUnknown1);
3603 IUnknown_Release(pUnknown2);
3604 IMarshal_Release(pMarshal);
3605 IClientSecurity_Release(pCliSec);
3606
3608}
#define E_INVALIDARG
Definition: ddrawi.h:101
WCHAR OLECHAR
Definition: compat.h:2292
static const IID IID_IWineTest
Definition: marshal.c:122
static const IID IID_IRemUnknown
Definition: marshal.c:130
#define RPC_C_IMP_LEVEL_IMPERSONATE
Definition: rpcdce.h:176

Referenced by START_TEST().

◆ test_cocreateinstance_proxy()

static void test_cocreateinstance_proxy ( void  )
static

Definition at line 149 of file marshal.c.

150{
151 IUnknown *pProxy;
152 IMultiQI *pMQI;
153 HRESULT hr;
154
155 pCoInitializeEx(NULL, COINIT_MULTITHREADED);
156
157 hr = CoCreateInstance(&CLSID_ShellDesktop, NULL, CLSCTX_INPROC, &IID_IUnknown, (void **)&pProxy);
159 hr = IUnknown_QueryInterface(pProxy, &IID_IMultiQI, (void **)&pMQI);
160 ok(hr == S_OK, "created object is not a proxy, so was created in the wrong apartment\n");
161 if (hr == S_OK)
162 IMultiQI_Release(pMQI);
163 IUnknown_Release(pProxy);
164
166}
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325

Referenced by START_TEST().

◆ test_CoGetStandardMarshal()

static void test_CoGetStandardMarshal ( void  )
static

Definition at line 1575 of file marshal.c.

1576{
1577 DUALSTRINGARRAY *dualstringarr;
1578 STDOBJREF *stdobjref;
1579 OBJREF objref;
1580 IMarshal *marshal;
1581 DWORD size, read;
1582 IStream *stream;
1583 IUnknown *unk;
1584 CLSID clsid;
1585 HRESULT hr;
1586
1589
1591 MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL, &marshal);
1593
1594 hr = IMarshal_GetUnmarshalClass(marshal, &IID_IUnknown, &Test_Unknown,
1595 MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL, &clsid);
1596 ok_ole_success(hr, IMarshal_GetUnmarshalClass);
1598
1599 hr = IMarshal_GetMarshalSizeMax(marshal, &IID_IUnknown, &Test_Unknown,
1600 MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL, &size);
1601 ok_ole_success(hr, IMarshal_GetMarshalSizeMax);
1603 MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1605 ok(size == read, "IMarshal_GetMarshalSizeMax size = %d, expected %d\n", size, read);
1606
1607 hr = IMarshal_MarshalInterface(marshal, stream, &IID_IUnknown,
1608 &Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1609 ok_ole_success(hr, IMarshal_MarshalInterface);
1610
1611 hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1612 ok_ole_success(hr, IStream_Seek);
1613 size = FIELD_OFFSET(OBJREF, u_objref.u_standard.saResAddr.aStringArray);
1614 hr = IStream_Read(stream, &objref, size, &read);
1615 ok_ole_success(hr, IStream_Read);
1616 ok(read == size, "read = %d, expected %d\n", read, size);
1617 ok(objref.signature == OBJREF_SIGNATURE, "objref.signature = %x\n",
1618 objref.signature);
1619 ok(objref.flags == OBJREF_STANDARD, "objref.flags = %x\n", objref.flags);
1620 ok(IsEqualIID(&objref.iid, &IID_IUnknown), "objref.iid = %s\n",
1621 wine_dbgstr_guid(&objref.iid));
1622 stdobjref = &objref.u_objref.u_standard.std;
1623 ok(stdobjref->flags == 0, "stdobjref.flags = %d\n", stdobjref->flags);
1624 ok(stdobjref->cPublicRefs == 5, "stdobjref.cPublicRefs = %d\n",
1625 stdobjref->cPublicRefs);
1626 dualstringarr = &objref.u_objref.u_standard.saResAddr;
1627 ok(dualstringarr->wNumEntries == 0, "dualstringarr.wNumEntries = %d\n",
1628 dualstringarr->wNumEntries);
1629 ok(dualstringarr->wSecurityOffset == 0, "dualstringarr.wSecurityOffset = %d\n",
1630 dualstringarr->wSecurityOffset);
1631
1632 hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1633 ok_ole_success(hr, IStream_Seek);
1634 hr = IMarshal_UnmarshalInterface(marshal, stream, &IID_IUnknown, (void**)&unk);
1635 ok_ole_success(hr, IMarshal_UnmarshalInterface);
1636 IUnknown_Release(unk);
1637
1638 hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1639 ok_ole_success(hr, IStream_Seek);
1640 hr = IMarshal_MarshalInterface(marshal, stream, &IID_IUnknown,
1641 &Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1642 ok_ole_success(hr, IMarshal_MarshalInterface);
1643
1644 hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1645 ok_ole_success(hr, IStream_Seek);
1646 hr = IMarshal_ReleaseMarshalData(marshal, stream);
1647 ok_ole_success(hr, IMarshal_ReleaseMarshalData);
1648 IStream_Release(stream);
1649
1650 IMarshal_Release(marshal);
1651}
#define read
Definition: acwin.h:96
HRESULT WINAPI CoGetMarshalSizeMax(ULONG *pulSize, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1800
static IUnknown Test_Unknown
Definition: marshal.c:265
#define OBJREF_SIGNATURE
Definition: marshal.c:77
#define OBJREF_STANDARD
Definition: marshal.c:78
unsigned short wSecurityOffset
Definition: marshal.c:83
unsigned short wNumEntries
Definition: marshal.c:82
ULONG flags
Definition: marshal.c:101
struct tagOBJREF::@1691::OR_STANDARD u_standard
GUID iid
Definition: marshal.c:102
ULONG signature
Definition: marshal.c:100
union tagOBJREF::@1691 u_objref
ULONG flags
Definition: marshal.c:92
ULONG cPublicRefs
Definition: marshal.c:93
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by START_TEST().

◆ test_crash_couninitialize()

static void test_crash_couninitialize ( void  )
static

Definition at line 1830 of file marshal.c.

1831{
1832 HANDLE thread;
1833 DWORD tid;
1834
1835 if(!GetProcAddress(GetModuleHandleA("kernel32.dll"), "CreateActCtxW")) {
1836 win_skip("Skipping crash tests on win2k.\n");
1837 return;
1838 }
1839
1842 ok(!WaitForSingleObject(thread, 10000), "wait timed out\n");
1844 ok(crash_thread_success, "Crash thread failed\n");
1845}
static DWORD CALLBACK crash_couninitialize_proc(void *p)
Definition: marshal.c:1792

Referenced by START_TEST().

◆ test_DfMarshal_custom_marshaling()

static void test_DfMarshal_custom_marshaling ( void  )
static

Definition at line 1526 of file marshal.c.

1527{
1528 DWORD size, read;
1529 IStream *stream;
1530 OBJREF objref;
1531 HRESULT hr;
1532
1535
1541 MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1546
1547 hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1548 ok_ole_success(hr, IStream_Seek);
1549 size = FIELD_OFFSET(OBJREF, u_objref.u_custom.pData);
1550 hr = IStream_Read(stream, &objref, size, &read);
1551 ok_ole_success(hr, IStream_Read);
1552 ok(read == size, "read = %d, expected %d\n", read, size);
1553 ok(objref.signature == OBJREF_SIGNATURE, "objref.signature = %x\n",
1554 objref.signature);
1555 ok(objref.flags == OBJREF_CUSTOM, "objref.flags = %x\n", objref.flags);
1556 ok(IsEqualIID(&objref.iid, &IID_IUnknown), "objref.iid = %s\n",
1557 wine_dbgstr_guid(&objref.iid));
1559 "custom.clsid = %s\n", wine_dbgstr_guid(&objref.u_objref.u_custom.clsid));
1560 ok(!objref.u_objref.u_custom.cbExtension, "custom.cbExtension = %d\n",
1561 objref.u_objref.u_custom.cbExtension);
1562 ok(!objref.u_objref.u_custom.size, "custom.size = %d\n",
1563 objref.u_objref.u_custom.size);
1564
1565 IStream_Release(stream);
1566
1569 MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1572 ok(size == sizeof(OBJREF), "size = %d, expected %d\n", size, (int)sizeof(OBJREF));
1573}
#define SET_EXPECT(func)
Definition: marshal.c:41
#define OBJREF_CUSTOM
Definition: marshal.c:79
static IMarshal CustomMarshal
Definition: marshal.c:1472
#define CHECK_CALLED(func)
Definition: marshal.c:56
static const GUID CLSID_DfMarshal
Definition: marshal.c:63
struct tagOBJREF::@1691::OR_CUSTOM u_custom

Referenced by START_TEST().

◆ test_disconnect_stub()

static void test_disconnect_stub ( void  )
static

Definition at line 2372 of file marshal.c.

2373{
2374 HRESULT hr;
2375 IStream *pStream = NULL;
2376
2377 cLocks = 0;
2379
2380 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
2382 hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
2384
2386
2388
2391
2392 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2393 hr = CoReleaseMarshalData(pStream);
2395 IStream_Release(pStream);
2396
2399
2401
2402 ok_no_locks();
2404
2406 ok( hr == E_INVALIDARG, "wrong status %x\n", hr );
2407}
HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases)
Definition: compobj.c:3743

Referenced by START_TEST().

◆ test_freethreadedmarshaldata()

static void test_freethreadedmarshaldata ( IStream pStream,
MSHCTX  mshctx,
void ptr,
DWORD  mshlflags 
)
static

Definition at line 3163 of file marshal.c.

3164{
3165 HGLOBAL hglobal;
3166 DWORD size;
3167 char *marshal_data;
3168 HRESULT hr;
3169
3170 hr = GetHGlobalFromStream(pStream, &hglobal);
3172
3173 size = GlobalSize(hglobal);
3174
3175 marshal_data = GlobalLock(hglobal);
3176
3177 if (mshctx == MSHCTX_INPROC)
3178 {
3179 DWORD expected_size = round_global_size(3*sizeof(DWORD) + sizeof(GUID));
3180 ok(size == expected_size ||
3181 broken(size == (2*sizeof(DWORD))) /* Win9x & NT4 */,
3182 "size should have been %d instead of %d\n", expected_size, size);
3183
3184 ok(*(DWORD *)marshal_data == mshlflags, "expected 0x%x, but got 0x%x for mshctx\n", mshlflags, *(DWORD *)marshal_data);
3185 marshal_data += sizeof(DWORD);
3186 ok(*(void **)marshal_data == ptr, "expected %p, but got %p for mshctx\n", ptr, *(void **)marshal_data);
3187 marshal_data += sizeof(void *);
3188 if (sizeof(void*) == 4 && size >= 3*sizeof(DWORD))
3189 {
3190 ok(*(DWORD *)marshal_data == 0, "expected 0x0, but got 0x%x\n", *(DWORD *)marshal_data);
3191 marshal_data += sizeof(DWORD);
3192 }
3193 if (size >= 3*sizeof(DWORD) + sizeof(GUID))
3194 {
3195 trace("got guid data: %s\n", wine_dbgstr_guid((GUID *)marshal_data));
3196 }
3197 }
3198 else
3199 {
3200 ok(size > sizeof(DWORD), "size should have been > sizeof(DWORD), not %d\n", size);
3201 ok(*(DWORD *)marshal_data == 0x574f454d /* MEOW */,
3202 "marshal data should be filled by standard marshal and start with MEOW signature\n");
3203 }
3204
3205 GlobalUnlock(hglobal);
3206}
HRESULT WINAPI GetHGlobalFromStream(IStream *pstm, HGLOBAL *phglobal)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static PVOID ptr
Definition: dispmode.c:27
static SIZE_T round_global_size(SIZE_T size)
Definition: marshal.c:3150
#define DWORD
Definition: nt_native.h:44

Referenced by test_freethreadedmarshaler().

◆ test_freethreadedmarshaler()

static void test_freethreadedmarshaler ( void  )
static

Definition at line 3208 of file marshal.c.

3209{
3210 HRESULT hr;
3211 IUnknown *pFTUnknown;
3212 IMarshal *pFTMarshal;
3213 IStream *pStream;
3214 IUnknown *pProxy;
3215 static const LARGE_INTEGER llZero;
3216 CLSID clsid;
3217
3218 cLocks = 0;
3219 hr = CoCreateFreeThreadedMarshaler(NULL, &pFTUnknown);
3221 hr = IUnknown_QueryInterface(pFTUnknown, &IID_IMarshal, (void **)&pFTMarshal);
3222 ok_ole_success(hr, IUnknown_QueryInterface);
3223 IUnknown_Release(pFTUnknown);
3224
3225 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
3227
3228 /* inproc normal marshaling */
3229
3230 hr = IMarshal_GetUnmarshalClass(pFTMarshal, &IID_IClassFactory,
3231 &Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL, &clsid);
3232 ok_ole_success(hr, IMarshal_GetUnmarshalClass);
3233 ok(IsEqualIID(&clsid, &CLSID_InProcFreeMarshaler), "clsid = %s\n",
3235
3236 hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
3237 &Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
3238 ok_ole_success(hr, IMarshal_MarshalInterface);
3239
3241
3242 test_freethreadedmarshaldata(pStream, MSHCTX_INPROC, &Test_ClassFactory, MSHLFLAGS_NORMAL);
3243
3244 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3245 hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
3246 ok_ole_success(hr, IMarshal_UnmarshalInterface);
3247
3248 IUnknown_Release(pProxy);
3249
3250 ok_no_locks();
3251
3252 /* inproc table-strong marshaling */
3253
3254 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3255 hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
3256 (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, (void *)0xdeadbeef,
3257 MSHLFLAGS_TABLESTRONG);
3258 ok_ole_success(hr, IMarshal_MarshalInterface);
3259
3261
3262 test_freethreadedmarshaldata(pStream, MSHCTX_INPROC, &Test_ClassFactory, MSHLFLAGS_TABLESTRONG);
3263
3264 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3265 hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
3266 ok_ole_success(hr, IMarshal_UnmarshalInterface);
3267
3268 IUnknown_Release(pProxy);
3269
3271
3272 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3273 hr = IMarshal_ReleaseMarshalData(pFTMarshal, pStream);
3274 ok_ole_success(hr, IMarshal_ReleaseMarshalData);
3275
3276 ok_no_locks();
3277
3278 /* inproc table-weak marshaling */
3279
3280 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3281 hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
3282 (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, (void *)0xdeadbeef,
3283 MSHLFLAGS_TABLEWEAK);
3284 ok_ole_success(hr, IMarshal_MarshalInterface);
3285
3286 ok_no_locks();
3287
3288 test_freethreadedmarshaldata(pStream, MSHCTX_INPROC, &Test_ClassFactory, MSHLFLAGS_TABLEWEAK);
3289
3290 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3291 hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
3292 ok_ole_success(hr, IMarshal_UnmarshalInterface);
3293
3295
3296 IUnknown_Release(pProxy);
3297
3298 ok_no_locks();
3299
3300 /* inproc normal marshaling (for extraordinary cases) */
3301
3302 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3303 hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
3304 &Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
3305 ok_ole_success(hr, IMarshal_MarshalInterface);
3306
3308
3309 /* this call shows that DisconnectObject does nothing */
3310 hr = IMarshal_DisconnectObject(pFTMarshal, 0);
3311 ok_ole_success(hr, IMarshal_DisconnectObject);
3312
3314
3315 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3316 hr = IMarshal_ReleaseMarshalData(pFTMarshal, pStream);
3317 ok_ole_success(hr, IMarshal_ReleaseMarshalData);
3318
3319 ok_no_locks();
3320
3321 /* doesn't enforce marshaling rules here and allows us to unmarshal the
3322 * interface, even though it was freed above */
3323 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3324 hr = IMarshal_UnmarshalInterface(pFTMarshal, pStream, &IID_IUnknown, (void **)&pProxy);
3325 ok_ole_success(hr, IMarshal_UnmarshalInterface);
3326
3327 ok_no_locks();
3328
3329 /* local normal marshaling */
3330
3331 hr = IMarshal_GetUnmarshalClass(pFTMarshal, &IID_IClassFactory,
3332 &Test_ClassFactory, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL, &clsid);
3333 ok_ole_success(hr, IMarshal_GetUnmarshalClass);
3334 ok(IsEqualIID(&clsid, &CLSID_StdMarshal), "clsid = %s\n",
3336
3337 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3338 hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory, &Test_ClassFactory, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
3339 ok_ole_success(hr, IMarshal_MarshalInterface);
3340
3342
3343 test_freethreadedmarshaldata(pStream, MSHCTX_LOCAL, &Test_ClassFactory, MSHLFLAGS_NORMAL);
3344
3345 IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
3346 hr = CoReleaseMarshalData(pStream);
3348
3349 ok_no_locks();
3350
3351 IStream_Release(pStream);
3352 IMarshal_Release(pFTMarshal);
3353}
const CLSID CLSID_InProcFreeMarshaler
HRESULT WINAPI CoCreateFreeThreadedMarshaler(LPUNKNOWN punkOuter, LPUNKNOWN *ppunkMarshal)
Definition: ftmarshal.c:331
static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *ptr, DWORD mshlflags)
Definition: marshal.c:3163
static const LARGE_INTEGER llZero
Definition: moniker.c:1113

Referenced by START_TEST().

◆ test_globalinterfacetable()

static void test_globalinterfacetable ( void  )
static

Definition at line 3967 of file marshal.c.

3968{
3969 HRESULT hr;
3971 DWORD cookie;
3972 HANDLE thread;
3973 DWORD tid;
3974 struct git_params params;
3975 DWORD ret;
3978 ULONG ref;
3979
3980 trace("test_globalinterfacetable\n");
3981 cLocks = 0;
3982
3983 hr = pDllGetClassObject(&CLSID_StdGlobalInterfaceTable, &IID_IClassFactory, (void**)&cf);
3984 ok(hr == S_OK, "got 0x%08x\n", hr);
3985
3986 hr = IClassFactory_QueryInterface(cf, &IID_IGlobalInterfaceTable, (void**)&object);
3987 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
3988
3989 IClassFactory_Release(cf);
3990
3991 hr = CoCreateInstance(&CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, &IID_IGlobalInterfaceTable, (void **)&git);
3993
3994 ref = IGlobalInterfaceTable_AddRef(git);
3995 ok(ref == 1, "ref=%d\n", ref);
3996 ref = IGlobalInterfaceTable_AddRef(git);
3997 ok(ref == 1, "ref=%d\n", ref);
3998
3999 ref = IGlobalInterfaceTable_Release(git);
4000 ok(ref == 1, "ref=%d\n", ref);
4001 ref = IGlobalInterfaceTable_Release(git);
4002 ok(ref == 1, "ref=%d\n", ref);
4003
4004 hr = IGlobalInterfaceTable_RegisterInterfaceInGlobal(git, (IUnknown *)&Test_ClassFactory, &IID_IClassFactory, &cookie);
4005 ok_ole_success(hr, IGlobalInterfaceTable_RegisterInterfaceInGlobal);
4006
4008
4009 params.cookie = cookie;
4010 params.git = git;
4011 /* note: params is on stack so we MUST wait for get_global_interface_proc
4012 * to exit before we can return */
4014
4016 while (ret == WAIT_OBJECT_0 + 1)
4017 {
4018 MSG msg;
4019 while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
4022 }
4023
4025
4026 /* test getting interface from global with different iid */
4027 hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(git, cookie, &IID_IUnknown, (void **)&object);
4028 ok_ole_success(hr, IGlobalInterfaceTable_GetInterfaceFromGlobal);
4029 IUnknown_Release(object);
4030
4031 /* test getting interface from global with same iid */
4032 hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(git, cookie, &IID_IClassFactory, (void **)&object);
4033 ok_ole_success(hr, IGlobalInterfaceTable_GetInterfaceFromGlobal);
4034 IUnknown_Release(object);
4035
4036 hr = IGlobalInterfaceTable_RevokeInterfaceFromGlobal(git, cookie);
4037 ok_ole_success(hr, IGlobalInterfaceTable_RevokeInterfaceFromGlobal);
4038
4039 ok_no_locks();
4040
4041 IGlobalInterfaceTable_Release(git);
4042}
const CLSID CLSID_StdGlobalInterfaceTable
static DWORD CALLBACK get_global_interface_proc(LPVOID pv)
Definition: marshal.c:3940
Definition: cookie.c:34
DWORD cookie
Definition: marshal.c:3936
IGlobalInterfaceTable * git
Definition: marshal.c:3937

Referenced by START_TEST().

◆ test_handler_marshaling()

static void test_handler_marshaling ( void  )
static

Definition at line 3472 of file marshal.c.

3473{
3474 HRESULT hr;
3475 IStream *pStream = NULL;
3476 IUnknown *pProxy = NULL;
3478 DWORD tid;
3479 HANDLE thread;
3480 static const LARGE_INTEGER ullZero;
3481
3483 return;
3484 cLocks = 0;
3485
3486 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
3487 ok_ole_success(hr, "CreateStreamOnHGlobal");
3488 tid = start_host_object(pStream, &IID_IUnknown, (IUnknown*)&Test_SMI, MSHLFLAGS_NORMAL, &thread);
3489
3491
3492 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
3493 hr = CoUnmarshalInterface(pStream, &IID_IUnknown, (void **)&pProxy);
3494 ok_ole_success(hr, "CoUnmarshalInterface");
3495 IStream_Release(pStream);
3496
3497 if(hr == S_OK)
3498 {
3500
3501 hr = IUnknown_QueryInterface(pProxy, &IID_IWineTest, (void **)&pObject);
3502 ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface with unknown IID should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
3503
3504 /* it's a handler as it supports IOleObject */
3505 hr = IUnknown_QueryInterface(pProxy, &IID_IOleObject, (void **)&pObject);
3506 todo_wine
3507 ok_ole_success(hr, "IUnknown_QueryInterface(&IID_IOleObject)");
3508 if (SUCCEEDED(hr)) IUnknown_Release(pObject);
3509
3510 IUnknown_Release(pProxy);
3511
3512 ok_no_locks();
3513 }
3514
3517
3518 /* FIXME: test IPersist interface has the same effect as IStdMarshalInfo */
3519}
FxObject * pObject
#define FAILED(hr)
Definition: intsafe.h:51
static IStdMarshalInfo Test_SMI
Definition: marshal.c:3470
static HRESULT reg_unreg_wine_test_class(BOOL Register)
Definition: marshal.c:3355
const GUID IID_IOleObject

Referenced by START_TEST().

◆ test_hresult_marshaling()

static void test_hresult_marshaling ( void  )
static

Definition at line 2451 of file marshal.c.

2452{
2453 HRESULT hr;
2454 HRESULT hr_marshaled = 0;
2455 IStream *pStream = NULL;
2456 static const HRESULT E_DEADBEEF = 0xdeadbeef;
2457
2458 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
2460
2461 hr = CoMarshalHresult(pStream, E_DEADBEEF);
2463
2464 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2465 hr = IStream_Read(pStream, &hr_marshaled, sizeof(HRESULT), NULL);
2466 ok_ole_success(hr, IStream_Read);
2467
2468 ok(hr_marshaled == E_DEADBEEF, "Didn't marshal HRESULT as expected: got value 0x%08x instead\n", hr_marshaled);
2469
2470 hr_marshaled = 0;
2471 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2472 hr = CoUnmarshalHresult(pStream, &hr_marshaled);
2474
2475 ok(hr_marshaled == E_DEADBEEF, "Didn't marshal HRESULT as expected: got value 0x%08x instead\n", hr_marshaled);
2476
2477 IStream_Release(pStream);
2478}
HRESULT WINAPI CoMarshalHresult(LPSTREAM pStm, HRESULT hresult)
Definition: marshal.c:2227
HRESULT WINAPI CoUnmarshalHresult(LPSTREAM pStm, HRESULT *phresult)
Definition: marshal.c:2248

Referenced by START_TEST().

◆ Test_IClassFactory_AddRef()

static ULONG WINAPI Test_IClassFactory_AddRef ( LPCLASSFACTORY  iface)
static

Definition at line 313 of file marshal.c.

314{
315 LockModule();
316 return 2; /* non-heap-based object */
317}
static void LockModule(void)
Definition: marshal.c:171

◆ Test_IClassFactory_CreateInstance()

static HRESULT WINAPI Test_IClassFactory_CreateInstance ( LPCLASSFACTORY  iface,
LPUNKNOWN  pUnkOuter,
REFIID  riid,
LPVOID ppvObj 
)
static

Definition at line 325 of file marshal.c.

330{
331 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
332 return IUnknown_QueryInterface(&Test_Unknown, riid, ppvObj);
333}
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662

◆ Test_IClassFactory_LockServer()

static HRESULT WINAPI Test_IClassFactory_LockServer ( LPCLASSFACTORY  iface,
BOOL  fLock 
)
static

Definition at line 335 of file marshal.c.

338{
339 return S_OK;
340}

◆ Test_IClassFactory_QueryInterface()

static HRESULT WINAPI Test_IClassFactory_QueryInterface ( LPCLASSFACTORY  iface,
REFIID  riid,
LPVOID ppvObj 
)
static

Definition at line 286 of file marshal.c.

290{
291 if (ppvObj == NULL) return E_POINTER;
292
295 /* the only other interface Wine is currently able to marshal (for testing two proxies) */
297 {
298 *ppvObj = iface;
299 IClassFactory_AddRef(iface);
300 return S_OK;
301 }
302
303 if (with_external_conn && IsEqualGUID(riid, &IID_IExternalConnection))
304 {
305 *ppvObj = &ExternalConnection;
306 return S_OK;
307 }
308
309 *ppvObj = NULL;
310 return E_NOINTERFACE;
311}
static IExternalConnection ExternalConnection
Definition: marshal.c:225

◆ Test_IClassFactory_Release()

static ULONG WINAPI Test_IClassFactory_Release ( LPCLASSFACTORY  iface)
static

Definition at line 319 of file marshal.c.

320{
321 UnlockModule();
322 return 1; /* non-heap-based object */
323}
static void UnlockModule(void)
Definition: marshal.c:176

◆ test_implicit_mta()

static void test_implicit_mta ( void  )
static

Definition at line 4197 of file marshal.c.

4198{
4200 HANDLE host_thread, thread;
4202 IUnknown *proxy;
4203 IStream *stream;
4204 HRESULT hr;
4205 DWORD tid;
4206
4207 cLocks = 0;
4209
4211
4212 /* Firstly: we can unmarshal and use an object while in the implicit MTA. */
4215 tid = start_host_object(stream, &IID_IClassFactory, (IUnknown *)&Test_ClassFactory, MSHLFLAGS_NORMAL, &host_thread);
4216
4219
4221 ok(!WaitForSingleObject(thread, 1000), "wait failed\n");
4223
4224 IStream_Release(stream);
4225 end_host_object(tid, host_thread);
4226
4227 /* Secondly: we can unmarshal an object into the real MTA and then use it
4228 * from the implicit MTA. */
4231 tid = start_host_object(stream, &IID_IClassFactory, (IUnknown *)&Test_ClassFactory, MSHLFLAGS_NORMAL, &host_thread);
4232
4235
4236 IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
4239
4241 ok(!WaitForSingleObject(thread, 1000), "wait failed\n");
4243
4244 IClassFactory_Release(cf);
4245 IStream_Release(stream);
4246
4247 ok_no_locks();
4250
4251 end_host_object(tid, host_thread);
4252
4253 /* Thirdly: we can marshal an object from the implicit MTA and then
4254 * unmarshal it into the real one. */
4255 data.start = CreateEventA(NULL, FALSE, FALSE, NULL);
4256 data.stop = CreateEventA(NULL, FALSE, FALSE, NULL);
4257
4258 hr = CreateStreamOnHGlobal(NULL, TRUE, &data.stream);
4260
4262 ok(!WaitForSingleObject(data.start, 1000), "wait failed\n");
4263
4264 IStream_Seek(data.stream, ullZero, STREAM_SEEK_SET, NULL);
4265 hr = CoUnmarshalInterface(data.stream, &IID_IClassFactory, (void **)&cf);
4267
4268 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4269 ok_ole_success(hr, IClassFactory_CreateInstance);
4270
4271 IUnknown_Release(proxy);
4272
4273 SetEvent(data.stop);
4274 ok(!WaitForSingleObject(thread, 1000), "wait failed\n");
4276
4277 IStream_Release(data.stream);
4278
4280}
static DWORD CALLBACK implicit_mta_use_proc(void *param)
Definition: marshal.c:4154
static DWORD CALLBACK implicit_mta_unmarshal_proc(void *param)
Definition: marshal.c:4119
static DWORD CALLBACK implicit_mta_marshal_proc(void *param)
Definition: marshal.c:4182

Referenced by START_TEST().

◆ test_inproc_handler()

static void test_inproc_handler ( void  )
static

Definition at line 3394 of file marshal.c.

3395{
3396 HRESULT hr;
3398 IUnknown *pObject2;
3399
3401 return;
3402
3403 hr = CoCreateInstance(&CLSID_WineTest, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&pObject);
3404 ok_ole_success(hr, "CoCreateInstance");
3405
3406 if (SUCCEEDED(hr))
3407 {
3408 hr = IUnknown_QueryInterface(pObject, &IID_IWineTest, (void **)&pObject2);
3409 ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface on handler for invalid interface returned 0x%08x instead of E_NOINTERFACE\n", hr);
3410
3411 /* it's a handler as it supports IOleObject */
3412 hr = IUnknown_QueryInterface(pObject, &IID_IOleObject, (void **)&pObject2);
3413 ok_ole_success(hr, "IUnknown_QueryInterface(&IID_IOleObject)");
3414 IUnknown_Release(pObject2);
3415
3416 IUnknown_Release(pObject);
3417 }
3418
3420}

Referenced by START_TEST().

◆ test_interthread_marshal_and_unmarshal()

static void test_interthread_marshal_and_unmarshal ( void  )
static

Definition at line 863 of file marshal.c.

864{
865 HRESULT hr;
866 IStream *pStream = NULL;
867 IUnknown *pProxy = NULL;
868 DWORD tid;
870
871 cLocks = 0;
873
874 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
876 tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
877
880
881 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
882 hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
884 IStream_Release(pStream);
885
888
889 IUnknown_Release(pProxy);
890
891 ok_no_locks();
894
896}

Referenced by START_TEST().

◆ Test_IUnknown_AddRef()

static ULONG WINAPI Test_IUnknown_AddRef ( LPUNKNOWN  iface)
static

Definition at line 246 of file marshal.c.

247{
248 LockModule();
249 return 2; /* non-heap-based object */
250}

◆ Test_IUnknown_QueryInterface()

static HRESULT WINAPI Test_IUnknown_QueryInterface ( LPUNKNOWN  iface,
REFIID  riid,
LPVOID ppvObj 
)
static

Definition at line 228 of file marshal.c.

232{
233 if (ppvObj == NULL) return E_POINTER;
234
236 {
237 *ppvObj = iface;
238 IUnknown_AddRef(iface);
239 return S_OK;
240 }
241
242 *ppvObj = NULL;
243 return E_NOINTERFACE;
244}

◆ Test_IUnknown_Release()

static ULONG WINAPI Test_IUnknown_Release ( LPUNKNOWN  iface)
static

Definition at line 252 of file marshal.c.

253{
254 UnlockModule();
255 return 1; /* non-heap-based object */
256}

◆ test_local_server()

static void test_local_server ( void  )
static

Definition at line 3824 of file marshal.c.

3825{
3826 DWORD cookie;
3827 HRESULT hr;
3828 IClassFactory * cf;
3829 IPersist *persist;
3830 DWORD ret;
3832 HANDLE quit_event;
3833 HANDLE ready_event;
3834 HANDLE repeat_event;
3835 CLSID clsid;
3836
3838
3839 cLocks = 0;
3840
3841 /* Start the object suspended */
3843 CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED, &cookie);
3845
3846 /* ... and CoGetClassObject does not find it and fails when it looks for the
3847 * class in the registry */
3848 hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER,
3850 ok(hr == REGDB_E_CLASSNOTREG || /* NT */
3851 hr == S_OK /* Win9x */,
3852 "CoGetClassObject should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
3853
3854 /* Resume the object suspended above ... */
3857
3858 /* ... and now it should succeed */
3859 hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER,
3862
3863 /* Now check the locking is working */
3864 /* NOTE: we are accessing the class directly, not through a proxy */
3865
3866 ok_no_locks();
3867
3868 hr = IClassFactory_LockServer(cf, TRUE);
3869 ok_ole_success(hr, IClassFactory_LockServer);
3870
3872
3873 IClassFactory_LockServer(cf, FALSE);
3874 ok_ole_success(hr, IClassFactory_LockServer);
3875
3876 ok_no_locks();
3877
3878 IClassFactory_Release(cf);
3879
3880 /* wait for shutdown signal */
3882 ok(ret != WAIT_TIMEOUT, "Server didn't shut down\n");
3883
3884 /* try to connect again after SCM has suspended registered class objects */
3885 hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, NULL,
3887 ok(hr == CO_E_SERVER_STOPPING || /* NT */
3888 hr == REGDB_E_CLASSNOTREG || /* win2k */
3889 hr == S_OK /* Win9x */,
3890 "CoGetClassObject should have returned CO_E_SERVER_STOPPING or REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
3891
3894
3896
3897 process = create_target_process("-Embedding");
3898 ok(process != NULL, "couldn't start local server process, error was %d\n", GetLastError());
3899
3900 ready_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Ready Event");
3901 ok( !WaitForSingleObject(ready_event, 10000), "wait timed out\n" );
3902
3903 hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_LOCAL_SERVER, &IID_IPersist, (void **)&persist);
3905
3906 IPersist_Release(persist);
3907
3908 hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_LOCAL_SERVER, &IID_IPersist, (void **)&persist);
3909 ok(hr == REGDB_E_CLASSNOTREG, "Second CoCreateInstance on REGCLS_SINGLEUSE object should have failed\n");
3910
3911 /* Re-register the class and try calling CoDisconnectObject from within a call to that object */
3912 repeat_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Repeat Event");
3913 SetEvent(repeat_event);
3914 CloseHandle(repeat_event);
3915
3916 ok( !WaitForSingleObject(ready_event, 10000), "wait timed out\n" );
3917 CloseHandle(ready_event);
3918
3919 hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_LOCAL_SERVER, &IID_IPersist, (void **)&persist);
3921
3922 /* GetClassID will call CoDisconnectObject */
3923 IPersist_GetClassID(persist, &clsid);
3924 IPersist_Release(persist);
3925
3926 quit_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Quit Event");
3927 SetEvent(quit_event);
3928
3930 CloseHandle(quit_event);
3932}
#define WAIT_TIMEOUT
Definition: dderror.h:14
HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(DWORD dwRegister)
Definition: compobj.c:1086
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3103
HRESULT WINAPI CoResumeClassObjects(void)
Definition: compobj.c:3288
static HANDLE heventShutdown
Definition: marshal.c:3610
static HANDLE create_target_process(const char *arg)
Definition: marshal.c:3804
static const CLSID CLSID_WineOOPTest
Definition: marshal.c:141
static IClassFactory TestOOP_ClassFactory
Definition: marshal.c:3752
@ REGCLS_SUSPENDED
Definition: objbase.h:395
void winetest_wait_child_process(HANDLE process)
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
#define CO_E_SERVER_STOPPING
Definition: winerror.h:2863

Referenced by START_TEST().

◆ test_lock_object_external()

static void test_lock_object_external ( void  )
static

Definition at line 2274 of file marshal.c.

2275{
2276 HRESULT hr;
2277 IStream *pStream = NULL;
2278
2279 cLocks = 0;
2281
2282 /* test the stub manager creation aspect of CoLockObjectExternal when the
2283 * object hasn't been marshaled yet */
2285
2288
2290
2291 ok_no_locks();
2294
2295 /* test our empty stub manager being handled correctly in
2296 * CoMarshalInterface */
2298
2299 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
2301 hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
2303
2305
2308
2309 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2310 hr = CoReleaseMarshalData(pStream);
2312 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2313
2317
2319
2323
2325
2326 ok_no_locks();
2329
2330 /* test CoLockObjectExternal releases reference to object with
2331 * fLastUnlockReleases as TRUE and there are only strong references on
2332 * the object */
2334
2337
2339
2340 ok_no_locks();
2341 ok_ze