ReactOS  0.4.13-dev-100-gc8611ae
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)
GLenum func
Definition: glext.h:6028

Definition at line 56 of file marshal.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)
GLenum func
Definition: glext.h:6028

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)
GLenum func
Definition: glext.h:6028
#define TRUE
Definition: types.h:120
#define expect_(expected, got, precision)
Definition: font.c:29

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 2476 of file marshal.c.

2477 {
2478  IClassFactory * cf = p;
2479  HRESULT hr;
2480  IUnknown * proxy = NULL;
2481 
2482  hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
2483  todo_wine
2485  "COM should have failed with CO_E_NOTINITIALIZED on using proxy without apartment, but instead returned 0x%08x\n",
2486  hr);
2487 
2488  hr = IClassFactory_QueryInterface(cf, &IID_IMultiQI, (LPVOID *)&proxy);
2489  /* Win9x returns S_OK, whilst NT returns RPC_E_WRONG_THREAD */
2490  trace("call to proxy's QueryInterface for local interface without apartment returned 0x%08x\n", hr);
2491  if (SUCCEEDED(hr))
2492  IUnknown_Release(proxy);
2493 
2494  hr = IClassFactory_QueryInterface(cf, &IID_IStream, (LPVOID *)&proxy);
2495  /* Win9x returns E_NOINTERFACE, whilst NT returns RPC_E_WRONG_THREAD */
2496  trace("call to proxy's QueryInterface without apartment returned 0x%08x\n", hr);
2497  if (SUCCEEDED(hr))
2498  IUnknown_Release(proxy);
2499 
2500  pCoInitializeEx(NULL, COINIT_MULTITHREADED);
2501 
2502  hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
2503  if (proxy) IUnknown_Release(proxy);
2505  "COM should have failed with RPC_E_WRONG_THREAD on using proxy from wrong apartment, but instead returned 0x%08x\n",
2506  hr);
2507 
2508  hr = IClassFactory_QueryInterface(cf, &IID_IStream, (LPVOID *)&proxy);
2509  /* Win9x returns E_NOINTERFACE, whilst NT returns RPC_E_WRONG_THREAD */
2510  trace("call to proxy's QueryInterface from wrong apartment returned 0x%08x\n", hr);
2511 
2512  /* now be really bad and release the proxy from the wrong apartment */
2513  IClassFactory_Release(cf);
2514 
2515  CoUninitialize();
2516 
2517  return 0;
2518 }
#define trace(...)
Definition: kmt_test.h:217
int proxy
Definition: main.c:67
HRESULT hr
Definition: shlfolder.c:183
#define RPC_E_WRONG_THREAD
Definition: winerror.h:2490
#define CO_E_NOTINITIALIZED
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define todo_wine
Definition: test.h:154
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
GLfloat GLfloat p
Definition: glext.h:8902
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_proxy_used_in_wrong_thread().

◆ crash_couninitialize_proc()

static DWORD CALLBACK crash_couninitialize_proc ( void p)
static

Definition at line 1786 of file marshal.c.

