blob: ee4e33b4c5842a68d1d9375296a44da4d24d959c [file] [log] [blame]
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00001/*
2 * Copyright 1995 Martin von Loewis
3 * Copyright 1998 Justin Bradford
4 * Copyright 1999 Francis Beaudet
5 * Copyright 1999 Sylvain St-Germain
6 * Copyright 2002 Marcus Meissner
Ove Kaavenef57c4d2003-06-04 20:11:34 +00007 * Copyright 2003 Ove Kåven, TransGaming Technologies
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00008 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
Francois Gouget3116bd92000-11-25 03:08:23 +000024#ifndef __WINE_OLE_COMPOBJ_H
25#define __WINE_OLE_COMPOBJ_H
26
27/* All private prototype functions used by OLE will be added to this header file */
28
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000029#include <stdarg.h>
30
31#include "windef.h"
32#include "winbase.h"
Francois Gouget3116bd92000-11-25 03:08:23 +000033#include "wtypes.h"
Ove Kaavenef57c4d2003-06-04 20:11:34 +000034#include "dcom.h"
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000035#include "winreg.h"
Alexandre Julliard7df1b9e2003-08-28 19:57:35 +000036#include "winternl.h"
Ove Kaavenef57c4d2003-06-04 20:11:34 +000037
Robert Shearman2eee7672004-02-10 01:36:20 +000038/* Windows maps COINIT values to 0x80 for apartment threaded, 0x140
39 * for free threaded, and 0 for uninitialized apartments. There is
40 * no real advantage in us doing this and certainly no release version
41 * of an app should be poking around with these flags. So we need a
42 * special value for uninitialized */
43#define COINIT_UNINITIALIZED 0x100
44
Ove Kaavenef57c4d2003-06-04 20:11:34 +000045/* exported interface */
46typedef struct tagXIF {
47 struct tagXIF *next;
48 LPVOID iface; /* interface pointer */
49 IID iid; /* interface ID */
50 IPID ipid; /* exported interface ID */
51 LPRPCSTUBBUFFER stub; /* interface stub */
52 DWORD refs; /* external reference count */
53 HRESULT hres; /* result of stub creation attempt */
54} XIF;
55
56/* exported object */
57typedef struct tagXOBJECT {
Alexandre Julliard48c4bb32004-08-12 23:00:51 +000058 IRpcStubBufferVtbl *lpVtbl;
Ove Kaavenef57c4d2003-06-04 20:11:34 +000059 struct tagAPARTMENT *parent;
60 struct tagXOBJECT *next;
61 LPUNKNOWN obj; /* object identity (IUnknown) */
62 OID oid; /* object ID */
63 DWORD ifc; /* interface ID counter */
64 XIF *ifaces; /* exported interfaces */
65 DWORD refs; /* external reference count */
66} XOBJECT;
67
68/* imported interface */
69typedef struct tagIIF {
70 struct tagIIF *next;
71 LPVOID iface; /* interface pointer */
72 IID iid; /* interface ID */
73 IPID ipid; /* imported interface ID */
74 LPRPCPROXYBUFFER proxy; /* interface proxy */
75 DWORD refs; /* imported (public) references */
76 HRESULT hres; /* result of proxy creation attempt */
77} IIF;
78
79/* imported object */
80typedef struct tagIOBJECT {
Alexandre Julliard48c4bb32004-08-12 23:00:51 +000081 IRemUnknownVtbl *lpVtbl;
Ove Kaavenef57c4d2003-06-04 20:11:34 +000082 struct tagAPARTMENT *parent;
83 struct tagIOBJECT *next;
84 LPRPCCHANNELBUFFER chan; /* channel to object */
85 OXID oxid; /* object exported ID */
86 OID oid; /* object ID */
87 IPID ipid; /* first imported interface ID */
88 IIF *ifaces; /* imported interfaces */
89 DWORD refs; /* proxy reference count */
90} IOBJECT;
91
92/* apartment */
93typedef struct tagAPARTMENT {
94 struct tagAPARTMENT *next, *prev, *parent;
95 DWORD model; /* threading model */
96 DWORD inits; /* CoInitialize count */
97 DWORD tid; /* thread id */
98 HANDLE thread; /* thread handle */
99 OXID oxid; /* object exporter ID */
100 OID oidc; /* object ID counter */
101 HWND win; /* message window */
102 CRITICAL_SECTION cs; /* thread safety */
103 LPMESSAGEFILTER filter; /* message filter */
104 XOBJECT *objs; /* exported objects */
105 IOBJECT *proxies; /* imported objects */
Robert Shearman2eee7672004-02-10 01:36:20 +0000106 LPUNKNOWN state; /* state object (see Co[Get,Set]State) */
Ove Kaavenef57c4d2003-06-04 20:11:34 +0000107 LPVOID ErrorInfo; /* thread error info */
108} APARTMENT;
109
110extern APARTMENT MTA, *apts;
Francois Gouget3116bd92000-11-25 03:08:23 +0000111
Mike Hearncb816d22003-03-11 01:45:38 +0000112extern void* StdGlobalInterfaceTable_Construct();
113extern void StdGlobalInterfaceTable_Destroy(void* self);
Mike Hearn739ccae2003-06-17 03:57:18 +0000114extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv);
Mike Hearncb816d22003-03-11 01:45:38 +0000115
Marcus Meissner0749fc22002-02-05 18:11:17 +0000116extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr);
117extern HRESULT create_marshalled_proxy(REFCLSID rclsid, REFIID iid, LPVOID *ppv);
118
Mike Hearn739ccae2003-06-17 03:57:18 +0000119extern void* StdGlobalInterfaceTableInstance;
120
Marcus Meissner0749fc22002-02-05 18:11:17 +0000121#define PIPEPREF "\\\\.\\pipe\\"
122#define OLESTUBMGR PIPEPREF"WINE_OLE_StubMgr"
Robert Shearman2e93adc2004-07-22 23:44:54 +0000123
Francois Gougetf803e2a2003-05-13 00:41:57 +0000124/* Standard Marshalling definitions */
Marcus Meissner0749fc22002-02-05 18:11:17 +0000125typedef struct _wine_marshal_id {
126 DWORD processid;
127 DWORD objectid; /* unique value corresp. IUnknown of object */
128 IID iid;
129} wine_marshal_id;
130
131inline static BOOL
132MARSHAL_Compare_Mids(wine_marshal_id *mid1,wine_marshal_id *mid2) {
133 return
134 (mid1->processid == mid2->processid) &&
135 (mid1->objectid == mid2->objectid) &&
136 IsEqualIID(&(mid1->iid),&(mid2->iid))
137 ;
138}
139
140/* compare without interface compare */
141inline static BOOL
142MARSHAL_Compare_Mids_NoInterface(wine_marshal_id *mid1, wine_marshal_id *mid2) {
143 return
144 (mid1->processid == mid2->processid) &&
145 (mid1->objectid == mid2->objectid)
146 ;
147}
148
149HRESULT MARSHAL_Find_Stub_Buffer(wine_marshal_id *mid,IRpcStubBuffer **stub);
Mike Hearn5169f3c2004-07-29 23:58:12 +0000150void MARSHAL_Invalidate_Stub_From_MID(wine_marshal_id *mid);
Mike Hearn81994232004-08-02 18:28:29 +0000151HRESULT MARSHAL_Disconnect_Proxies();
Marcus Meissner0749fc22002-02-05 18:11:17 +0000152
153HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);
154
Marcus Meissner0749fc22002-02-05 18:11:17 +0000155void STUBMGR_Start();
156
157extern HRESULT PIPE_GetNewPipeBuf(wine_marshal_id *mid, IRpcChannelBuffer **pipebuf);
158
Francois Gouget3116bd92000-11-25 03:08:23 +0000159/* This function initialize the Running Object Table */
160HRESULT WINAPI RunningObjectTableImpl_Initialize();
161
162/* This function uninitialize the Running Object Table */
163HRESULT WINAPI RunningObjectTableImpl_UnInitialize();
164
165/* This function decomposes a String path to a String Table containing all the elements ("\" or "subDirectory" or "Directory" or "FileName") of the path */
Patrik Stridvallbc38d6b2001-07-20 18:00:00 +0000166int WINAPI FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable);
Francois Gouget3116bd92000-11-25 03:08:23 +0000167
Juergen Schmiedd1c14412002-08-03 00:17:10 +0000168HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id);
169
Ove Kaavenef57c4d2003-06-04 20:11:34 +0000170/*
171 * Per-thread values are stored in the TEB on offset 0xF80,
172 * see http://www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm
173 */
174static inline APARTMENT* COM_CurrentInfo(void) WINE_UNUSED;
175static inline APARTMENT* COM_CurrentInfo(void)
176{
Alexandre Julliard02f28132003-08-27 23:14:29 +0000177 APARTMENT* apt = NtCurrentTeb()->ReservedForOle;
Ove Kaavenef57c4d2003-06-04 20:11:34 +0000178 return apt;
179}
180static inline APARTMENT* COM_CurrentApt(void) WINE_UNUSED;
181static inline APARTMENT* COM_CurrentApt(void)
182{
183 APARTMENT* apt = COM_CurrentInfo();
184 if (apt && apt->parent) apt = apt->parent;
185 return apt;
186}
187
188/* compobj.c */
Robert Shearman2eee7672004-02-10 01:36:20 +0000189APARTMENT* COM_CreateApartment(DWORD model);
Ove Kaavenef57c4d2003-06-04 20:11:34 +0000190HWND COM_GetApartmentWin(OXID oxid);
191
Alexandre Julliard936198c2004-08-13 00:44:22 +0000192#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
193
Francois Gouget3116bd92000-11-25 03:08:23 +0000194#endif /* __WINE_OLE_COMPOBJ_H */