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
7 * Copyright 2003 Ove Kåven, TransGaming Technologies
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.
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.
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
24 #ifndef __WINE_OLE_COMPOBJ_H
25 #define __WINE_OLE_COMPOBJ_H
27 /* All private prototype functions used by OLE will be added to this header file */
38 /* 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
45 /* exported interface */
46 typedef struct tagXIF
{
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 */
57 typedef struct tagXOBJECT
{
58 IRpcStubBufferVtbl
*lpVtbl
;
59 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 */
68 /* imported interface */
69 typedef struct tagIIF
{
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 */
80 typedef struct tagIOBJECT
{
81 IRemUnknownVtbl
*lpVtbl
;
82 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 */
93 typedef 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 */
106 LPUNKNOWN state
; /* state object (see Co[Get,Set]State) */
107 LPVOID ErrorInfo
; /* thread error info */
110 extern APARTMENT MTA
, *apts
;
112 extern void* StdGlobalInterfaceTable_Construct();
113 extern void StdGlobalInterfaceTable_Destroy(void* self
);
114 extern HRESULT
StdGlobalInterfaceTable_GetFactory(LPVOID
*ppv
);
116 extern HRESULT
WINE_StringFromCLSID(const CLSID
*id
,LPSTR idstr
);
117 extern HRESULT
create_marshalled_proxy(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
);
119 extern void* StdGlobalInterfaceTableInstance
;
121 #define PIPEPREF "\\\\.\\pipe\\"
122 #define OLESTUBMGR PIPEPREF"WINE_OLE_StubMgr"
124 /* Standard Marshalling definitions */
125 typedef struct _wine_marshal_id
{
127 OID oid
; /* unique value corresp. IUnknown of object */
132 MARSHAL_Compare_Mids(wine_marshal_id
*mid1
,wine_marshal_id
*mid2
) {
134 (mid1
->oxid
== mid2
->oxid
) &&
135 (mid1
->oid
== mid2
->oid
) &&
136 IsEqualIID(&(mid1
->iid
),&(mid2
->iid
))
140 /* compare without interface compare */
142 MARSHAL_Compare_Mids_NoInterface(wine_marshal_id
*mid1
, wine_marshal_id
*mid2
) {
144 (mid1
->oxid
== mid2
->oxid
) &&
145 (mid1
->oid
== mid2
->oid
)
149 HRESULT
MARSHAL_Find_Stub_Buffer(wine_marshal_id
*mid
,IRpcStubBuffer
**stub
);
150 void MARSHAL_Invalidate_Stub_From_MID(wine_marshal_id
*mid
);
151 HRESULT
MARSHAL_Disconnect_Proxies();
153 HRESULT
MARSHAL_GetStandardMarshalCF(LPVOID
*ppv
);
155 void start_listener_thread();
157 extern HRESULT
PIPE_GetNewPipeBuf(wine_marshal_id
*mid
, IRpcChannelBuffer
**pipebuf
);
159 /* This function initialize the Running Object Table */
160 HRESULT WINAPI
RunningObjectTableImpl_Initialize();
162 /* This function uninitialize the Running Object Table */
163 HRESULT WINAPI
RunningObjectTableImpl_UnInitialize();
165 /* This function decomposes a String path to a String Table containing all the elements ("\" or "subDirectory" or "Directory" or "FileName") of the path */
166 int WINAPI
FileMonikerImpl_DecomposePath(LPCOLESTR str
, LPOLESTR
** stringTable
);
168 HRESULT WINAPI
__CLSIDFromStringA(LPCSTR idstr
, CLSID
*id
);
171 * Per-thread values are stored in the TEB on offset 0xF80,
172 * see http://www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm
174 static inline APARTMENT
* COM_CurrentInfo(void)
176 APARTMENT
* apt
= NtCurrentTeb()->ReservedForOle
;
179 static inline APARTMENT
* COM_CurrentApt(void)
181 APARTMENT
* apt
= COM_CurrentInfo();
182 if (apt
&& apt
->parent
) apt
= apt
->parent
;
187 APARTMENT
* COM_CreateApartment(DWORD model
);
188 HWND
COM_GetApartmentWin(OXID oxid
);
190 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
192 #endif /* __WINE_OLE_COMPOBJ_H */