1787 {
1788  IStream *stream;
1789  HRESULT hr;
1790 
1791  cLocks = 0;
1792 
1793  CoInitialize(NULL);
1794 
1797 
1798  hr = CoMarshalInterface(stream, &IID_IUnknown, &TestCrash_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1800 
1801  IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1802 
1805 
1806  ok_no_locks();
1807 
1808  hr = CoMarshalInterface(stream, &IID_IUnknown, &TestCrash_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1810 
1812 
1813  trace("CoUninitialize >>>\n");
1814  CoUninitialize();
1815  trace("CoUninitialize <<<\n");
1816 
1817  ok_no_locks();
1818 
1819  IStream_Release(stream);
1821  return 0;
1822 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:2056
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
static LONG cLocks
Definition: marshal.c:169
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
#define ok_more_than_one_lock()
Definition: marshal.c:70
#define ok_no_locks()
Definition: marshal.c:71
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
static IUnknown TestCrash_Unknown
Definition: marshal.c:284
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
static BOOL crash_thread_success
Definition: marshal.c:1784
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by test_crash_couninitialize().

◆ create_target_process()

static HANDLE create_target_process ( const char arg)
static

Definition at line 3798 of file marshal.c.

3799 {
3800  char **argv;
3801  char cmdline[MAX_PATH];
3802  BOOL ret;
3804  STARTUPINFOA si = { 0 };
3805  si.cb = sizeof(si);
3806 
3807  pi.hThread = NULL;
3808  pi.hProcess = NULL;
3810  sprintf(cmdline, "\"%s\" %s %s", argv[0], argv[1], arg);
3811  ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
3812  ok(ret, "CreateProcess failed with error: %u\n", GetLastError());
3813  if (pi.hThread) CloseHandle(pi.hThread);
3814  return pi.hProcess;
3815 }
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define argv
Definition: mplay32.c:18
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
DWORD cb
Definition: winbase.h:796
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:4772
#define MAX_PATH
Definition: compat.h:26
int winetest_get_mainargs(char ***pargv)
static DWORD pi
Definition: protocol.c:150
int ret

Referenced by test_local_server().

◆ CustomMarshal_AddRef()

static ULONG WINAPI CustomMarshal_AddRef ( IMarshal iface)
static

Definition at line 1378 of file marshal.c.

1379 {
1380  return 2;
1381 }

◆ CustomMarshal_DisconnectObject()

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

Definition at line 1447 of file marshal.c.

1448 {
1449  ok(0, "unexpected call\n");
1450  return E_NOTIMPL;
1451 }
#define ok(value,...)
#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 1396 of file marshal.c.

1398 {
1400  ok(size != NULL, "size = NULL\n");
1401 
1402  *size = 0;
1403  return S_OK;
1404 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
static HRESULT WINAPI CustomMarshal_GetMarshalSizeMax(IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, DWORD *size)
Definition: marshal.c:1396
#define S_OK
Definition: intsafe.h:59

Referenced by 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 1388 of file marshal.c.

1390 {
1392  *clsid = *unmarshal_class;
1393  return S_OK;
1394 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50
static HRESULT WINAPI CustomMarshal_GetUnmarshalClass(IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, CLSID *clsid)
Definition: marshal.c:1388
REFCLSID clsid
Definition: msctf.c:84
static const CLSID * unmarshal_class
Definition: marshal.c:1359
#define S_OK
Definition: intsafe.h:59

Referenced by 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 1406 of file marshal.c.

1408 {
1409  IMarshal *std_marshal;
1410  STATSTG stat;
1411  HRESULT hr;
1412 
1414 
1416  return S_OK;
1417 
1418  hr = IStream_Stat(stream, &stat, STATFLAG_DEFAULT);
1419  ok_ole_success(hr, IStream_Stat);
1420  ok(U(stat.cbSize).LowPart == 0, "stream is not empty (%d)\n", U(stat.cbSize).LowPart);
1421  ok(U(stat.cbSize).HighPart == 0, "stream is not empty (%d)\n", U(stat.cbSize).HighPart);
1422 
1424  dwDestContext, NULL, mshlflags, &std_marshal);
1426  hr = IMarshal_MarshalInterface(std_marshal, stream, riid, pv,
1427  dwDestContext, pvDestContext, mshlflags);
1428  ok_ole_success(hr, IMarshal_MarshalInterface);
1429  IMarshal_Release(std_marshal);
1430 
1431  return S_OK;
1432 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
static HRESULT WINAPI CustomMarshal_MarshalInterface(IMarshal *iface, IStream *stream, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags)
Definition: marshal.c:1406
#define U(x)
Definition: wordpad.c:44
LPVOID iface
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
Definition: parse.h:22
Definition: stat.h:55
const CLSID CLSID_StdMarshal
static const CLSID * unmarshal_class
Definition: marshal.c:1359
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI CoGetStandardMarshal(REFIID riid, IUnknown *pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags, LPMARSHAL *ppMarshal)
Definition: marshal.c:1677
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by 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 1364 of file marshal.c.

1365 {
1366  if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMarshal)) {
1367  *ppv = iface;
1368  }
1369  else
1370  {
1371  *ppv = NULL;
1372  return E_NOINTERFACE;
1373  }
1374  IUnknown_AddRef((IUnknown*)*ppv);
1375  return S_OK;
1376 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
LPVOID iface
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90

◆ CustomMarshal_Release()

static ULONG WINAPI CustomMarshal_Release ( IMarshal iface)
static

Definition at line 1383 of file marshal.c.

1384 {
1385  return 1;
1386 }

◆ CustomMarshal_ReleaseMarshalData()

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

Definition at line 1441 of file marshal.c.

1442 {
1443  ok(0, "unexpected call\n");
1444  return E_NOTIMPL;
1445 }
#define ok(value,...)
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ CustomMarshal_UnmarshalInterface()

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

Definition at line 1434 of file marshal.c.

1436 {
1437  ok(0, "unexpected call\n");
1438  return E_NOTIMPL;
1439 }
#define ok(value,...)
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ debugstr_iid()

static const char* debugstr_iid ( REFIID  riid)
static

Definition at line 4276 of file marshal.c.

4277 {
4278  static char name[256];
4279  HKEY hkeyInterface;
4280  WCHAR bufferW[39];
4281  char buffer[39];
4282  LONG name_size = sizeof(name);
4283  StringFromGUID2(riid, bufferW, ARRAY_SIZE(bufferW));
4284  WideCharToMultiByte(CP_ACP, 0, bufferW, ARRAY_SIZE(bufferW), buffer, sizeof(buffer), NULL, NULL);
4285  if (RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_QUERY_VALUE, &hkeyInterface) != ERROR_SUCCESS)
4286  {
4287  memcpy(name, buffer, sizeof(buffer));
4288  goto done;
4289  }
4290  if (RegQueryValueA(hkeyInterface, buffer, name, &name_size) != ERROR_SUCCESS)
4291  {
4292  memcpy(name, buffer, sizeof(buffer));
4293  goto done;
4294  }
4295  RegCloseKey(hkeyInterface);
4296 done:
4297  return name;
4298 }
LSTATUS WINAPI RegQueryValueA(HKEY hkey, LPCSTR name, LPSTR data, LPLONG count)
Definition: reg.c:4243
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
REFIID riid
Definition: precomp.h:44
#define CP_ACP
Definition: compat.h:99
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3346
GLuint buffer
Definition: glext.h:5915
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2343
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ARRAY_SIZE(a)
Definition: main.h:24
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
Definition: name.c:36
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by TestChannelHook_ClientGetSize(), and TestChannelHook_ServerGetSize().

◆ DEFINE_EXPECT() [1/8]

DEFINE_EXPECT ( Invoke  )

◆ DEFINE_EXPECT() [2/8]

DEFINE_EXPECT ( CreateStub  )

◆ DEFINE_EXPECT() [3/8]

DEFINE_EXPECT ( CreateProxy  )

◆ DEFINE_EXPECT() [4/8]

DEFINE_EXPECT ( GetWindow  )

◆ DEFINE_EXPECT() [5/8]

DEFINE_EXPECT ( Disconnect  )

◆ DEFINE_EXPECT() [6/8]

DEFINE_EXPECT ( CustomMarshal_GetUnmarshalClass  )

◆ DEFINE_EXPECT() [7/8]

DEFINE_EXPECT ( CustomMarshal_GetMarshalSizeMax  )

◆ DEFINE_EXPECT() [8/8]

DEFINE_EXPECT ( CustomMarshal_MarshalInterface  )

◆ duo_marshal_thread_proc()

static DWORD CALLBACK duo_marshal_thread_proc ( void p)
static

Definition at line 2008 of file marshal.c.

2009 {
2010  HRESULT hr;
2011  struct duo_marshal_data *data = p;
2012  HANDLE hQuitEvent = data->hQuitEvent;
2013  MSG msg;
2014 
2015  pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
2016 
2017  hr = CoMarshalInterface(data->pStream1, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, data->marshal_flags1);
2018  ok_ole_success(hr, "CoMarshalInterface");
2019 
2020  hr = CoMarshalInterface(data->pStream2, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, data->marshal_flags2);
2021  ok_ole_success(hr, "CoMarshalInterface");
2022 
2023  /* force the message queue to be created before signaling parent thread */
2025 
2026  SetEvent(data->hReadyEvent);
2027 
2029  {
2030  while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
2031  {
2032  if (msg.hwnd == NULL && msg.message == RELEASEMARSHALDATA)
2033  {
2034  CoReleaseMarshalData(msg.wParam == 1 ? data->pStream1 : data->pStream2);
2035  SetEvent((HANDLE)msg.lParam);
2036  }
2037  else
2039  }
2040  }
2042 
2043  CoUninitialize();
2044 
2045  return 0;
2046 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:2056
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define CloseHandle
Definition: compat.h:398
HRESULT hr
Definition: shlfolder.c:183
#define RELEASEMARSHALDATA
Definition: marshal.c:600
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_NOREMOVE
Definition: winuser.h:1181
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
LONG HRESULT
Definition: typedefs.h:77
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
#define WM_USER
Definition: winuser.h:1856
HANDLE hQuitEvent
Definition: marshal.c:2005
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define QS_ALLINPUT
Definition: winuser.h:874
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182
GLfloat GLfloat p
Definition: glext.h:8902
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72

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 }
#define CloseHandle
Definition: compat.h:398
#define WM_QUIT
Definition: winuser.h:1605
BOOL WINAPI PostThreadMessageA(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
static HANDLE thread
Definition: service.c:33
int ret
static TfClientId tid

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 }
#define trace(...)
Definition: kmt_test.h:217
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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416

◆ 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 }
#define trace(...)
Definition: kmt_test.h:217
static BOOL last_release_closes
Definition: marshal.c:183
static DWORD external_connections
Definition: marshal.c:182

◆ get_global_interface_proc()

static DWORD CALLBACK get_global_interface_proc ( LPVOID  pv)
static

Definition at line 3934 of file marshal.c.

3935 {
3936  HRESULT hr;
3937  struct git_params *params = pv;
3938  IClassFactory *cf;
3939 
3940  hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
3941  ok(hr == CO_E_NOTINITIALIZED ||
3942  broken(hr == E_UNEXPECTED) /* win2k */ ||
3943  broken(hr == S_OK) /* NT 4 */,
3944  "IGlobalInterfaceTable_GetInterfaceFromGlobal should have failed with error CO_E_NOTINITIALIZED or E_UNEXPECTED instead of 0x%08x\n",
3945  hr);
3946  if (hr == S_OK)
3947  IClassFactory_Release(cf);
3948 
3949  CoInitialize(NULL);
3950 
3951  hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
3952  ok_ole_success(hr, IGlobalInterfaceTable_GetInterfaceFromGlobal);
3953 
3954  IClassFactory_Release(cf);
3955 
3956  CoUninitialize();
3957 
3958  return hr;
3959 }
static IClassFactory * cf
HRESULT hr
Definition: shlfolder.c:183
#define CO_E_NOTINITIALIZED
GLenum const GLfloat * params
Definition: glext.h:5645
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define broken(x)
Definition: _sntprintf.h:21
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define E_UNEXPECTED
Definition: winerror.h:2456
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by test_globalinterfacetable().

◆ HeapUnknown_AddRef()

static ULONG WINAPI HeapUnknown_AddRef ( IUnknown iface)
static

Definition at line 2795 of file marshal.c.

2796 {
2798  return InterlockedIncrement((LONG*)&This->refs);
2799 }
long LONG
Definition: pedump.c:60
#define InterlockedIncrement
Definition: armddk.h:53
static HeapUnknown * impl_from_IUnknown(IUnknown *iface)
Definition: marshal.c:2778

◆ HeapUnknown_QueryInterface()

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

Definition at line 2783 of file marshal.c.

2784 {
2785  if (IsEqualIID(riid, &IID_IUnknown))
2786  {
2787  IUnknown_AddRef(iface);
2788  *ppv = iface;
2789  return S_OK;
2790  }
2791  *ppv = NULL;
2792  return E_NOINTERFACE;
2793 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90

◆ HeapUnknown_Release()

static ULONG WINAPI HeapUnknown_Release ( IUnknown iface)
static

Definition at line 2801 of file marshal.c.

2802 {
2804  ULONG refs = InterlockedDecrement((LONG*)&This->refs);
2805  if (!refs) HeapFree(GetProcessHeap(), 0, This);
2806  return refs;
2807 }
long LONG
Definition: pedump.c:60
#define GetProcessHeap()
Definition: compat.h:395
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
static HeapUnknown * impl_from_IUnknown(IUnknown *iface)
Definition: marshal.c:2778

◆ 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 
662  CoUninitialize();
663 
664  return hr;
665 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:2056
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
HRESULT hr
Definition: shlfolder.c:183
#define RELEASEMARSHALDATA
Definition: marshal.c:600
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_NOREMOVE
Definition: winuser.h:1181
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WM_USER
Definition: winuser.h:1856
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister)
Definition: compobj.c:2806
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define msg(x)
Definition: auth_time.c:54
GLfloat GLfloat p
Definition: glext.h:8902
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
HRESULT WINAPI CoRegisterMessageFilter(LPMESSAGEFILTER lpMessageFilter, LPMESSAGEFILTER *lplpMessageFilter)
Definition: compobj.c:3955
#define ok_ole_success(hr, func)
Definition: marshal.c:72
#define HeapFree(x, y, z)
Definition: compat.h:394

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 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

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 2778 of file marshal.c.

2779 {
2780  return CONTAINING_RECORD(iface, HeapUnknown, IUnknown_iface);
2781 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by HeapUnknown_AddRef(), and HeapUnknown_Release().

◆ implicit_mta_marshal_proc()

static DWORD CALLBACK implicit_mta_marshal_proc ( void param)
static

Definition at line 4176 of file marshal.c.

4177 {
4179  HRESULT hr;
4180 
4182  (IUnknown *)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
4184 
4185  SetEvent(data->start);
4186 
4187  ok(!WaitForSingleObject(data->stop, 1000), "wait failed\n");
4188  return 0;
4189 }
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
GLfloat param
Definition: glext.h:5796
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by test_implicit_mta().

◆ implicit_mta_unmarshal_proc()

static DWORD CALLBACK implicit_mta_unmarshal_proc ( void param)
static

Definition at line 4113 of file marshal.c.

4114 {
4115  IStream *stream = param;
4116  IClassFactory *cf;
4117  IUnknown *proxy;
4118  HRESULT hr;
4119 
4120  IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
4123 
4124  hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4125  ok_ole_success(hr, IClassFactory_CreateInstance);
4126 
4127  IUnknown_Release(proxy);
4128 
4129  /* But if we initialize an STA in this apartment, it becomes the wrong one. */
4131 
4132  hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4133  ok(hr == RPC_E_WRONG_THREAD, "got %#x\n", hr);
4134 
4135  CoUninitialize();
4136 
4139 
4140  IClassFactory_Release(cf);
4141 
4142  ok_no_locks();
4145  return 0;
4146 }
static IClassFactory * cf
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1982
int proxy
Definition: main.c:67
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define RPC_E_WRONG_THREAD
Definition: winerror.h:2490
#define ok_more_than_one_lock()
Definition: marshal.c:70
#define ok_non_zero_external_conn()
Definition: marshal.c:73
#define ok_no_locks()
Definition: marshal.c:71
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
GLfloat param
Definition: glext.h:5796
Definition: parse.h:22
#define ok_zero_external_conn()
Definition: marshal.c:74
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:1935
#define ok_last_release_closes(b)
Definition: marshal.c:75
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by test_implicit_mta().

◆ implicit_mta_use_proc()

static DWORD CALLBACK implicit_mta_use_proc ( void param)
static

Definition at line 4148 of file marshal.c.

4149 {
4150  IClassFactory *cf = param;
4151  IUnknown *proxy;
4152  HRESULT hr;
4153 
4154  hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4155  ok_ole_success(hr, IClassFactory_CreateInstance);
4156 
4157  IUnknown_Release(proxy);
4158 
4159  /* But if we initialize an STA in this apartment, it becomes the wrong one. */
4161 
4162  hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void **)&proxy);
4163  ok(hr == RPC_E_WRONG_THREAD, "got %#x\n", hr);
4164 
4165  CoUninitialize();
4166  return 0;
4167 }
int proxy
Definition: main.c:67
HRESULT hr
Definition: shlfolder.c:183
#define RPC_E_WRONG_THREAD
Definition: winerror.h:2490
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
GLfloat param
Definition: glext.h:5796
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:1935
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by test_implicit_mta().

◆ local_server_AddRef()

static ULONG WINAPI local_server_AddRef ( IPersist iface)
static

Definition at line 3642 of file marshal.c.

3643 {
3644  return 2;
3645 }

◆ local_server_GetClassID()

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

Definition at line 3652 of file marshal.c.

3653 {
3654  HRESULT hr;
3655 
3656  *clsid = IID_IUnknown;
3657 
3658  /* Test calling CoDisconnectObject within a COM call */
3659  hr = CoDisconnectObject((IUnknown *)iface, 0);
3660  ok(hr == S_OK, "got %08x\n", hr);
3661 
3662  /* Initialize and uninitialize the apartment to show that we
3663  * remain in the autojoined mta */
3664  hr = pCoInitializeEx( NULL, COINIT_MULTITHREADED );
3665  ok( hr == S_FALSE, "got %08x\n", hr );
3666  CoUninitialize();
3667 
3668  return S_OK;
3669 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI CoDisconnectObject(LPUNKNOWN lpUnk, DWORD reserved)
Definition: compobj.c:2058
#define ok(value,...)
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
REFCLSID clsid
Definition: msctf.c:84
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991

◆ local_server_QueryInterface()

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

Definition at line 3626 of file marshal.c.

3627 {
3628  *obj = NULL;
3629 
3630  if (IsEqualGUID(iid, &IID_IUnknown) ||
3631  IsEqualGUID(iid, &IID_IPersist))
3632  *obj = iface;
3633 
3634  if (*obj)
3635  {
3636  IPersist_AddRef(iface);
3637  return S_OK;
3638  }
3639  return E_NOINTERFACE;
3640 }
#define E_NOINTERFACE
Definition: winerror.h:2364
const GUID IID_IPersist
Definition: proxy.cpp:14
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

◆ local_server_Release()

static ULONG WINAPI local_server_Release ( IPersist iface)
static

Definition at line 3647 of file marshal.c.

3648 {
3649  return 1;
3650 }

◆ LockModule()

static void LockModule ( void  )
static

Definition at line 171 of file marshal.c.

172 {
174 }
static LONG cLocks
Definition: marshal.c:169
#define InterlockedIncrement
Definition: armddk.h:53

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

◆ LockModuleOOP()

static void LockModuleOOP ( void  )
static

Definition at line 3606 of file marshal.c.

3607 {
3608  InterlockedIncrement(&cLocks); /* for test purposes only */
3610 }
ULONG WINAPI CoAddRefServerProcess(void)
Definition: compobj.c:4071
static LONG cLocks
Definition: marshal.c:169
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by TestOOP_IClassFactory_LockServer().

◆ MessageFilter_AddRef()

static ULONG WINAPI MessageFilter_AddRef ( IMessageFilter iface)
static

Definition at line 2578 of file marshal.c.

2579 {
2580  return 2; /* non-heap object */
2581 }

◆ MessageFilter_HandleInComingCall()

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

Definition at line 2588 of file marshal.c.

2594 {
2595  static int callcount = 0;
2596  DWORD ret;
2597  trace("HandleInComingCall\n");
2598  switch (callcount)
2599  {
2600  case 0:
2601  ret = SERVERCALL_REJECTED;
2602  break;
2603  case 1:
2604  ret = SERVERCALL_RETRYLATER;
2605  break;
2606  default:
2607  ret = SERVERCALL_ISHANDLED;
2608  break;
2609  }
2610  callcount++;
2611  return ret;
2612 }
#define trace(...)
Definition: kmt_test.h:217
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret

◆ MessageFilter_MessagePending()

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

Definition at line 2624 of file marshal.c.

2629 {
2630  trace("MessagePending\n");
2631  return PENDINGMSG_WAITNOPROCESS;
2632 }
#define trace(...)
Definition: kmt_test.h:217

◆ MessageFilter_QueryInterface()

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

Definition at line 2563 of file marshal.c.

2564 {
2565  if (ppvObj == NULL) return E_POINTER;
2566 
2567  if (IsEqualGUID(riid, &IID_IUnknown) ||
2569  {
2570  *ppvObj = iface;
2571  IMessageFilter_AddRef(iface);
2572  return S_OK;
2573  }
2574 
2575  return E_NOINTERFACE;
2576 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define E_POINTER
Definition: winerror.h:2365
const GUID IID_IClassFactory

◆ MessageFilter_Release()

static ULONG WINAPI MessageFilter_Release ( IMessageFilter iface)
static

Definition at line 2583 of file marshal.c.

2584 {
2585  return 1; /* non-heap object */
2586 }

◆ MessageFilter_RetryRejectedCall()

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

Definition at line 2614 of file marshal.c.

2619 {
2620  trace("RetryRejectedCall\n");
2621  return 0;
2622 }
#define trace(...)
Definition: kmt_test.h:217

◆ no_couninitialize_client_proc()

static DWORD CALLBACK no_couninitialize_client_proc ( LPVOID  p)
static

Definition at line 1727 of file marshal.c.

1728 {
1729  struct ncu_params *ncu_params = p;
1730  HRESULT hr;
1731  IUnknown *pProxy = NULL;
1732 
1733  pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1734 
1735  hr = CoUnmarshalInterface(ncu_params->stream, &IID_IClassFactory, (void **)&pProxy);
1737  IStream_Release(ncu_params->stream);
1738 
1740 
1741  /* die without calling CoUninitialize */
1742 
1743  return 0;
1744 }
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1982
HRESULT hr
Definition: shlfolder.c:183
#define ok_more_than_one_lock()
Definition: marshal.c:70
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
LPSTREAM stream
Definition: marshal.c:1648
GLfloat GLfloat p
Definition: glext.h:8902
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by test_no_couninitialize_client().

◆ no_couninitialize_server_proc()

static DWORD CALLBACK no_couninitialize_server_proc ( LPVOID  p)
static

Definition at line 1654 of file marshal.c.

1655 {
1656  struct ncu_params *ncu_params = p;
1657  HRESULT hr;
1658 
1659  pCoInitializeEx(NULL, COINIT_MULTITHREADED);
1660 
1661  hr = CoMarshalInterface(ncu_params->stream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1663 
1665 
1666  ok( !WaitForSingleObject(ncu_params->unmarshal_event, 10000), "wait timed out\n" );
1667 
1668  /* die without calling CoUninitialize */
1669 
1670  return 0;
1671 }
HANDLE unmarshal_event
Definition: marshal.c:1650
HRESULT hr
Definition: shlfolder.c:183
HANDLE marshal_event
Definition: marshal.c:1649
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
LPSTREAM stream
Definition: marshal.c:1648
GLfloat GLfloat p
Definition: glext.h:8902
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72

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))
398  *ppv = &Test_OleWindow;
399  else
400  {
401  *ppv = NULL;
402  return E_NOINTERFACE;
403  }
404 
405  IUnknown_AddRef((IUnknown*)*ppv);
406  return S_OK;
407 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
const GUID IID_IOleClientSite
REFIID LPVOID * ppv
Definition: atlbase.h:39
static IOleWindow Test_OleWindow
Definition: marshal.c:391
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
const GUID IID_IOleWindow

◆ 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 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HANDLE HWND
Definition: compat.h:13
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define S_OK
Definition: intsafe.h:59

◆ 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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
const char * wine_dbgstr_guid(const GUID *guid)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416

◆ 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 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
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 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50
static rfbScreenInfoPtr server
Definition: vnc.c:74
HRESULT hr
Definition: shlfolder.c:183
static IOleClientSite Test_OleClientSite
Definition: marshal.c:426
REFIID riid
Definition: precomp.h:44
Definition: stubgen.c:11
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
struct _stub stub
#define ok(value,...)
LONG HRESULT
Definition: typedefs.h:77
static IPSFactoryBuffer * ps_factory_buffer
Definition: marshal.c:536
static const IRpcStubBufferVtbl RpcStubBufferVtbl
Definition: marshal.c:523
#define S_OK
Definition: intsafe.h:59

◆ 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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90

◆ 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 3349 of file marshal.c.

3350 {
3351  HRESULT hr;
3352  char buffer[256];
3353  LPOLESTR pszClsid;
3354  HKEY hkey;
3355  DWORD dwDisposition;
3356  DWORD error;
3357 
3358  hr = StringFromCLSID(&CLSID_WineTest, &pszClsid);
3359  ok_ole_success(hr, "StringFromCLSID");
3360  strcpy(buffer, "CLSID\\");
3361  WideCharToMultiByte(CP_ACP, 0, pszClsid, -1, buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), NULL, NULL);
3362  CoTaskMemFree(pszClsid);
3363  strcat(buffer, "\\InprocHandler32");
3364  if (Register)
3365  {
3366  error = RegCreateKeyExA(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey, &dwDisposition);
3367  if (error == ERROR_ACCESS_DENIED)
3368  {
3369  skip("Not authorized to modify the Classes key\n");
3370  return E_FAIL;
3371  }
3372  ok(error == ERROR_SUCCESS, "RegCreateKeyEx failed with error %d\n", error);
3373  if (error != ERROR_SUCCESS) hr = E_FAIL;
3374  error = RegSetValueExA(hkey, NULL, 0, REG_SZ, (const unsigned char *)"\"ole32.dll\"", strlen("\"ole32.dll\"") + 1);
3375  ok(error == ERROR_SUCCESS, "RegSetValueEx failed with error %d\n", error);
3376  if (error != ERROR_SUCCESS) hr = E_FAIL;
3377  RegCloseKey(hkey);
3378  }
3379  else
3380  {
3382  *strrchr(buffer, '\\') = '\0';
3384  }
3385  return hr;
3386 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
#define KEY_SET_VALUE
Definition: nt_native.h:1017
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
GLuint buffer
Definition: glext.h:5915
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static LPOLESTR
Definition: stg_prop.c:27
#define E_FAIL
Definition: ddrawi.h:102
#define CLSID_WineTest
Definition: marshal.c:139
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1225
#define skip(...)
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4831
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:1032
#define ok_ole_success(hr, func)
Definition: marshal.c:72
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2321
#define REG_SZ
Definition: layer.c:22

Referenced by test_handler_marshaling(), and test_inproc_handler().

◆ register_test_window()

static void register_test_window ( void  )
static

Definition at line 3033 of file marshal.c.

3034 {
3035  WNDCLASSA wndclass;
3036 
3037  memset(&wndclass, 0, sizeof(wndclass));
3038  wndclass.lpfnWndProc = window_proc;
3039  wndclass.lpszClassName = "WineCOMTest";
3040  RegisterClassA(&wndclass);
3041 }
static LRESULT CALLBACK window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: marshal.c:2915
LPCSTR lpszClassName
Definition: winuser.h:3125
WNDPROC lpfnWndProc
Definition: winuser.h:3117
#define memset(x, y, z)
Definition: compat.h:39
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 {
694  HANDLE event = CreateEventA(NULL, FALSE, FALSE, NULL);
696  ok( !WaitForSingleObject(event, 10000), "wait timed out\n" );
698 }
#define CloseHandle
Definition: compat.h:398
#define RELEASEMARSHALDATA
Definition: marshal.c:600
BOOL WINAPI PostThreadMessageA(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:583
struct _cl_event * event
Definition: glext.h:7739
static TfClientId tid

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 3144 of file marshal.c.

3145 {
3146  static SIZE_T global_size_alignment = -1;
3147  if (global_size_alignment == -1)
3148  {
3149  void *p = GlobalAlloc(GMEM_FIXED, 1);
3150  global_size_alignment = GlobalSize(p);
3151  GlobalFree(p);
3152  }
3153 
3154  return ((size + global_size_alignment - 1) & ~(global_size_alignment - 1));
3155 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
GLsizeiptr size
Definition: glext.h:5919
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define GMEM_FIXED
Definition: winbase.h:290
ULONG_PTR SIZE_T
Definition: typedefs.h:78
GLfloat GLfloat p
Definition: glext.h:8902

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
#define InterlockedIncrement
Definition: armddk.h:53

◆ 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 }
#define ok(value,...)
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define ok(value,...)
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define ok(value,...)
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define ok(value,...)

◆ RpcStubBuffer_Disconnect()

static void WINAPI RpcStubBuffer_Disconnect ( IRpcStubBuffer iface)
static

Definition at line 477 of file marshal.c.

478 {
479  CHECK_EXPECT(Disconnect);
480 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50

◆ 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 }
#define CHECK_EXPECT(func)
Definition: marshal.c:50
HRESULT hr
Definition: shlfolder.c:183
static StubBufferWrapper * impl_from_IRpcStubBuffer(IRpcStubBuffer *iface)
Definition: marshal.c:434
#define ok(value,...)
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59

◆ 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 }
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416

◆ 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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
static StubBufferWrapper * impl_from_IRpcStubBuffer(IRpcStubBuffer *iface)
Definition: marshal.c:434
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

◆ 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);
466  heap_free(This);
467  }
468  return ref;
469 }
static StubBufferWrapper * impl_from_IRpcStubBuffer(IRpcStubBuffer *iface)
Definition: marshal.c:434
Definition: send.c:47
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
#define InterlockedDecrement
Definition: armddk.h:52
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ start_host_object()

