Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencompobj_private.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 1995 Martin von Loewis 00003 * Copyright 1998 Justin Bradford 00004 * Copyright 1999 Francis Beaudet 00005 * Copyright 1999 Sylvain St-Germain 00006 * Copyright 2002 Marcus Meissner 00007 * Copyright 2003 Ove Kåven, TransGaming Technologies 00008 * Copyright 2004 Mike Hearn, Rob Shearman, CodeWeavers Inc 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00023 */ 00024 00025 #ifndef __WINE_OLE_COMPOBJ_H 00026 #define __WINE_OLE_COMPOBJ_H 00027 00028 /* All private prototype functions used by OLE will be added to this header file */ 00029 00030 #include <stdarg.h> 00031 00032 #include "wine/list.h" 00033 00034 #include "windef.h" 00035 #include "winbase.h" 00036 #include "wtypes.h" 00037 #include "dcom.h" 00038 #include "winreg.h" 00039 #include "winternl.h" 00040 00041 struct apartment; 00042 typedef struct apartment APARTMENT; 00043 00044 DEFINE_OLEGUID( CLSID_DfMarshal, 0x0000030b, 0, 0 ); 00045 00046 /* signal to stub manager that this is a rem unknown object */ 00047 #define MSHLFLAGSP_REMUNKNOWN 0x80000000 00048 00049 /* Thread-safety Annotation Legend: 00050 * 00051 * RO - The value is read only. It never changes after creation, so no 00052 * locking is required. 00053 * LOCK - The value is written to only using Interlocked* functions. 00054 * CS - The value is read or written to inside a critical section. 00055 * The identifier following "CS" is the specific critical section that 00056 * must be used. 00057 * MUTEX - The value is read or written to with a mutex held. 00058 * The identifier following "MUTEX" is the specific mutex that 00059 * must be used. 00060 */ 00061 00062 typedef enum ifstub_state 00063 { 00064 STUBSTATE_NORMAL_MARSHALED, 00065 STUBSTATE_NORMAL_UNMARSHALED, 00066 STUBSTATE_TABLE_WEAK_MARSHALED, 00067 STUBSTATE_TABLE_WEAK_UNMARSHALED, 00068 STUBSTATE_TABLE_STRONG, 00069 } STUB_STATE; 00070 00071 /* an interface stub */ 00072 struct ifstub 00073 { 00074 struct list entry; /* entry in stub_manager->ifstubs list (CS stub_manager->lock) */ 00075 IRpcStubBuffer *stubbuffer; /* RO */ 00076 IID iid; /* RO */ 00077 IPID ipid; /* RO */ 00078 IUnknown *iface; /* RO */ 00079 MSHLFLAGS flags; /* so we can enforce process-local marshalling rules (RO) */ 00080 IRpcChannelBuffer*chan; /* channel passed to IRpcStubBuffer::Invoke (RO) */ 00081 }; 00082 00083 00084 /* stub managers hold refs on the object and each interface stub */ 00085 struct stub_manager 00086 { 00087 struct list entry; /* entry in apartment stubmgr list (CS apt->cs) */ 00088 struct list ifstubs; /* list of active ifstubs for the object (CS lock) */ 00089 CRITICAL_SECTION lock; 00090 APARTMENT *apt; /* owning apt (RO) */ 00091 00092 ULONG extrefs; /* number of 'external' references (CS lock) */ 00093 ULONG refs; /* internal reference count (CS apt->cs) */ 00094 ULONG weakrefs; /* number of weak references (CS lock) */ 00095 OID oid; /* apartment-scoped unique identifier (RO) */ 00096 IUnknown *object; /* the object we are managing the stub for (RO) */ 00097 ULONG next_ipid; /* currently unused (LOCK) */ 00098 OXID_INFO oxid_info; /* string binding, ipid of rem unknown and other information (RO) */ 00099 00100 /* We need to keep a count of the outstanding marshals, so we can enforce the 00101 * marshalling rules (ie, you can only unmarshal normal marshals once). Note 00102 * that these counts do NOT include unmarshalled interfaces, once a stream is 00103 * unmarshalled and a proxy set up, this count is decremented. 00104 */ 00105 00106 ULONG norm_refs; /* refcount of normal marshals (CS lock) */ 00107 }; 00108 00109 /* imported interface proxy */ 00110 struct ifproxy 00111 { 00112 struct list entry; /* entry in proxy_manager list (CS parent->cs) */ 00113 struct proxy_manager *parent; /* owning proxy_manager (RO) */ 00114 LPVOID iface; /* interface pointer (RO) */ 00115 STDOBJREF stdobjref; /* marshal data that represents this object (RO) */ 00116 IID iid; /* interface ID (RO) */ 00117 LPRPCPROXYBUFFER proxy; /* interface proxy (RO) */ 00118 ULONG refs; /* imported (public) references (LOCK) */ 00119 IRpcChannelBuffer *chan; /* channel to object (CS parent->cs) */ 00120 }; 00121 00122 struct apartment 00123 { 00124 struct list entry; 00125 00126 LONG refs; /* refcount of the apartment (LOCK) */ 00127 BOOL multi_threaded; /* multi-threaded or single-threaded apartment? (RO) */ 00128 DWORD tid; /* thread id (RO) */ 00129 OXID oxid; /* object exporter ID (RO) */ 00130 LONG ipidc; /* interface pointer ID counter, starts at 1 (LOCK) */ 00131 CRITICAL_SECTION cs; /* thread safety */ 00132 struct list proxies; /* imported objects (CS cs) */ 00133 struct list stubmgrs; /* stub managers for exported objects (CS cs) */ 00134 BOOL remunk_exported; /* has the IRemUnknown interface for this apartment been created yet? (CS cs) */ 00135 LONG remoting_started; /* has the RPC system been started for this apartment? (LOCK) */ 00136 struct list psclsids; /* list of registered PS CLSIDs (CS cs) */ 00137 struct list loaded_dlls; /* list of dlls loaded by this apartment (CS cs) */ 00138 DWORD host_apt_tid; /* thread ID of apartment hosting objects of differing threading model (CS cs) */ 00139 HWND host_apt_hwnd; /* handle to apartment window of host apartment (CS cs) */ 00140 00141 /* FIXME: OIDs should be given out by RPCSS */ 00142 OID oidc; /* object ID counter, starts at 1, zero is invalid OID (CS cs) */ 00143 00144 /* STA-only fields */ 00145 HWND win; /* message window (LOCK) */ 00146 LPMESSAGEFILTER filter; /* message filter (CS cs) */ 00147 BOOL main; /* is this a main-threaded-apartment? (RO) */ 00148 }; 00149 00150 /* this is what is stored in TEB->ReservedForOle */ 00151 struct oletls 00152 { 00153 struct apartment *apt; 00154 IErrorInfo *errorinfo; /* see errorinfo.c */ 00155 IUnknown *state; /* see CoSetState */ 00156 DWORD apt_mask; /* apartment mask (+0Ch on x86) */ 00157 IInitializeSpy *spy; /* The "SPY" from CoInitializeSpy */ 00158 DWORD inits; /* number of times CoInitializeEx called */ 00159 DWORD ole_inits; /* number of times OleInitialize called */ 00160 GUID causality_id; /* unique identifier for each COM call */ 00161 LONG pending_call_count_client; /* number of client calls pending */ 00162 LONG pending_call_count_server; /* number of server calls pending */ 00163 DWORD unknown; 00164 IObjContext *context_token; /* (+38h on x86) */ 00165 IUnknown *call_state; /* current call context (+3Ch on x86) */ 00166 DWORD unknown2[46]; 00167 IUnknown *cancel_object; /* cancel object set by CoSetCancelObject (+F8h on x86) */ 00168 }; 00169 00170 00171 /* Global Interface Table Functions */ 00172 00173 extern void* StdGlobalInterfaceTable_Construct(void) DECLSPEC_HIDDEN; 00174 extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv) DECLSPEC_HIDDEN; 00175 extern void* StdGlobalInterfaceTableInstance DECLSPEC_HIDDEN; 00176 00177 HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key) DECLSPEC_HIDDEN; 00178 HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey) DECLSPEC_HIDDEN; 00179 HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv) DECLSPEC_HIDDEN; 00180 HRESULT FTMarshalCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN; 00181 00182 /* Stub Manager */ 00183 00184 ULONG stub_manager_int_release(struct stub_manager *This) DECLSPEC_HIDDEN; 00185 struct stub_manager *new_stub_manager(APARTMENT *apt, IUnknown *object) DECLSPEC_HIDDEN; 00186 ULONG stub_manager_ext_addref(struct stub_manager *m, ULONG refs, BOOL tableweak) DECLSPEC_HIDDEN; 00187 ULONG stub_manager_ext_release(struct stub_manager *m, ULONG refs, BOOL tableweak, BOOL last_unlock_releases) DECLSPEC_HIDDEN; 00188 struct ifstub *stub_manager_new_ifstub(struct stub_manager *m, IRpcStubBuffer *sb, IUnknown *iptr, REFIID iid, MSHLFLAGS flags) DECLSPEC_HIDDEN; 00189 struct ifstub *stub_manager_find_ifstub(struct stub_manager *m, REFIID iid, MSHLFLAGS flags) DECLSPEC_HIDDEN; 00190 struct stub_manager *get_stub_manager(APARTMENT *apt, OID oid) DECLSPEC_HIDDEN; 00191 struct stub_manager *get_stub_manager_from_object(APARTMENT *apt, void *object) DECLSPEC_HIDDEN; 00192 BOOL stub_manager_notify_unmarshal(struct stub_manager *m, const IPID *ipid) DECLSPEC_HIDDEN; 00193 BOOL stub_manager_is_table_marshaled(struct stub_manager *m, const IPID *ipid) DECLSPEC_HIDDEN; 00194 void stub_manager_release_marshal_data(struct stub_manager *m, ULONG refs, const IPID *ipid, BOOL tableweak) DECLSPEC_HIDDEN; 00195 HRESULT ipid_get_dispatch_params(const IPID *ipid, APARTMENT **stub_apt, IRpcStubBuffer **stub, IRpcChannelBuffer **chan, IID *iid, IUnknown **iface) DECLSPEC_HIDDEN; 00196 HRESULT start_apartment_remote_unknown(void) DECLSPEC_HIDDEN; 00197 00198 HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnknown *obj, MSHLFLAGS mshlflags) DECLSPEC_HIDDEN; 00199 00200 /* RPC Backend */ 00201 00202 struct dispatch_params; 00203 00204 void RPC_StartRemoting(struct apartment *apt) DECLSPEC_HIDDEN; 00205 HRESULT RPC_CreateClientChannel(const OXID *oxid, const IPID *ipid, 00206 const OXID_INFO *oxid_info, 00207 DWORD dest_context, void *dest_context_data, 00208 IRpcChannelBuffer **chan) DECLSPEC_HIDDEN; 00209 HRESULT RPC_CreateServerChannel(IRpcChannelBuffer **chan) DECLSPEC_HIDDEN; 00210 void RPC_ExecuteCall(struct dispatch_params *params) DECLSPEC_HIDDEN; 00211 HRESULT RPC_RegisterInterface(REFIID riid) DECLSPEC_HIDDEN; 00212 void RPC_UnregisterInterface(REFIID riid) DECLSPEC_HIDDEN; 00213 HRESULT RPC_StartLocalServer(REFCLSID clsid, IStream *stream, BOOL multi_use, void **registration) DECLSPEC_HIDDEN; 00214 void RPC_StopLocalServer(void *registration) DECLSPEC_HIDDEN; 00215 HRESULT RPC_GetLocalClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) DECLSPEC_HIDDEN; 00216 HRESULT RPC_RegisterChannelHook(REFGUID rguid, IChannelHook *hook) DECLSPEC_HIDDEN; 00217 void RPC_UnregisterAllChannelHooks(void) DECLSPEC_HIDDEN; 00218 HRESULT RPC_ResolveOxid(OXID oxid, OXID_INFO *oxid_info) DECLSPEC_HIDDEN; 00219 00220 /* This function initialize the Running Object Table */ 00221 HRESULT WINAPI RunningObjectTableImpl_Initialize(void) DECLSPEC_HIDDEN; 00222 00223 /* This function uninitialize the Running Object Table */ 00224 HRESULT WINAPI RunningObjectTableImpl_UnInitialize(void) DECLSPEC_HIDDEN; 00225 00226 /* Drag and drop */ 00227 void OLEDD_UnInitialize(void) DECLSPEC_HIDDEN; 00228 00229 /* Apartment Functions */ 00230 00231 APARTMENT *apartment_findfromoxid(OXID oxid, BOOL ref) DECLSPEC_HIDDEN; 00232 APARTMENT *apartment_findfromtid(DWORD tid) DECLSPEC_HIDDEN; 00233 DWORD apartment_release(struct apartment *apt) DECLSPEC_HIDDEN; 00234 HRESULT apartment_disconnectproxies(struct apartment *apt) DECLSPEC_HIDDEN; 00235 void apartment_disconnectobject(struct apartment *apt, void *object) DECLSPEC_HIDDEN; 00236 static inline HRESULT apartment_getoxid(const struct apartment *apt, OXID *oxid) 00237 { 00238 *oxid = apt->oxid; 00239 return S_OK; 00240 } 00241 HRESULT apartment_createwindowifneeded(struct apartment *apt) DECLSPEC_HIDDEN; 00242 HWND apartment_getwindow(const struct apartment *apt) DECLSPEC_HIDDEN; 00243 void apartment_joinmta(void) DECLSPEC_HIDDEN; 00244 00245 00246 /* DCOM messages used by the apartment window (not compatible with native) */ 00247 #define DM_EXECUTERPC (WM_USER + 0) /* WPARAM = 0, LPARAM = (struct dispatch_params *) */ 00248 #define DM_HOSTOBJECT (WM_USER + 1) /* WPARAM = 0, LPARAM = (struct host_object_params *) */ 00249 00250 /* 00251 * Per-thread values are stored in the TEB on offset 0xF80 00252 */ 00253 00254 /* will create if necessary */ 00255 static inline struct oletls *COM_CurrentInfo(void) 00256 { 00257 if (!NtCurrentTeb()->ReservedForOle) 00258 NtCurrentTeb()->ReservedForOle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct oletls)); 00259 00260 return NtCurrentTeb()->ReservedForOle; 00261 } 00262 00263 static inline APARTMENT* COM_CurrentApt(void) 00264 { 00265 return COM_CurrentInfo()->apt; 00266 } 00267 00268 static inline GUID COM_CurrentCausalityId(void) 00269 { 00270 struct oletls *info = COM_CurrentInfo(); 00271 if (!info) 00272 return GUID_NULL; 00273 if (IsEqualGUID(&info->causality_id, &GUID_NULL)) 00274 CoCreateGuid(&info->causality_id); 00275 return info->causality_id; 00276 } 00277 00278 /* helpers for debugging */ 00279 # define DEBUG_SET_CRITSEC_NAME(cs, name) (cs)->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": " name) 00280 # define DEBUG_CLEAR_CRITSEC_NAME(cs) (cs)->DebugInfo->Spare[0] = 0 00281 00282 #define CHARS_IN_GUID 39 /* including NULL */ 00283 00284 #define WINE_CLSCTX_DONT_HOST 0x80000000 00285 00286 /* from dlldata.c */ 00287 extern HINSTANCE hProxyDll DECLSPEC_HIDDEN; 00288 extern HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN; 00289 extern HRESULT WINAPI OLE32_DllRegisterServer(void) DECLSPEC_HIDDEN; 00290 extern HRESULT WINAPI OLE32_DllUnregisterServer(void) DECLSPEC_HIDDEN; 00291 00292 extern HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN; 00293 extern HRESULT HandlerCF_Create(REFCLSID rclsid, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN; 00294 00295 /* Exported non-interface Data Advise Holder functions */ 00296 HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate) DECLSPEC_HIDDEN; 00297 void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface) DECLSPEC_HIDDEN; 00298 00299 extern UINT ownerlink_clipboard_format DECLSPEC_HIDDEN; 00300 extern UINT filename_clipboard_format DECLSPEC_HIDDEN; 00301 extern UINT filenameW_clipboard_format DECLSPEC_HIDDEN; 00302 extern UINT dataobject_clipboard_format DECLSPEC_HIDDEN; 00303 extern UINT embedded_object_clipboard_format DECLSPEC_HIDDEN; 00304 extern UINT embed_source_clipboard_format DECLSPEC_HIDDEN; 00305 extern UINT custom_link_source_clipboard_format DECLSPEC_HIDDEN; 00306 extern UINT link_source_clipboard_format DECLSPEC_HIDDEN; 00307 extern UINT object_descriptor_clipboard_format DECLSPEC_HIDDEN; 00308 extern UINT link_source_descriptor_clipboard_format DECLSPEC_HIDDEN; 00309 extern UINT ole_private_data_clipboard_format DECLSPEC_HIDDEN; 00310 00311 #endif /* __WINE_OLE_COMPOBJ_H */ Generated on Sat May 26 2012 04:24:07 for ReactOS by
1.7.6.1
|