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 ICOM_VTABLE(IRpcStubBuffer
) *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 ICOM_VTABLE(IRemUnknown
) *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 inline static HRESULT
122 get_facbuf_for_iid(REFIID riid
,IPSFactoryBuffer
**facbuf
) {
126 if ((hres
= CoGetPSClsid(riid
,&pxclsid
)))
128 return CoGetClassObject(&pxclsid
,CLSCTX_INPROC_SERVER
,NULL
,&IID_IPSFactoryBuffer
,(LPVOID
*)facbuf
);
131 #define PIPEPREF "\\\\.\\pipe\\"
132 #define OLESTUBMGR PIPEPREF"WINE_OLE_StubMgr"
133 /* Standard Marshalling definitions */
134 typedef struct _wine_marshal_id
{
136 DWORD objectid
; /* unique value corresp. IUnknown of object */
141 MARSHAL_Compare_Mids(wine_marshal_id
*mid1
,wine_marshal_id
*mid2
) {
143 (mid1
->processid
== mid2
->processid
) &&
144 (mid1
->objectid
== mid2
->objectid
) &&
145 IsEqualIID(&(mid1
->iid
),&(mid2
->iid
))
149 /* compare without interface compare */
151 MARSHAL_Compare_Mids_NoInterface(wine_marshal_id
*mid1
, wine_marshal_id
*mid2
) {
153 (mid1
->processid
== mid2
->processid
) &&
154 (mid1
->objectid
== mid2
->objectid
)
158 HRESULT
MARSHAL_Find_Stub_Buffer(wine_marshal_id
*mid
,IRpcStubBuffer
**stub
);
159 HRESULT
MARSHAL_Find_Stub_Server(wine_marshal_id
*mid
,LPUNKNOWN
*punk
);
160 HRESULT
MARSHAL_Register_Stub(wine_marshal_id
*mid
,LPUNKNOWN punk
, IRpcStubBuffer
*stub
);
162 HRESULT
MARSHAL_GetStandardMarshalCF(LPVOID
*ppv
);
164 typedef struct _wine_marshal_data
{
170 #define REQTYPE_REQUEST 0
171 typedef struct _wine_rpc_request_header
{
176 } wine_rpc_request_header
;
178 #define REQTYPE_RESPONSE 1
179 typedef struct _wine_rpc_response_header
{
183 } wine_rpc_response_header
;
185 #define REQSTATE_START 0
186 #define REQSTATE_REQ_QUEUED 1
187 #define REQSTATE_REQ_WAITING_FOR_REPLY 2
188 #define REQSTATE_REQ_GOT 3
189 #define REQSTATE_INVOKING 4
190 #define REQSTATE_RESP_QUEUED 5
191 #define REQSTATE_RESP_GOT 6
192 #define REQSTATE_DONE 6
194 void STUBMGR_Start();
196 extern HRESULT
PIPE_GetNewPipeBuf(wine_marshal_id
*mid
, IRpcChannelBuffer
**pipebuf
);
198 /* This function initialize the Running Object Table */
199 HRESULT WINAPI
RunningObjectTableImpl_Initialize();
201 /* This function uninitialize the Running Object Table */
202 HRESULT WINAPI
RunningObjectTableImpl_UnInitialize();
204 /* This function decomposes a String path to a String Table containing all the elements ("\" or "subDirectory" or "Directory" or "FileName") of the path */
205 int WINAPI
FileMonikerImpl_DecomposePath(LPCOLESTR str
, LPOLESTR
** stringTable
);
207 HRESULT WINAPI
__CLSIDFromStringA(LPCSTR idstr
, CLSID
*id
);
210 * Per-thread values are stored in the TEB on offset 0xF80,
211 * see http://www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm
213 static inline APARTMENT
* COM_CurrentInfo(void) WINE_UNUSED
;
214 static inline APARTMENT
* COM_CurrentInfo(void)
216 APARTMENT
* apt
= NtCurrentTeb()->ReservedForOle
;
219 static inline APARTMENT
* COM_CurrentApt(void) WINE_UNUSED
;
220 static inline APARTMENT
* COM_CurrentApt(void)
222 APARTMENT
* apt
= COM_CurrentInfo();
223 if (apt
&& apt
->parent
) apt
= apt
->parent
;
228 APARTMENT
* COM_CreateApartment(DWORD model
);
229 HWND
COM_GetApartmentWin(OXID oxid
);
231 #endif /* __WINE_OLE_COMPOBJ_H */