static DWORD start_host_object ( IStream stream,
REFIID  riid,
IUnknown object,
MSHLFLAGS  marshal_flags,
HANDLE thread 
)
static

◆ 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 CloseHandle
Definition: compat.h:398
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
static DWORD CALLBACK host_object_proc(LPVOID p)
Definition: marshal.c:618
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:112
HANDLE marshal_event
Definition: marshal.c:611
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:583
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HANDLE thread
Definition: service.c:33
static TfClientId tid

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

◆ START_TEST()

START_TEST ( marshal  )

Definition at line 4597 of file marshal.c.

4598 {
4599  HMODULE hOle32 = GetModuleHandleA("ole32");
4600  int argc;
4601  char **argv;
4602 
4603  if (!GetProcAddress(hOle32, "CoRegisterSurrogateEx")) {
4604  win_skip("skipping test on win9x\n");
4605  return;
4606  }
4607 
4608  pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx");
4609  pDllGetClassObject = (void*)GetProcAddress(hOle32, "DllGetClassObject");
4610 
4612  if (argc > 2 && (!strcmp(argv[2], "-Embedding")))
4613  {
4614  pCoInitializeEx(NULL, COINIT_MULTITHREADED);
4616  CoUninitialize();
4617 
4618  return;
4619  }
4620 
4622 
4625 
4626  pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
4627 
4628  /* FIXME: test CoCreateInstanceEx */
4629 
4630  /* lifecycle management and marshaling tests */
4631  do
4632  {
4658 
4660  } while (with_external_conn);
4661 
4680 
4682 
4686 
4687  /* must be last test as channel hooks can't be unregistered */
4689 
4690  CoUninitialize();
4691 }
static void test_proxy_marshal_and_unmarshal_strong(void)
Definition: marshal.c:1095
static void register_test_window(void)
Definition: marshal.c:3033
static int argc
Definition: ServiceArgs.c:12
static void test_globalinterfacetable(void)
Definition: marshal.c:3961
static void test_marshal_proxy_mta_apartment_shutdown(void)
Definition: marshal.c:1246
static void test_cocreateinstance_proxy(void)
Definition: marshal.c:149
static void test_no_couninitialize_server(void)
Definition: marshal.c:1675
static void test_proxy_marshal_and_unmarshal2(void)
Definition: marshal.c:978
static void test_crash_couninitialize(void)
Definition: marshal.c:1824
static void test_tableweak_marshal_releasedata1(void)
Definition: marshal.c:1898
static void test_marshal_channel_buffer(void)
Definition: marshal.c:1290
static void test_StdMarshal_custom_marshaling(void)
Definition: marshal.c:1468
static void test_register_local_server(void)
Definition: marshal.c:3748
#define argv
Definition: mplay32.c:18
static void test_disconnect_stub(void)
Definition: marshal.c:2366
static void test_tableweak_and_normal_marshal_and_releasedata(void)
Definition: marshal.c:2119
static void test_proxy_marshal_and_unmarshal_weak(void)
Definition: marshal.c:1042
static void test_marshal_proxy_apartment_shutdown(void)
Definition: marshal.c:1204
static void test_marshal_stub_apartment_shutdown(void)
Definition: marshal.c:1164
smooth NULL
Definition: ftsmooth.c:416
static void test_no_couninitialize_client(void)
Definition: marshal.c:1747
static void test_channel_hook(void)
Definition: marshal.c:4547
static void test_WM_QUIT_handling(void)
Definition: marshal.c:3127
static void test_lock_object_external(void)
Definition: marshal.c:2268
static void test_normal_marshal_and_release(void)
Definition: marshal.c:725
static void test_freethreadedmarshaler(void)
Definition: marshal.c:3202
static void test_proxybuffer(REFIID riid)
Definition: marshal.c:2816
static void test_call_from_message(void)
Definition: marshal.c:3083
static void test_manualresetevent(void)
Definition: marshal.c:4038
static void test_tableweak_marshal_releasedata2(void)
Definition: marshal.c:1959
static void test_interthread_marshal_and_unmarshal(void)
Definition: marshal.c:863
static void test_same_apartment_unmarshal_failure(void)
Definition: marshal.c:830
static void test_two_tableweak_marshal_and_releasedata(void)
Definition: marshal.c:2169
static void test_proxy_used_in_wrong_thread(void)
Definition: marshal.c:2521
int winetest_get_mainargs(char ***pargv)
static void test_implicit_mta(void)
Definition: marshal.c:4191
static void test_local_server(void)
Definition: marshal.c:3818
static void test_client_security(void)
Definition: marshal.c:3516
static void test_tableweak_marshal_and_unmarshal_twice(void)
Definition: marshal.c:1842
static void test_CoGetStandardMarshal(void)
Definition: marshal.c:1569
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
static void test_normal_marshal_and_unmarshal_twice(void)
Definition: marshal.c:2404
static void test_normal_marshal_and_unmarshal(void)
Definition: marshal.c:752
static void test_stubbuffer(REFIID riid)
Definition: marshal.c:2854
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
static void test_hresult_marshaling(void)
Definition: marshal.c:2445
static void test_marshal_and_unmarshal_invalid(void)
Definition: marshal.c:784
static void test_no_marshaler(void)
Definition: marshal.c:711
static void test_bad_marshal_stream(void)
Definition: marshal.c:2697
static void test_message_filter(void)
Definition: marshal.c:2646
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define GetProcAddress(x, y)
Definition: compat.h:410
static void test_tableweak_and_normal_marshal_and_unmarshal(void)
Definition: marshal.c:2049
static void test_inproc_handler(void)
Definition: marshal.c:3388
static void test_proxy_interfaces(void)
Definition: marshal.c:2722
const GUID IID_IClassFactory
static BOOL with_external_conn
Definition: marshal.c:181
#define win_skip
Definition: test.h:141
static void test_proxy_marshal_and_unmarshal(void)
Definition: marshal.c:903
static void test_tablestrong_marshal_and_unmarshal_twice(void)
Definition: marshal.c:2215
static void test_message_reentrancy(void)
Definition: marshal.c:3043
static void test_DfMarshal_custom_marshaling(void)
Definition: marshal.c:1520
static void test_handler_marshaling(void)
Definition: marshal.c:3466

