ReactOS  0.4.12-dev-90-g2e2e63e
compobj_private.h File Reference
#include <stdarg.h>
#include "wine/list.h"
#include "wine/heap.h"
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "dcom.h"
#include "winreg.h"
#include "winternl.h"
Include dependency graph for compobj_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ifstub
 
struct  stub_manager
 
struct  ifproxy
 
struct  apartment
 
struct  oletls
 

Macros

#define MSHLFLAGSP_REMUNKNOWN   0x80000000
 
#define DM_EXECUTERPC   (WM_USER + 0) /* WPARAM = 0, LPARAM = (struct dispatch_params *) */
 
#define DM_HOSTOBJECT   (WM_USER + 1) /* WPARAM = 0, LPARAM = (struct host_object_params *) */
 
#define DEBUG_SET_CRITSEC_NAME(cs, name)   (cs)->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": " name)
 
#define DEBUG_CLEAR_CRITSEC_NAME(cs)   (cs)->DebugInfo->Spare[0] = 0
 
#define CHARS_IN_GUID   39 /* including NULL */
 
#define WINE_CLSCTX_DONT_HOST   0x80000000
 

Typedefs

typedef struct apartment APARTMENT
 
typedef struct LocalServer LocalServer
 
typedef enum ifstub_state STUB_STATE
 

Enumerations

enum  ifstub_state {
  STUBSTATE_NORMAL_MARSHALED, STUBSTATE_NORMAL_UNMARSHALED, STUBSTATE_TABLE_WEAK_MARSHALED, STUBSTATE_TABLE_WEAK_UNMARSHALED,
  STUBSTATE_TABLE_STRONG
}
 

Functions

 DEFINE_OLEGUID (CLSID_DfMarshal, 0x0000030b, 0, 0)
 
IGlobalInterfaceTableget_std_git (void) DECLSPEC_HIDDEN
 
void release_std_git (void) DECLSPEC_HIDDEN
 
HRESULT StdGlobalInterfaceTable_GetFactory (LPVOID *ppv) DECLSPEC_HIDDEN
 
HRESULT COM_OpenKeyForCLSID (REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key) DECLSPEC_HIDDEN
 
HRESULT COM_OpenKeyForAppIdFromCLSID (REFCLSID clsid, REGSAM access, HKEY *subkey) DECLSPEC_HIDDEN
 
HRESULT MARSHAL_GetStandardMarshalCF (LPVOID *ppv) DECLSPEC_HIDDEN
 
HRESULT FTMarshalCF_Create (REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN
 
ULONG stub_manager_int_release (struct stub_manager *This) DECLSPEC_HIDDEN
 
ULONG stub_manager_ext_addref (struct stub_manager *m, ULONG refs, BOOL tableweak) DECLSPEC_HIDDEN
 
ULONG stub_manager_ext_release (struct stub_manager *m, ULONG refs, BOOL tableweak, BOOL last_unlock_releases) DECLSPEC_HIDDEN
 
struct ifstubstub_manager_new_ifstub (struct stub_manager *m, IRpcStubBuffer *sb, REFIID iid, DWORD dest_context, void *dest_context_data, MSHLFLAGS flags) DECLSPEC_HIDDEN
 
struct ifstubstub_manager_find_ifstub (struct stub_manager *m, REFIID iid, MSHLFLAGS flags) DECLSPEC_HIDDEN
 
struct stub_managerget_stub_manager (APARTMENT *apt, OID oid) DECLSPEC_HIDDEN
 
struct stub_managerget_stub_manager_from_object (APARTMENT *apt, IUnknown *object, BOOL alloc) DECLSPEC_HIDDEN
 
BOOL stub_manager_notify_unmarshal (struct stub_manager *m, const IPID *ipid) DECLSPEC_HIDDEN
 
BOOL stub_manager_is_table_marshaled (struct stub_manager *m, const IPID *ipid) DECLSPEC_HIDDEN
 
void stub_manager_release_marshal_data (struct stub_manager *m, ULONG refs, const IPID *ipid, BOOL tableweak) DECLSPEC_HIDDEN
 
void stub_manager_disconnect (struct stub_manager *m) DECLSPEC_HIDDEN
 
HRESULT ipid_get_dispatch_params (const IPID *ipid, APARTMENT **stub_apt, struct stub_manager **manager, IRpcStubBuffer **stub, IRpcChannelBuffer **chan, IID *iid, IUnknown **iface) DECLSPEC_HIDDEN
 
HRESULT start_apartment_remote_unknown (APARTMENT *apt) DECLSPEC_HIDDEN
 
HRESULT marshal_object (APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnknown *obj, DWORD dest_context, void *dest_context_data, MSHLFLAGS mshlflags) DECLSPEC_HIDDEN
 
void RPC_StartRemoting (struct apartment *apt) DECLSPEC_HIDDEN
 
HRESULT RPC_CreateClientChannel (const OXID *oxid, const IPID *ipid, const OXID_INFO *oxid_info, DWORD dest_context, void *dest_context_data, IRpcChannelBuffer **chan, APARTMENT *apt) DECLSPEC_HIDDEN
 
HRESULT RPC_CreateServerChannel (DWORD dest_context, void *dest_context_data, IRpcChannelBuffer **chan) DECLSPEC_HIDDEN
 
void RPC_ExecuteCall (struct dispatch_params *params) DECLSPEC_HIDDEN
 
HRESULT RPC_RegisterInterface (REFIID riid) DECLSPEC_HIDDEN
 
void RPC_UnregisterInterface (REFIID riid, BOOL wait) DECLSPEC_HIDDEN
 
HRESULT RPC_StartLocalServer (REFCLSID clsid, IStream *stream, BOOL multi_use, void **registration) DECLSPEC_HIDDEN
 
void RPC_StopLocalServer (void *registration) DECLSPEC_HIDDEN
 
HRESULT RPC_GetLocalClassObject (REFCLSID rclsid, REFIID iid, LPVOID *ppv) DECLSPEC_HIDDEN
 
HRESULT RPC_RegisterChannelHook (REFGUID rguid, IChannelHook *hook) DECLSPEC_HIDDEN
 
void RPC_UnregisterAllChannelHooks (void) DECLSPEC_HIDDEN
 
HRESULT RPC_ResolveOxid (OXID oxid, OXID_INFO *oxid_info) DECLSPEC_HIDDEN
 
HRESULT WINAPI RunningObjectTableImpl_Initialize (void) DECLSPEC_HIDDEN
 
HRESULT WINAPI RunningObjectTableImpl_UnInitialize (void) DECLSPEC_HIDDEN
 
void OLEDD_UnInitialize (void) DECLSPEC_HIDDEN
 
APARTMENTapartment_findfromoxid (OXID oxid, BOOL ref) DECLSPEC_HIDDEN
 
APARTMENTapartment_findfromtid (DWORD tid) DECLSPEC_HIDDEN
 
DWORD apartment_release (struct apartment *apt) DECLSPEC_HIDDEN
 
HRESULT apartment_disconnectproxies (struct apartment *apt) DECLSPEC_HIDDEN
 
static HRESULT apartment_getoxid (const struct apartment *apt, OXID *oxid)
 
HRESULT apartment_createwindowifneeded (struct apartment *apt) DECLSPEC_HIDDEN
 
HWND apartment_getwindow (const struct apartment *apt) DECLSPEC_HIDDEN
 
HRESULT enter_apartment (struct oletls *info, DWORD model) DECLSPEC_HIDDEN
 
void leave_apartment (struct oletls *info) DECLSPEC_HIDDEN
 
APARTMENTapartment_get_current_or_mta (void) DECLSPEC_HIDDEN
 
static struct oletlsCOM_CurrentInfo (void)
 
static APARTMENTCOM_CurrentApt (void)
 
static GUID COM_CurrentCausalityId (void)
 
HRESULT WINAPI OLE32_DllGetClassObject (REFCLSID rclsid, REFIID iid, LPVOID *ppv) DECLSPEC_HIDDEN
 
HRESULT WINAPI OLE32_DllRegisterServer (void) DECLSPEC_HIDDEN
 
HRESULT WINAPI OLE32_DllUnregisterServer (void) DECLSPEC_HIDDEN
 
HRESULT Handler_DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN
 
HRESULT HandlerCF_Create (REFCLSID rclsid, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN
 
HRESULT WINAPI GlobalOptions_CreateInstance (IClassFactory *iface, IUnknown *pUnk, REFIID riid, void **ppv) DECLSPEC_HIDDEN
 
HRESULT DataAdviseHolder_OnConnect (IDataAdviseHolder *iface, IDataObject *pDelegate) DECLSPEC_HIDDEN
 
void DataAdviseHolder_OnDisconnect (IDataAdviseHolder *iface) DECLSPEC_HIDDEN
 
LSTATUS create_classes_key (HKEY, const WCHAR *, REGSAM, HKEY *) DECLSPEC_HIDDEN
 
LSTATUS open_classes_key (HKEY, const WCHAR *, REGSAM, HKEY *) DECLSPEC_HIDDEN
 
BOOL actctx_get_miscstatus (const CLSID *, DWORD, DWORD *) DECLSPEC_HIDDEN
 
const chardebugstr_formatetc (const FORMATETC *formatetc) DECLSPEC_HIDDEN
 
static HRESULT copy_formatetc (FORMATETC *dst, const FORMATETC *src)
 
HRESULT EnumSTATDATA_Construct (IUnknown *holder, ULONG index, DWORD array_len, STATDATA *data, BOOL copy, IEnumSTATDATA **ppenum) DECLSPEC_HIDDEN
 

Variables

HINSTANCE hProxyDll DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ CHARS_IN_GUID

#define CHARS_IN_GUID   39 /* including NULL */

Definition at line 289 of file compobj_private.h.

◆ DEBUG_CLEAR_CRITSEC_NAME

#define DEBUG_CLEAR_CRITSEC_NAME (   cs)    (cs)->DebugInfo->Spare[0] = 0

◆ DEBUG_SET_CRITSEC_NAME

#define DEBUG_SET_CRITSEC_NAME (   cs,
  name 
)    (cs)->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": " name)

◆ DM_EXECUTERPC

#define DM_EXECUTERPC   (WM_USER + 0) /* WPARAM = 0, LPARAM = (struct dispatch_params *) */

◆ DM_HOSTOBJECT

#define DM_HOSTOBJECT   (WM_USER + 1) /* WPARAM = 0, LPARAM = (struct host_object_params *) */

◆ MSHLFLAGSP_REMUNKNOWN

#define MSHLFLAGSP_REMUNKNOWN   0x80000000

Definition at line 49 of file compobj_private.h.

Referenced by start_apartment_remote_unknown(), and stub_manager_new_ifstub().

◆ WINE_CLSCTX_DONT_HOST

#define WINE_CLSCTX_DONT_HOST   0x80000000

Definition at line 291 of file compobj_private.h.

Referenced by CoGetClassObject(), and get_facbuf_for_iid().

Typedef Documentation

◆ APARTMENT

Definition at line 43 of file compobj_private.h.

◆ LocalServer

Definition at line 44 of file compobj_private.h.

◆ STUB_STATE

Enumeration Type Documentation

◆ ifstub_state

Enumerator
STUBSTATE_NORMAL_MARSHALED 
STUBSTATE_NORMAL_UNMARSHALED 
STUBSTATE_TABLE_WEAK_MARSHALED 
STUBSTATE_TABLE_WEAK_UNMARSHALED 
STUBSTATE_TABLE_STRONG 

Definition at line 64 of file compobj_private.h.

Function Documentation

◆ actctx_get_miscstatus()

BOOL actctx_get_miscstatus ( const CLSID ,
DWORD  ,
DWORD  
)

Definition at line 259 of file compobj.c.

Referenced by OleRegGetMiscStatus().

260 {
261  ACTCTX_SECTION_KEYED_DATA data;
262 
263  data.cbSize = sizeof(data);
264  if (FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
265  clsid, &data))
266  {
267  struct comclassredirect_data *comclass = (struct comclassredirect_data*)data.lpData;
268  enum comclass_miscfields misc = dvaspect_to_miscfields(aspect);
269 
270  if (!(comclass->miscmask & misc))
271  {
272  if (!(comclass->miscmask & MiscStatus))
273  {
274  *status = 0;
275  return TRUE;
276  }
277  misc = MiscStatus;
278  }
279 
280  switch (misc)
281  {
282  case MiscStatus:
283  *status = comclass->miscstatus;
284  break;
285  case MiscStatusIcon:
286  *status = comclass->miscstatusicon;
287  break;
288  case MiscStatusContent:
289  *status = comclass->miscstatuscontent;
290  break;
291  case MiscStatusThumbnail:
292  *status = comclass->miscstatusthumbnail;
293  break;
294  case MiscStatusDocPrint:
295  *status = comclass->miscstatusdocprint;
296  break;
297  default:
298  ;
299  };
300 
301  return TRUE;
302  }
303  else
304  return FALSE;
305 }
#define TRUE
Definition: types.h:120
comclass_miscfields
Definition: compobj.c:103
DWORD miscstatusdocprint
Definition: compobj.c:133
static enum comclass_miscfields dvaspect_to_miscfields(DWORD aspect)
Definition: compobj.c:242
smooth NULL
Definition: ftsmooth.c:416
DWORD miscstatusthumbnail
Definition: compobj.c:131
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
REFCLSID clsid
Definition: msctf.c:84
BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, const GUID *lpSearchGuid, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:183
Definition: ps.c:97

◆ apartment_createwindowifneeded()

HRESULT apartment_createwindowifneeded ( struct apartment apt)

