2002-03-09 23:29:33 +00: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 20:11:34 +00:00
* Copyright 2003 Ove K <EFBFBD> ven , TransGaming Technologies
2005-02-08 12:55:26 +00:00
* Copyright 2004 Mike Hearn , Rob Shearman , CodeWeavers Inc
2002-03-09 23:29:33 +00: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 03:08:23 +00: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-05 23:08:26 +00:00
# include <stdarg.h>
2004-12-27 19:21:47 +00:00
# include "wine/list.h"
2003-09-05 23:08:26 +00:00
# include "windef.h"
# include "winbase.h"
2000-11-25 03:08:23 +00:00
# include "wtypes.h"
2003-06-04 20:11:34 +00:00
# include "dcom.h"
2003-09-05 23:08:26 +00:00
# include "winreg.h"
2003-08-28 19:57:35 +00:00
# include "winternl.h"
2003-06-04 20:11:34 +00:00
2005-01-05 17:14:33 +00:00
struct apartment ;
2005-01-14 17:20:27 +00:00
typedef struct apartment APARTMENT ;
2005-01-05 17:14:33 +00:00
2005-01-14 17:20:27 +00:00
/* Thread-safety Annotation Legend:
*
* 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 with a critical section held .
* The identifier following " CS " is the specific critical section that
* must be used .
*/
2005-01-17 13:39:40 +00:00
typedef enum ifstub_state
{
IFSTUB_STATE_NORMAL_MARSHALED ,
IFSTUB_STATE_NORMAL_UNMARSHALED ,
IFSTUB_STATE_TABLE_MARSHALED
} IFSTUB_STATE ;
2005-01-14 17:20:27 +00: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 */
2005-01-17 13:39:40 +00:00
IFSTUB_STATE state ; /* CS stub_manager->lock */
2005-01-14 17:20:27 +00:00
} ;
2004-02-10 01:36:20 +00:00
2005-01-14 17:20:27 +00: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) */
ULONG extrefs ; /* number of 'external' references (LOCK) */
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) */
} ;
2003-06-04 20:11:34 +00:00
2005-01-04 11:58:23 +00:00
/* imported interface proxy */
struct ifproxy
{
2005-01-17 13:39:40 +00:00
struct list entry ; /* entry in proxy_manager list (CS parent->cs) */
struct proxy_manager * parent ; /* owning proxy_manager (RO) */
2005-01-14 17:20:27 +00:00
LPVOID iface ; /* interface pointer (RO) */
IID iid ; /* interface ID (RO) */
IPID ipid ; /* imported interface ID (RO) */
LPRPCPROXYBUFFER proxy ; /* interface proxy (RO) */
2005-01-17 13:39:40 +00:00
DWORD refs ; /* imported (public) references (CS parent->cs) */
2005-01-04 11:58:23 +00:00
} ;
2003-06-04 20:11:34 +00:00
2005-01-04 11:58:23 +00:00
/* imported object / proxy manager */
struct proxy_manager
{
2005-01-26 21:07:05 +00:00
const IMultiQIVtbl * lpVtbl ;
2005-01-14 17:20:27 +00:00
struct apartment * parent ; /* owning apartment (RO) */
struct list entry ; /* entry in apartment (CS parent->cs) */
LPRPCCHANNELBUFFER chan ; /* channel to object (CS cs) */
OXID oxid ; /* object exported ID (RO) */
OID oid ; /* object ID (RO) */
struct list interfaces ; /* imported interfaces (CS cs) */
DWORD refs ; /* proxy reference count (LOCK) */
CRITICAL_SECTION cs ; /* thread safety for this object and children */
2005-01-24 11:24:08 +00:00
ULONG sorflags ; /* STDOBJREF flags (RO) */
2005-01-25 10:57:24 +00:00
IRemUnknown * remunk ; /* proxy to IRemUnknown used for lifecycle management (CS cs) */
2005-01-04 11:58:23 +00:00
} ;
2003-06-04 20:11:34 +00:00
2005-01-05 17:14:33 +00:00
/* this needs to become a COM object that implements IRemUnknown */
struct apartment
{
struct list entry ;
2005-01-14 17:20:27 +00:00
DWORD refs ; /* refcount of the apartment (LOCK) */
DWORD model ; /* threading model (RO) */
DWORD tid ; /* thread id (RO) */
HANDLE thread ; /* thread handle (RO) */
OXID oxid ; /* object exporter ID (RO) */
2005-01-26 20:53:06 +00:00
DWORD ipidc ; /* interface pointer ID counter, starts at 1 (LOCK) */
2005-01-14 17:20:27 +00:00
HWND win ; /* message window (RO) */
2003-06-04 20:11:34 +00:00
CRITICAL_SECTION cs ; /* thread safety */
2005-01-14 17:20:27 +00: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 10:57:24 +00:00
BOOL remunk_exported ; /* has the IRemUnknown interface for this apartment been created yet? (CS cs) */
2005-01-14 17:20:27 +00:00
2005-02-08 12:55:26 +00:00
/* FIXME: These should all be removed long term as they leak information that should be encapsulated */
OID oidc ; /* object ID counter, starts at 1, zero is invalid OID (CS cs) */
DWORD listenertid ; /* id of apartment_listener_thread */
HANDLE shutdown_event ; /* event used to tell the client_dispatch_thread to shut down */
2005-01-05 17:14:33 +00:00
} ;
2003-06-04 20:11:34 +00:00
2005-01-14 17:20:27 +00: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 03:08:23 +00:00
2004-12-13 21:19:01 +00:00
extern void * StdGlobalInterfaceTable_Construct ( void ) ;
2003-03-11 01:45:38 +00:00
extern void StdGlobalInterfaceTable_Destroy ( void * self ) ;
2003-06-17 03:57:18 +00:00
extern HRESULT StdGlobalInterfaceTable_GetFactory ( LPVOID * ppv ) ;
2003-03-11 01:45:38 +00:00
2005-01-14 17:20:27 +00:00
/* FIXME: these shouldn't be needed, except for 16-bit functions */
2002-02-05 18:11:17 +00:00
extern HRESULT WINE_StringFromCLSID ( const CLSID * id , LPSTR idstr ) ;
2005-01-14 17:20:27 +00:00
HRESULT WINAPI __CLSIDFromStringA ( LPCSTR idstr , CLSID * id ) ;
2002-02-05 18:11:17 +00:00
extern HRESULT create_marshalled_proxy ( REFCLSID rclsid , REFIID iid , LPVOID * ppv ) ;
2003-06-17 03:57:18 +00:00
extern void * StdGlobalInterfaceTableInstance ;
2003-05-13 00:41:57 +00:00
/* Standard Marshalling definitions */
2002-02-05 18:11:17 +00:00
typedef struct _wine_marshal_id {
2004-12-27 19:21:47 +00:00
OXID oxid ; /* id of apartment */
OID oid ; /* id of stub manager */
2005-01-07 15:33:41 +00:00
IPID ipid ; /* id of interface pointer */
2002-02-05 18:11:17 +00:00
} wine_marshal_id ;
inline static BOOL
MARSHAL_Compare_Mids ( wine_marshal_id * mid1 , wine_marshal_id * mid2 ) {
return
2004-12-08 17:49:30 +00:00
( mid1 - > oxid = = mid2 - > oxid ) & &
( mid1 - > oid = = mid2 - > oid ) & &
2005-01-07 15:33:41 +00:00
IsEqualGUID ( & ( mid1 - > ipid ) , & ( mid2 - > ipid ) )
2002-02-05 18:11:17 +00:00
;
}
2005-01-04 11:58:23 +00:00
HRESULT MARSHAL_Disconnect_Proxies ( APARTMENT * apt ) ;
2002-02-05 18:11:17 +00:00
HRESULT MARSHAL_GetStandardMarshalCF ( LPVOID * ppv ) ;
2005-01-11 10:45:34 +00:00
ULONG stub_manager_int_addref ( struct stub_manager * This ) ;
ULONG stub_manager_int_release ( struct stub_manager * This ) ;
2004-12-27 19:21:47 +00:00
struct stub_manager * new_stub_manager ( APARTMENT * apt , IUnknown * object ) ;
2005-01-11 10:45:34 +00:00
ULONG stub_manager_ext_addref ( struct stub_manager * m , ULONG refs ) ;
ULONG stub_manager_ext_release ( struct stub_manager * m , ULONG refs ) ;
2005-01-07 15:33:41 +00:00
struct ifstub * stub_manager_new_ifstub ( struct stub_manager * m , IRpcStubBuffer * sb , IUnknown * iptr , REFIID iid , BOOL tablemarshal ) ;
2005-01-14 16:48:34 +00: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-08 16:51:22 +00:00
void apartment_disconnect_object ( APARTMENT * apt , void * object ) ;
2005-01-17 13:39:40 +00:00
BOOL stub_manager_notify_unmarshal ( struct stub_manager * m , const IPID * ipid ) ;
BOOL stub_manager_is_table_marshaled ( struct stub_manager * m , const IPID * ipid ) ;
2005-01-25 10:57:24 +00:00
HRESULT register_ifstub ( APARTMENT * apt , STDOBJREF * stdobjref , REFIID riid , IUnknown * obj , MSHLFLAGS mshlflags ) ;
HRESULT ipid_to_stub_manager ( const IPID * ipid , APARTMENT * * stub_apt , struct stub_manager * * stubmgr_ret ) ;
IRpcStubBuffer * ipid_to_stubbuffer ( const IPID * ipid ) ;
HRESULT start_apartment_remote_unknown ( void ) ;
2004-12-27 19:21:47 +00:00
IRpcStubBuffer * mid_to_stubbuffer ( wine_marshal_id * mid ) ;
2004-12-27 16:59:28 +00:00
void start_apartment_listener_thread ( void ) ;
2002-02-05 18:11:17 +00:00
extern HRESULT PIPE_GetNewPipeBuf ( wine_marshal_id * mid , IRpcChannelBuffer * * pipebuf ) ;
2004-12-27 19:24:55 +00:00
void RPC_StartLocalServer ( REFCLSID clsid , IStream * stream ) ;
2002-02-05 18:11:17 +00:00
2000-11-25 03:08:23 +00:00
/* This function initialize the Running Object Table */
2004-12-13 21:19:01 +00:00
HRESULT WINAPI RunningObjectTableImpl_Initialize ( void ) ;
2000-11-25 03:08:23 +00:00
/* This function uninitialize the Running Object Table */
2004-12-13 21:19:01 +00:00
HRESULT WINAPI RunningObjectTableImpl_UnInitialize ( void ) ;
2000-11-25 03:08:23 +00:00
/* This function decomposes a String path to a String Table containing all the elements ("\" or "subDirectory" or "Directory" or "FileName") of the path */
2001-07-20 18:00:00 +00:00
int WINAPI FileMonikerImpl_DecomposePath ( LPCOLESTR str , LPOLESTR * * stringTable ) ;
2000-11-25 03:08:23 +00:00
2005-01-05 17:14:33 +00:00
/* compobj.c */
APARTMENT * COM_ApartmentFromOXID ( OXID oxid , BOOL ref ) ;
2005-01-25 10:57:24 +00:00
APARTMENT * COM_ApartmentFromTID ( DWORD tid ) ;
2005-01-05 17:14:33 +00:00
DWORD COM_ApartmentAddRef ( struct apartment * apt ) ;
DWORD COM_ApartmentRelease ( struct apartment * apt ) ;
2003-06-04 20:11:34 +00: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 17:14:33 +00:00
/* will create if necessary */
static inline struct oletls * COM_CurrentInfo ( void )
2003-06-04 20:11:34 +00:00
{
2005-01-12 19:48:39 +00:00
if ( ! NtCurrentTeb ( ) - > ReservedForOle )
2005-01-05 17:14:33 +00:00
NtCurrentTeb ( ) - > ReservedForOle = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( struct oletls ) ) ;
2005-01-12 19:48:39 +00:00
2005-01-05 17:14:33 +00:00
return NtCurrentTeb ( ) - > ReservedForOle ;
2003-06-04 20:11:34 +00:00
}
2005-01-05 17:14:33 +00:00
2003-06-04 20:11:34 +00:00
static inline APARTMENT * COM_CurrentApt ( void )
2005-01-05 17:14:33 +00:00
{
return COM_CurrentInfo ( ) - > apt ;
2003-06-04 20:11:34 +00:00
}
2004-08-13 00:44:22 +00:00
# define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
2000-11-25 03:08:23 +00:00
# endif /* __WINE_OLE_COMPOBJ_H */