Apparently this portion of the test was failing under some versions of
[wine] / dlls / ole32 / compobj_private.h
1 /*
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
8  *
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
24 #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
29 #include <stdarg.h>
30
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wtypes.h"
34 #include "dcom.h"
35 #include "winreg.h"
36 #include "winternl.h"
37
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
44
45 /* exported interface */
46 typedef 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 */
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 */
66 } XOBJECT;
67
68 /* imported interface */
69 typedef 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 */
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 */
90 } IOBJECT;
91
92 /* apartment */
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 */
108 } APARTMENT;
109
110 extern APARTMENT MTA, *apts;
111
112 extern void* StdGlobalInterfaceTable_Construct();
113 extern void  StdGlobalInterfaceTable_Destroy(void* self);
114 extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv);
115
116 extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr);
117 extern HRESULT create_marshalled_proxy(REFCLSID rclsid, REFIID iid, LPVOID *ppv);
118
119 extern void* StdGlobalInterfaceTableInstance;
120
121 #define PIPEPREF "\\\\.\\pipe\\"
122 #define OLESTUBMGR PIPEPREF"WINE_OLE_StubMgr"
123
124 /* Standard Marshalling definitions */
125 typedef struct _wine_marshal_id {
126     DWORD       processid;
127     DWORD       objectid;       /* unique value corresp. IUnknown of object */
128     IID         iid;
129 } wine_marshal_id;
130
131 inline static BOOL
132 MARSHAL_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 */
141 inline static BOOL
142 MARSHAL_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
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();
152
153 HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);
154
155 void STUBMGR_Start();
156
157 extern HRESULT PIPE_GetNewPipeBuf(wine_marshal_id *mid, IRpcChannelBuffer **pipebuf);
158
159 /* This function initialize the Running Object Table */
160 HRESULT WINAPI RunningObjectTableImpl_Initialize();
161
162 /* This function uninitialize the Running Object Table */
163 HRESULT 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 */
166 int WINAPI FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable);
167
168 HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id);
169
170 /*
171  * Per-thread values are stored in the TEB on offset 0xF80,
172  * see http://www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm
173  */
174 static inline APARTMENT* COM_CurrentInfo(void)
175 {
176   APARTMENT* apt = NtCurrentTeb()->ReservedForOle;
177   return apt;
178 }
179 static inline APARTMENT* COM_CurrentApt(void)
180 {
181   APARTMENT* apt = COM_CurrentInfo();
182   if (apt && apt->parent) apt = apt->parent;
183   return apt;
184 }
185
186 /* compobj.c */
187 APARTMENT* COM_CreateApartment(DWORD model);
188 HWND COM_GetApartmentWin(OXID oxid);
189
190 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
191
192 #endif /* __WINE_OLE_COMPOBJ_H */