◆ test_bad_marshal_stream()

static void test_bad_marshal_stream ( void  )
static

Definition at line 2697 of file marshal.c.

2698 {
2699  HRESULT hr;
2700  IStream *pStream = NULL;
2701 
2702  hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
2704  hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
2706 
2708 
2709  /* try to read beyond end of stream */
2710  hr = CoReleaseMarshalData(pStream);
2711  ok(hr == STG_E_READFAULT, "Should have failed with STG_E_READFAULT, but returned 0x%08x instead\n", hr);
2712 
2713  /* now release for real */
2714  IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2715  hr = CoReleaseMarshalData(pStream);
2717 
2718  IStream_Release(pStream);
2719 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:2056
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
#define ok_more_than_one_lock()
Definition: marshal.c:70
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
#define STG_E_READFAULT
Definition: winerror.h:2576
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by START_TEST().

◆ test_call_from_message()

static void test_call_from_message ( void  )
static

Definition at line 3083 of file marshal.c.

3084 {
3085  MSG msg;
3086  IStream *pStream;
3087  HRESULT hr;
3089  DWORD tid;
3090  HANDLE thread;
3091  IUnknown *object;
3092 
3094  ok(hwnd_app != NULL, "Window creation failed\n");
3095 
3096  hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
3098  tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&TestMsg_ClassFactory, MSHLFLAGS_NORMAL, &thread);
3099 
3101 
3102  IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
3103  hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&proxy);
3105  IStream_Release(pStream);
3106 
3108 
3109  /* start message re-entrancy test */
3110  hr = IClassFactory_CreateInstance(proxy, NULL, &IID_IUnknown, (void **)&object);
3111  ok_ole_success(hr, IClassFactory_CreateInstance);
3112 
3113  IClassFactory_Release(proxy);
3114 
3115  ok_no_locks();
3116 
3118 
3119  while (GetMessageA(&msg, NULL, 0, 0))
3120  {
3123  }
3125 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:2056
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1982
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
int proxy
Definition: main.c:67
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
static HWND hwnd_app
Definition: marshal.c:2886
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define ok_more_than_one_lock()
Definition: marshal.c:70
#define ok_no_locks()
Definition: marshal.c:71
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok(value,...)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE thread
Definition: service.c:33
static void end_host_object(DWORD tid, HANDLE thread)
Definition: marshal.c:700
static IClassFactory TestMsg_ClassFactory
Definition: marshal.c:3081
#define msg(x)
Definition: auth_time.c:54
static DWORD start_host_object(IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, HANDLE *thread)
Definition: marshal.c:684
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72
static TfClientId tid
void * object
Definition: jmemsys.h:48

