Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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 |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 7 | * Copyright 2003 Ove Kåven, TransGaming Technologies |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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 | |
Francois Gouget | 3116bd9 | 2000-11-25 03:08:23 +0000 | [diff] [blame] | 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 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 29 | #include <stdarg.h> |
| 30 | |
| 31 | #include "windef.h" |
| 32 | #include "winbase.h" |
Francois Gouget | 3116bd9 | 2000-11-25 03:08:23 +0000 | [diff] [blame] | 33 | #include "wtypes.h" |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 34 | #include "dcom.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 35 | #include "winreg.h" |
Alexandre Julliard | 7df1b9e | 2003-08-28 19:57:35 +0000 | [diff] [blame] | 36 | #include "winternl.h" |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 37 | |
Robert Shearman | 2eee767 | 2004-02-10 01:36:20 +0000 | [diff] [blame] | 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 | |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 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 { |
Alexandre Julliard | 48c4bb3 | 2004-08-12 23:00:51 +0000 | [diff] [blame] | 58 | IRpcStubBufferVtbl *lpVtbl; |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 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 { |
Alexandre Julliard | 48c4bb3 | 2004-08-12 23:00:51 +0000 | [diff] [blame] | 81 | IRemUnknownVtbl *lpVtbl; |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 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 */ |
Robert Shearman | 2eee767 | 2004-02-10 01:36:20 +0000 | [diff] [blame] | 106 | LPUNKNOWN state; /* state object (see Co[Get,Set]State) */ |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 107 | LPVOID ErrorInfo; /* thread error info */ |
| 108 | } APARTMENT; |
| 109 | |
| 110 | extern APARTMENT MTA, *apts; |
Francois Gouget | 3116bd9 | 2000-11-25 03:08:23 +0000 | [diff] [blame] | 111 | |
Mike Hearn | cb816d2 | 2003-03-11 01:45:38 +0000 | [diff] [blame] | 112 | extern void* StdGlobalInterfaceTable_Construct(); |
| 113 | extern void StdGlobalInterfaceTable_Destroy(void* self); |
Mike Hearn | 739ccae | 2003-06-17 03:57:18 +0000 | [diff] [blame] | 114 | extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv); |
Mike Hearn | cb816d2 | 2003-03-11 01:45:38 +0000 | [diff] [blame] | 115 | |
Marcus Meissner | 0749fc2 | 2002-02-05 18:11:17 +0000 | [diff] [blame] | 116 | extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr); |
| 117 | extern HRESULT create_marshalled_proxy(REFCLSID rclsid, REFIID iid, LPVOID *ppv); |
| 118 | |
Mike Hearn | 739ccae | 2003-06-17 03:57:18 +0000 | [diff] [blame] | 119 | extern void* StdGlobalInterfaceTableInstance; |
| 120 | |
Marcus Meissner | 0749fc2 | 2002-02-05 18:11:17 +0000 | [diff] [blame] | 121 | #define PIPEPREF "\\\\.\\pipe\\" |
| 122 | #define OLESTUBMGR PIPEPREF"WINE_OLE_StubMgr" |
Robert Shearman | 2e93adc | 2004-07-22 23:44:54 +0000 | [diff] [blame] | 123 | |
Francois Gouget | f803e2a | 2003-05-13 00:41:57 +0000 | [diff] [blame] | 124 | /* Standard Marshalling definitions */ |
Marcus Meissner | 0749fc2 | 2002-02-05 18:11:17 +0000 | [diff] [blame] | 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); |
Mike Hearn | 5169f3c | 2004-07-29 23:58:12 +0000 | [diff] [blame] | 150 | void MARSHAL_Invalidate_Stub_From_MID(wine_marshal_id *mid); |
Mike Hearn | 8199423 | 2004-08-02 18:28:29 +0000 | [diff] [blame] | 151 | HRESULT MARSHAL_Disconnect_Proxies(); |
Marcus Meissner | 0749fc2 | 2002-02-05 18:11:17 +0000 | [diff] [blame] | 152 | |
| 153 | HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv); |
| 154 | |
Marcus Meissner | 0749fc2 | 2002-02-05 18:11:17 +0000 | [diff] [blame] | 155 | void STUBMGR_Start(); |
| 156 | |
| 157 | extern HRESULT PIPE_GetNewPipeBuf(wine_marshal_id *mid, IRpcChannelBuffer **pipebuf); |
| 158 | |
Francois Gouget | 3116bd9 | 2000-11-25 03:08:23 +0000 | [diff] [blame] | 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 */ |
Patrik Stridvall | bc38d6b | 2001-07-20 18:00:00 +0000 | [diff] [blame] | 166 | int WINAPI FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable); |
Francois Gouget | 3116bd9 | 2000-11-25 03:08:23 +0000 | [diff] [blame] | 167 | |
Juergen Schmied | d1c1441 | 2002-08-03 00:17:10 +0000 | [diff] [blame] | 168 | HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id); |
| 169 | |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 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) WINE_UNUSED; |
| 175 | static inline APARTMENT* COM_CurrentInfo(void) |
| 176 | { |
Alexandre Julliard | 02f2813 | 2003-08-27 23:14:29 +0000 | [diff] [blame] | 177 | APARTMENT* apt = NtCurrentTeb()->ReservedForOle; |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 178 | return apt; |
| 179 | } |
| 180 | static inline APARTMENT* COM_CurrentApt(void) WINE_UNUSED; |
| 181 | static 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 Shearman | 2eee767 | 2004-02-10 01:36:20 +0000 | [diff] [blame] | 189 | APARTMENT* COM_CreateApartment(DWORD model); |
Ove Kaaven | ef57c4d | 2003-06-04 20:11:34 +0000 | [diff] [blame] | 190 | HWND COM_GetApartmentWin(OXID oxid); |
| 191 | |
Alexandre Julliard | 936198c | 2004-08-13 00:44:22 +0000 | [diff] [blame^] | 192 | #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field)) |
| 193 | |
Francois Gouget | 3116bd9 | 2000-11-25 03:08:23 +0000 | [diff] [blame] | 194 | #endif /* __WINE_OLE_COMPOBJ_H */ |