2002-03-10 00:29:33 +01:00
/*
* Copyright 1995 Martin von Loewis
* Copyright 1998 Justin Bradford
* Copyright 1999 Francis Beaudet
* Copyright 1999 Sylvain St - Germain
* Copyright 2002 Marcus Meissner
2003-06-04 22:11:34 +02:00
* Copyright 2003 Ove K <EFBFBD> ven , TransGaming Technologies
2005-02-08 13:55:26 +01:00
* Copyright 2004 Mike Hearn , Rob Shearman , CodeWeavers Inc
2002-03-10 00:29:33 +01:00
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ; either
* version 2.1 of the License , or ( at your option ) any later version .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
2000-11-25 04:08:23 +01:00
# ifndef __WINE_OLE_COMPOBJ_H
# define __WINE_OLE_COMPOBJ_H
/* All private prototype functions used by OLE will be added to this header file */
2003-09-06 01:08:26 +02:00
# include <stdarg.h>
2004-12-27 20:21:47 +01:00
# include "wine/list.h"
2003-09-06 01:08:26 +02:00
# include "windef.h"
# include "winbase.h"
2000-11-25 04:08:23 +01:00
# include "wtypes.h"
2003-06-04 22:11:34 +02:00
# include "dcom.h"
2003-09-06 01:08:26 +02:00
# include "winreg.h"
2003-08-28 21:57:35 +02:00
# include "winternl.h"
2003-06-04 22:11:34 +02:00
2005-01-05 18:14:33 +01:00
struct apartment ;
2005-01-14 18:20:27 +01:00
typedef struct apartment APARTMENT ;
2005-01-05 18:14:33 +01:00
2005-01-14 18:20:27 +01:00
/* Thread-safety Annotation Legend:
*
2005-03-17 11:26:20 +01:00
* RO - The value is read only . It never changes after creation , so no
* locking is required .
* LOCK - The value is written to only using Interlocked * functions .
* CS - The value is read or written to inside a critical section .
* The identifier following " CS " is the specific critical setion that
* must be used .
* MUTEX - The value is read or written to with a mutex held .
* The identifier following " MUTEX " is the specific mutex that
* must be used .
2005-01-14 18:20:27 +01:00
*/
2005-01-17 14:39:40 +01:00
typedef enum ifstub_state
{
2005-02-18 21:03:23 +01:00
STUBSTATE_NORMAL_MARSHALED ,
STUBSTATE_NORMAL_UNMARSHALED ,
STUBSTATE_TABLE_WEAK_MARSHALED ,
STUBSTATE_TABLE_WEAK_UNMARSHALED ,
STUBSTATE_TABLE_STRONG ,
} STUB_STATE ;
2005-01-17 14:39:40 +01:00
2005-01-14 18:20:27 +01:00
/* an interface stub */
struct ifstub
{
struct list entry ; /* entry in stub_manager->ifstubs list (CS stub_manager->lock) */
IRpcStubBuffer * stubbuffer ; /* RO */
IID iid ; /* RO */
IPID ipid ; /* RO */
IUnknown * iface ; /* RO */
} ;
2004-02-10 02:36:20 +01:00
2005-01-14 18:20:27 +01:00
/* stub managers hold refs on the object and each interface stub */
struct stub_manager
{
struct list entry ; /* entry in apartment stubmgr list (CS apt->cs) */
struct list ifstubs ; /* list of active ifstubs for the object (CS lock) */
CRITICAL_SECTION lock ;
APARTMENT * apt ; /* owning apt (RO) */
2005-02-18 21:03:23 +01:00
ULONG extrefs ; /* number of 'external' references (CS lock) */
2005-01-14 18:20:27 +01:00
ULONG refs ; /* internal reference count (CS apt->cs) */
OID oid ; /* apartment-scoped unique identifier (RO) */
IUnknown * object ; /* the object we are managing the stub for (RO) */
ULONG next_ipid ; /* currently unused (LOCK) */
2005-02-18 21:03:23 +01:00
STUB_STATE state ; /* state machine (CS lock) */
2005-01-14 18:20:27 +01:00
} ;
2003-06-04 22:11:34 +02:00
2005-01-04 12:58:23 +01:00
/* imported interface proxy */
struct ifproxy
{
2005-01-17 14:39:40 +01:00
struct list entry ; /* entry in proxy_manager list (CS parent->cs) */
struct proxy_manager * parent ; /* owning proxy_manager (RO) */
2005-01-14 18:20:27 +01:00
LPVOID iface ; /* interface pointer (RO) */
IID iid ; /* interface ID (RO) */
IPID ipid ; /* imported interface ID (RO) */
LPRPCPROXYBUFFER proxy ; /* interface proxy (RO) */
2005-03-17 11:26:20 +01:00
DWORD refs ; /* imported (public) references (MUTEX parent->remoting_mutex) */
2005-03-07 18:14:11 +01:00
IRpcChannelBuffer * chan ; /* channel to object (CS parent->cs) */
2005-01-04 12:58:23 +01:00
} ;
2003-06-04 22:11:34 +02:00
2005-01-04 12:58:23 +01:00
/* imported object / proxy manager */
struct proxy_manager
{
2005-01-26 22:07:05 +01:00
const IMultiQIVtbl * lpVtbl ;
2005-01-14 18:20:27 +01:00
struct apartment * parent ; /* owning apartment (RO) */
struct list entry ; /* entry in apartment (CS parent->cs) */
OXID oxid ; /* object exported ID (RO) */
OID oid ; /* object ID (RO) */
struct list interfaces ; /* imported interfaces (CS cs) */
2005-07-05 13:02:54 +02:00
LONG refs ; /* proxy reference count (LOCK) */
2005-01-14 18:20:27 +01:00
CRITICAL_SECTION cs ; /* thread safety for this object and children */
2005-01-24 12:24:08 +01:00
ULONG sorflags ; /* STDOBJREF flags (RO) */
2005-01-25 11:57:24 +01:00
IRemUnknown * remunk ; /* proxy to IRemUnknown used for lifecycle management (CS cs) */
2005-03-17 11:26:20 +01:00
HANDLE remoting_mutex ; /* mutex used for synchronizing access to IRemUnknown */
2005-01-04 12:58:23 +01:00
} ;
2003-06-04 22:11:34 +02:00
2005-01-05 18:14:33 +01:00
/* this needs to become a COM object that implements IRemUnknown */
struct apartment
{
struct list entry ;
2005-07-05 13:02:54 +02:00
LONG refs ; /* refcount of the apartment (LOCK) */
2005-01-14 18:20:27 +01:00
DWORD model ; /* threading model (RO) */
DWORD tid ; /* thread id (RO) */
HANDLE thread ; /* thread handle (RO) */
OXID oxid ; /* object exporter ID (RO) */
2005-07-05 13:02:54 +02:00
LONG ipidc ; /* interface pointer ID counter, starts at 1 (LOCK) */
2005-01-14 18:20:27 +01:00
HWND win ; /* message window (RO) */
2003-06-04 22:11:34 +02:00
CRITICAL_SECTION cs ; /* thread safety */
2005-01-14 18:20:27 +01:00
LPMESSAGEFILTER filter ; /* message filter (CS cs) */
struct list proxies ; /* imported objects (CS cs) */
struct list stubmgrs ; /* stub managers for exported objects (CS cs) */
2005-01-25 11:57:24 +01:00
BOOL remunk_exported ; /* has the IRemUnknown interface for this apartment been created yet? (CS cs) */
2005-02-15 16:44:25 +01:00
LONG remoting_started ; /* has the RPC system been started for this apartment? (LOCK) */
2005-01-14 18:20:27 +01:00
2005-02-15 16:44:25 +01:00
/* FIXME: OID's should be given out by RPCSS */
2005-02-08 13:55:26 +01:00
OID oidc ; /* object ID counter, starts at 1, zero is invalid OID (CS cs) */
2005-01-05 18:14:33 +01:00
} ;
2003-06-04 22:11:34 +02:00
2005-01-14 18:20:27 +01:00
/* this is what is stored in TEB->ReservedForOle */
struct oletls
{
struct apartment * apt ;
IErrorInfo * errorinfo ; /* see errorinfo.c */
IUnknown * state ; /* see CoSetState */
DWORD inits ; /* number of times CoInitializeEx called */
} ;
2000-11-25 04:08:23 +01:00
2005-02-15 16:44:25 +01:00
/* Global Interface Table Functions */
2004-12-13 22:19:01 +01:00
extern void * StdGlobalInterfaceTable_Construct ( void ) ;
2003-03-11 02:45:38 +01:00
extern void StdGlobalInterfaceTable_Destroy ( void * self ) ;
2003-06-17 05:57:18 +02:00
extern HRESULT StdGlobalInterfaceTable_GetFactory ( LPVOID * ppv ) ;
2005-02-15 16:44:25 +01:00
extern void * StdGlobalInterfaceTableInstance ;
2003-03-11 02:45:38 +01:00
2005-01-14 18:20:27 +01:00
/* FIXME: these shouldn't be needed, except for 16-bit functions */
2002-02-05 19:11:17 +01:00
extern HRESULT WINE_StringFromCLSID ( const CLSID * id , LPSTR idstr ) ;
2005-01-14 18:20:27 +01:00
HRESULT WINAPI __CLSIDFromStringA ( LPCSTR idstr , CLSID * id ) ;
2005-06-20 12:33:17 +02:00
DWORD COM_OpenKeyForCLSID ( REFCLSID clsid , REGSAM access , HKEY * key ) ;
2002-02-05 19:11:17 +01:00
HRESULT MARSHAL_GetStandardMarshalCF ( LPVOID * ppv ) ;
2005-02-15 16:44:25 +01:00
/* Stub Manager */
2005-01-11 11:45:34 +01:00
ULONG stub_manager_int_addref ( struct stub_manager * This ) ;
ULONG stub_manager_int_release ( struct stub_manager * This ) ;
2005-02-18 21:03:23 +01:00
struct stub_manager * new_stub_manager ( APARTMENT * apt , IUnknown * object , MSHLFLAGS mshlflags ) ;
2005-01-11 11:45:34 +01:00
ULONG stub_manager_ext_addref ( struct stub_manager * m , ULONG refs ) ;
ULONG stub_manager_ext_release ( struct stub_manager * m , ULONG refs ) ;
2005-02-18 21:03:23 +01:00
struct ifstub * stub_manager_new_ifstub ( struct stub_manager * m , IRpcStubBuffer * sb , IUnknown * iptr , REFIID iid ) ;
2005-01-14 17:48:34 +01:00
struct stub_manager * get_stub_manager ( APARTMENT * apt , OID oid ) ;
struct stub_manager * get_stub_manager_from_object ( APARTMENT * apt , void * object ) ;
2005-02-18 21:03:23 +01:00
BOOL stub_manager_notify_unmarshal ( struct stub_manager * m ) ;
BOOL stub_manager_is_table_marshaled ( struct stub_manager * m ) ;
void stub_manager_release_marshal_data ( struct stub_manager * m , ULONG refs ) ;
2005-01-25 11:57:24 +01:00
HRESULT ipid_to_stub_manager ( const IPID * ipid , APARTMENT * * stub_apt , struct stub_manager * * stubmgr_ret ) ;
2005-02-14 12:50:51 +01:00
IRpcStubBuffer * ipid_to_apt_and_stubbuffer ( const IPID * ipid , APARTMENT * * stub_apt ) ;
2005-01-25 11:57:24 +01:00
HRESULT start_apartment_remote_unknown ( void ) ;
2004-12-27 20:21:47 +01:00
2005-03-11 11:19:10 +01:00
HRESULT marshal_object ( APARTMENT * apt , STDOBJREF * stdobjref , REFIID riid , IUnknown * obj , MSHLFLAGS mshlflags ) ;
2005-02-15 16:44:25 +01:00
/* RPC Backend */
2002-02-05 19:11:17 +01:00
2005-03-17 11:26:20 +01:00
struct dispatch_params ;
2005-02-15 16:44:25 +01:00
void RPC_StartRemoting ( struct apartment * apt ) ;
HRESULT RPC_CreateClientChannel ( const OXID * oxid , const IPID * ipid , IRpcChannelBuffer * * pipebuf ) ;
2005-03-17 11:26:20 +01:00
HRESULT RPC_ExecuteCall ( struct dispatch_params * params ) ;
2005-02-15 16:02:49 +01:00
HRESULT RPC_RegisterInterface ( REFIID riid ) ;
2005-02-15 16:44:25 +01:00
void RPC_UnregisterInterface ( REFIID riid ) ;
void RPC_StartLocalServer ( REFCLSID clsid , IStream * stream ) ;
HRESULT RPC_GetLocalClassObject ( REFCLSID rclsid , REFIID iid , LPVOID * ppv ) ;
2002-02-05 19:11:17 +01:00
2000-11-25 04:08:23 +01:00
/* This function initialize the Running Object Table */
2004-12-13 22:19:01 +01:00
HRESULT WINAPI RunningObjectTableImpl_Initialize ( void ) ;
2000-11-25 04:08:23 +01:00
/* This function uninitialize the Running Object Table */
2004-12-13 22:19:01 +01:00
HRESULT WINAPI RunningObjectTableImpl_UnInitialize ( void ) ;
2000-11-25 04:08:23 +01:00
/* This function decomposes a String path to a String Table containing all the elements ("\" or "subDirectory" or "Directory" or "FileName") of the path */
2005-05-12 11:57:21 +02:00
int FileMonikerImpl_DecomposePath ( LPCOLESTR str , LPOLESTR * * stringTable ) ;
2000-11-25 04:08:23 +01:00
2005-02-15 16:44:25 +01:00
/* Apartment Functions */
2005-03-11 11:19:10 +01:00
APARTMENT * apartment_findfromoxid ( OXID oxid , BOOL ref ) ;
APARTMENT * apartment_findfromtid ( DWORD tid ) ;
DWORD apartment_addref ( struct apartment * apt ) ;
DWORD apartment_release ( struct apartment * apt ) ;
HRESULT apartment_disconnectproxies ( struct apartment * apt ) ;
void apartment_disconnectobject ( struct apartment * apt , void * object ) ;
static inline HRESULT apartment_getoxid ( struct apartment * apt , OXID * oxid )
{
* oxid = apt - > oxid ;
return S_OK ;
}
2005-01-05 18:14:33 +01:00
2005-03-17 11:26:20 +01:00
/* DCOM messages used by the apartment window (not compatible with native) */
# define DM_EXECUTERPC (WM_USER + 0) /* WPARAM = 0, LPARAM = (struct dispatch_params *) */
2005-02-14 12:50:51 +01:00
2003-06-04 22:11:34 +02:00
/*
* Per - thread values are stored in the TEB on offset 0xF80 ,
* see http : //www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm
*/
2005-01-05 18:14:33 +01:00
/* will create if necessary */
static inline struct oletls * COM_CurrentInfo ( void )
2003-06-04 22:11:34 +02:00
{
2005-01-12 20:48:39 +01:00
if ( ! NtCurrentTeb ( ) - > ReservedForOle )
2005-01-05 18:14:33 +01:00
NtCurrentTeb ( ) - > ReservedForOle = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( struct oletls ) ) ;
2005-01-12 20:48:39 +01:00
2005-01-05 18:14:33 +01:00
return NtCurrentTeb ( ) - > ReservedForOle ;
2003-06-04 22:11:34 +02:00
}
2005-01-05 18:14:33 +01:00
2003-06-04 22:11:34 +02:00
static inline APARTMENT * COM_CurrentApt ( void )
2005-01-05 18:14:33 +01:00
{
return COM_CurrentInfo ( ) - > apt ;
2003-06-04 22:11:34 +02:00
}
2004-08-13 02:44:22 +02:00
# define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
2005-03-17 11:26:20 +01:00
/* helpers for debugging */
# ifdef __i386__
# define DEBUG_SET_CRITSEC_NAME(cs, name) (cs)->DebugInfo->Spare[1] = (DWORD)(__FILE__ ": " name)
# define DEBUG_CLEAR_CRITSEC_NAME(cs) (cs)->DebugInfo->Spare[1] = 0
# else
# define DEBUG_SET_CRITSEC_NAME(cs, name)
# define DEBUG_CLEAR_CRITSEC_NAME(cs)
# endif
2005-05-16 16:12:53 +02:00
extern HINSTANCE OLE32_hInstance ; /* FIXME: make static */
2005-06-20 12:33:17 +02:00
# define CHARS_IN_GUID 39 /* including NULL */
2000-11-25 04:08:23 +01:00
# endif /* __WINE_OLE_COMPOBJ_H */