Referenced by START_TEST().

◆ test_channel_hook()

static void test_channel_hook ( void  )
static

Definition at line 4547 of file marshal.c.

4548 {
4549  IClassFactory *cf = NULL;
4550  DWORD tid;
4551  IUnknown *proxy = NULL;
4552  HANDLE thread;
4553  HRESULT hr;
4554 
4555  struct host_object_data object_data = { NULL, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory,
4556  MSHLFLAGS_NORMAL, &MessageFilter };
4557 
4560 
4563 
4564  cLocks = 0;
4565 
4566  hr = CreateStreamOnHGlobal(NULL, TRUE, &object_data.stream);
4568  tid = start_host_object2(&object_data, &thread);
4569  server_tid = tid;
4570 
4572 
4573  IStream_Seek(object_data.stream, ullZero, STREAM_SEEK_SET, NULL);
4574  hr = CoUnmarshalInterface(object_data.stream, &IID_IClassFactory, (void **)&cf);
4576  IStream_Release(object_data.stream);
4577 
4579 
4580  method = 3;
4581  hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
4582  ok_ole_success(hr, IClassFactory_CreateInstance);
4583 
4584  method = 5;
4585  IUnknown_Release(proxy);
4586 
4587  IClassFactory_Release(cf);
4588 
4589  ok_no_locks();
4590 
4592 
4595 }
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1982
int proxy
Definition: main.c:67
#define TRUE
Definition: types.h:120
HRESULT WINAPI CoRegisterChannelHook(REFGUID guidExtension, IChannelHook *pChannelHook)
Definition: compobj.c:4696
HRESULT hr
Definition: shlfolder.c:183
static LONG cLocks
Definition: marshal.c:169
static IChannelHook TestChannelHook
Definition: marshal.c:4545
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
IStream * stream
Definition: marshal.c:604
#define ok_more_than_one_lock()
Definition: marshal.c:70
#define ok_no_locks()
Definition: marshal.c:71
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define EXTENTID_WineTest
Definition: marshal.c:138
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static IMessageFilter MessageFilter
Definition: marshal.c:2644
const GUID IID_IUnknown
unsigned long DWORD
Definition: ntddk_ex.h:95
method
Definition: dragdrop.c:53
static HANDLE thread
Definition: service.c:33
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
static void end_host_object(DWORD tid, HANDLE thread)
Definition: marshal.c:700
static int server_tid
Definition: marshal.c:4324
const GUID IID_IClassFactory
HRESULT WINAPI CoRegisterMessageFilter(LPMESSAGEFILTER lpMessageFilter, LPMESSAGEFILTER *lplpMessageFilter)
Definition: compobj.c:3955
#define ok_ole_success(hr, func)
Definition: marshal.c:72
static TfClientId tid
static DWORD start_host_object2(struct host_object_data *object_data, HANDLE *thread)
Definition: marshal.c:667

