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 */
33 /* exported interface */
34 typedef struct tagXIF
{
36 LPVOID iface
; /* interface pointer */
37 IID iid
; /* interface ID */
38 IPID ipid
; /* exported interface ID */
39 LPRPCSTUBBUFFER stub
; /* interface stub */
40 DWORD refs
; /* external reference count */
41 HRESULT hres
; /* result of stub creation attempt */
45 typedef struct tagXOBJECT
{
46 ICOM_VTABLE(IRpcStubBuffer
) *lpVtbl
;
47 struct tagAPARTMENT
*parent
;
48 struct tagXOBJECT
*next
;
49 LPUNKNOWN obj
; /* object identity (IUnknown) */
50 OID oid
; /* object ID */
51 DWORD ifc
; /* interface ID counter */
52 XIF
*ifaces
; /* exported interfaces */
53 DWORD refs
; /* external reference count */
56 /* imported interface */
57 typedef struct tagIIF
{
59 LPVOID iface
; /* interface pointer */
60 IID iid
; /* interface ID */
61 IPID ipid
; /* imported interface ID */
62 LPRPCPROXYBUFFER proxy
; /* interface proxy */
63 DWORD refs
; /* imported (public) references */
64 HRESULT hres
; /* result of proxy creation attempt */
68 typedef struct tagIOBJECT
{
69 ICOM_VTABLE(IRemUnknown
) *lpVtbl
;
70 struct tagAPARTMENT
*parent
;
71 struct tagIOBJECT
*next
;
72 LPRPCCHANNELBUFFER chan
; /* channel to object */
73 OXID oxid
; /* object exported ID */
74 OID oid
; /* object ID */
75 IPID ipid
; /* first imported interface ID */
76 IIF
*ifaces
; /* imported interfaces */
77 DWORD refs
; /* proxy reference count */
81 typedef struct tagAPARTMENT
{
82 struct tagAPARTMENT
*next
, *prev
, *parent
;
83 DWORD model
; /* threading model */
84 DWORD inits
; /* CoInitialize count */
85 DWORD tid
; /* thread id */
86 HANDLE thread
; /* thread handle */
87 OXID oxid
; /* object exporter ID */
88 OID oidc
; /* object ID counter */
89 HWND win
; /* message window */
90 CRITICAL_SECTION cs
; /* thread safety */
91 LPMESSAGEFILTER filter
; /* message filter */
92 XOBJECT
*objs
; /* exported objects */
93 IOBJECT
*proxies
; /* imported objects */
94 LPVOID ErrorInfo
; /* thread error info */
97 extern APARTMENT MTA
, *apts
;
99 extern void* StdGlobalInterfaceTable_Construct();
100 extern void StdGlobalInterfaceTable_Destroy(void* self
);
101 extern HRESULT
StdGlobalInterfaceTable_GetFactory(LPVOID
*ppv
);
103 extern HRESULT
WINE_StringFromCLSID(const CLSID
*id
,LPSTR idstr
);
104 extern HRESULT
create_marshalled_proxy(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
);
106 extern void* StdGlobalInterfaceTableInstance
;
108 inline static HRESULT
109 get_facbuf_for_iid(REFIID riid
,IPSFactoryBuffer
**facbuf
) {
113 if ((hres
= CoGetPSClsid(riid
,&pxclsid
)))
115 return CoGetClassObject(&pxclsid
,CLSCTX_INPROC_SERVER
,NULL
,&IID_IPSFactoryBuffer
,(LPVOID
*)facbuf
);
118 #define PIPEPREF "\\\\.\\pipe\\"
119 #define OLESTUBMGR PIPEPREF"WINE_OLE_StubMgr"
120 /* Standard Marshalling definitions */
121 typedef struct _wine_marshal_id
{
123 DWORD objectid
; /* unique value corresp. IUnknown of object */
128 MARSHAL_Compare_Mids(wine_marshal_id
*mid1
,wine_marshal_id
*mid2
) {
130 (mid1
->processid
== mid2
->processid
) &&
131 (mid1
->objectid
== mid2
->objectid
) &&
132 IsEqualIID(&(mid1
->iid
),&(mid2
->iid
))
136 /* compare without interface compare */
138 MARSHAL_Compare_Mids_NoInterface(wine_marshal_id
*mid1
, wine_marshal_id
*mid2
) {
140 (mid1
->processid
== mid2
->processid
) &&
141 (mid1
->objectid
== mid2
->objectid
)
145 HRESULT
MARSHAL_Find_Stub_Buffer(wine_marshal_id
*mid
,IRpcStubBuffer
**stub
);
146 HRESULT
MARSHAL_Find_Stub_Server(wine_marshal_id
*mid
,LPUNKNOWN
*punk
);
147 HRESULT
MARSHAL_Register_Stub(wine_marshal_id
*mid
,LPUNKNOWN punk
, IRpcStubBuffer
*stub
);
149 HRESULT
MARSHAL_GetStandardMarshalCF(LPVOID
*ppv
);
151 typedef struct _wine_marshal_data
{
157 #define REQTYPE_REQUEST 0
158 typedef struct _wine_rpc_request_header
{
163 } wine_rpc_request_header
;
165 #define REQTYPE_RESPONSE 1
166 typedef struct _wine_rpc_response_header
{
170 } wine_rpc_response_header
;
172 #define REQSTATE_START 0
173 #define REQSTATE_REQ_QUEUED 1
174 #define REQSTATE_REQ_WAITING_FOR_REPLY 2
175 #define REQSTATE_REQ_GOT 3
176 #define REQSTATE_INVOKING 4
177 #define REQSTATE_RESP_QUEUED 5
178 #define REQSTATE_RESP_GOT 6
179 #define REQSTATE_DONE 6
181 void STUBMGR_Start();
183 extern HRESULT
PIPE_GetNewPipeBuf(wine_marshal_id
*mid
, IRpcChannelBuffer
**pipebuf
);
185 /* This function initialize the Running Object Table */
186 HRESULT WINAPI
RunningObjectTableImpl_Initialize();
188 /* This function uninitialize the Running Object Table */
189 HRESULT WINAPI
RunningObjectTableImpl_UnInitialize();
191 /* This function decomposes a String path to a String Table containing all the elements ("\" or "subDirectory" or "Directory" or "FileName") of the path */
192 int WINAPI
FileMonikerImpl_DecomposePath(LPCOLESTR str
, LPOLESTR
** stringTable
);
194 HRESULT WINAPI
__CLSIDFromStringA(LPCSTR idstr
, CLSID
*id
);
197 * Per-thread values are stored in the TEB on offset 0xF80,
198 * see http://www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm
200 static inline APARTMENT
* COM_CurrentInfo(void) WINE_UNUSED
;
201 static inline APARTMENT
* COM_CurrentInfo(void)
203 APARTMENT
* apt
= NtCurrentTeb()->ErrorInfo
;
206 static inline APARTMENT
* COM_CurrentApt(void) WINE_UNUSED
;
207 static inline APARTMENT
* COM_CurrentApt(void)
209 APARTMENT
* apt
= COM_CurrentInfo();
210 if (apt
&& apt
->parent
) apt
= apt
->parent
;
215 HWND
COM_GetApartmentWin(OXID oxid
);
217 #endif /* __WINE_OLE_COMPOBJ_H */