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
2004-12-27 20:21:47 +01:00
* Copyright 2004 Mike Hearn , 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:
*
* 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 14:39:40 +01:00
typedef enum ifstub_state
{
IFSTUB_STATE_NORMAL_MARSHALED ,
IFSTUB_STATE_NORMAL_UNMARSHALED ,
IFSTUB_STATE_TABLE_MARSHALED
} IFSTUB_STATE ;
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 */
2005-01-17 14:39:40 +01:00
IFSTUB_STATE state ; /* CS stub_manager->lock */
2005-01-14 18:20:27 +01:00
} ;
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) */
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 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-01-17 14:39:40 +01:00
DWORD refs ; /* imported (public) references (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) */
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 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-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-01-14 18:20:27 +01: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 21:53:06 +01:00
DWORD 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-01-14 18:20:27 +01:00
2005-01-25 11:57:24 +01:00
OID oidc ; /* object ID counter, starts at 1, zero is invalid OID (CS cs). FIXME: remove me */
2005-01-14 18:20:27 +01:00
DWORD listenertid ; /* id of apartment_listener_thread. FIXME: remove me */
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
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 ) ;
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 ) ;
2002-02-05 19:11:17 +01:00
extern HRESULT create_marshalled_proxy ( REFCLSID rclsid , REFIID iid , LPVOID * ppv ) ;
2003-06-17 05:57:18 +02:00
extern void * StdGlobalInterfaceTableInstance ;
2003-05-13 02:41:57 +02:00
/* Standard Marshalling definitions */
2002-02-05 19:11:17 +01:00
typedef struct _wine_marshal_id {
2004-12-27 20:21:47 +01:00
OXID oxid ; /* id of apartment */
OID oid ; /* id of stub manager */
2005-01-07 16:33:41 +01:00
IPID ipid ; /* id of interface pointer */
2002-02-05 19:11:17 +01:00
} wine_marshal_id ;
inline static BOOL
MARSHAL_Compare_Mids ( wine_marshal_id * mid1 , wine_marshal_id * mid2 ) {
return
2004-12-08 18:49:30 +01:00
( mid1 - > oxid = = mid2 - > oxid ) & &
( mid1 - > oid = = mid2 - > oid ) & &
2005-01-07 16:33:41 +01:00
IsEqualGUID ( & ( mid1 - > ipid ) , & ( mid2 - > ipid ) )
2002-02-05 19:11:17 +01:00
;
}
2005-01-04 12:58:23 +01:00
HRESULT MARSHAL_Disconnect_Proxies ( APARTMENT * apt ) ;
2002-02-05 19:11:17 +01:00
HRESULT MARSHAL_GetStandardMarshalCF ( LPVOID * ppv ) ;
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 ) ;
2004-12-27 20:21:47 +01:00
struct stub_manager * new_stub_manager ( APARTMENT * apt , IUnknown * object ) ;
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-01-07 16:33:41 +01:00
struct ifstub * stub_manager_new_ifstub ( struct stub_manager * m , IRpcStubBuffer * sb , IUnknown * iptr , REFIID iid , BOOL tablemarshal ) ;
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-01-17 14:39:40 +01: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 11:57:24 +01: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 20:21:47 +01:00
IRpcStubBuffer * mid_to_stubbuffer ( wine_marshal_id * mid ) ;
2004-12-27 17:59:28 +01:00
void start_apartment_listener_thread ( void ) ;
2002-02-05 19:11:17 +01:00
extern HRESULT PIPE_GetNewPipeBuf ( wine_marshal_id * mid , IRpcChannelBuffer * * pipebuf ) ;
2004-12-27 20:24:55 +01:00
void RPC_StartLocalServer ( REFCLSID clsid , IStream * stream ) ;
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 */
2001-07-20 20:00:00 +02:00
int WINAPI FileMonikerImpl_DecomposePath ( LPCOLESTR str , LPOLESTR * * stringTable ) ;
2000-11-25 04:08:23 +01:00
2005-01-05 18:14:33 +01:00
/* compobj.c */
APARTMENT * COM_CreateApartment ( DWORD model ) ;
APARTMENT * COM_ApartmentFromOXID ( OXID oxid , BOOL ref ) ;
2005-01-25 11:57:24 +01:00
APARTMENT * COM_ApartmentFromTID ( DWORD tid ) ;
2005-01-05 18:14:33 +01:00
DWORD COM_ApartmentAddRef ( struct apartment * apt ) ;
DWORD COM_ApartmentRelease ( struct apartment * apt ) ;
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))
2000-11-25 04:08:23 +01:00
# endif /* __WINE_OLE_COMPOBJ_H */