Referenced by START_TEST().

◆ test_client_security()

static void test_client_security ( void  )
static

Definition at line 3516 of file marshal.c.

3517 {
3518  HRESULT hr;
3519  IStream *pStream = NULL;
3520  IClassFactory *pProxy = NULL;
3521  IUnknown *pProxy2 = NULL;
3522  IUnknown *pUnknown1 = NULL;
3523  IUnknown *pUnknown2 = NULL;
3524  IClientSecurity *pCliSec = NULL;
3525  IMarshal *pMarshal;
3526  DWORD tid;
3527  HANDLE thread;
3528  static const LARGE_INTEGER ullZero;
3529  DWORD dwAuthnSvc;
3530  DWORD dwAuthzSvc;
3531  OLECHAR *pServerPrincName;
3532  DWORD dwAuthnLevel;
3533  DWORD dwImpLevel;
3534  void *pAuthInfo;
3535  DWORD dwCapabilities;
3536  void *pv;
3537 
3538  cLocks = 0;
3539 
3540  hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
3541  ok_ole_success(hr, "CreateStreamOnHGlobal");
3542  tid = start_host_object(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHLFLAGS_NORMAL, &thread);
3543 
3544  IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
3545  hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
3546  ok_ole_success(hr, "CoUnmarshalInterface");
3547  IStream_Release(pStream);
3548 
3549  hr = IClassFactory_QueryInterface(pProxy, &IID_IUnknown, (LPVOID*)&pUnknown1);
3550  ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown");
3551 
3552  hr = IClassFactory_QueryInterface(pProxy, &IID_IRemUnknown, (LPVOID*)&pProxy2);
3553  ok_ole_success(hr, "IUnknown_QueryInterface IID_IStream");
3554 
3555  hr = IUnknown_QueryInterface(pProxy2, &IID_IUnknown, (LPVOID*)&pUnknown2);
3556  ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown");
3557 
3558  ok(pUnknown1 == pUnknown2, "both proxy's IUnknowns should be the same - %p, %p\n", pUnknown1, pUnknown2);
3559 
3560  hr = IClassFactory_QueryInterface(pProxy, &IID_IMarshal, (LPVOID*)&pMarshal);
3561  ok_ole_success(hr, "IUnknown_QueryInterface IID_IMarshal");
3562 
3563  hr = IClassFactory_QueryInterface(pProxy, &IID_IClientSecurity, (LPVOID*)&pCliSec);
3564  ok_ole_success(hr, "IUnknown_QueryInterface IID_IClientSecurity");
3565 
3566  hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pProxy, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3567  todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket (all NULLs)");
3568 
3569  hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pMarshal, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3570  todo_wine ok(hr == E_NOINTERFACE, "IClientSecurity_QueryBlanket with local interface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
3571 
3572  hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pProxy, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
3573  todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket");
3574 
3575  hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pProxy, dwAuthnSvc, dwAuthzSvc, pServerPrincName, dwAuthnLevel, RPC_C_IMP_LEVEL_IMPERSONATE, pAuthInfo, dwCapabilities);
3576  todo_wine ok_ole_success(hr, "IClientSecurity_SetBlanket");
3577 
3578  hr = IClassFactory_CreateInstance(pProxy, NULL, &IID_IWineTest, &pv);
3579  ok(hr == E_NOINTERFACE, "COM call should have succeeded instead of returning 0x%08x\n", hr);
3580 
3581  hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pMarshal, dwAuthnSvc, dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities);
3582  todo_wine ok(hr == E_NOINTERFACE, "IClientSecurity_SetBlanket with local interface should have returned E_NOINTERFACE instead of 0x%08x\n", hr);
3583 
3584  hr = IClientSecurity_SetBlanket(pCliSec, (IUnknown *)pProxy, 0xdeadbeef, dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo, dwCapabilities);
3585  todo_wine ok(hr == E_INVALIDARG, "IClientSecurity_SetBlanke with invalid dwAuthnSvc should have returned E_INVALIDARG instead of 0x%08x\n", hr);
3586 
3587  CoTaskMemFree(pServerPrincName);
3588 
3589  hr = IClientSecurity_QueryBlanket(pCliSec, pUnknown1, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
3590  todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket(IUnknown)");
3591 
3592  CoTaskMemFree(pServerPrincName);
3593 
3594  IClassFactory_Release(pProxy);
3595  IUnknown_Release(pProxy2);
3596  IUnknown_Release(pUnknown1);
3597  IUnknown_Release(pUnknown2);
3598  IMarshal_Release(pMarshal);
3599  IClientSecurity_Release(pCliSec);
3600 
3602 }
WCHAR OLECHAR
Definition: compat.h:1933
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1982
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
HRESULT hr
Definition: shlfolder.c:183
static LONG cLocks
Definition: marshal.c:169
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
#define RPC_C_IMP_LEVEL_IMPERSONATE
Definition: rpcdce.h:176
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
unsigned long DWORD
Definition: ntddk_ex.h:95
static const IID IID_IRemUnknown
Definition: marshal.c:130
static HANDLE thread
Definition: service.c:33
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
#define todo_wine
Definition: test.h:154
static void end_host_object(DWORD tid, HANDLE thread)
Definition: marshal.c:700
static const IID IID_IWineTest
Definition: marshal.c:122
static DWORD start_host_object(IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, HANDLE *thread)
Definition: marshal.c:684
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72
static TfClientId tid

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 
165  CoUninitialize();
166 }
HRESULT hr
Definition: shlfolder.c:183
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define ok_ole_success(hr, func)
Definition: marshal.c:72