Definition at line 1710 of file compobj.c.

Referenced by apartment_get_or_create(), apartment_getoxid(), apartment_hostobject_thread(), and marshal_object().

1711 {
1712  static INIT_ONCE class_init_once = INIT_ONCE_STATIC_INIT;
1713 
1714  if (apt->multi_threaded)
1715  return S_OK;
1716 
1717  if (!apt->win)
1718  {
1719  HWND hwnd;
1720 
1721  InitOnceExecuteOnce( &class_init_once, register_class, NULL, NULL );
1722 
1723  hwnd = CreateWindowW(wszAptWinClass, NULL, 0, 0, 0, 0, 0,
1724  HWND_MESSAGE, 0, hProxyDll, NULL);
1725  if (!hwnd)
1726  {
1727  ERR("CreateWindow failed with error %d\n", GetLastError());
1728  return HRESULT_FROM_WIN32(GetLastError());
1729  }
1730  if (InterlockedCompareExchangePointer((PVOID *)&apt->win, hwnd, NULL))
1731  /* someone beat us to it */
1732  DestroyWindow(hwnd);
1733  }
1734 
1735  return S_OK;
1736 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
BOOL multi_threaded
#define INIT_ONCE_STATIC_INIT
Definition: winbase.h:593
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HWND_MESSAGE
Definition: winuser.h:1196
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4185
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
smooth NULL
Definition: ftsmooth.c:416
BOOL NTAPI InitOnceExecuteOnce(INIT_ONCE *once, PINIT_ONCE_FN func, void *param, void **context)
static BOOL WINAPI register_class(INIT_ONCE *once, void *param, void **context)
Definition: compobj.c:1687
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
static const WCHAR wszAptWinClass[]
Definition: compobj.c:486

◆ apartment_disconnectproxies()

HRESULT apartment_disconnectproxies ( struct apartment apt)

Definition at line 1144 of file marshal.c.

Referenced by apartment_release().

1145 {
1146  struct list * cursor;
1147 
1148  LIST_FOR_EACH(cursor, &apt->proxies)
1149  {
1150  struct proxy_manager * proxy = LIST_ENTRY(cursor, struct proxy_manager, entry);
1151  proxy_manager_disconnect(proxy);
1152  }
1153 
1154  return S_OK;
1155 }
int proxy
Definition: main.c:67
uint8_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
struct list proxies
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:59
const char cursor[]
Definition: icontest.c:13
static void proxy_manager_disconnect(struct proxy_manager *This)
Definition: marshal.c:978
#define LIST_ENTRY(type)
Definition: queue.h:175

◆ apartment_findfromoxid()

APARTMENT* apartment_findfromoxid ( OXID  oxid,
BOOL  ref 
)

Definition at line 1279 of file compobj.c.

Referenced by ipid_to_ifstub(), StdMarshalImpl_ReleaseMarshalData(), and StdMarshalImpl_UnmarshalInterface().

1280 {
1281  APARTMENT *result = NULL;
1282  struct list *cursor;
1283 
1285  LIST_FOR_EACH( cursor, &apts )
1286  {
1287  struct apartment *apt = LIST_ENTRY( cursor, struct apartment, entry );
1288  if (apt->oxid == oxid)
1289  {
1290  result = apt;
1291  if (ref) apartment_addref(result);
1292  break;
1293  }
1294  }
1296 
1297  return result;
1298 }
static DWORD apartment_addref(struct apartment *apt)
Definition: compobj.c:622
uint8_t entry
Definition: isohybrid.c:63
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Definition: send.c:47
static struct list apts
Definition: compobj.c:83
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
smooth NULL
Definition: ftsmooth.c:416
static CRITICAL_SECTION csApartment
Definition: compobj.c:85
Definition: _list.h:228
const char cursor[]
Definition: icontest.c:13
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
GLuint64EXT * result
Definition: glext.h:11304

◆ apartment_findfromtid()

APARTMENT* apartment_findfromtid ( DWORD  tid)

Definition at line 1303 of file compobj.c.

Referenced by ipid_to_ifstub().

1304 {
1305  APARTMENT *result = NULL;
1306  struct list *cursor;
1307 
1309  LIST_FOR_EACH( cursor, &apts )
1310  {
1311  struct apartment *apt = LIST_ENTRY( cursor, struct apartment, entry );
1312  if (apt->tid == tid)
1313  {
1314  result = apt;
1315  apartment_addref(result);
1316  break;
1317  }
1318  }
1320 
1321  return result;
1322 }
static DWORD apartment_addref(struct apartment *apt)
Definition: compobj.c:622
uint8_t entry
Definition: isohybrid.c:63
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static struct list apts
Definition: compobj.c:83
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
smooth NULL
Definition: ftsmooth.c:416
static CRITICAL_SECTION csApartment
Definition: compobj.c:85
Definition: _list.h:228
const char cursor[]
Definition: icontest.c:13
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
GLuint64EXT * result
Definition: glext.h:11304
static TfClientId tid

◆ apartment_get_current_or_mta()

APARTMENT* apartment_get_current_or_mta ( void  )

◆ apartment_getoxid()

static HRESULT apartment_getoxid ( const struct apartment apt,
OXID *  oxid 
)
inlinestatic

Definition at line 242 of file compobj_private.h.

Referenced by ClientRpcChannelBuffer_IsCorrectApartment(), marshal_object(), RPC_CreateClientChannel(), and StdMarshalImpl_UnmarshalInterface().

243 {
244  *oxid = apt->oxid;
245  return S_OK;
246 }
#define S_OK
Definition: intsafe.h:59

◆ apartment_getwindow()

HWND apartment_getwindow ( const struct apartment apt)

Definition at line 1739 of file compobj.c.

Referenced by apartment_getoxid(), apartment_hostobject_in_hostapt(), apartment_hostobject_thread(), ClientRpcChannelBuffer_GetBuffer(), and dispatch_rpc().

1740 {
1741  assert(!apt->multi_threaded);
1742  return apt->win;
1743 }
BOOL multi_threaded
#define assert(x)
Definition: debug.h:53

◆ apartment_release()

DWORD apartment_release ( struct apartment apt)

Definition at line 1175 of file compobj.c.

Referenced by apartment_hostobject_in_hostapt(), ClientIdentity_QueryMultipleInterfaces(), ClientRpcChannelBuffer_GetBuffer(), ClientRpcChannelBuffer_SendReceive(), CoCreateInstanceEx(), CoDisconnectObject(), CoGetApartmentType(), CoGetClassObject(), CoGetContextToken(), CoGetPSClsid(), CoLockObjectExternal(), COM_TlsDestroy(), CoRegisterClassObject(), CoRegisterPSClsid(), CoRevokeClassObject(), dispatch_rpc(), ipid_to_ifstub(), leave_apartment(), proxy_manager_get_remunknown(), RemUnknown_RemAddRef(), RemUnknown_RemQueryInterface(), RemUnknown_RemRelease(), StdMarshalImpl_MarshalInterface(), StdMarshalImpl_ReleaseMarshalData(), and StdMarshalImpl_UnmarshalInterface().

1176 {
1177  DWORD ret;
1178 
1180 
1181  ret = InterlockedDecrement(&apt->refs);
1182  TRACE("%s: after = %d\n", wine_dbgstr_longlong(apt->oxid), ret);
1183 
1184  if (apt->being_destroyed)
1185  {
1187  return ret;
1188  }
1189 
1190  /* destruction stuff that needs to happen under csApartment CS */
1191  if (ret == 0)
1192  {
1193  apt->being_destroyed = TRUE;
1194  if (apt == MTA) MTA = NULL;
1195  else if (apt == MainApartment) MainApartment = NULL;
1196  list_remove(&apt->entry);
1197  }
1198 
1200 
1201  if (ret == 0)
1202  {
1203  struct list *cursor, *cursor2;
1204 
1205  TRACE("destroying apartment %p, oxid %s\n", apt, wine_dbgstr_longlong(apt->oxid));
1206 
1207  if(apt->local_server) {
1210 
1211  memset(&zero, 0, sizeof(zero));
1212  IStream_Seek(local_server->marshal_stream, zero, STREAM_SEEK_SET, NULL);
1213  CoReleaseMarshalData(local_server->marshal_stream);
1214  IStream_Release(local_server->marshal_stream);
1215  local_server->marshal_stream = NULL;
1216 
1217  apt->local_server = NULL;
1218  local_server->apt = NULL;
1219  IServiceProvider_Release(&local_server->IServiceProvider_iface);
1220  }
1221 
1222  /* Release the references to the registered class objects */
1223  COM_RevokeAllClasses(apt);
1224 
1225  /* no locking is needed for this apartment, because no other thread
1226  * can access it at this point */
1227 
1229 
1230  if (apt->win) DestroyWindow(apt->win);
1231  if (apt->host_apt_tid) PostThreadMessageW(apt->host_apt_tid, WM_QUIT, 0, 0);
1232 
1233  LIST_FOR_EACH_SAFE(cursor, cursor2, &apt->stubmgrs)
1234  {
1235  struct stub_manager *stubmgr = LIST_ENTRY(cursor, struct stub_manager, entry);
1236  /* release the implicit reference given by the fact that the
1237  * stub has external references (it must do since it is in the
1238  * stub manager list in the apartment and all non-apartment users
1239  * must have a ref on the apartment and so it cannot be destroyed).
1240  */
1241  stub_manager_int_release(stubmgr);
1242  }
1243 
1244  /* if this assert fires, then another thread took a reference to a
1245  * stub manager without taking a reference to the containing
1246  * apartment, which it must do. */
1247  assert(list_empty(&apt->stubmgrs));
1248 
1249  if (apt->filter) IMessageFilter_Release(apt->filter);
1250 
1251  /* free as many unused libraries as possible... */
1253 
1254  /* ... and free the memory for the apartment loaded dll entry and
1255  * release the dll list reference without freeing the library for the
1256  * rest */
1257  while ((cursor = list_head(&apt->loaded_dlls)))
1258  {
1259  struct apartment_loaded_dll *apartment_loaded_dll = LIST_ENTRY(cursor, struct apartment_loaded_dll, entry);
1260  COMPOBJ_DllList_ReleaseRef(apartment_loaded_dll->dll, FALSE);
1261  list_remove(cursor);
1262  HeapFree(GetProcessHeap(), 0, apartment_loaded_dll);
1263  }
1264 
1266  DeleteCriticalSection(&apt->cs);
1267 
1268  HeapFree(GetProcessHeap(), 0, apt);
1269  }
1270 
1271  return ret;
1272 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:1907
DWORD host_apt_tid
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
#define TRUE
Definition: types.h:120
static void apartment_freeunusedlibraries(struct apartment *apt, DWORD delay)
Definition: compobj.c:1135
IStream * marshal_stream
Definition: compobj.c:199
ULONG stub_manager_int_release(struct stub_manager *This) DECLSPEC_HIDDEN
Definition: stubmanager.c:311
uint8_t entry
Definition: isohybrid.c:63
static APARTMENT * MainApartment
Definition: compobj.c:82
#define WM_QUIT
Definition: winuser.h:1605
#define assert(x)
Definition: debug.h:53
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
BOOL WINAPI DestroyWindow(_In_ HWND)
IServiceProvider IServiceProvider_iface
Definition: compobj.c:196
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
#define DEBUG_CLEAR_CRITSEC_NAME(cs)
static APARTMENT * MTA
Definition: compobj.c:81
smooth NULL
Definition: ftsmooth.c:416
LocalServer * local_server
static void COM_RevokeAllClasses(const struct apartment *apt)
Definition: compobj.c:767
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
unsigned long DWORD
Definition: ntddk_ex.h:95
static double zero
Definition: j0_y0.c:96
int ret
static void COMPOBJ_DllList_ReleaseRef(OpenDll *entry, BOOL free_entry)
Definition: compobj.c:586
#define InterlockedDecrement
Definition: armddk.h:52
struct list loaded_dlls
static CRITICAL_SECTION csApartment
Definition: compobj.c:85
Definition: _list.h:228
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
HRESULT apartment_disconnectproxies(struct apartment *apt) DECLSPEC_HIDDEN
Definition: marshal.c:1144
const char cursor[]
Definition: icontest.c:13
struct list entry
APARTMENT * apt
Definition: compobj.c:198
LPMESSAGEFILTER filter
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
struct list stubmgrs
BOOL being_destroyed
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
CRITICAL_SECTION cs
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI PostThreadMessageW(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ COM_CurrentApt()

◆ COM_CurrentCausalityId()

static GUID COM_CurrentCausalityId ( void  )
inlinestatic

Definition at line 275 of file compobj_private.h.

Referenced by ClientRpcChannelBuffer_GetBuffer(), and CoGetCurrentLogicalThreadId().

276 {
277  struct oletls *info = COM_CurrentInfo();
278  if (!info)
279  return GUID_NULL;
280  if (IsEqualGUID(&info->causality_id, &GUID_NULL))
281  CoCreateGuid(&info->causality_id);
282  return info->causality_id;
283 }
static struct oletls * COM_CurrentInfo(void)
GUID causality_id
HRESULT WINAPI CoCreateGuid(GUID *pguid)
Definition: compobj.c:2118
#define GUID_NULL
Definition: ks.h:106
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4024

◆ COM_CurrentInfo()

◆ COM_OpenKeyForAppIdFromCLSID()

HRESULT COM_OpenKeyForAppIdFromCLSID ( REFCLSID  clsid,
REGSAM  access,
HKEY subkey 
)

Definition at line 2392 of file compobj.c.

Referenced by create_local_service().

2393 {
2394  static const WCHAR szAppId[] = { 'A','p','p','I','d',0 };
2395  static const WCHAR szAppIdKey[] = { 'A','p','p','I','d','\\',0 };
2396  DWORD res;
2398  WCHAR keyname[ARRAYSIZE(szAppIdKey) + CHARS_IN_GUID];
2399  DWORD size;
2400  HKEY hkey;
2401  DWORD type;
2402  HRESULT hr;
2403 
2404  /* read the AppID value under the class's key */
2405  hr = COM_OpenKeyForCLSID(clsid, NULL, KEY_READ, &hkey);
2406  if (FAILED(hr))
2407  return hr;
2408 
2409  size = sizeof(buf);
2410  res = RegQueryValueExW(hkey, szAppId, NULL, &type, (LPBYTE)buf, &size);
2411  RegCloseKey(hkey);
2412  if (res == ERROR_FILE_NOT_FOUND)
2413  return REGDB_E_KEYMISSING;
2414  else if (res != ERROR_SUCCESS || type!=REG_SZ)
2415  return REGDB_E_READREGDB;
2416 
2417  strcpyW(keyname, szAppIdKey);
2418  strcatW(keyname, buf);
2419  res = open_classes_key(HKEY_CLASSES_ROOT, keyname, access, subkey);
2420  if (res == ERROR_FILE_NOT_FOUND)
2421  return REGDB_E_KEYMISSING;
2422  else if (res != ERROR_SUCCESS)
2423  return REGDB_E_READREGDB;
2424 
2425  return S_OK;
2426 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define KEY_READ
Definition: nt_native.h:1023
#define REGDB_E_READREGDB
Definition: winerror.h:2692
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CHARS_IN_GUID
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REGDB_E_KEYMISSING
Definition: winerror.h:2694
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *subkey)
Definition: compobj.c:2360
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
REFCLSID clsid
Definition: msctf.c:84
#define ARRAYSIZE(array)
Definition: compobj.c:75
#define S_OK
Definition: intsafe.h:59
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
LSTATUS open_classes_key(HKEY hkey, const WCHAR *name, REGSAM access, HKEY *retkey)
Definition: compobj.c:425
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
GLuint res
Definition: glext.h:9613
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define REG_SZ
Definition: layer.c:22

◆ COM_OpenKeyForCLSID()

HRESULT COM_OpenKeyForCLSID ( REFCLSID  clsid,
LPCWSTR  keyname,
REGSAM  access,
HKEY key 
)

Definition at line 2360 of file compobj.c.

Referenced by CoGetClassObject(), CoGetTreatAsClass(), COM_OpenKeyForAppIdFromCLSID(), CoTreatAsClass(), create_server(), Handler_DllGetClassObject(), OleGetAutoConvert(), OleRegEnumVerbs(), OleRegGetMiscStatus(), OleRegGetUserType(), OleSetAutoConvert(), and ProgIDFromCLSID().

2361 {
2362  static const WCHAR wszCLSIDSlash[] = {'C','L','S','I','D','\\',0};
2363  WCHAR path[CHARS_IN_GUID + ARRAYSIZE(wszCLSIDSlash) - 1];
2364  LONG res;
2365  HKEY key;
2366 
2367  strcpyW(path, wszCLSIDSlash);
2368  StringFromGUID2(clsid, path + strlenW(wszCLSIDSlash), CHARS_IN_GUID);
2369  res = open_classes_key(HKEY_CLASSES_ROOT, path, keyname ? KEY_READ : access, &key);
2370  if (res == ERROR_FILE_NOT_FOUND)
2371  return REGDB_E_CLASSNOTREG;
2372  else if (res != ERROR_SUCCESS)
2373  return REGDB_E_READREGDB;
2374 
2375  if (!keyname)
2376  {
2377  *subkey = key;
2378  return S_OK;
2379  }
2380 
2381  res = open_classes_key(key, keyname, access, subkey);
2382  RegCloseKey(key);
2383  if (res == ERROR_FILE_NOT_FOUND)
2384  return REGDB_E_KEYMISSING;
2385  else if (res != ERROR_SUCCESS)
2386  return REGDB_E_READREGDB;
2387 
2388  return S_OK;
2389 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define REGDB_E_READREGDB
Definition: winerror.h:2692
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CHARS_IN_GUID
#define REGDB_E_KEYMISSING
Definition: winerror.h:2694
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2346
REFCLSID clsid
Definition: msctf.c:84
HKEY key
Definition: reg.c:42
#define ARRAYSIZE(array)
Definition: compobj.c:75
#define S_OK
Definition: intsafe.h:59
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
LSTATUS open_classes_key(HKEY hkey, const WCHAR *name, REGSAM access, HKEY *retkey)
Definition: compobj.c:425
Definition: services.c:325
GLuint res
Definition: glext.h:9613
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

◆ copy_formatetc()

static HRESULT copy_formatetc ( FORMATETC *  dst,
const FORMATETC *  src 
)
inlinestatic

Definition at line 329 of file compobj_private.h.

Referenced by copy_statdata(), DataCache_EnumCache(), init_cache_entry(), and OLEClipbrd_IEnumFORMATETC_Next().

330 {
331  *dst = *src;
332  if (src->ptd)
333  {
334  dst->ptd = CoTaskMemAlloc( src->ptd->tdSize );
335  if (!dst->ptd) return E_OUTOFMEMORY;
336  memcpy( dst->ptd, src->ptd, src->ptd->tdSize );
337  }
338  return S_OK;
339 }
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406

◆ create_classes_key()

LSTATUS create_classes_key ( HKEY  ,
const WCHAR ,
REGSAM  ,
HKEY  
)

Definition at line 407 of file compobj.c.

Referenced by COMCAT_ICatRegister_RegisterCategories(), COMCAT_RegisterClassCategories(), and get_classes_root_hkey().

408 {
411 
412  if (!(hkey = get_classes_root_hkey( hkey, access ))) return ERROR_INVALID_HANDLE;
413 
414  attr.Length = sizeof(attr);
415  attr.RootDirectory = hkey;
416  attr.ObjectName = &nameW;
417  attr.Attributes = 0;
418  attr.SecurityDescriptor = NULL;
420  RtlInitUnicodeString( &nameW, name );
421 
422  return RtlNtStatusToDosError( create_key( retkey, access, &attr ) );
423 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HKEY get_classes_root_hkey(HKEY hkey, REGSAM access)
Definition: compobj.c:386
static NTSTATUS create_key(HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr)
Definition: compobj.c:308
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR nameW[]
Definition: main.c:46
__u8 attr
Definition: mkdosfs.c:359
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
PVOID SecurityDescriptor
Definition: umtypes.h:187
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
PVOID SecurityQualityOfService
Definition: umtypes.h:188
Definition: name.c:36
PUNICODE_STRING ObjectName
Definition: umtypes.h:185
HANDLE RootDirectory
Definition: umtypes.h:184
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

◆ DataAdviseHolder_OnConnect()

HRESULT DataAdviseHolder_OnConnect ( IDataAdviseHolder iface,
IDataObject pDelegate 
)

Definition at line 809 of file oleobj.c.

Referenced by DefaultHandler_DAdvise(), and DefaultHandler_Run().

810 {
812  DWORD index;
813  HRESULT hr = S_OK;
814 
815  for(index = 0; index < This->maxCons; index++)
816  {
817  if(This->connections[index].pAdvSink != NULL)
818  {
819  hr = IDataObject_DAdvise(pDelegate, &This->connections[index].formatetc,
820  This->connections[index].advf,
821  This->connections[index].pAdvSink,
822  &This->remote_connections[index]);
823  if (FAILED(hr)) break;
824  This->connections[index].advf |= WINE_ADVF_REMOTE;
825  }
826  }
827  This->delegate = pDelegate;
828  return hr;
829 }
DWORD * remote_connections
Definition: oleobj.c:542
STATDATA * connections
Definition: oleobj.c:541
smooth NULL
Definition: ftsmooth.c:416
#define WINE_ADVF_REMOTE
Definition: oleobj.c:547
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD maxCons
Definition: oleobj.c:540
#define index(s, c)
Definition: various.h:29
IDataObject * delegate
Definition: oleobj.c:543
#define S_OK
Definition: intsafe.h:59
static DataAdviseHolder * impl_from_IDataAdviseHolder(IDataAdviseHolder *iface)
Definition: oleobj.c:549

◆ DataAdviseHolder_OnDisconnect()

void DataAdviseHolder_OnDisconnect ( IDataAdviseHolder iface)

Definition at line 831 of file oleobj.c.

Referenced by DefaultHandler_Stop().

832 {
834  DWORD index;
835 
836  for(index = 0; index < This->maxCons; index++)
837  {
838  if((This->connections[index].pAdvSink != NULL) &&
839  (This->connections[index].advf & WINE_ADVF_REMOTE))
840  {
841  IDataObject_DUnadvise(This->delegate, This->remote_connections[index]);
842  This->remote_connections[index] = 0;
843  This->connections[index].advf &= ~WINE_ADVF_REMOTE;
844  }
845  }
846  This->delegate = NULL;
847 }
DWORD * remote_connections
Definition: oleobj.c:542
STATDATA * connections
Definition: oleobj.c:541
smooth NULL
Definition: ftsmooth.c:416
#define WINE_ADVF_REMOTE
Definition: oleobj.c:547
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD maxCons
Definition: oleobj.c:540
#define index(s, c)
Definition: various.h:29
IDataObject * delegate
Definition: oleobj.c:543
static DataAdviseHolder * impl_from_IDataAdviseHolder(IDataAdviseHolder *iface)
Definition: oleobj.c:549

◆ debugstr_formatetc()

const char* debugstr_formatetc ( const FORMATETC *  formatetc)

Definition at line 217 of file datacache.c.

Referenced by add_cache_entry(), DataCache_Cache(), DataCache_GetData(), DataCache_IOleCache2_SetData(), DataCache_OnDataChange(), DataCache_QueryGetData(), DataCacheEntry_Save(), and OleCreateFromFileEx().

218 {
219  return wine_dbg_sprintf("{ cfFormat = 0x%x, ptd = %p, dwAspect = %d, lindex = %d, tymed = %d }",
220  formatetc->cfFormat, formatetc->ptd, formatetc->dwAspect,
221  formatetc->lindex, formatetc->tymed);
222 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271

◆ DEFINE_OLEGUID()

DEFINE_OLEGUID ( CLSID_DfMarshal  ,
0x0000030b  ,
,
 
)

◆ enter_apartment()

HRESULT enter_apartment ( struct oletls info,
DWORD  model 
)

Definition at line 1849 of file compobj.c.

Referenced by apartment_getoxid(), CoInitializeEx(), and dispatch_rpc().

1850 {
1851  HRESULT hr = S_OK;
1852 
1853  if (!info->apt)
1854  {
1855  if (!apartment_get_or_create( model ))
1856  return E_OUTOFMEMORY;
1857  }
1858  else if (!apartment_is_model( info->apt, model ))
1859  {
1860  WARN( "Attempt to change threading model of this apartment from %s to %s\n",
1861  info->apt->multi_threaded ? "multi-threaded" : "apartment threaded",
1862  model & COINIT_APARTMENTTHREADED ? "apartment threaded" : "multi-threaded" );
1863  return RPC_E_CHANGED_MODE;
1864  }
1865  else
1866  hr = S_FALSE;
1867 
1868  info->inits++;
1869 
1870  return hr;
1871 }
#define WARN(fmt,...)
Definition: debug.h:111
static BOOL apartment_is_model(const APARTMENT *apt, DWORD model)
Definition: compobj.c:721
struct apartment * apt
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:77
#define RPC_E_CHANGED_MODE
Definition: winerror.h:2482
DWORD inits
static APARTMENT * apartment_get_or_create(DWORD model)
Definition: compobj.c:673
#define S_OK
Definition: intsafe.h:59

◆ EnumSTATDATA_Construct()

HRESULT EnumSTATDATA_Construct ( IUnknown holder,
ULONG  index,
DWORD  array_len,
STATDATA *  data,
BOOL  copy,
IEnumSTATDATA **  ppenum 
)

Definition at line 200 of file oleobj.c.

Referenced by copy_formatetc(), DataAdviseHolder_EnumAdvise(), DataCache_EnumCache(), EnumSTATDATA_Clone(), and OleAdviseHolderImpl_EnumAdvise().

202 {
203  EnumSTATDATA *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
204  DWORD i, count;
205 
206  if (!This) return E_OUTOFMEMORY;
207 
209  This->ref = 1;
210  This->index = index;
211 
212  if (copy)
213  {
214  This->statdata = HeapAlloc(GetProcessHeap(), 0, array_len * sizeof(*This->statdata));
215  if(!This->statdata)
216  {
217  HeapFree(GetProcessHeap(), 0, This);
218  return E_OUTOFMEMORY;
219  }
220 
221  for(i = 0, count = 0; i < array_len; i++)
222  {
223  if(data[i].pAdvSink)
224  {
225  copy_statdata(This->statdata + count, data + i);
226  count++;
227  }
228  }
229  }
230  else
231  {
232  This->statdata = data;
233  count = array_len;
234  }
235 
236  This->num_of_elems = count;
237  This->holder = holder;
238  if (holder) IUnknown_AddRef(holder);
239  *ppenum = &This->IEnumSTATDATA_iface;
240  return S_OK;
241 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
IEnumSTATDATA IEnumSTATDATA_iface
Definition: oleobj.c:76
static HRESULT copy_statdata(STATDATA *dst, const STATDATA *src)
Definition: oleobj.c:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
ULONG index
Definition: oleobj.c:79
static const IEnumSTATDATAVtbl EnumSTATDATA_VTable
Definition: oleobj.c:189
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
STATDATA * statdata
Definition: oleobj.c:81
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG ref
Definition: oleobj.c:77
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define index(s, c)
Definition: various.h:29
IUnknown * holder
Definition: oleobj.c:82
#define S_OK
Definition: intsafe.h:59
DWORD num_of_elems
Definition: oleobj.c:80
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ FTMarshalCF_Create()

HRESULT FTMarshalCF_Create ( REFIID  riid,
LPVOID ppv 
)

Definition at line 413 of file ftmarshal.c.

Referenced by CoGetClassObject().

414 {
415  return IClassFactory_QueryInterface((IClassFactory *)&FTMarshalCF, riid, ppv);
416 }
REFIID riid
Definition: precomp.h:44
static const IClassFactoryVtbl * FTMarshalCF
Definition: ftmarshal.c:411

◆ get_std_git()

IGlobalInterfaceTable* get_std_git ( void  )

Definition at line 360 of file git.c.

Referenced by CoCreateInstanceEx(), and GITCF_CreateInstance().

361 {
362  if (!std_git)
363  {
365 
366  newGIT = HeapAlloc(GetProcessHeap(), 0, sizeof(StdGlobalInterfaceTableImpl));
367  if (!newGIT) return NULL;
368 
370  list_init(&newGIT->list);
371  newGIT->nextCookie = 0xf100; /* that's where windows starts, so that's where we start */
372 
374  {
375  HeapFree(GetProcessHeap(), 0, newGIT);
376  }
377  else
378  TRACE("Created the GIT at %p\n", newGIT);
379  }
380 
381  return std_git;
382 }
static IGlobalInterfaceTable * std_git
Definition: git.c:72
IGlobalInterfaceTable IGlobalInterfaceTable_iface
Definition: git.c:65
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct list list
Definition: git.c:67
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
static const IGlobalInterfaceTableVtbl StdGlobalInterfaceTableImpl_Vtbl
Definition: git.c:350
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ get_stub_manager()

struct stub_manager* get_stub_manager ( APARTMENT apt,
OID  oid 
)

Definition at line 380 of file stubmanager.c.

Referenced by StdMarshalImpl_ReleaseMarshalData(), and StdMarshalImpl_UnmarshalInterface().

381 {
382  struct stub_manager *result = NULL;
383  struct list *cursor;
384 
385  EnterCriticalSection(&apt->cs);
386  LIST_FOR_EACH( cursor, &apt->stubmgrs )
387  {
388  struct stub_manager *m = LIST_ENTRY( cursor, struct stub_manager, entry );
389 
390  if (m->oid == oid)
391  {
392  result = m;
393  stub_manager_int_addref(result);
394  break;
395  }
396  }
397  LeaveCriticalSection(&apt->cs);
398 
399  if (result)
400  TRACE("found %p for oid %s\n", result, wine_dbgstr_longlong(oid));
401  else
402  TRACE("not found for oid %s\n", wine_dbgstr_longlong(oid));
403 
404  return result;
405 }
uint8_t entry
Definition: isohybrid.c:63
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
Definition: _list.h:228
const GLfloat * m
Definition: glext.h:10848
static ULONG stub_manager_int_addref(struct stub_manager *This)
Definition: stubmanager.c:297
const char cursor[]
Definition: icontest.c:13
CONST GLfloat m[16]
Definition: m_xform.h:144
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
struct list stubmgrs
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
CRITICAL_SECTION cs
GLuint64EXT * result
Definition: glext.h:11304

◆ get_stub_manager_from_object()

struct stub_manager* get_stub_manager_from_object ( APARTMENT apt,
IUnknown object,
BOOL  alloc 
)

Definition at line 337 of file stubmanager.c.

Referenced by CoDisconnectObject(), CoLockObjectExternal(), and marshal_object().

338 {
339  struct stub_manager *result = NULL;
340  struct list *cursor;
341  IUnknown *object;
342  HRESULT hres;
343 
344  hres = IUnknown_QueryInterface(obj, &IID_IUnknown, (void**)&object);
345  if (FAILED(hres)) {
346  ERR("QueryInterface(IID_IUnknown failed): %08x\n", hres);
347  return NULL;
348  }
349 
350  EnterCriticalSection(&apt->cs);
351  LIST_FOR_EACH( cursor, &apt->stubmgrs )
352  {
353  struct stub_manager *m = LIST_ENTRY( cursor, struct stub_manager, entry );
354 
355  if (m->object == object)
356  {
357  result = m;
358  stub_manager_int_addref(result);
359  break;
360  }
361  }
362  LeaveCriticalSection(&apt->cs);
363 
364  if (result) {
365  TRACE("found %p for object %p\n", result, object);
366  }else if (alloc) {
367  TRACE("not found, creating new stub manager...\n");
368  result = new_stub_manager(apt, object);
369  }else {
370  TRACE("not found for object %p\n", object);
371  }
372 
373  IUnknown_Release(object);
374  return result;
375 }
uint8_t entry
Definition: isohybrid.c:63
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static struct stub_manager * new_stub_manager(APARTMENT *apt, IUnknown *object)
Definition: stubmanager.c:180
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
Definition: _list.h:228
#define ERR(fmt,...)
Definition: debug.h:109
const GLfloat * m
Definition: glext.h:10848
static ULONG stub_manager_int_addref(struct stub_manager *This)
Definition: stubmanager.c:297
IUnknown * object
const char cursor[]
Definition: icontest.c:13
#define alloc
Definition: rosglue.h:13
CONST GLfloat m[16]
Definition: m_xform.h:144
struct list stubmgrs
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
CRITICAL_SECTION cs
GLuint64EXT * result
Definition: glext.h:11304
void * object
Definition: jmemsys.h:48

◆ GlobalOptions_CreateInstance()

HRESULT WINAPI GlobalOptions_CreateInstance ( IClassFactory iface,
IUnknown pUnk,
REFIID  riid,
void **  ppv 
)

Definition at line 5243 of file compobj.c.

5244 {
5246  HRESULT hres;
5247 
5248  TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
5249 
5250  if (outer)
5251  return E_INVALIDARG;
5252 
5253  global_options = heap_alloc(sizeof(*global_options));
5254  if (!global_options)
5255  return E_OUTOFMEMORY;
5256  global_options->IGlobalOptions_iface.lpVtbl = &GlobalOptionsVtbl;
5257  global_options->ref = 1;
5258 
5259  hres = IGlobalOptions_QueryInterface(&global_options->IGlobalOptions_iface, riid, ppv);
5260  IGlobalOptions_Release(&global_options->IGlobalOptions_iface);
5261  return hres;
5262 }
REFIID riid
Definition: precomp.h:44
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static const struct optioninfo global_options[]
Definition: adh-opts.c:43
static const IGlobalOptionsVtbl GlobalOptionsVtbl
Definition: compobj.c:5235
IGlobalOptions IGlobalOptions_iface
Definition: compobj.c:5169

◆ Handler_DllGetClassObject()

HRESULT Handler_DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 5079 of file compobj.c.

Referenced by DllGetClassObject().

5080 {
5081  static const WCHAR wszInprocHandler32[] = {'I','n','p','r','o','c','H','a','n','d','l','e','r','3','2',0};
5082  HKEY hkey;
5083  HRESULT hres;
5084 
5085  hres = COM_OpenKeyForCLSID(rclsid, wszInprocHandler32, KEY_READ, &hkey);
5086  if (SUCCEEDED(hres))
5087  {
5088  struct class_reg_data regdata;
5089  WCHAR dllpath[MAX_PATH+1];
5090 
5091  regdata.u.hkey = hkey;
5092  regdata.hkey = TRUE;
5093 
5094  if (COM_RegReadPath(&regdata, dllpath, ARRAYSIZE(dllpath)) == ERROR_SUCCESS)
5095  {
5096  static const WCHAR wszOle32[] = {'o','l','e','3','2','.','d','l','l',0};
5097  if (!strcmpiW(dllpath, wszOle32))
5098  {
5099  RegCloseKey(hkey);
5100  return HandlerCF_Create(rclsid, riid, ppv);
5101  }
5102  }
5103  else
5104  WARN("not creating object for inproc handler path %s\n", debugstr_w(dllpath));
5105  RegCloseKey(hkey);
5106  }
5107 
5109 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static DWORD COM_RegReadPath(const struct class_reg_data *regdata, WCHAR *dst, DWORD dstlen)
Definition: compobj.c:1420
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define debugstr_w
Definition: kernel32.h:32
HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *subkey)
Definition: compobj.c:2360
HRESULT hres
Definition: protocol.c:465
WCHAR dllpath[MAX_PATH]
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
#define ARRAYSIZE(array)
Definition: compobj.c:75
HRESULT HandlerCF_Create(REFCLSID rclsid, REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ HandlerCF_Create()

HRESULT HandlerCF_Create ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 2359 of file defaulthandler.c.

Referenced by Handler_DllGetClassObject().

2360 {
2361  HRESULT hr;
2362  HandlerCF *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
2363  if (!This) return E_OUTOFMEMORY;
2365  This->refs = 0;
2366  This->clsid = *rclsid;
2367 
2368  hr = IClassFactory_QueryInterface(&This->IClassFactory_iface, riid, ppv);
2369  if (FAILED(hr))
2370  HeapFree(GetProcessHeap(), 0, This);
2371 
2372  return hr;
2373 }
REFIID riid
Definition: precomp.h:44
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const IClassFactoryVtbl HandlerClassFactoryVtbl
IClassFactory IClassFactory_iface
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ ipid_get_dispatch_params()

HRESULT ipid_get_dispatch_params ( const IPID *  ipid,
APARTMENT **  stub_apt,
struct stub_manager **  manager,
IRpcStubBuffer **  stub,
IRpcChannelBuffer **  chan,
IID iid,
IUnknown **  iface 
)

Definition at line 533 of file stubmanager.c.

Referenced by ClientRpcChannelBuffer_GetBuffer(), and dispatch_rpc().

537 {
538  struct stub_manager *stubmgr;
539  struct ifstub *ifstub;
540  APARTMENT *apt;
541  HRESULT hr;
542 
543  hr = ipid_to_ifstub(ipid, &apt, &stubmgr, &ifstub);
544  if (hr != S_OK) return RPC_E_DISCONNECTED;
545 
546  *stub = ifstub->stubbuffer;
547  IRpcStubBuffer_AddRef(*stub);
548  *chan = ifstub->chan;
549  IRpcChannelBuffer_AddRef(*chan);
550  *stub_apt = apt;
551  *iid = ifstub->iid;
552  *iface = ifstub->iface;
553 
554  if (manager)
555  *manager = stubmgr;
556  else
557  stub_manager_int_release(stubmgr);
558  return S_OK;
559 }
IUnknown * iface
IRpcChannelBuffer * chan
IRpcStubBuffer * stubbuffer
LONG HRESULT
Definition: typedefs.h:77
#define RPC_E_DISCONNECTED
Definition: winerror.h:2484
static HRESULT ipid_to_ifstub(const IPID *ipid, APARTMENT **stub_apt, struct stub_manager **stubmgr_ret, struct ifstub **ifstub)
Definition: stubmanager.c:501
#define S_OK
Definition: intsafe.h:59
ULONG stub_manager_int_release(struct stub_manager *This)
Definition: stubmanager.c:311

◆ leave_apartment()

void leave_apartment ( struct oletls info)

Definition at line 1873 of file compobj.c.

Referenced by apartment_getoxid(), CoUninitialize(), and dispatch_rpc().

1874 {
1875  if (!--info->inits)
1876  {
1877  if (info->ole_inits)
1878  WARN( "Uninitializing apartment while Ole is still initialized\n" );
1879  apartment_release( info->apt );
1880  info->apt = NULL;
1881  }
1882 }
DWORD apartment_release(struct apartment *apt)
Definition: compobj.c:1175
#define WARN(fmt,...)
Definition: debug.h:111
DWORD ole_inits
struct apartment * apt
smooth NULL
Definition: ftsmooth.c:416
DWORD inits

◆ MARSHAL_GetStandardMarshalCF()

HRESULT MARSHAL_GetStandardMarshalCF ( LPVOID ppv)

Definition at line 2050 of file marshal.c.

Referenced by DllGetClassObject().

2051 {
2052  *ppv = &StdMarshalCF;
2053  return S_OK;
2054 }
static const IClassFactoryVtbl * StdMarshalCF
Definition: marshal.c:2048
#define S_OK
Definition: intsafe.h:59

◆ marshal_object()

HRESULT marshal_object ( APARTMENT apt,
STDOBJREF *  stdobjref,
REFIID  riid,
IUnknown obj,
DWORD  dest_context,
void dest_context_data,
MSHLFLAGS  mshlflags 
)

Definition at line 124 of file marshal.c.

Referenced by RemUnknown_RemQueryInterface(), start_apartment_remote_unknown(), and StdMarshalImpl_MarshalInterface().

126 {
127  struct stub_manager *manager;
128  struct ifstub *ifstub;
129  BOOL tablemarshal;
130  HRESULT hr;
131 
132  hr = apartment_getoxid(apt, &stdobjref->oxid);
133  if (hr != S_OK)
134  return hr;
135 
137  if (hr != S_OK)
138  return hr;
139 
140  if (!(manager = get_stub_manager_from_object(apt, object, TRUE)))
141  return E_OUTOFMEMORY;
142 
143  stdobjref->flags = SORF_NULL;
144  if (mshlflags & MSHLFLAGS_TABLEWEAK)
145  stdobjref->flags |= SORFP_TABLEWEAK;
146  if (mshlflags & MSHLFLAGS_NOPING)
147  stdobjref->flags |= SORF_NOPING;
148  stdobjref->oid = manager->oid;
149 
150  tablemarshal = ((mshlflags & MSHLFLAGS_TABLESTRONG) || (mshlflags & MSHLFLAGS_TABLEWEAK));
151 
152  /* make sure ifstub that we are creating is unique */
153  ifstub = stub_manager_find_ifstub(manager, riid, mshlflags);
154  if (!ifstub) {
156 
157  /* IUnknown doesn't require a stub buffer, because it never goes out on
158  * the wire */
159  if (!IsEqualIID(riid, &IID_IUnknown))
160  {
161  IPSFactoryBuffer *psfb;
162 
163  hr = get_facbuf_for_iid(riid, &psfb);
164  if (hr == S_OK) {
165  hr = IPSFactoryBuffer_CreateStub(psfb, riid, manager->object, &stub);
166  IPSFactoryBuffer_Release(psfb);
167  if (hr != S_OK)
168  ERR("Failed to create an IRpcStubBuffer from IPSFactory for %s with error 0x%08x\n",
169  debugstr_guid(riid), hr);
170  }else {
171  ERR("couldn't get IPSFactory buffer for interface %s\n", debugstr_guid(riid));
172  hr = E_NOINTERFACE;
173  }
174 
175  }
176 
177  if (hr == S_OK) {
178  ifstub = stub_manager_new_ifstub(manager, stub, riid, dest_context, dest_context_data, mshlflags);
179  if (!ifstub)
180  hr = E_OUTOFMEMORY;
181  }
182  if (stub) IRpcStubBuffer_Release(stub);
183 
184  if (hr != S_OK) {
185  stub_manager_int_release(manager);
186  /* destroy the stub manager if it has no ifstubs by releasing
187  * zero external references */
188  stub_manager_ext_release(manager, 0, FALSE, TRUE);
189  return hr;
190  }
191  }
192 
193  if (!tablemarshal)
194  {
195  stdobjref->cPublicRefs = NORMALEXTREFS;
196  stub_manager_ext_addref(manager, stdobjref->cPublicRefs, FALSE);
197  }
198  else
199  {
200  stdobjref->cPublicRefs = 0;
201  if (mshlflags & MSHLFLAGS_TABLESTRONG)
202  stub_manager_ext_addref(manager, 1, FALSE);
203  else
204  stub_manager_ext_addref(manager, 0, TRUE);
205  }
206 
207  /* FIXME: check return value */
209 
210  stdobjref->ipid = ifstub->ipid;
211 
212  stub_manager_int_release(manager);
213  return S_OK;
214 }
struct ifstub * stub_manager_new_ifstub(struct stub_manager *m, IRpcStubBuffer *sb, REFIID iid, DWORD dest_context, void *dest_context_data, MSHLFLAGS flags) DECLSPEC_HIDDEN
Definition: stubmanager.c:70
struct ifstub * stub_manager_find_ifstub(struct stub_manager *m, REFIID iid, MSHLFLAGS flags) DECLSPEC_HIDDEN
Definition: stubmanager.c:158
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT apartment_createwindowifneeded(struct apartment *apt)
Definition: compobj.c:1710
static HRESULT apartment_getoxid(const struct apartment *apt, OXID *oxid)
REFIID riid
Definition: precomp.h:44
ULONG stub_manager_int_release(struct stub_manager *This) DECLSPEC_HIDDEN
Definition: stubmanager.c:311
Definition: stubgen.c:11
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
ULONG stub_manager_ext_addref(struct stub_manager *m, ULONG refs, BOOL tableweak) DECLSPEC_HIDDEN
Definition: stubmanager.c:408
#define debugstr_guid
Definition: kernel32.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
HRESULT RPC_RegisterInterface(REFIID riid) DECLSPEC_HIDDEN
Definition: rpc.c:1532
#define NORMALEXTREFS
Definition: marshal.c:46
#define ERR(fmt,...)
Definition: debug.h:109
ULONG stub_manager_ext_release(struct stub_manager *m, ULONG refs, BOOL tableweak, BOOL last_unlock_releases) DECLSPEC_HIDDEN
Definition: stubmanager.c:439
#define S_OK
Definition: intsafe.h:59
IUnknown * object
static HRESULT get_facbuf_for_iid(REFIID riid, IPSFactoryBuffer **facbuf)
Definition: marshal.c:111
struct stub_manager * get_stub_manager_from_object(APARTMENT *apt, IUnknown *object, BOOL alloc) DECLSPEC_HIDDEN
Definition: stubmanager.c:337
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
#define SORFP_TABLEWEAK
Definition: marshal.c:50

◆ OLE32_DllGetClassObject()

HRESULT WINAPI OLE32_DllGetClassObject ( REFCLSID  rclsid,
REFIID  iid,
LPVOID ppv 
)

Referenced by DllGetClassObject().

◆ OLE32_DllRegisterServer()

HRESULT WINAPI OLE32_DllRegisterServer ( void  )

Referenced by DllRegisterServer().

◆ OLE32_DllUnregisterServer()

HRESULT WINAPI OLE32_DllUnregisterServer ( void  )

Referenced by DllUnregisterServer().

◆ OLEDD_UnInitialize()

void OLEDD_UnInitialize ( void  )

◆ open_classes_key()

LSTATUS open_classes_key ( HKEY  ,
const WCHAR ,
REGSAM  ,
HKEY  
)

Definition at line 425 of file compobj.c.

Referenced by CATIDEnumGUID_Clone(), CATIDEnumGUID_Construct(), clsid_from_string_reg(), CLSIDEnumGUID_Clone(), CLSIDEnumGUID_Construct(), CLSIDEnumGUID_Next(), COM_OpenKeyForAppIdFromCLSID(), COM_OpenKeyForCLSID(), COMCAT_ICatInformation_GetCategoryDesc(), COMCAT_ICatInformation_IsClassOfCategories(), COMCAT_ICatRegister_UnRegisterCategories(), COMCAT_IEnumCATEGORYINFO_Clone(), COMCAT_IEnumCATEGORYINFO_Next(), COMCAT_IsClassOfCategories(), COMCAT_UnRegisterClassCategories(), EnumCATEGORYINFO_Construct(), get_ps_clsid_from_registry(), OLECONVERT_CreateCompObjStream(), and OleRegGetMiscStatus().

426 {
429 
430  if (!(hkey = get_classes_root_hkey( hkey, access ))) return ERROR_INVALID_HANDLE;
431 
432  attr.Length = sizeof(attr);
433  attr.RootDirectory = hkey;
434  attr.ObjectName = &nameW;
435  attr.Attributes = 0;
436  attr.SecurityDescriptor = NULL;
438  RtlInitUnicodeString( &nameW, name );
439 
440  return RtlNtStatusToDosError( NtOpenKey( (HANDLE *)retkey, access, &attr ) );
441 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HKEY get_classes_root_hkey(HKEY hkey, REGSAM access)
Definition: compobj.c:386
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR nameW[]
Definition: main.c:46
__u8 attr
Definition: mkdosfs.c:359
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
PVOID SecurityDescriptor
Definition: umtypes.h:187
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
PVOID SecurityQualityOfService
Definition: umtypes.h:188
Definition: name.c:36
PUNICODE_STRING ObjectName
Definition: umtypes.h:185
HANDLE RootDirectory
Definition: umtypes.h:184
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

◆ release_std_git()

void release_std_git ( void  )

Definition at line 384 of file git.c.

Referenced by DllMain().

385 {
387  StdGITEntry *entry, *entry2;
388 
389  if (!std_git) return;
390 
392  LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &git->list, StdGITEntry, entry)
393  {
394  list_remove(&entry->entry);
395 
397  IStream_Release(entry->stream);
398  HeapFree(GetProcessHeap(), 0, entry);
399  }
400 
401  HeapFree(GetProcessHeap(), 0, git);
402 }
HRESULT WINAPI CoReleaseMarshalData(IStream *pStream)
Definition: marshal.c:1907
static IGlobalInterfaceTable * std_git
Definition: git.c:72
uint8_t entry
Definition: isohybrid.c:63
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define GetProcessHeap()
Definition: compat.h:395
struct list entry
Definition: git.c:59
IStream * stream
Definition: git.c:57
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct list list
Definition: git.c:67
#define HeapFree(x, y, z)
Definition: compat.h:394
static StdGlobalInterfaceTableImpl * impl_from_IGlobalInterfaceTable(IGlobalInterfaceTable *iface)
Definition: git.c:84

◆ RPC_CreateClientChannel()

HRESULT RPC_CreateClientChannel ( const OXID *  oxid,
const IPID *  ipid,
const OXID_INFO *  oxid_info,
DWORD  dest_context,
void dest_context_data,
IRpcChannelBuffer **  chan,
APARTMENT apt 
)

Definition at line 1098 of file rpc.c.

Referenced by unmarshal_object().

1102 {
1104  WCHAR endpoint[200];
1107  LPWSTR string_binding;
1108 
1109  /* FIXME: get the endpoint from oxid_info->psa instead */
1110  get_rpc_endpoint(endpoint, oxid);
1111 
1112  TRACE("proxy pipe: connecting to endpoint: %s\n", debugstr_w(endpoint));
1113 
1114  status = RpcStringBindingComposeW(
1115  NULL,
1117  NULL,
1118  endpoint,
1119  NULL,
1120  &string_binding);
1121 
1122  if (status == RPC_S_OK)
1123  {
1124  status = RpcBindingFromStringBindingW(string_binding, &bind);
1125 
1126  if (status == RPC_S_OK)
1127  {
1128  IPID ipid2 = *ipid; /* why can't RpcBindingSetObject take a const? */
1129  status = RpcBindingSetObject(bind, &ipid2);
1130  if (status != RPC_S_OK)
1131  RpcBindingFree(&bind);
1132  }
1133 
1134  RpcStringFreeW(&string_binding);
1135  }
1136 
1137  if (status != RPC_S_OK)
1138  {
1139  ERR("Couldn't get binding for endpoint %s, status = %d\n", debugstr_w(endpoint), status);
1140  return HRESULT_FROM_WIN32(status);
1141  }
1142 
1143  This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
1144  if (!This)
1145  {
1146  RpcBindingFree(&bind);
1147  return E_OUTOFMEMORY;
1148  }
1149 
1151  This->super.refs = 1;
1152  This->super.dest_context = dest_context;
1153  This->super.dest_context_data = dest_context_data;
1154  This->bind = bind;
1155  apartment_getoxid(apt, &This->oxid);
1156  This->server_pid = oxid_info->dwPid;
1157  This->event = NULL;
1158 
1159  *chan = &This->super.IRpcChannelBuffer_iface;
1160 
1161  return S_OK;
1162 }
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:877
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:784
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
static HRESULT apartment_getoxid(const struct apartment *apt, OXID *oxid)
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:177
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
LONG refs
Definition: rpc.c:98
RPC_STATUS WINAPI RpcStringBindingComposeW(RPC_WSTR ObjUuid, RPC_WSTR Protseq, RPC_WSTR NetworkAddr, RPC_WSTR Endpoint, RPC_WSTR Options, RPC_WSTR *StringBinding)
Definition: rpc_binding.c:511
IRpcChannelBuffer IRpcChannelBuffer_iface
Definition: rpc.c:97
long RPC_STATUS
Definition: rpc.h:52
static void get_rpc_endpoint(LPWSTR endpoint, const OXID *oxid)
Definition: rpc.c:88
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
RPC_BINDING_HANDLE bind
Definition: rpc.c:108
smooth NULL
Definition: ftsmooth.c:416
void * dest_context_data
Definition: rpc.c:101
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
RpcChannelBuffer super
Definition: rpc.c:106
RPC_STATUS WINAPI RpcBindingSetObject(RPC_BINDING_HANDLE Binding, UUID *ObjectUuid)
Definition: rpc_binding.c:825
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
Definition: nis.h:10
static const IRpcChannelBufferVtbl ClientRpcChannelBufferVtbl
Definition: rpc.c:1073
DWORD dest_context
Definition: rpc.c:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
static WCHAR wszRpcTransport[]
Definition: rpc.c:77

◆ RPC_CreateServerChannel()

HRESULT RPC_CreateServerChannel ( DWORD  dest_context,
void dest_context_data,
IRpcChannelBuffer **  chan 
)

Definition at line 1164 of file rpc.c.

Referenced by stub_manager_new_ifstub().

1165 {
1166  RpcChannelBuffer *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
1167  if (!This)
1168  return E_OUTOFMEMORY;
1169 
1171  This->refs = 1;
1172  This->dest_context = dest_context;
1173  This->dest_context_data = dest_context_data;
1174 
1175  *chan = &This->IRpcChannelBuffer_iface;
1176 
1177  return S_OK;
1178 }
LONG refs
Definition: rpc.c:98
IRpcChannelBuffer IRpcChannelBuffer_iface
Definition: rpc.c:97
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
void * dest_context_data
Definition: rpc.c:101
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59
static const IRpcChannelBufferVtbl ServerRpcChannelBufferVtbl
Definition: rpc.c:1085
DWORD dest_context
Definition: rpc.c:100

◆ RPC_ExecuteCall()

void RPC_ExecuteCall ( struct dispatch_params params)

Definition at line 1329 of file rpc.c.

Referenced by apartment_wndproc(), and dispatch_rpc().

1330 {
1331  struct message_state *message_state = NULL;
1332  RPC_MESSAGE *msg = (RPC_MESSAGE *)params->msg;
1333  char *original_buffer = msg->Buffer;
1334  ORPCTHIS orpcthis;
1335  ORPC_EXTENT_ARRAY orpc_ext_array;
1336  WIRE_ORPC_EXTENT *first_wire_orpc_extent;
1337  GUID old_causality_id;
1338 
1339  /* handle ORPCTHIS and server extensions */
1340 
1341  params->hr = unmarshal_ORPCTHIS(msg, &orpcthis, &orpc_ext_array, &first_wire_orpc_extent);
1342  if (params->hr != S_OK)
1343  {
1344  msg->Buffer = original_buffer;
1345  goto exit;
1346  }
1347 
1348  message_state = HeapAlloc(GetProcessHeap(), 0, sizeof(*message_state));
1349  if (!message_state)
1350  {
1351  params->hr = E_OUTOFMEMORY;
1352  msg->Buffer = original_buffer;
1353  goto exit;
1354  }
1355 
1356  message_state->prefix_data_len = (char *)msg->Buffer - original_buffer;
1357  message_state->binding_handle = msg->Handle;
1358  message_state->bypass_rpcrt = params->bypass_rpcrt;
1359 
1360  message_state->channel_hook_info.iid = params->iid;
1361  message_state->channel_hook_info.cbSize = sizeof(message_state->channel_hook_info);
1362  message_state->channel_hook_info.uCausality = orpcthis.cid;
1363  message_state->channel_hook_info.dwServerPid = GetCurrentProcessId();
1364  message_state->channel_hook_info.iMethod = msg->ProcNum;
1365  message_state->channel_hook_info.pObject = params->iface;
1366 
1367  if (orpcthis.extensions && first_wire_orpc_extent &&
1368  orpcthis.extensions->size)
1369  ChannelHooks_ServerNotify(&message_state->channel_hook_info, msg->DataRepresentation, first_wire_orpc_extent, orpcthis.extensions->size);
1370 
1371  msg->Handle = message_state;
1372  msg->BufferLength -= message_state->prefix_data_len;
1373 
1374  /* call message filter */
1375 
1376  if (COM_CurrentApt()->filter)
1377  {
1378  DWORD handlecall;
1379  INTERFACEINFO interface_info;
1380  CALLTYPE calltype;
1381 
1382  interface_info.pUnk = params->iface;
1383  interface_info.iid = params->iid;
1384  interface_info.wMethod = msg->ProcNum;
1385 
1386  if (IsEqualGUID(&orpcthis.cid, &COM_CurrentInfo()->causality_id))
1387  calltype = CALLTYPE_NESTED;
1388  else if (COM_CurrentInfo()->pending_call_count_server == 0)
1389  calltype = CALLTYPE_TOPLEVEL;
1390  else
1391  calltype = CALLTYPE_TOPLEVEL_CALLPENDING;
1392 
1393  handlecall = IMessageFilter_HandleInComingCall(COM_CurrentApt()->filter,
1394  calltype,
1396  0 /* FIXME */,
1397  &interface_info);
1398  TRACE("IMessageFilter_HandleInComingCall returned %d\n", handlecall);
1399  switch (handlecall)
1400  {
1401  case SERVERCALL_REJECTED:
1402  params->hr = RPC_E_CALL_REJECTED;
1403  goto exit_reset_state;
1404  case SERVERCALL_RETRYLATER:
1405 #if 0 /* FIXME: handle retries on the client side before enabling this code */
1406  params->hr = RPC_E_RETRY;
1407  goto exit_reset_state;
1408 #else
1409  FIXME("retry call later not implemented\n");
1410  break;
1411 #endif
1412  case SERVERCALL_ISHANDLED:
1413  default:
1414  break;
1415  }
1416  }
1417 
1418  /* invoke the method */
1419 
1420  /* save the old causality ID - note: any calls executed while processing
1421  * messages received during the SendReceive will appear to originate from
1422  * this call - this should be checked with what Windows does */
1423  old_causality_id = COM_CurrentInfo()->causality_id;
1424  COM_CurrentInfo()->causality_id = orpcthis.cid;
1425  COM_CurrentInfo()->pending_call_count_server++;
1426  params->hr = IRpcStubBuffer_Invoke(params->stub, params->msg, params->chan);
1427  COM_CurrentInfo()->pending_call_count_server--;
1428  COM_CurrentInfo()->causality_id = old_causality_id;
1429 
1430  /* the invoke allocated a new buffer, so free the old one */
1431  if (message_state->bypass_rpcrt && original_buffer != msg->Buffer)
1432  HeapFree(GetProcessHeap(), 0, original_buffer);
1433 
1434 exit_reset_state:
1435  message_state = msg->Handle;
1436  msg->Handle = message_state->binding_handle;
1437  msg->Buffer = (char *)msg->Buffer - message_state->prefix_data_len;
1438  msg->BufferLength += message_state->prefix_data_len;
1439 
1440 exit:
1441  HeapFree(GetProcessHeap(), 0, message_state);
1442  if (params->handle) SetEvent(params->handle);
1443 }
IUnknown * iface
Definition: rpc.c:120
static void ChannelHooks_ServerNotify(SChannelHookCallInfo *info, DWORD lDataRep, WIRE_ORPC_EXTENT *first_wire_orpc_extent, ULONG extension_count)
Definition: rpc.c:277
RPC_BINDING_HANDLE binding_handle
Definition: rpc.c:129
SChannelHookCallInfo channel_hook_info
Definition: rpc.c:131
IRpcChannelBuffer * chan
Definition: rpc.c:118
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
RPCOLEMESSAGE * msg
Definition: rpc.c:116
static struct oletls * COM_CurrentInfo(void)
static APARTMENT * COM_CurrentApt(void)
unsigned int BufferLength
Definition: rpcdcep.h:41
void * Buffer
Definition: rpcdcep.h:40
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned int ProcNum
Definition: rpcdcep.h:42
UINT msg
Definition: msvc.h:92
smooth NULL
Definition: ftsmooth.c:416
HANDLE handle
Definition: rpc.c:121
BOOL bypass_rpcrt
Definition: rpc.c:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
ULONG prefix_data_len
Definition: rpc.c:130
#define UlongToHandle(ul)
Definition: basetsd.h:97
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RPC_E_CALL_REJECTED
Definition: winerror.h:2458
#define S_OK
Definition: intsafe.h:59
static HRESULT unmarshal_ORPCTHIS(RPC_MESSAGE *msg, ORPCTHIS *orpcthis, ORPC_EXTENT_ARRAY *orpc_ext_array, WIRE_ORPC_EXTENT **first_wire_orpc_extent)
Definition: rpc.c:1235
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4024
BOOL bypass_rpcrt
Definition: rpc.c:122
#define RPC_E_RETRY
Definition: winerror.h:2485
HRESULT hr
Definition: rpc.c:124
void exit(int exitcode)
Definition: _exit.c:33
IRpcStubBuffer * stub
Definition: rpc.c:117
ULONG DataRepresentation
Definition: rpcdcep.h:39
RPC_BINDING_HANDLE Handle
Definition: rpcdcep.h:38
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define HeapFree(x, y, z)
Definition: compat.h:394
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1188

◆ RPC_GetLocalClassObject()

HRESULT RPC_GetLocalClassObject ( REFCLSID  rclsid,
REFIID  iid,
LPVOID ppv 
)

Definition at line 1806 of file rpc.c.

Referenced by CoGetClassObject().

1807 {
1808  HRESULT hres;
1809  HANDLE hPipe;
1810  WCHAR pipefn[100];
1811  DWORD res, bufferlen;
1812  char marshalbuffer[200];
1813  IStream *pStm;
1815  ULARGE_INTEGER newpos;
1816  int tries = 0;
1818 
1819  static const int MAXTRIES = 30; /* 30 seconds */
1820 
1821  TRACE("rclsid=%s, iid=%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
1822 
1823  get_localserver_pipe_name(pipefn, rclsid);
1824 
1825  while (tries++ < MAXTRIES) {
1826  TRACE("waiting for %s\n", debugstr_w(pipefn));
1827 
1829  hPipe = CreateFileW(pipefn, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
1830  if (hPipe == INVALID_HANDLE_VALUE) {
1831  DWORD index;
1832  DWORD start_ticks;
1833  HANDLE process = 0;
1834  if (tries == 1) {
1835  if ( (hres = create_local_service(rclsid)) &&
1836  (hres = create_server(rclsid, &process)) )
1837  return hres;
1838  } else {
1839  WARN("Connecting to %s, no response yet, retrying: le is %u\n", debugstr_w(pipefn), GetLastError());
1840  }
1841  /* wait for one second, even if messages arrive */
1842  start_ticks = GetTickCount();
1843  do {
1844  if (SUCCEEDED(CoWaitForMultipleHandles(0, 1000, (process != 0),
1845  &process, &index)) && process && !index)
1846  {
1847  WARN( "server for %s failed to start\n", debugstr_guid(rclsid) );
1848  CloseHandle( hPipe );
1849  CloseHandle( process );
1850  return E_NOINTERFACE;
1851  }
1852  } while (GetTickCount() - start_ticks < 1000);
1853  if (process) CloseHandle( process );
1854  continue;
1855  }
1856  bufferlen = 0;
1857  if (!ReadFile(hPipe,marshalbuffer,sizeof(marshalbuffer),&bufferlen,NULL)) {
1858  FIXME("Failed to read marshal id from classfactory of %s.\n",debugstr_guid(rclsid));
1859  CloseHandle(hPipe);
1860  Sleep(1000);
1861  continue;
1862  }
1863  TRACE("read marshal id from pipe\n");
1864  CloseHandle(hPipe);
1865  break;
1866  }
1867 
1868  if (tries >= MAXTRIES)
1869  return E_NOINTERFACE;
1870 
1871  hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
1872  if (hres != S_OK) return hres;
1873  hres = IStream_Write(pStm,marshalbuffer,bufferlen,&res);
1874  if (hres != S_OK) goto out;
1875  seekto.u.LowPart = 0;seekto.u.HighPart = 0;
1876  hres = IStream_Seek(pStm,seekto,STREAM_SEEK_SET,&newpos);
1877 
1878  TRACE("unmarshalling local server\n");
1879  hres = CoUnmarshalInterface(pStm, &IID_IServiceProvider, (void**)&local_server);
1880  if(SUCCEEDED(hres))
1881  hres = IServiceProvider_QueryService(local_server, rclsid, iid, ppv);
1882  IServiceProvider_Release(local_server);
1883 out:
1884  IStream_Release(pStm);
1885  return hres;
1886 }
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1838
struct _LARGE_INTEGER::@2193 u
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define E_NOINTERFACE
Definition: winerror.h:2364
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WARN(fmt,...)
Definition: debug.h:111
BOOL WINAPI WaitNamedPipeW(LPCWSTR lpNamedPipeName, DWORD nTimeOut)
Definition: npipe.c:458
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
static LONG bufferlen
Definition: sync.c:1600
static HRESULT create_server(REFCLSID rclsid, HANDLE *process)
Definition: rpc.c:1655
static LPSTR local_server
Definition: info.c:89
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
#define NMPWAIT_WAIT_FOREVER
Definition: winbase.h:133
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define OPEN_EXISTING
Definition: compat.h:426
HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout, ULONG cHandles, LPHANDLE pHandles, LPDWORD lpdwindex)
Definition: compobj.c:4490
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29
#define seekto(pos, errstr)
Definition: mkdosfs.c:1613
#define GENERIC_READ
Definition: compat.h:124
#define S_OK
Definition: intsafe.h:59
static HRESULT create_local_service(REFCLSID rclsid)
Definition: rpc.c:1743
#define CreateFileW
Definition: compat.h:400
GLuint res
Definition: glext.h:9613
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static void get_localserver_pipe_name(WCHAR *pipefn, REFCLSID rclsid)
Definition: rpc.c:1798

◆ RPC_RegisterChannelHook()

HRESULT RPC_RegisterChannelHook ( REFGUID  rguid,
IChannelHook hook 
)

Definition at line 427 of file rpc.c.

Referenced by CoRegisterChannelHook().

428 {
429  struct channel_hook_entry *entry;
430 
431  TRACE("(%s, %p)\n", debugstr_guid(rguid), hook);
432 
433  entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
434  if (!entry)
435  return E_OUTOFMEMORY;
436 
437  entry->id = *rguid;
438  entry->hook = hook;
439  IChannelHook_AddRef(hook);
440 
442  list_add_tail(&channel_hooks, &entry->entry);
444 
445  return S_OK;
446 }
uint8_t entry
Definition: isohybrid.c:63
static CRITICAL_SECTION csChannelHook
Definition: rpc.c:68
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static struct list channel_hooks
Definition: rpc.c:67
IChannelHook * hook
Definition: rpc.c:174
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
struct list entry
Definition: rpc.c:172
#define debugstr_guid
Definition: kernel32.h:35
Definition: msg.h:42
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
Definition: rpc.c:170
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
GUID id
Definition: rpc.c:173

◆ RPC_RegisterInterface()

HRESULT RPC_RegisterInterface ( REFIID  riid)

Definition at line 1532 of file rpc.c.

Referenced by marshal_object().

1533 {
1534  struct registered_if *rif;
1535  BOOL found = FALSE;
1536  HRESULT hr = S_OK;
1537 
1538  TRACE("(%s)\n", debugstr_guid(riid));
1539 
1542  {
1544  {
1545  rif->refs++;
1546  found = TRUE;
1547  break;
1548  }
1549  }
1550  if (!found)
1551  {
1552  TRACE("Creating new interface\n");
1553 
1554  rif = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*rif));
1555  if (rif)
1556  {
1558 
1559  rif->refs = 1;
1560  rif->If.Length = sizeof(RPC_SERVER_INTERFACE);
1561  /* RPC interface ID = COM interface ID */
1562  rif->If.InterfaceId.SyntaxGUID = *riid;
1563  rif->If.DispatchTable = &rpc_dispatch;
1564  /* all other fields are 0, including the version asCOM objects
1565  * always have a version of 0.0 */
1566  status = RpcServerRegisterIfEx(
1567  (RPC_IF_HANDLE)&rif->If,
1568  NULL, NULL,
1571  NULL);
1572  if (status == RPC_S_OK)
1574  else
1575  {
1576  ERR("RpcServerRegisterIfEx failed with error %d\n", status);
1577  HeapFree(GetProcessHeap(), 0, rif);
1578  hr = HRESULT_FROM_WIN32(status);
1579  }
1580  }
1581  else
1582  hr = E_OUTOFMEMORY;
1583  }
1585  return hr;
1586 }
#define TRUE
Definition: types.h:120
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
PRPC_DISPATCH_TABLE DispatchTable
Definition: rpcdcep.h:106
REFIID riid
Definition: precomp.h:44
uint8_t entry
Definition: isohybrid.c:63
#define RPC_IF_OLE
Definition: rpcdce.h:314
struct list entry
Definition: rpc.c:82
DWORD refs
Definition: rpc.c:83
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define RPC_IF_AUTOLISTEN
Definition: rpcdce.h:313
static CRITICAL_SECTION csRegIf
Definition: rpc.c:58
RPC_STATUS WINAPI RpcServerRegisterIfEx(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv, UINT Flags, UINT MaxCalls, RPC_IF_CALLBACK_FN *IfCallbackFn)
Definition: rpc_server.c:1132
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:104
long RPC_STATUS
Definition: rpc.h:52
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define RPC_C_LISTEN_MAX_CALLS_DEFAULT
Definition: rpcdce.h:122
smooth NULL
Definition: ftsmooth.c:416
unsigned int Length
Definition: rpcdcep.h:103
#define debugstr_guid
Definition: kernel32.h:35
static RPC_DISPATCH_TABLE rpc_dispatch
Definition: rpc.c:55
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
RPC_SERVER_INTERFACE If
Definition: rpc.c:84
struct _RPC_SERVER_INTERFACE RPC_SERVER_INTERFACE
static struct list registered_interfaces
Definition: rpc.c:57
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4024
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ RPC_ResolveOxid()

HRESULT RPC_ResolveOxid ( OXID  oxid,
OXID_INFO *  oxid_info 
)

Definition at line 1611 of file rpc.c.

Referenced by proxy_manager_construct().

1612 {
1613  TRACE("%s\n", wine_dbgstr_longlong(oxid));
1614 
1615  oxid_info->dwTid = 0;
1616  oxid_info->dwPid = 0;
1617  oxid_info->dwAuthnHint = RPC_C_AUTHN_LEVEL_NONE;
1618  /* FIXME: this is a hack around not having an OXID resolver yet -
1619  * this function should contact the machine's OXID resolver and then it
1620  * should give us the IPID of the IRemUnknown interface */
1621  oxid_info->ipidRemUnknown.Data1 = 0xffffffff;
1622  oxid_info->ipidRemUnknown.Data2 = 0xffff;
1623  oxid_info->ipidRemUnknown.Data3 = 0xffff;
1624  memcpy(oxid_info->ipidRemUnknown.Data4, &oxid, sizeof(OXID));
1625  oxid_info->psa = NULL /* FIXME */;
1626 
1627  return S_OK;
1628 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
#define RPC_C_AUTHN_LEVEL_NONE
Definition: rpcdce.h:146

◆ RPC_StartLocalServer()

HRESULT RPC_StartLocalServer ( REFCLSID  clsid,
IStream stream,
BOOL  multi_use,
void **  registration 
)

Definition at line 1998 of file rpc.c.

Referenced by CoRegisterClassObject().

1999 {
2000  DWORD tid, err;
2001  struct local_server_params *lsp;
2002  WCHAR pipefn[100];
2003 
2004  lsp = HeapAlloc(GetProcessHeap(), 0, sizeof(*lsp));
2005  if (!lsp)
2006  return E_OUTOFMEMORY;
2007 
2008  lsp->clsid = *clsid;
2009  lsp->stream = stream;
2010  IStream_AddRef(stream);
2012  if (!lsp->stop_event)
2013  {
2014  HeapFree(GetProcessHeap(), 0, lsp);
2015  return HRESULT_FROM_WIN32(GetLastError());
2016  }
2017  lsp->multi_use = multi_use;
2018 
2019  get_localserver_pipe_name(pipefn, &lsp->clsid);
2022  4096, 4096, 500 /* 0.5 second timeout */, NULL);
2023  if (lsp->pipe == INVALID_HANDLE_VALUE)
2024  {
2025  err = GetLastError();
2026  FIXME("pipe creation failed for %s, le is %u\n", debugstr_w(pipefn), GetLastError());
2027  CloseHandle(lsp->stop_event);
2028  HeapFree(GetProcessHeap(), 0, lsp);
2029  return HRESULT_FROM_WIN32(err);
2030  }
2031 
2032  lsp->thread = CreateThread(NULL, 0, local_server_thread, lsp, 0, &tid);
2033  if (!lsp->thread)
2034  {
2035  CloseHandle(lsp->pipe);
2036  CloseHandle(lsp->stop_event);
2037  HeapFree(GetProcessHeap(), 0, lsp);
2038  return HRESULT_FROM_WIN32(GetLastError());
2039  }
2040 
2041  *registration = lsp;
2042  return S_OK;
2043 }
#define PIPE_UNLIMITED_INSTANCES
Definition: winbase.h:175
#define CloseHandle
Definition: compat.h:398
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PIPE_WAIT
Definition: winbase.h:171
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
HANDLE stop_event
Definition: rpc.c:1894
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
unsigned long DWORD
Definition: ntddk_ex.h:95
IStream * stream
Definition: rpc.c:1892
REFCLSID clsid
Definition: msctf.c:84
GLuint GLuint stream
Definition: glext.h:7522
static DWORD WINAPI local_server_thread(LPVOID param)
Definition: rpc.c:1900
#define err(...)
#define S_OK
Definition: intsafe.h:59
HANDLE thread
Definition: rpc.c:1895
HANDLE WINAPI CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:246
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
static TfClientId tid
#define HeapFree(x, y, z)
Definition: compat.h:394
static void get_localserver_pipe_name(WCHAR *pipefn, REFCLSID rclsid)
Definition: rpc.c:1798

◆ RPC_StartRemoting()

void RPC_StartRemoting ( struct apartment apt)

Definition at line 1632 of file rpc.c.

Referenced by StdMarshalImpl_MarshalInterface().

1633 {
1635  {
1636  WCHAR endpoint[200];
1638 
1639  get_rpc_endpoint(endpoint, &apt->oxid);
1640 
1641  status = RpcServerUseProtseqEpW(
1644  endpoint,
1645  NULL);
1646  if (status != RPC_S_OK)
1647  ERR("Couldn't register endpoint %s\n", debugstr_w(endpoint));
1648 
1649  /* FIXME: move remote unknown exporting into this function */
1650  }
1652 }
#define TRUE
Definition: types.h:120
__wchar_t WCHAR
Definition: xmlstorage.h:180
long RPC_STATUS
Definition: rpc.h:52
static void get_rpc_endpoint(LPWSTR endpoint, const OXID *oxid)
Definition: rpc.c:88
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
LONG remoting_started
HRESULT start_apartment_remote_unknown(APARTMENT *apt) DECLSPEC_HIDDEN
Definition: stubmanager.c:818
#define InterlockedExchange
Definition: armddk.h:54
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:934
#define ERR(fmt,...)
Definition: debug.h:109
Definition: nis.h:10
#define RPC_C_PROTSEQ_MAX_REQS_DEFAULT
Definition: rpcdce.h:123
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
static WCHAR wszRpcTransport[]
Definition: rpc.c:77

◆ RPC_StopLocalServer()

void RPC_StopLocalServer ( void registration)

Definition at line 2046 of file rpc.c.

Referenced by COM_RevokeRegisteredClassObject().

2047 {
2048  struct local_server_params *lsp = registration;
2049 
2050  /* signal local_server_thread to stop */
2051  SetEvent(lsp->stop_event);
2052  /* wait for it to exit */
2054 
2055  IStream_Release(lsp->stream);
2056  CloseHandle(lsp->stop_event);
2057  CloseHandle(lsp->thread);
2058  HeapFree(GetProcessHeap(), 0, lsp);
2059 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE stop_event
Definition: rpc.c:1894
#define GetProcessHeap()
Definition: compat.h:395
IStream * stream
Definition: rpc.c:1892
HANDLE thread
Definition: rpc.c:1895
#define INFINITE
Definition: serial.h:102
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ RPC_UnregisterAllChannelHooks()

void RPC_UnregisterAllChannelHooks ( void  )

Definition at line 448 of file rpc.c.

Referenced by DllMain().

449 {
450  struct channel_hook_entry *cursor;
451  struct channel_hook_entry *cursor2;
452 
455  HeapFree(GetProcessHeap(), 0, cursor);
459 }
uint8_t entry
Definition: isohybrid.c:63
static CRITICAL_SECTION csChannelHook
Definition: rpc.c:68
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static struct list channel_hooks
Definition: rpc.c:67
static CRITICAL_SECTION csRegIf
Definition: rpc.c:58
#define GetProcessHeap()
Definition: compat.h:395
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
Definition: rpc.c:170
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
const char cursor[]
Definition: icontest.c:13
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ RPC_UnregisterInterface()

void RPC_UnregisterInterface ( REFIID  riid,
BOOL  wait 
)

Definition at line 1589 of file rpc.c.

Referenced by stub_manager_delete_ifstub(), and stub_manager_disconnect().

1590 {
1591  struct registered_if *rif;
1594  {
1596  {
1597  if (!--rif->refs)
1598  {
1599  RpcServerUnregisterIf((RPC_IF_HANDLE)&rif->If, NULL, wait);
1600  list_remove(&rif->entry);
1601  HeapFree(GetProcessHeap(), 0, rif);
1602  }
1603  break;
1604  }
1605  }
1607 }
REFIID riid
Definition: precomp.h:44
uint8_t entry
Definition: isohybrid.c:63
struct list entry
Definition: rpc.c:82
DWORD refs
Definition: rpc.c:83
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
RPC_STATUS WINAPI RpcServerUnregisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, UINT WaitForCallsToComplete)
Definition: rpc_server.c:1209
static CRITICAL_SECTION csRegIf
Definition: rpc.c:58
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:104
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
smooth NULL
Definition: ftsmooth.c:416
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define GetProcessHeap()
Definition: compat.h:395
RPC_SERVER_INTERFACE If
Definition: rpc.c:84
static struct list registered_interfaces
Definition: rpc.c:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4024
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ RunningObjectTableImpl_Initialize()

HRESULT WINAPI RunningObjectTableImpl_Initialize ( void  )

Definition at line 983 of file moniker.c.

Referenced by CoInitializeEx().

984 {
985  TRACE("\n");
986 
987  /* create the unique instance of the RunningObjectTableImpl structure */
989 
991  return E_OUTOFMEMORY;
992 
993  /* initialize the virtual table function */
995 
996  /* the initial reference is set to "1" so that it isn't destroyed after its
997  * first use until the process is destroyed, as the running object table is
998  * a process-wide cache of a global table */
1000 
1003  DEBUG_SET_CRITSEC_NAME(&runningObjectTableInstance->lock, "RunningObjectTableImpl.lock");
1004 
1005  return S_OK;
1006 }
static RunningObjectTableImpl * runningObjectTableInstance
Definition: moniker.c:82
struct list rot
Definition: moniker.c:78
#define DEBUG_SET_CRITSEC_NAME(cs, name)
static const IRunningObjectTableVtbl VT_RunningObjectTableImpl
Definition: moniker.c:966
CRITICAL_SECTION lock
Definition: moniker.c:79
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
IRunningObjectTable IRunningObjectTable_iface
Definition: moniker.c:75

◆ RunningObjectTableImpl_UnInitialize()

HRESULT WINAPI RunningObjectTableImpl_UnInitialize ( void  )

Definition at line 1011 of file moniker.c.

Referenced by CoUninitialize().

1012 {
1013  TRACE("\n");
1014 
1016  return E_POINTER;
1017 
1019 
1021 
1022  return S_OK;
1023 }
static RunningObjectTableImpl * runningObjectTableInstance
Definition: moniker.c:82
static HRESULT RunningObjectTableImpl_Destroy(void)
Definition: moniker.c:367
static ULONG WINAPI RunningObjectTableImpl_Release(IRunningObjectTable *iface)
Definition: moniker.c:404
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
IRunningObjectTable IRunningObjectTable_iface
Definition: moniker.c:75
#define E_POINTER
Definition: winerror.h:2365

◆ start_apartment_remote_unknown()

HRESULT start_apartment_remote_unknown ( APARTMENT apt)

Definition at line 818 of file stubmanager.c.

Referenced by RPC_StartRemoting().

819 {
820  IRemUnknown *pRemUnknown;
821  HRESULT hr = S_OK;
822 
823  EnterCriticalSection(&apt->cs);
824  if (!apt->remunk_exported)
825  {
826  /* create the IRemUnknown object */
827  hr = RemUnknown_Construct(&pRemUnknown);
828  if (hr == S_OK)
829  {
830  STDOBJREF stdobjref; /* dummy - not used */
831  /* register it with the stub manager */
832  hr = marshal_object(apt, &stdobjref, &IID_IRemUnknown, (IUnknown *)pRemUnknown, MSHCTX_DIFFERENTMACHINE, NULL, MSHLFLAGS_NORMAL|MSHLFLAGSP_REMUNKNOWN);
833  /* release our reference to the object as the stub manager will manage the life cycle for us */
834  IRemUnknown_Release(pRemUnknown);
835  if (hr == S_OK)
836  apt->remunk_exported = TRUE;
837  }
838  }
839  LeaveCriticalSection(&apt->cs);
840  return hr;
841 }
#define MSHLFLAGSP_REMUNKNOWN
static HRESULT RemUnknown_Construct(IRemUnknown **ppRemUnknown)
Definition: stubmanager.c:643
#define TRUE
Definition: types.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static const IID IID_IRemUnknown
Definition: marshal.c:88
HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnknown *obj, DWORD dest_context, void *dest_context_data, MSHLFLAGS mshlflags) DECLSPEC_HIDDEN
Definition: marshal.c:124
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION cs
BOOL remunk_exported

◆ StdGlobalInterfaceTable_GetFactory()

HRESULT StdGlobalInterfaceTable_GetFactory ( LPVOID ppv)

Definition at line 342 of file git.c.

Referenced by DllGetClassObject().

343 {
344  *ppv = &git_classfactory;
345  TRACE("Returning GIT classfactory\n");
346  return S_OK;
347 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
static IClassFactory git_classfactory
Definition: git.c:340

◆ stub_manager_disconnect()

void stub_manager_disconnect ( struct stub_manager m)

Definition at line 244 of file stubmanager.c.

Referenced by CoDisconnectObject().

245 {
246  struct ifstub *ifstub;
247 
249  if (!m->disconnected)
250  {
251  LIST_FOR_EACH_ENTRY(ifstub, &m->ifstubs, struct ifstub, entry)
252  RPC_UnregisterInterface(&ifstub->iid, FALSE);
253 
254  m->disconnected = TRUE;
255  }
257 }
#define TRUE
Definition: types.h:120
uint8_t entry
Definition: isohybrid.c:63
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION lock
struct list ifstubs
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
void RPC_UnregisterInterface(REFIID riid, BOOL wait) DECLSPEC_HIDDEN
Definition: rpc.c:1589
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ stub_manager_ext_addref()

ULONG stub_manager_ext_addref ( struct stub_manager m,
ULONG  refs,
BOOL  tableweak 
)

Definition at line 408 of file stubmanager.c.

Referenced by CoLockObjectExternal(), marshal_object(), and RemUnknown_RemAddRef().

409 {
410  BOOL first_extern_ref;
411  ULONG rc;
412 
414 
415  first_extern_ref = refs && !m->extrefs;
416 
417  /* make sure we don't overflow extrefs */
418  refs = min(refs, (ULONG_MAX-1 - m->extrefs));
419  rc = (m->extrefs += refs);
420 
421  if (tableweak)
422  rc += ++m->weakrefs;
423 
425 
426  TRACE("added %u refs to %p (oid %s), rc is now %u\n", refs, m, wine_dbgstr_longlong(m->oid), rc);
427 
428  /*
429  * NOTE: According to tests, creating a stub causes two AddConnection calls followed by
430  * one ReleaseConnection call (with fLastReleaseCloses=FALSE).
431  */
432  if(first_extern_ref && m->extern_conn)
433  IExternalConnection_AddConnection(m->extern_conn, EXTCONN_STRONG, 0);
434 
435  return rc;
436 }
IExternalConnection * extern_conn
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION lock
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define ULONG_MAX
Definition: limits.h:44

◆ stub_manager_ext_release()

ULONG stub_manager_ext_release ( struct stub_manager m,
ULONG  refs,
BOOL  tableweak,
BOOL  last_unlock_releases 
)

Definition at line 439 of file stubmanager.c.

Referenced by CoLockObjectExternal(), marshal_object(), RemUnknown_RemRelease(), StdMarshalImpl_UnmarshalInterface(), and stub_manager_release_marshal_data().

440 {
441  BOOL last_extern_ref;
442  ULONG rc;
443 
445 
446  /* make sure we don't underflow extrefs */
447  refs = min(refs, m->extrefs);
448  rc = (m->extrefs -= refs);
449 
450  if (tableweak)
451  --m->weakrefs;
452  if (!last_unlock_releases)
453  rc += m->weakrefs;
454 
455  last_extern_ref = refs && !m->extrefs;
456 
458 
459  TRACE("removed %u refs from %p (oid %s), rc is now %u\n", refs, m, wine_dbgstr_longlong(m->oid), rc);
460 
461  if (last_extern_ref && m->extern_conn)
462  IExternalConnection_ReleaseConnection(m->extern_conn, EXTCONN_STRONG, 0, last_unlock_releases);
463 
464  if (rc == 0)
465  if (!(m->extern_conn && last_unlock_releases && m->weakrefs))
467 
468  return rc;
469 }
IExternalConnection * extern_conn
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION lock
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG stub_manager_int_release(struct stub_manager *This)
Definition: stubmanager.c:311

◆ stub_manager_find_ifstub()

struct ifstub* stub_manager_find_ifstub ( struct stub_manager m,
REFIID  iid,
MSHLFLAGS  flags 
)

Definition at line 158 of file stubmanager.c.

Referenced by marshal_object().

159 {
160  struct ifstub *result = NULL;
161  struct ifstub *ifstub;
162 
164  LIST_FOR_EACH_ENTRY( ifstub, &m->ifstubs, struct ifstub, entry )
165  {
166  if (IsEqualIID(iid, &ifstub->iid) && (ifstub->flags == flags))
167  {
168  result = ifstub;
169  break;
170  }
171  }
173 
174  return result;
175 }
uint8_t entry
Definition: isohybrid.c:63
MSHLFLAGS flags
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION lock
struct list ifstubs
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
smooth NULL
Definition: ftsmooth.c:416
GLbitfield flags
Definition: glext.h:7161
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
GLuint64EXT * result
Definition: glext.h:11304
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90

◆ stub_manager_int_release()

ULONG stub_manager_int_release ( struct stub_manager This)

Definition at line 311 of file stubmanager.c.

Referenced by apartment_release(), CoDisconnectObject(), CoLockObjectExternal(), dispatch_rpc(), ipid_get_dispatch_params(), marshal_object(), RemUnknown_RemAddRef(), RemUnknown_RemQueryInterface(), RemUnknown_RemRelease(), StdMarshalImpl_ReleaseMarshalData(), StdMarshalImpl_UnmarshalInterface(), and stub_manager_ext_release().

312 {
313  ULONG refs;
314  APARTMENT *apt = This->apt;
315 
316  EnterCriticalSection(&apt->cs);
317  refs = --This->refs;
318 
319  TRACE("after %d\n", refs);
320 
321  /* remove from apartment so no other thread can access it... */
322  if (!refs)
323  list_remove(&This->entry);
324 
325  LeaveCriticalSection(&apt->cs);
326 
327  /* ... so now we can delete it without being inside the apartment critsec */
328  if (!refs)
329  stub_manager_delete(This);
330 
331  return refs;
332 }
static void stub_manager_delete(struct stub_manager *m)
Definition: stubmanager.c:260
struct list entry
APARTMENT * apt
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION cs

◆ stub_manager_is_table_marshaled()

BOOL stub_manager_is_table_marshaled ( struct stub_manager m,
const IPID *  ipid 
)

Definition at line 609 of file stubmanager.c.

Referenced by StdMarshalImpl_UnmarshalInterface().

610 {
612 
613  assert( ifstub );
614 
615  return ifstub->flags & (MSHLFLAGS_TABLESTRONG | MSHLFLAGS_TABLEWEAK);
616 }
MSHLFLAGS flags
#define assert(x)
Definition: debug.h:53
static struct ifstub * stub_manager_ipid_to_ifstub(struct stub_manager *m, const IPID *ipid)
Definition: stubmanager.c:137

◆ stub_manager_new_ifstub()

struct ifstub* stub_manager_new_ifstub ( struct stub_manager m,
IRpcStubBuffer sb,
REFIID  iid,
DWORD  dest_context,
void dest_context_data,
MSHLFLAGS  flags 
)

Definition at line 70 of file stubmanager.c.

Referenced by marshal_object().

72 {
73  struct ifstub *stub;
74  HRESULT hr;
75 
76  TRACE("oid=%s, stubbuffer=%p, iid=%s, dest_context=%x\n", wine_dbgstr_longlong(m->oid), sb,
77  debugstr_guid(iid), dest_context);
78 
79  stub = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct ifstub));
80  if (!stub) return NULL;
81 
82  hr = IUnknown_QueryInterface(m->object, iid, (void **)&stub->iface);
83  if (hr != S_OK)
84  {
85  HeapFree(GetProcessHeap(), 0, stub);
86  return NULL;
87  }
88 
89  hr = RPC_CreateServerChannel(dest_context, dest_context_data, &stub->chan);
90  if (hr != S_OK)
91  {
92  IUnknown_Release(stub->iface);
93  HeapFree(GetProcessHeap(), 0, stub);
94  return NULL;
95  }
96 
97  stub->stubbuffer = sb;
98  if (sb) IRpcStubBuffer_AddRef(sb);
99 
100  stub->flags = flags;
101  stub->iid = *iid;
102 
103  /* FIXME: find a cleaner way of identifying that we are creating an ifstub
104  * for the remunknown interface */
106  stub->ipid = m->oxid_info.ipidRemUnknown;
107  else
108  generate_ipid(m, &stub->ipid);
109 
111  list_add_head(&m->ifstubs, &stub->entry);
112  /* every normal marshal is counted so we don't allow more than we should */
113  if (flags & MSHLFLAGS_NORMAL) m->norm_refs++;
115 
116  TRACE("ifstub %p created with ipid %s\n", stub, debugstr_guid(&stub->ipid));
117 
118  return stub;
119 }
#define MSHLFLAGSP_REMUNKNOWN
superblock * sb
Definition: btrfs.c:3876
IUnknown * iface
MSHLFLAGS flags
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION lock
struct list ifstubs
struct _stub stub
IRpcChannelBuffer * chan
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
IRpcStubBuffer * stubbuffer
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static HRESULT generate_ipid(struct stub_manager *m, IPID *ipid)
Definition: stubmanager.c:52
OXID_INFO oxid_info
LONG HRESULT
Definition: typedefs.h:77
struct list entry
HRESULT RPC_CreateServerChannel(DWORD dest_context, void *dest_context_data, IRpcChannelBuffer **chan) DECLSPEC_HIDDEN
Definition: rpc.c:1164
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:59
IUnknown * object
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ stub_manager_notify_unmarshal()

BOOL stub_manager_notify_unmarshal ( struct stub_manager m,
const IPID *  ipid 
)

Definition at line 562 of file stubmanager.c.

Referenced by StdMarshalImpl_UnmarshalInterface().

563 {
564  BOOL ret = TRUE;
565  struct ifstub *ifstub;
566 
567  if (!(ifstub = stub_manager_ipid_to_ifstub(m, ipid)))
568  {
569  ERR("attempted unmarshal of unknown IPID %s\n", debugstr_guid(ipid));
570  return FALSE;
571  }
572 
574 
575  /* track normal marshals so we can enforce rules whilst in-process */
576  if (ifstub->flags & MSHLFLAGS_NORMAL)
577  {
578  if (m->norm_refs)
579  m->norm_refs--;
580  else
581  {
582  ERR("attempted invalid normal unmarshal, norm_refs is zero\n");
583  ret = FALSE;
584  }
585  }
586 
588 
589  return ret;
590 }
#define TRUE
Definition: types.h:120
MSHLFLAGS flags
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION lock
#define debugstr_guid
Definition: kernel32.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
static struct ifstub * stub_manager_ipid_to_ifstub(struct stub_manager *m, const IPID *ipid)
Definition: stubmanager.c:137
#define ERR(fmt,...)
Definition: debug.h:109
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ stub_manager_release_marshal_data()

void stub_manager_release_marshal_data ( struct stub_manager m,
ULONG  refs,
const IPID *  ipid,
BOOL  tableweak 
)

Definition at line 593 of file stubmanager.c.

Referenced by StdMarshalImpl_ReleaseMarshalData().

594 {
595  struct ifstub *ifstub;
596 
597  if (!(ifstub = stub_manager_ipid_to_ifstub(m, ipid)))
598  return;
599 
600  if (ifstub->flags & MSHLFLAGS_TABLEWEAK)
601  refs = 0;
602  else if (ifstub->flags & MSHLFLAGS_TABLESTRONG)
603  refs = 1;
604 
605  stub_manager_ext_release(m, refs, tableweak, !tableweak);
606 }
ULONG stub_manager_ext_release(struct stub_manager *m, ULONG refs, BOOL tableweak, BOOL last_unlock_releases)
Definition: stubmanager.c:439
MSHLFLAGS flags
static struct ifstub * stub_manager_ipid_to_ifstub(struct stub_manager *m, const IPID *ipid)
Definition: stubmanager.c:137

Variable Documentation

◆ DECLSPEC_HIDDEN

Definition at line 304 of file compobj_private.h.

Referenced by apartment_getoxid(), and copy_formatetc().