Referenced by START_TEST().

◆ test_CoGetStandardMarshal()

static void test_CoGetStandardMarshal ( void  )
static

Definition at line 1569 of file marshal.c.

1570 {
1571  DUALSTRINGARRAY *dualstringarr;
1572  STDOBJREF *stdobjref;
1573  OBJREF objref;
1574  IMarshal *marshal;
1575  DWORD size, read;
1576  IStream *stream;
1577  IUnknown *unk;
1578  CLSID clsid;
1579  HRESULT hr;
1580 
1583 
1585  MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL, &marshal);
1587 
1588  hr = IMarshal_GetUnmarshalClass(marshal, &IID_IUnknown, &Test_Unknown,
1589  MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL, &clsid);
1590  ok_ole_success(hr, IMarshal_GetUnmarshalClass);
1591  ok(IsEqualGUID(&clsid, &CLSID_StdMarshal), "clsid = %s\n", wine_dbgstr_guid(&clsid));
1592 
1593  hr = IMarshal_GetMarshalSizeMax(marshal, &IID_IUnknown, &Test_Unknown,
1594  MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL, &size);
1595  ok_ole_success(hr, IMarshal_GetMarshalSizeMax);
1597  MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1599  ok(size == read, "IMarshal_GetMarshalSizeMax size = %d, expected %d\n", size, read);
1600 
1601  hr = IMarshal_MarshalInterface(marshal, stream, &IID_IUnknown,
1602  &Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1603  ok_ole_success(hr, IMarshal_MarshalInterface);
1604 
1605  hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1606  ok_ole_success(hr, IStream_Seek);
1607  size = FIELD_OFFSET(OBJREF, u_objref.u_standard.saResAddr.aStringArray);
1608  hr = IStream_Read(stream, &objref, size, &read);
1609  ok_ole_success(hr, IStream_Read);
1610  ok(read == size, "read = %d, expected %d\n", read, size);
1611  ok(objref.signature == OBJREF_SIGNATURE, "objref.signature = %x\n",
1612  objref.signature);
1613  ok(objref.flags == OBJREF_STANDARD, "objref.flags = %x\n", objref.flags);
1614  ok(IsEqualIID(&objref.iid, &IID_IUnknown), "objref.iid = %s\n",
1615  wine_dbgstr_guid(&objref.iid));
1616  stdobjref = &objref.u_objref.u_standard.std;
1617  ok(stdobjref->flags == 0, "stdobjref.flags = %d\n", stdobjref->flags);
1618  ok(stdobjref->cPublicRefs == 5, "stdobjref.cPublicRefs = %d\n",
1619  stdobjref->cPublicRefs);
1620  dualstringarr = &objref.u_objref.u_standard.saResAddr;
1621  ok(dualstringarr->wNumEntries == 0, "dualstringarr.wNumEntries = %d\n",
1622  dualstringarr->wNumEntries);
1623  ok(dualstringarr->wSecurityOffset == 0, "dualstringarr.wSecurityOffset = %d\n",
1624  dualstringarr->wSecurityOffset);
1625 
1626  hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1627  ok_ole_success(hr, IStream_Seek);
1628  hr = IMarshal_UnmarshalInterface(marshal, stream, &IID_IUnknown, (void**)&unk);
1629  ok_ole_success(hr, IMarshal_UnmarshalInterface);
1630  IUnknown_Release(unk);
1631 
1632  hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1633  ok_ole_success(hr, IStream_Seek);
1634  hr = IMarshal_MarshalInterface(marshal, stream, &IID_IUnknown,
1635  &Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1636  ok_ole_success(hr, IMarshal_MarshalInterface);
1637 
1638  hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1639  ok_ole_success(hr, IStream_Seek);
1640  hr = IMarshal_ReleaseMarshalData(marshal, stream);
1641  ok_ole_success(hr, IMarshal_ReleaseMarshalData);
1642  IStream_Release(stream);
1643 
1644  IMarshal_Release(marshal);
1645 }
ULONG flags
Definition: marshal.c:92
#define TRUE
Definition: types.h:120
#define OBJREF_SIGNATURE
Definition: marshal.c:77
HRESULT hr
Definition: shlfolder.c:183
union tagOBJREF::@1614 u_objref
GUID iid
Definition: marshal.c:102
ULONG signature
Definition: marshal.c:100
const char * wine_dbgstr_guid(const GUID *guid)
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define OBJREF_STANDARD
Definition: marshal.c:78
ULONG flags
Definition: marshal.c:101
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
struct tagOBJREF::@1614::OR_STANDARD u_standard
const GUID IID_IUnknown
unsigned long DWORD
Definition: ntddk_ex.h:95
REFCLSID clsid
Definition: msctf.c:84
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
unsigned short wSecurityOffset
Definition: marshal.c:83
HRESULT WINAPI CoGetMarshalSizeMax(ULONG *pulSize, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1801
const CLSID CLSID_StdMarshal
HRESULT WINAPI CoGetStandardMarshal(REFIID riid, IUnknown *pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags, LPMARSHAL *ppMarshal)
Definition: marshal.c:1677
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
static IUnknown Test_Unknown
Definition: marshal.c:265
ULONG cPublicRefs
Definition: marshal.c:93
#define ok_ole_success(hr, func)
Definition: marshal.c:72
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
unsigned short wNumEntries
Definition: marshal.c:82
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by START_TEST().

◆ test_crash_couninitialize()

static void test_crash_couninitialize ( void  )
static

Definition at line 1824 of file marshal.c.

1825 {
1826  HANDLE thread;
1827  DWORD tid;
1828 
1829  if(!GetProcAddress(GetModuleHandleA("kernel32.dll"), "CreateActCtxW")) {
1830  win_skip("Skipping crash tests on win2k.\n");
1831  return;
1832  }
1833 
1836  ok(!WaitForSingleObject(thread, 10000), "wait timed out\n");
1838  ok(crash_thread_success, "Crash thread failed\n");
1839 }
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
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:112
smooth NULL
Definition: ftsmooth.c:416
static DWORD CALLBACK crash_couninitialize_proc(void *p)
Definition: marshal.c:1786
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE thread
Definition: service.c:33
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
#define GetProcAddress(x, y)
Definition: compat.h:410
static BOOL crash_thread_success
Definition: marshal.c:1784
#define win_skip
Definition: test.h:141
static TfClientId tid

Referenced by START_TEST().

◆ test_DfMarshal_custom_marshaling()

static void test_DfMarshal_custom_marshaling ( void  )
static

Definition at line 1520 of file marshal.c.

1521 {
1522  DWORD size, read;
1523  IStream *stream;
1524  OBJREF objref;
1525  HRESULT hr;
1526 
1529 
1535  MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1540 
1541  hr = IStream_Seek(stream, ullZero, STREAM_SEEK_SET, NULL);
1542  ok_ole_success(hr, IStream_Seek);
1543  size = FIELD_OFFSET(OBJREF, u_objref.u_custom.pData);
1544  hr = IStream_Read(stream, &objref, size, &read);
1545  ok_ole_success(hr, IStream_Read);
1546  ok(read == size, "read = %d, expected %d\n", read, size);
1547  ok(objref.signature == OBJREF_SIGNATURE, "objref.signature = %x\n",
1548  objref.signature);
1549  ok(objref.flags == OBJREF_CUSTOM, "objref.flags = %x\n", objref.flags);
1550  ok(IsEqualIID(&objref.iid, &IID_IUnknown), "objref.iid = %s\n",
1551  wine_dbgstr_guid(&objref.iid));
1552  ok(IsEqualIID(&objref.u_objref.u_custom.clsid, &CLSID_DfMarshal),
1553  "custom.clsid = %s\n", wine_dbgstr_guid(&objref.u_objref.u_custom.clsid));
1554  ok(!objref.u_objref.u_custom.cbExtension, "custom.cbExtension = %d\n",
1555  objref.u_objref.u_custom.cbExtension);
1556  ok(!objref.u_objref.u_custom.size, "custom.size = %d\n",
1557  objref.u_objref.u_custom.size);
1558 
1559  IStream_Release(stream);
1560 
1563  MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1566  ok(size == sizeof(OBJREF), "size = %d, expected %d\n", size, (int)sizeof(OBJREF));
1567 }
#define SET_EXPECT(func)
Definition: marshal.c:41
#define TRUE
Definition: types.h:120
#define OBJREF_SIGNATURE
Definition: marshal.c:77
HRESULT hr
Definition: shlfolder.c:183
union tagOBJREF::@1614 u_objref
static HRESULT WINAPI CustomMarshal_MarshalInterface(IMarshal *iface, IStream *stream, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags)
Definition: marshal.c:1406
GUID iid
Definition: marshal.c:102
ULONG signature
Definition: marshal.c:100
const char * wine_dbgstr_guid(const GUID *guid)
static HRESULT WINAPI CustomMarshal_GetUnmarshalClass(IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, CLSID *clsid)
Definition: marshal.c:1388
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
struct tagOBJREF::@1614::OR_CUSTOM u_custom
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static const GUID CLSID_DfMarshal
Definition: marshal.c:63
ULONG flags
Definition: marshal.c:101
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
static HRESULT WINAPI CustomMarshal_GetMarshalSizeMax(IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, DWORD *size)
Definition: marshal.c:1396
const GUID IID_IUnknown
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
static IMarshal CustomMarshal
Definition: marshal.c:1466
HRESULT WINAPI CoGetMarshalSizeMax(ULONG *pulSize, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1801
#define OBJREF_CUSTOM
Definition: marshal.c:79
static const CLSID * unmarshal_class
Definition: marshal.c:1359
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
#define CHECK_CALLED(func)
Definition: marshal.c:56
#define ok_ole_success(hr, func)
Definition: marshal.c:72
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by START_TEST().

◆ test_disconnect_stub()

static void test_disconnect_stub ( void  )
static

Definition at line 2366 of file marshal.c.

2367 {
2368  HRESULT hr;
2369  IStream *pStream = NULL;
2370 
2371  cLocks = 0;
2373 
2374  hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
2376  hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
2378 
2380 
2382 
2385 
2386  IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
2387  hr = CoReleaseMarshalData(pStream);
2389  IStream_Release(pStream);
2390 
2393 
2395 
2396  ok_no_locks();
2398 
2399  hr = CoDisconnectObject(NULL, 0);
2400  ok( hr == E_INVALIDARG, "wrong status %x\n", hr );
2401 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:2056
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI CoDisconnectObject(LPUNKNOWN lpUnk, DWORD reserved)
Definition: compobj.c:2058
static LONG cLocks
Definition: marshal.c:169
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
#define ok_more_than_one_lock()
Definition: marshal.c:70
#define ok_non_zero_external_conn()
Definition: marshal.c:73
#define ok_no_locks()
Definition: marshal.c:71
static const LARGE_INTEGER ullZero
Definition: marshal.c:168
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases)
Definition: compobj.c:3652
static IClassFactory Test_ClassFactory
Definition: marshal.c:351
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1877
const GUID IID_IClassFactory
#define ok_ole_success(hr, func)
Definition: marshal.c:72
static DWORD external_connections
Definition: marshal.c:182

Referenced by START_TEST().

◆ test_freethreadedmarshaldata()

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

Definition at line 3157 of file marshal.c.

3158 {
3159  HGLOBAL hglobal;
3160  DWORD size;
3161  char *marshal_data;
3162  HRESULT hr;
3163 
3164  hr = GetHGlobalFromStream(pStream, &hglobal);
3166 
3167  size = GlobalSize(hglobal);
3168 
3169  marshal_data = GlobalLock(hglobal);
3170 
3171  if (mshctx == MSHCTX_INPROC)
3172  {
3173  DWORD expected_size = round_global_size(3*sizeof(DWORD) + sizeof(GUID));
3174  ok(size == expected_size ||
3175  broken(size == (2*sizeof(DWORD))) /* Win9x & NT4 */,
3176  "size should have been %d instead of %d\n", expected_size, size);
3177 
3178  ok(*(DWORD *)marshal_data == mshlflags, "expected 0x%x, but got 0x%x for mshctx\n", mshlflags, *(DWORD *)marshal_data);
3179  marshal_data += sizeof(DWORD);
3180  ok(*(void **)marshal_data == ptr, "expected %p, but got %p for mshctx\n", ptr, *(void **)marshal_data);
3181  marshal_data += sizeof(void *);
3182  if (sizeof(void*) == 4 && size >= 3*sizeof(DWORD))
3183  {
3184  ok(*(DWORD *)marshal_data == 0, "expected 0x0, but got 0x%x\n", *(DWORD *)marshal_data);
3185  marshal_data += sizeof(DWORD);
3186  }
3187  if (size >= 3*sizeof(DWORD) + sizeof(GUID))
3188  {
3189  trace("got guid data: %s\n", wine_dbgstr_guid((GUID *)marshal_data));
3190  }
3191  }
3192  else
3193  {
3194  ok(size > sizeof(DWORD), "size should have been > sizeof(DWORD), not %d\n", size);
3195  ok(*(DWORD *)marshal_data == 0x574f454d /* MEOW */,
3196  "marshal data should be filled by standard marshal and start with MEOW signature\n");
3197  }
3198 
3199  GlobalUnlock(hglobal);
3200 }
#define trace(...)
Definition: kmt_test.h:217
HRESULT WINAPI GetHGlobalFromStream(IStream *pstm, HGLOBAL *phglobal)
HRESULT hr
Definition: shlfolder.c:183