ReactOS 0.4.16-dev-2320-ge1853c6
rpc.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winsvc.h"
#include "servprov.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "combase_private.h"
#include "irpcss.h"
Include dependency graph for rpc.c:

Go to the source code of this file.

Classes

struct  registered_if
 
struct  RpcChannelBuffer
 
struct  ClientRpcChannelBuffer
 
struct  dispatch_params
 
struct  message_state
 
struct  WIRE_ORPC_EXTENT
 
struct  WIRE_ORPC_EXTENT_ARRAY
 
struct  WIRE_ORPCTHIS
 
struct  WIRE_ORPCTHAT
 
struct  channel_hook_entry
 
struct  channel_hook_buffer_data
 

Macros

#define COBJMACROS
 
#define RPCSS_CALL_START
 
#define RPCSS_CALL_END
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static void __RPC_STUB dispatch_rpc (RPC_MESSAGE *msg)
 
static void get_rpc_endpoint (LPWSTR endpoint, const OXID *oxid)
 
void *__RPC_USER MIDL_user_allocate (SIZE_T size)
 
void __RPC_USER MIDL_user_free (void *p)
 
static LONG WINAPI rpc_filter (EXCEPTION_POINTERS *eptr)
 
static BOOL start_rpcss (void)
 
static RPC_BINDING_HANDLE get_rpc_handle (unsigned short *protseq, unsigned short *endpoint)
 
static RPC_BINDING_HANDLE get_irpcss_handle (void)
 
static RPC_BINDING_HANDLE get_irot_handle (void)
 
HRESULT rpcss_get_next_seqid (DWORD *id)
 
HRESULT WINAPI InternalIrotRegister (const MonikerComparisonData *moniker_data, const InterfaceData *object, const InterfaceData *moniker, const FILETIME *time, DWORD flags, IrotCookie *cookie, IrotContextHandle *ctxt_handle)
 
HRESULT WINAPI InternalIrotIsRunning (const MonikerComparisonData *moniker_data)
 
HRESULT WINAPI InternalIrotGetObject (const MonikerComparisonData *moniker_data, PInterfaceData *obj, IrotCookie *cookie)
 
HRESULT WINAPI InternalIrotNoteChangeTime (IrotCookie cookie, const FILETIME *time)
 
HRESULT WINAPI InternalIrotGetTimeOfLastChange (const MonikerComparisonData *moniker_data, FILETIME *time)
 
HRESULT WINAPI InternalIrotEnumRunning (PInterfaceList *list)
 
HRESULT WINAPI InternalIrotRevoke (IrotCookie cookie, IrotContextHandle *ctxt_handle, PInterfaceData *object, PInterfaceData *moniker)
 
static HRESULT rpcss_server_register (REFCLSID clsid, DWORD flags, MInterfacePointer *obj, unsigned int *cookie)
 
HRESULT rpc_revoke_local_server (unsigned int cookie)
 
static HRESULT rpcss_get_class_object (REFCLSID rclsid, PMInterfacePointer *objref)
 
static DWORD start_local_service (const WCHAR *name, DWORD num, LPCWSTR *params)
 
static HRESULT create_local_service (REFCLSID rclsid)
 
static HRESULT create_server (REFCLSID rclsid, HANDLE *process)
 
static HRESULT create_surrogate_server (REFCLSID rclsid, HANDLE *process)
 
HRESULT rpc_get_local_class_object (REFCLSID rclsid, REFIID riid, void **obj)
 
HRESULT rpc_register_local_server (REFCLSID clsid, IStream *stream, DWORD flags, unsigned int *cookie)
 
static HRESULT unmarshal_ORPCTHAT (RPC_MESSAGE *msg, ORPCTHAT *orpcthat, ORPC_EXTENT_ARRAY *orpc_ext_array, WIRE_ORPC_EXTENT **first_wire_orpc_extent)
 
static ULONG ChannelHooks_ClientGetSize (SChannelHookCallInfo *info, struct channel_hook_buffer_data **data, unsigned int *hook_count, ULONG *extension_count)
 
static unsigned charChannelHooks_ClientFillBuffer (SChannelHookCallInfo *info, unsigned char *buffer, struct channel_hook_buffer_data *data, unsigned int hook_count)
 
static void ChannelHooks_ServerNotify (SChannelHookCallInfo *info, DWORD lDataRep, WIRE_ORPC_EXTENT *first_wire_orpc_extent, ULONG extension_count)
 
static ULONG ChannelHooks_ServerGetSize (SChannelHookCallInfo *info, struct channel_hook_buffer_data **data, unsigned int *hook_count, ULONG *extension_count)
 
static unsigned charChannelHooks_ServerFillBuffer (SChannelHookCallInfo *info, unsigned char *buffer, struct channel_hook_buffer_data *data, unsigned int hook_count)
 
static void ChannelHooks_ClientNotify (SChannelHookCallInfo *info, DWORD lDataRep, WIRE_ORPC_EXTENT *first_wire_orpc_extent, ULONG extension_count, HRESULT hrFault)
 
HRESULT rpc_register_channel_hook (REFGUID rguid, IChannelHook *hook)
 
void rpc_unregister_channel_hooks (void)
 
static HRESULT WINAPI RpcChannelBuffer_QueryInterface (IRpcChannelBuffer *iface, REFIID riid, LPVOID *ppv)
 
static ULONG WINAPI RpcChannelBuffer_AddRef (LPRPCCHANNELBUFFER iface)
 
static ULONG WINAPI ServerRpcChannelBuffer_Release (LPRPCCHANNELBUFFER iface)
 
static ULONG WINAPI ClientRpcChannelBuffer_Release (LPRPCCHANNELBUFFER iface)
 
static HRESULT WINAPI ServerRpcChannelBuffer_GetBuffer (LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, REFIID riid)
 
static HANDLE ClientRpcChannelBuffer_GetEventHandle (ClientRpcChannelBuffer *This)
 
static void ClientRpcChannelBuffer_ReleaseEventHandle (ClientRpcChannelBuffer *This, HANDLE event)
 
static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer (LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, REFIID riid)
 
static HRESULT WINAPI ServerRpcChannelBuffer_SendReceive (LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus)
 
static DWORD WINAPI rpc_sendreceive_thread (LPVOID param)
 
static HRESULT ClientRpcChannelBuffer_IsCorrectApartment (ClientRpcChannelBuffer *This, const struct apartment *apt)
 
static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive (LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus)
 
static HRESULT WINAPI ServerRpcChannelBuffer_FreeBuffer (LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg)
 
static HRESULT WINAPI ClientRpcChannelBuffer_FreeBuffer (LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg)
 
static HRESULT WINAPI ClientRpcChannelBuffer_GetDestCtx (LPRPCCHANNELBUFFER iface, DWORD *pdwDestContext, void **ppvDestContext)
 
static HRESULT WINAPI ServerRpcChannelBuffer_GetDestCtx (LPRPCCHANNELBUFFER iface, DWORD *dest_context, void **dest_context_data)
 
static HRESULT WINAPI RpcChannelBuffer_IsConnected (LPRPCCHANNELBUFFER iface)
 
HRESULT rpc_create_clientchannel (const OXID *oxid, const IPID *ipid, const OXID_INFO *oxid_info, const IID *iid, DWORD dest_context, void *dest_context_data, IRpcChannelBuffer **chan, struct apartment *apt)
 
HRESULT rpc_create_serverchannel (DWORD dest_context, void *dest_context_data, IRpcChannelBuffer **chan)
 
static HRESULT unmarshal_ORPC_EXTENT_ARRAY (RPC_MESSAGE *msg, const char *end, ORPC_EXTENT_ARRAY *extensions, WIRE_ORPC_EXTENT **first_wire_orpc_extent)
 
static HRESULT unmarshal_ORPCTHIS (RPC_MESSAGE *msg, ORPCTHIS *orpcthis, ORPC_EXTENT_ARRAY *orpc_ext_array, WIRE_ORPC_EXTENT **first_wire_orpc_extent)
 
void rpc_execute_call (struct dispatch_params *params)
 
HRESULT rpc_register_interface (REFIID riid)
 
void rpc_unregister_interface (REFIID riid, BOOL wait)
 
HRESULT rpc_resolve_oxid (OXID oxid, OXID_INFO *oxid_info)
 
void rpc_start_remoting (struct apartment *apt)
 
BOOL WINAPI DllDebugObjectRPCHook (BOOL trace, void *args)
 
HRESULT WINAPI CoDecodeProxy (DWORD client_pid, UINT64 proxy_addr, ServerInformation *server_info)
 

Variables

static RPC_DISPATCH_FUNCTION rpc_dispatch_table [1] = { dispatch_rpc }
 
static RPC_DISPATCH_TABLE rpc_dispatch = { 1, rpc_dispatch_table }
 
static struct list registered_interfaces = LIST_INIT(registered_interfaces)
 
static CRITICAL_SECTION csRegIf = { &csRegIf_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG csRegIf_debug
 
static struct list channel_hooks = LIST_INIT(channel_hooks)
 
static CRITICAL_SECTION csChannelHook = { &csChannelHook_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG csChannelHook_debug
 
static WCHAR rpctransportW [] = L"ncalrpc"
 
static const IRpcChannelBufferVtbl ClientRpcChannelBufferVtbl
 
static const IRpcChannelBufferVtbl ServerRpcChannelBufferVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file rpc.c.

◆ RPCSS_CALL_END

#define RPCSS_CALL_END
Value:
} \
__ENDTRY \
if (start_rpcss()) \
continue; \
} \
break; \
} \
return hr;
static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *eptr)
Definition: rpc.c:184
static BOOL start_rpcss(void)
Definition: rpc.c:189
#define GetExceptionCode
Definition: excpt.h:83
HRESULT hr
Definition: shlfolder.c:183
#define __EXCEPT(func)
Definition: exception.h:62
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1389

Definition at line 295 of file rpc.c.

◆ RPCSS_CALL_START

#define RPCSS_CALL_START
Value:
for (;;) { \
#define __TRY
Definition: compat.h:80

Definition at line 290 of file rpc.c.

Function Documentation

◆ ChannelHooks_ClientFillBuffer()

static unsigned char * ChannelHooks_ClientFillBuffer ( SChannelHookCallInfo *  info,
unsigned char buffer,
struct channel_hook_buffer_data data,
unsigned int  hook_count 
)
static

Definition at line 781 of file rpc.c.

784{
786
788
790 {
791 unsigned int i;
792 ULONG extension_size = 0;
793 WIRE_ORPC_EXTENT *wire_orpc_extent = (WIRE_ORPC_EXTENT *)buffer;
794
795 for (i = 0; i < hook_count; i++)
796 if (IsEqualGUID(&entry->id, &data[i].id))
797 extension_size = data[i].extension_size;
798
799 /* an extension is only put onto the wire if it has data to write */
800 if (!extension_size)
801 continue;
802
803 IChannelHook_ClientFillBuffer(entry->hook, &entry->id, &info->iid,
804 &extension_size, buffer + FIELD_OFFSET(WIRE_ORPC_EXTENT, data[0]));
805
806 TRACE("%s: extension_size = %lu\n", debugstr_guid(&entry->id), extension_size);
807
808 /* FIXME: set unused portion of wire_orpc_extent->data to 0? */
809
810 wire_orpc_extent->conformance = (extension_size+7)&~7;
811 wire_orpc_extent->size = extension_size;
812 wire_orpc_extent->id = entry->id;
813 buffer += FIELD_OFFSET(WIRE_ORPC_EXTENT, data[wire_orpc_extent->conformance]);
814 }
815
817
818 return buffer;
819}
static CRITICAL_SECTION csChannelHook
Definition: rpc.c:61
static struct list channel_hooks
Definition: rpc.c:60
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
ULONG size
Definition: rpc.c:136
ULONG conformance
Definition: rpc.c:134
Definition: rpc.c:163
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by ClientRpcChannelBuffer_GetBuffer().

◆ ChannelHooks_ClientGetSize()

static ULONG ChannelHooks_ClientGetSize ( SChannelHookCallInfo *  info,
struct channel_hook_buffer_data **  data,
unsigned int hook_count,
ULONG extension_count 
)
static

Definition at line 734 of file rpc.c.

736{
738 ULONG total_size = 0;
739 unsigned int hook_index = 0;
740
741 *hook_count = 0;
742 *extension_count = 0;
743
745
747 (*hook_count)++;
748
749 if (*hook_count)
750 *data = malloc(*hook_count * sizeof(struct channel_hook_buffer_data));
751 else
752 *data = NULL;
753
755 {
756 ULONG extension_size = 0;
757
758 IChannelHook_ClientGetSize(entry->hook, &entry->id, &info->iid, &extension_size);
759
760 TRACE("%s: extension_size = %lu\n", debugstr_guid(&entry->id), extension_size);
761
762 extension_size = (extension_size+7)&~7;
763 (*data)[hook_index].id = entry->id;
764 (*data)[hook_index].extension_size = extension_size;
765
766 /* an extension is only put onto the wire if it has data to write */
767 if (extension_size)
768 {
769 total_size += FIELD_OFFSET(WIRE_ORPC_EXTENT, data[extension_size]);
770 (*extension_count)++;
771 }
772
773 hook_index++;
774 }
775
777
778 return total_size;
779}
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112

Referenced by ClientRpcChannelBuffer_GetBuffer().

◆ ChannelHooks_ClientNotify()

static void ChannelHooks_ClientNotify ( SChannelHookCallInfo *  info,
DWORD  lDataRep,
WIRE_ORPC_EXTENT first_wire_orpc_extent,
ULONG  extension_count,
HRESULT  hrFault 
)
static

Definition at line 941 of file rpc.c.

944{
946 ULONG i;
947
949
951 {
952 WIRE_ORPC_EXTENT *wire_orpc_extent;
953 for (i = 0, wire_orpc_extent = first_wire_orpc_extent;
954 i < extension_count;
955 i++, wire_orpc_extent = (WIRE_ORPC_EXTENT *)&wire_orpc_extent->data[wire_orpc_extent->conformance])
956 {
957 if (IsEqualGUID(&entry->id, &wire_orpc_extent->id))
958 break;
959 }
960 if (i == extension_count) wire_orpc_extent = NULL;
961
962 IChannelHook_ClientNotify(entry->hook, &entry->id, &info->iid,
963 wire_orpc_extent ? wire_orpc_extent->size : 0,
964 wire_orpc_extent ? wire_orpc_extent->data : NULL,
965 lDataRep, hrFault);
966 }
967
969}
unsigned char data[1]
Definition: rpc.c:137

Referenced by ClientRpcChannelBuffer_SendReceive().

◆ ChannelHooks_ServerFillBuffer()

static unsigned char * ChannelHooks_ServerFillBuffer ( SChannelHookCallInfo *  info,
unsigned char buffer,
struct channel_hook_buffer_data data,
unsigned int  hook_count 
)
static

Definition at line 900 of file rpc.c.

903{
905
907
909 {
910 unsigned int i;
911 ULONG extension_size = 0;
912 WIRE_ORPC_EXTENT *wire_orpc_extent = (WIRE_ORPC_EXTENT *)buffer;
913
914 for (i = 0; i < hook_count; i++)
915 if (IsEqualGUID(&entry->id, &data[i].id))
916 extension_size = data[i].extension_size;
917
918 /* an extension is only put onto the wire if it has data to write */
919 if (!extension_size)
920 continue;
921
922 IChannelHook_ServerFillBuffer(entry->hook, &entry->id, &info->iid,
923 &extension_size, buffer + FIELD_OFFSET(WIRE_ORPC_EXTENT, data[0]),
924 S_OK);
925
926 TRACE("%s: extension_size = %lu\n", debugstr_guid(&entry->id), extension_size);
927
928 /* FIXME: set unused portion of wire_orpc_extent->data to 0? */
929
930 wire_orpc_extent->conformance = (extension_size+7)&~7;
931 wire_orpc_extent->size = extension_size;
932 wire_orpc_extent->id = entry->id;
933 buffer += FIELD_OFFSET(WIRE_ORPC_EXTENT, data[wire_orpc_extent->conformance]);
934 }
935
937
938 return buffer;
939}
#define S_OK
Definition: intsafe.h:52

Referenced by ServerRpcChannelBuffer_GetBuffer().

◆ ChannelHooks_ServerGetSize()

static ULONG ChannelHooks_ServerGetSize ( SChannelHookCallInfo *  info,
struct channel_hook_buffer_data **  data,
unsigned int hook_count,
ULONG extension_count 
)
static

Definition at line 851 of file rpc.c.

854{
856 ULONG total_size = 0;
857 unsigned int hook_index = 0;
858
859 *hook_count = 0;
860 *extension_count = 0;
861
863
865 (*hook_count)++;
866
867 if (*hook_count)
868 *data = malloc(*hook_count * sizeof(struct channel_hook_buffer_data));
869 else
870 *data = NULL;
871
873 {
874 ULONG extension_size = 0;
875
876 IChannelHook_ServerGetSize(entry->hook, &entry->id, &info->iid, S_OK,
877 &extension_size);
878
879 TRACE("%s: extension_size = %lu\n", debugstr_guid(&entry->id), extension_size);
880
881 extension_size = (extension_size+7)&~7;
882 (*data)[hook_index].id = entry->id;
883 (*data)[hook_index].extension_size = extension_size;
884
885 /* an extension is only put onto the wire if it has data to write */
886 if (extension_size)
887 {
888 total_size += FIELD_OFFSET(WIRE_ORPC_EXTENT, data[extension_size]);
889 (*extension_count)++;
890 }
891
892 hook_index++;
893 }
894
896
897 return total_size;
898}

Referenced by ServerRpcChannelBuffer_GetBuffer().

◆ ChannelHooks_ServerNotify()

static void ChannelHooks_ServerNotify ( SChannelHookCallInfo *  info,
DWORD  lDataRep,
WIRE_ORPC_EXTENT first_wire_orpc_extent,
ULONG  extension_count 
)
static

Definition at line 821 of file rpc.c.

824{
826 ULONG i;
827
829
831 {
832 WIRE_ORPC_EXTENT *wire_orpc_extent;
833 for (i = 0, wire_orpc_extent = first_wire_orpc_extent;
834 i < extension_count;
835 i++, wire_orpc_extent = (WIRE_ORPC_EXTENT *)&wire_orpc_extent->data[wire_orpc_extent->conformance])
836 {
837 if (IsEqualGUID(&entry->id, &wire_orpc_extent->id))
838 break;
839 }
840 if (i == extension_count) wire_orpc_extent = NULL;
841
842 IChannelHook_ServerNotify(entry->hook, &entry->id, &info->iid,
843 wire_orpc_extent ? wire_orpc_extent->size : 0,
844 wire_orpc_extent ? wire_orpc_extent->data : NULL,
845 lDataRep);
846 }
847
849}

Referenced by rpc_execute_call().

◆ ClientRpcChannelBuffer_FreeBuffer()

static HRESULT WINAPI ClientRpcChannelBuffer_FreeBuffer ( LPRPCCHANNELBUFFER  iface,
RPCOLEMESSAGE *  olemsg 
)
static

Definition at line 1551 of file rpc.c.

1552{
1553 RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg;
1556
1557 TRACE("(%p)\n", msg);
1558
1559 message_state = msg->Handle;
1560 /* restore the binding handle and the real start of data */
1561 msg->Handle = message_state->binding_handle;
1562 msg->Buffer = (char *)msg->Buffer - message_state->prefix_data_len;
1563 msg->BufferLength += message_state->prefix_data_len;
1564
1565 if (message_state->params.bypass_rpcrt)
1566 {
1567 free(msg->Buffer);
1568 status = RPC_S_OK;
1569 }
1570 else
1572
1573 free(msg->RpcInterfaceInformation);
1574 msg->RpcInterfaceInformation = NULL;
1575
1576 if (message_state->params.stub)
1577 IRpcStubBuffer_Release(message_state->params.stub);
1578 if (message_state->params.chan)
1579 IRpcChannelBuffer_Release(message_state->params.chan);
1581
1582 TRACE("-- %ld\n", status);
1583
1584 return HRESULT_FROM_WIN32(status);
1585}
#define msg(x)
Definition: auth_time.c:54
#define free
Definition: debug_ros.c:5
if(dx< 0)
Definition: linetemp.h:194
RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1692
#define RPC_S_OK
Definition: rpcnterr.h:22
long RPC_STATUS
Definition: rpc.h:48
struct dispatch_params params
Definition: rpc.c:129
ULONG prefix_data_len
Definition: rpc.c:122
RPC_BINDING_HANDLE binding_handle
Definition: rpc.c:121
Definition: ps.c:97

◆ ClientRpcChannelBuffer_GetBuffer()

static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer ( LPRPCCHANNELBUFFER  iface,
RPCOLEMESSAGE *  olemsg,
REFIID  riid 
)
static

Definition at line 1164 of file rpc.c.

1165{
1167 RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg;
1170 ORPCTHIS *orpcthis;
1172 ULONG extensions_size;
1173 struct channel_hook_buffer_data *channel_hook_data;
1174 unsigned int channel_hook_count;
1175 ULONG extension_count;
1176 IPID ipid;
1177 HRESULT hr;
1178 struct apartment *apt = NULL;
1179
1180 TRACE("(%p)->(%p,%s)\n", This, olemsg, debugstr_guid(riid));
1181
1182 cif = calloc(1, sizeof(RPC_CLIENT_INTERFACE));
1183 if (!cif)
1184 return E_OUTOFMEMORY;
1185
1187 if (!message_state)
1188 {
1189 free(cif);
1190 return E_OUTOFMEMORY;
1191 }
1192
1193 cif->Length = sizeof(RPC_CLIENT_INTERFACE);
1194 /* RPC interface ID = COM interface ID */
1195 cif->InterfaceId.SyntaxGUID = This->iid;
1196 /* COM objects always have a version of 0.0 */
1199 msg->Handle = This->bind;
1200 msg->RpcInterfaceInformation = cif;
1201
1204
1208 message_state->channel_hook_info.dwServerPid = This->server_pid;
1209 message_state->channel_hook_info.iMethod = msg->ProcNum & ~RPC_FLAGS_VALID_BIT;
1210 message_state->channel_hook_info.pObject = NULL; /* only present on server-side */
1214
1216 &channel_hook_data, &channel_hook_count, &extension_count);
1217
1218 msg->BufferLength += FIELD_OFFSET(WIRE_ORPCTHIS, extensions) + sizeof(DWORD);
1219 if (extensions_size)
1220 {
1221 msg->BufferLength += FIELD_OFFSET(WIRE_ORPC_EXTENT_ARRAY, extent[2*sizeof(DWORD) + extensions_size]);
1222 if (extension_count & 1)
1223 msg->BufferLength += FIELD_OFFSET(WIRE_ORPC_EXTENT, data[0]);
1224 }
1225
1227 hr = ipid_get_dispatch_params(&ipid, &apt, NULL, &message_state->params.stub,
1228 &message_state->params.chan,
1229 &message_state->params.iid,
1230 &message_state->params.iface);
1231 if (hr == S_OK)
1232 {
1233 /* stub, chan, iface and iid are unneeded in multi-threaded case as we go
1234 * via the RPC runtime */
1235 if (apt->multi_threaded)
1236 {
1237 IRpcStubBuffer_Release(message_state->params.stub);
1238 message_state->params.stub = NULL;
1239 IRpcChannelBuffer_Release(message_state->params.chan);
1240 message_state->params.chan = NULL;
1241 message_state->params.iface = NULL;
1242 }
1243 else
1244 {
1245 message_state->params.bypass_rpcrt = TRUE;
1248 /* we assume later on that this being non-NULL is the indicator that
1249 * means call directly instead of going through RPC runtime */
1251 ERR("window for apartment %s is NULL\n", wine_dbgstr_longlong(apt->oxid));
1252 }
1253 }
1254 if (apt) apartment_release(apt);
1256 /* Note: message_state->params.msg is initialised in
1257 * ClientRpcChannelBuffer_SendReceive */
1258
1259 /* shortcut the RPC runtime */
1261 {
1262 msg->Buffer = malloc(msg->BufferLength);
1263 if (msg->Buffer)
1264 status = RPC_S_OK;
1265 else
1267 }
1268 else
1270
1271 msg->Handle = message_state;
1272
1273 if (status == RPC_S_OK)
1274 {
1275 orpcthis = msg->Buffer;
1276 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPCTHIS, extensions);
1277
1278 orpcthis->version.MajorVersion = COM_MAJOR_VERSION;
1279 orpcthis->version.MinorVersion = COM_MINOR_VERSION;
1280 orpcthis->flags = message_state->channel_hook_info.dwServerPid ? ORPCF_LOCAL : ORPCF_NULL;
1281 orpcthis->reserved1 = 0;
1282 orpcthis->cid = message_state->channel_hook_info.uCausality;
1283
1284 /* NDR representation of orpcthis->extensions */
1285 *(DWORD *)msg->Buffer = extensions_size ? 1 : 0;
1286 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1287
1288 if (extensions_size)
1289 {
1290 ORPC_EXTENT_ARRAY *orpc_extent_array = msg->Buffer;
1291 orpc_extent_array->size = extension_count;
1292 orpc_extent_array->reserved = 0;
1293 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPC_EXTENT_ARRAY, extent);
1294 /* NDR representation of orpc_extent_array->extent */
1295 *(DWORD *)msg->Buffer = 1;
1296 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1297 /* NDR representation of [size_is] attribute of orpc_extent_array->extent */
1298 *(DWORD *)msg->Buffer = (extension_count + 1) & ~1;
1299 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1300
1302 msg->Buffer, channel_hook_data, channel_hook_count);
1303
1304 /* we must add a dummy extension if there is an odd extension
1305 * count to meet the contract specified by the size_is attribute */
1306 if (extension_count & 1)
1307 {
1308 WIRE_ORPC_EXTENT *wire_orpc_extent = msg->Buffer;
1309 wire_orpc_extent->conformance = 0;
1310 wire_orpc_extent->id = GUID_NULL;
1311 wire_orpc_extent->size = 0;
1312 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPC_EXTENT, data[0]);
1313 }
1314 }
1315
1316 /* store the prefixed data length so that we can restore the real buffer
1317 * pointer in ClientRpcChannelBuffer_SendReceive. */
1318 message_state->prefix_data_len = (char *)msg->Buffer - (char *)orpcthis;
1319 msg->BufferLength -= message_state->prefix_data_len;
1320 }
1321
1322 free(channel_hook_data);
1323
1324 TRACE("-- %ld\n", status);
1325
1326 return HRESULT_FROM_WIN32(status);
1327}
void apartment_release(struct apartment *apt)
Definition: apartment.c:444
HWND apartment_getwindow(const struct apartment *apt)
Definition: apartment.c:1278
#define ERR(fmt,...)
Definition: precomp.h:57
HRESULT ipid_get_dispatch_params(const IPID *ipid, struct apartment **stub_apt, struct stub_manager **manager, IRpcStubBuffer **stub, IRpcChannelBuffer **chan, IID *iid, IUnknown **iface)
Definition: stubmanager.c:530
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define TRUE
Definition: types.h:120
HRESULT WINAPI CoGetCurrentLogicalThreadId(GUID *id)
Definition: combase.c:2714
static unsigned char * ChannelHooks_ClientFillBuffer(SChannelHookCallInfo *info, unsigned char *buffer, struct channel_hook_buffer_data *data, unsigned int hook_count)
Definition: rpc.c:781
static ULONG ChannelHooks_ClientGetSize(SChannelHookCallInfo *info, struct channel_hook_buffer_data **data, unsigned int *hook_count, ULONG *extension_count)
Definition: rpc.c:734
static HANDLE ClientRpcChannelBuffer_GetEventHandle(ClientRpcChannelBuffer *This)
Definition: rpc.c:1146
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
#define GUID_NULL
Definition: ks.h:106
#define DWORD
Definition: nt_native.h:44
#define calloc
Definition: rosglue.h:14
RPC_STATUS WINAPI RpcBindingInqObject(RPC_BINDING_HANDLE Binding, UUID *ObjectUuid)
Definition: rpc_binding.c:798
RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1634
struct _RPC_CLIENT_INTERFACE RPC_CLIENT_INTERFACE
#define memset(x, y, z)
Definition: compat.h:39
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:117
unsigned int Length
Definition: rpcdcep.h:116
RPC_VERSION SyntaxVersion
Definition: rpcdcep.h:33
unsigned short MajorVersion
Definition: rpcdcep.h:27
unsigned short MinorVersion
Definition: rpcdcep.h:28
BOOL multi_threaded
HWND target_hwnd
Definition: rpc.c:127
SChannelHookCallInfo channel_hook_info
Definition: rpc.c:123
DWORD target_tid
Definition: rpc.c:128

◆ ClientRpcChannelBuffer_GetDestCtx()

static HRESULT WINAPI ClientRpcChannelBuffer_GetDestCtx ( LPRPCCHANNELBUFFER  iface,
DWORD pdwDestContext,
void **  ppvDestContext 
)
static

Definition at line 1587 of file rpc.c.

1588{
1590
1591 TRACE("(%p,%p)\n", pdwDestContext, ppvDestContext);
1592
1593 *pdwDestContext = This->super.dest_context;
1594 *ppvDestContext = This->super.dest_context_data;
1595
1596 return S_OK;
1597}

◆ ClientRpcChannelBuffer_GetEventHandle()

static HANDLE ClientRpcChannelBuffer_GetEventHandle ( ClientRpcChannelBuffer This)
static

Definition at line 1146 of file rpc.c.

1147{
1148 HANDLE event = InterlockedExchangePointer(&This->event, NULL);
1149
1150 /* Note: must be auto-reset event so we can reuse it without a call
1151 * to ResetEvent */
1152 if (!event) event = CreateEventW(NULL, FALSE, FALSE, NULL);
1153
1154 return event;
1155}
#define FALSE
Definition: types.h:117
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
struct _cl_event * event
Definition: glext.h:7739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587

Referenced by ClientRpcChannelBuffer_GetBuffer().

◆ ClientRpcChannelBuffer_IsCorrectApartment()

static HRESULT ClientRpcChannelBuffer_IsCorrectApartment ( ClientRpcChannelBuffer This,
const struct apartment apt 
)
inlinestatic

Definition at line 1351 of file rpc.c.

1352{
1353 if (!apt)
1354 return S_FALSE;
1355 if (This->oxid != apartment_getoxid(apt))
1356 return S_FALSE;
1357 return S_OK;
1358}
OXID apartment_getoxid(const struct apartment *apt)
Definition: apartment.c:1284
#define S_FALSE
Definition: winerror.h:3451

Referenced by ClientRpcChannelBuffer_SendReceive().

◆ ClientRpcChannelBuffer_Release()

static ULONG WINAPI ClientRpcChannelBuffer_Release ( LPRPCCHANNELBUFFER  iface)
static

Definition at line 1036 of file rpc.c.

1037{
1039 ULONG ref;
1040
1041 ref = InterlockedDecrement(&This->super.refs);
1042 if (ref)
1043 return ref;
1044
1045 if (This->event) CloseHandle(This->event);
1046 RpcBindingFree(&This->bind);
1047 free(This);
1048 return 0;
1049}
#define InterlockedDecrement
Definition: armddk.h:52
#define CloseHandle
Definition: compat.h:739
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:769
Definition: send.c:48

◆ ClientRpcChannelBuffer_ReleaseEventHandle()

static void ClientRpcChannelBuffer_ReleaseEventHandle ( ClientRpcChannelBuffer This,
HANDLE  event 
)
static

Definition at line 1157 of file rpc.c.

1158{
1160 /* already a handle cached in This */
1162}
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144

Referenced by ClientRpcChannelBuffer_SendReceive().

◆ ClientRpcChannelBuffer_SendReceive()

static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive ( LPRPCCHANNELBUFFER  iface,
RPCOLEMESSAGE *  olemsg,
ULONG pstatus 
)
static

Definition at line 1360 of file rpc.c.

1361{
1363 HRESULT hr;
1364 RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg;
1366 DWORD index;
1368 ORPCTHAT orpcthat;
1369 ORPC_EXTENT_ARRAY orpc_ext_array;
1370 WIRE_ORPC_EXTENT *first_wire_orpc_extent = NULL;
1371 HRESULT hrFault = S_OK;
1373 struct tlsdata *tlsdata;
1374
1375 TRACE("%p, iMethod %ld\n", olemsg, olemsg->iMethod);
1376
1378 if (hr != S_OK)
1379 {
1380 ERR("called from wrong apartment, should have been 0x%s\n",
1381 wine_dbgstr_longlong(This->oxid));
1383 return RPC_E_WRONG_THREAD;
1384 }
1385
1387 return hr;
1388
1389 /* This situation should be impossible in multi-threaded apartments,
1390 * because the calling thread isn't re-enterable.
1391 * Note: doing a COM call during the processing of a sent message is
1392 * only disallowed if a client call is already being waited for
1393 * completion */
1394 if (!apt->multi_threaded &&
1396 InSendMessage())
1397 {
1398 ERR("can't make an outgoing COM call in response to a sent message\n");
1401 }
1402
1403 message_state = msg->Handle;
1404 /* restore the binding handle and the real start of data */
1405 msg->Handle = message_state->binding_handle;
1406 msg->Buffer = (char *)msg->Buffer - message_state->prefix_data_len;
1407 msg->BufferLength += message_state->prefix_data_len;
1408
1409 /* Note: this is an optimization in the Microsoft OLE runtime that we need
1410 * to copy, as shown by the test_no_couninitialize_client test. without
1411 * short-circuiting the RPC runtime in the case below, the test will
1412 * deadlock on the loader lock due to the RPC runtime needing to create
1413 * a thread to process the RPC when this function is called indirectly
1414 * from DllMain */
1415
1416 message_state->params.msg = olemsg;
1417 if (message_state->params.bypass_rpcrt)
1418 {
1419 TRACE("Calling apartment thread %#lx...\n", message_state->target_tid);
1420
1421 msg->ProcNum &= ~RPC_FLAGS_VALID_BIT;
1422
1425 {
1426 ERR("PostMessage failed with error %lu\n", GetLastError());
1427
1428 /* Note: message_state->params.iface doesn't have a reference and
1429 * so doesn't need to be released */
1430
1432 }
1433 }
1434 else
1435 {
1436 /* we use a separate thread here because we need to be able to
1437 * pump the message loop in the application thread: if we do not,
1438 * any windows created by this thread will hang and RPCs that try
1439 * and re-enter this STA from an incoming server thread will
1440 * deadlock. InstallShield is an example of that.
1441 */
1443 {
1444 ERR("QueueUserWorkItem failed with error %lu\n", GetLastError());
1445 hr = E_UNEXPECTED;
1446 }
1447 else
1448 hr = S_OK;
1449 }
1450
1451 if (hr == S_OK)
1452 {
1454 {
1458 }
1459 }
1461
1462 /* for WM shortcut, faults are returned in params->hr */
1463 if (hr == S_OK)
1464 hrFault = message_state->params.hr;
1465
1466 status = message_state->params.status;
1467
1468 orpcthat.flags = ORPCF_NULL;
1469 orpcthat.extensions = NULL;
1470
1471 TRACE("RPC call status: %#lx\n", status);
1472 if (status != RPC_S_OK)
1474
1475 TRACE("hrFault = %#lx\n", hrFault);
1476
1477 /* FIXME: this condition should be
1478 * "hr == S_OK && (!hrFault || msg->BufferLength > FIELD_OFFSET(ORPCTHAT, extensions) + 4)"
1479 * but we don't currently reset the message length for PostMessage
1480 * dispatched calls */
1481 if (hr == S_OK && hrFault == S_OK)
1482 {
1483 HRESULT hr2;
1484 char *original_buffer = msg->Buffer;
1485
1486 /* handle ORPCTHAT and client extensions */
1487
1488 hr2 = unmarshal_ORPCTHAT(msg, &orpcthat, &orpc_ext_array, &first_wire_orpc_extent);
1489 if (FAILED(hr2))
1490 hr = hr2;
1491
1492 message_state->prefix_data_len = (char *)msg->Buffer - original_buffer;
1493 msg->BufferLength -= message_state->prefix_data_len;
1494 }
1495 else
1497
1498 if (hr == S_OK)
1499 {
1501 msg->DataRepresentation,
1502 first_wire_orpc_extent,
1503 orpcthat.extensions && first_wire_orpc_extent ? orpcthat.extensions->size : 0,
1504 hrFault);
1505 }
1506
1507 /* save away the message state again */
1508 msg->Handle = message_state;
1509
1510 if (pstatus) *pstatus = status;
1511
1512 if (hr == S_OK)
1513 hr = hrFault;
1514
1515 TRACE("-- %#lx\n", hr);
1516
1518 return hr;
1519}
struct apartment * apartment_get_current_or_mta(void)
Definition: apartment.c:623
#define index(s, c)
Definition: various.h:29
#define DM_EXECUTERPC
static HRESULT com_get_tlsdata(struct tlsdata **data)
HRESULT WINAPI CoWaitForMultipleHandles(DWORD flags, DWORD timeout, ULONG handle_count, HANDLE *handles, DWORD *index)
Definition: combase.c:2067
static HRESULT unmarshal_ORPCTHAT(RPC_MESSAGE *msg, ORPCTHAT *orpcthat, ORPC_EXTENT_ARRAY *orpc_ext_array, WIRE_ORPC_EXTENT **first_wire_orpc_extent)
Definition: rpc.c:1831
static DWORD WINAPI rpc_sendreceive_thread(LPVOID param)
Definition: rpc.c:1336
static void ClientRpcChannelBuffer_ReleaseEventHandle(ClientRpcChannelBuffer *This, HANDLE event)
Definition: rpc.c:1157
static void ChannelHooks_ClientNotify(SChannelHookCallInfo *info, DWORD lDataRep, WIRE_ORPC_EXTENT *first_wire_orpc_extent, ULONG extension_count, HRESULT hrFault)
Definition: rpc.c:941
static HRESULT ClientRpcChannelBuffer_IsCorrectApartment(ClientRpcChannelBuffer *This, const struct apartment *apt)
Definition: rpc.c:1351
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1076
#define INFINITE
Definition: serial.h:102
GLuint index
Definition: glext.h:6031
#define FAILED(hr)
Definition: intsafe.h:51
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG pending_call_count_client
struct apartment * apt
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define RPC_E_WRONG_THREAD
Definition: winerror.h:3562
#define RPC_E_CANTCALLOUT_ININPUTSYNCCALL
Definition: winerror.h:3561
#define E_UNEXPECTED
Definition: winerror.h:3528
#define WT_EXECUTEDEFAULT
Definition: winnt_old.h:1092
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI InSendMessage(void)
Definition: message.c:1372

◆ CoDecodeProxy()

HRESULT WINAPI CoDecodeProxy ( DWORD  client_pid,
UINT64  proxy_addr,
ServerInformation server_info 
)

Definition at line 2221 of file rpc.c.

2222{
2223 FIXME("%lx, %s, %p.\n", client_pid, wine_dbgstr_longlong(proxy_addr), server_info);
2224 return E_NOTIMPL;
2225}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99
static DWORD client_pid
Definition: msiexec.c:401

◆ create_local_service()

static HRESULT create_local_service ( REFCLSID  rclsid)
static

Definition at line 428 of file rpc.c.

429{
430 HRESULT hr;
432 HKEY hkey;
433 LONG r;
434 DWORD type, sz;
435
436 TRACE("Attempting to start Local service for %s\n", debugstr_guid(rclsid));
437
438 hr = open_appidkey_from_clsid(rclsid, KEY_READ, &hkey);
439 if (FAILED(hr))
440 return hr;
441
442 /* read the LocalService and ServiceParameters values from the AppID key */
443 sz = sizeof buf;
444 r = RegQueryValueExW(hkey, L"LocalService", NULL, &type, (LPBYTE)buf, &sz);
445 if (r == ERROR_SUCCESS && type == REG_SZ)
446 {
447 DWORD num_args = 0;
448 LPWSTR args[1] = { NULL };
449
450 /*
451 * FIXME: I'm not really sure how to deal with the service parameters.
452 * I suspect that the string returned from RegQueryValueExW
453 * should be split into a number of arguments by spaces.
454 * It would make more sense if ServiceParams contained a
455 * REG_MULTI_SZ here, but it's a REG_SZ for the services
456 * that I'm interested in for the moment.
457 */
458 r = RegQueryValueExW(hkey, L"ServiceParams", NULL, &type, NULL, &sz);
459 if (r == ERROR_SUCCESS && type == REG_SZ && sz)
460 {
461 args[0] = calloc(1, sz);
462 num_args++;
463 RegQueryValueExW(hkey, L"ServiceParams", NULL, &type, (LPBYTE)args[0], &sz);
464 }
465 r = start_local_service(buf, num_args, (LPCWSTR *)args);
466 if (r != ERROR_SUCCESS)
467 hr = REGDB_E_CLASSNOTREG; /* FIXME: check retval */
468 free(args[0]);
469 }
470 else
471 {
472 WARN("No LocalService value\n");
473 hr = REGDB_E_CLASSNOTREG; /* FIXME: check retval */
474 }
475 RegCloseKey(hkey);
476
477 return hr;
478}
#define WARN(fmt,...)
Definition: precomp.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
#define CHARS_IN_GUID
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
HRESULT open_appidkey_from_clsid(REFCLSID clsid, REGSAM access, HKEY *subkey)
Definition: combase.c:353
static DWORD start_local_service(const WCHAR *name, DWORD num, LPCWSTR *params)
Definition: rpc.c:389
#define L(x)
Definition: resources.c:13
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define REG_SZ
Definition: layer.c:22
#define KEY_READ
Definition: nt_native.h:1026
long LONG
Definition: pedump.c:60
Definition: match.c:390
unsigned char * LPBYTE
Definition: typedefs.h:53
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:3801
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by rpc_get_local_class_object().

◆ create_server()

static HRESULT create_server ( REFCLSID  rclsid,
HANDLE process 
)
static

Definition at line 480 of file rpc.c.

481{
482 static const WCHAR embeddingW[] = L" -Embedding";
483 HKEY key;
484 int arch = (sizeof(void *) > sizeof(int)) ? 64 : 32;
485 REGSAM opposite = (arch == 64) ? KEY_WOW64_32KEY : KEY_WOW64_64KEY;
486 BOOL is_wow64 = FALSE, is_opposite = FALSE;
487 HRESULT hr;
488 WCHAR command[MAX_PATH + ARRAY_SIZE(embeddingW)];
489 DWORD size = (MAX_PATH+1) * sizeof(WCHAR);
492 LONG ret;
493
494 TRACE("Attempting to start server for %s\n", debugstr_guid(rclsid));
495
496 hr = open_key_for_clsid(rclsid, L"LocalServer32", KEY_READ, &key);
497 if (FAILED(hr) && (arch == 64 || (IsWow64Process(GetCurrentProcess(), &is_wow64) && is_wow64)))
498 {
499 hr = open_key_for_clsid(rclsid, L"LocalServer32", opposite | KEY_READ, &key);
500 is_opposite = TRUE;
501 }
502 if (FAILED(hr))
503 {
504 ERR("class %s not registered\n", debugstr_guid(rclsid));
505 return hr;
506 }
507
510 if (ret)
511 {
512 WARN("No default value for LocalServer32 key\n");
513 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
514 }
515
516 memset(&sinfo, 0, sizeof(sinfo));
517 sinfo.cb = sizeof(sinfo);
518
519 /* EXE servers are started with the -Embedding switch. */
520
521 lstrcatW(command, embeddingW);
522
523 TRACE("activating local server %s for %s\n", debugstr_w(command), debugstr_guid(rclsid));
524
525 /* FIXME: Win2003 supports a ServerExecutable value that is passed into
526 * CreateProcess */
527 if (is_opposite)
528 {
529 void *cookie;
532 {
533 WARN("failed to run local server %s\n", debugstr_w(command));
535 }
537 if (FAILED(hr)) return hr;
538 }
540 {
541 WARN("failed to run local server %s\n", debugstr_w(command));
543 }
544 *process = pinfo.hProcess;
545 CloseHandle(pinfo.hThread);
546
547 return S_OK;
548}
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT open_key_for_clsid(REFCLSID clsid, const WCHAR *keyname, REGSAM access, HKEY *subkey)
Definition: combase.c:320
#define GetCurrentProcess()
Definition: compat.h:759
#define IsWow64Process
Definition: compat.h:760
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4442
BOOL WINAPI Wow64RevertWow64FsRedirection(IN PVOID OldValue)
Definition: utils.c:809
BOOL WINAPI Wow64DisableWow64FsRedirection(IN PVOID *OldValue)
Definition: utils.c:786
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_w
Definition: kernel32.h:32
BOOL is_wow64
Definition: main.c:38
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
Definition: cookie.c:34
Definition: copy.c:22
Definition: general.c:220
#define DETACHED_PROCESS
Definition: winbase.h:183
ACCESS_MASK REGSAM
Definition: winreg.h:76
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46

Referenced by rpc_get_local_class_object().

◆ create_surrogate_server()

static HRESULT create_surrogate_server ( REFCLSID  rclsid,
HANDLE process 
)
static

Definition at line 550 of file rpc.c.

551{
552 static const WCHAR processidW[] = L" /PROCESSID:";
553 HKEY key;
554 int arch = (sizeof(void *) > sizeof(int)) ? 64 : 32;
555 REGSAM opposite = (arch == 64) ? KEY_WOW64_32KEY : KEY_WOW64_64KEY;
556 BOOL is_wow64 = FALSE, is_opposite = FALSE;
557 HRESULT hr;
559 DWORD size;
562 LONG ret;
563
564 TRACE("Attempting to start surrogate server for %s\n", debugstr_guid(rclsid));
565
566 hr = open_key_for_clsid(rclsid, NULL, KEY_READ, &key);
567 if (FAILED(hr) && (arch == 64 || (IsWow64Process(GetCurrentProcess(), &is_wow64) && is_wow64)))
568 hr = open_key_for_clsid(rclsid, NULL, opposite | KEY_READ, &key);
569 if (FAILED(hr)) return hr;
571
573 if (FAILED(hr) && (arch == 64 || (IsWow64Process(GetCurrentProcess(), &is_wow64) && is_wow64)))
574 {
575 hr = open_appidkey_from_clsid(rclsid, opposite | KEY_READ, &key);
576 if (FAILED(hr)) return hr;
577 is_opposite = TRUE;
578 }
579
580 size = (MAX_PATH + 1) * sizeof(WCHAR);
581 ret = RegQueryValueExW(key, L"DllSurrogate", NULL, NULL, (LPBYTE)command, &size);
583 if (ret || !size || !command[0])
584 {
585 TRACE("No value for DllSurrogate key\n");
586
587 if ((sizeof(void *) == 8 || is_wow64) && opposite == KEY_WOW64_32KEY)
589 else
590 GetSystemDirectoryW(command, MAX_PATH - ARRAY_SIZE(L"\\dllhost.exe"));
591
592 wcscat(command, L"\\dllhost.exe");
593 }
594
595 /* Surrogate EXE servers are started with the /PROCESSID:{GUID} switch. */
596 wcscat(command, processidW);
598
599 memset(&si, 0, sizeof(si));
600 si.cb = sizeof(si);
601
602 TRACE("Activating surrogate local server %s\n", debugstr_w(command));
603
604 if (is_opposite)
605 {
606 void *cookie;
609 {
610 WARN("failed to run surrogate local server %s\n", debugstr_w(command));
612 }
614 }
616 {
617 WARN("failed to run surrogate local server %s\n", debugstr_w(command));
619 }
620
621 if (FAILED(hr)) return hr;
622
625
626 return S_OK;
627}
INT WINAPI StringFromGUID2(REFGUID guid, LPOLESTR str, INT cmax)
Definition: combase.c:1525
UINT WINAPI GetSystemWow64DirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2340
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2232
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static SYSTEM_INFO si
Definition: virtual.c:39
wcscat

Referenced by rpc_get_local_class_object().

◆ dispatch_rpc()

static void __RPC_STUB dispatch_rpc ( RPC_MESSAGE msg)
static

Definition at line 1997 of file rpc.c.

1998{
1999 struct dispatch_params *params;
2000 struct stub_manager *stub_manager;
2001 struct apartment *apt;
2002 IPID ipid;
2003 HRESULT hr;
2004
2005 RpcBindingInqObject(msg->Handle, &ipid);
2006
2007 TRACE("ipid = %s, iMethod = %d\n", debugstr_guid(&ipid), msg->ProcNum);
2008
2009 params = malloc(sizeof(*params));
2010 if (!params)
2011 {
2013 return;
2014 }
2015
2016 hr = ipid_get_dispatch_params(&ipid, &apt, &stub_manager, &params->stub, &params->chan,
2017 &params->iid, &params->iface);
2018 if (hr != S_OK)
2019 {
2020 ERR("no apartment found for ipid %s\n", debugstr_guid(&ipid));
2021 free(params);
2023 return;
2024 }
2025
2026 params->msg = (RPCOLEMESSAGE *)msg;
2027 params->status = RPC_S_OK;
2028 params->hr = S_OK;
2029 params->handle = NULL;
2030 params->bypass_rpcrt = FALSE;
2031
2032 /* Note: this is the important difference between STAs and MTAs - we
2033 * always execute RPCs to STAs in the thread that originally created the
2034 * apartment (i.e. the one that pumps messages to the window) */
2035 if (!apt->multi_threaded)
2036 {
2037 params->handle = CreateEventW(NULL, FALSE, FALSE, NULL);
2038
2039 TRACE("Calling apartment thread %#lx...\n", apt->tid);
2040
2043 else
2044 {
2045 ERR("PostMessage failed with error %lu\n", GetLastError());
2046 IRpcChannelBuffer_Release(params->chan);
2047 IRpcStubBuffer_Release(params->stub);
2048 }
2049 CloseHandle(params->handle);
2050 }
2051 else
2052 {
2053 BOOL joined = FALSE;
2054 struct tlsdata *tlsdata;
2055
2057
2058 if (!tlsdata->apt)
2059 {
2061 joined = TRUE;
2062 }
2064 if (joined)
2065 {
2067 }
2068 }
2069
2070 hr = params->hr;
2071 if (params->chan)
2072 IRpcChannelBuffer_Release(params->chan);
2073 if (params->stub)
2074 IRpcStubBuffer_Release(params->stub);
2075 free(params);
2076
2079
2080 /* if IRpcStubBuffer_Invoke fails, we should raise an exception to tell
2081 * the RPC runtime that the call failed */
2082 if (hr != S_OK) RpcRaiseException(hr);
2083}
HRESULT enter_apartment(struct tlsdata *data, DWORD model)
Definition: apartment.c:1129
void leave_apartment(struct tlsdata *data)
Definition: apartment.c:1153
ULONG stub_manager_int_release(struct stub_manager *stub_manager)
Definition: stubmanager.c:309
void rpc_execute_call(struct dispatch_params *params)
Definition: rpc.c:1874
GLenum const GLfloat * params
Definition: glext.h:5645
@ COINIT_MULTITHREADED
Definition: objbase.h:280
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:213

◆ DllDebugObjectRPCHook()

BOOL WINAPI DllDebugObjectRPCHook ( BOOL  trace,
void args 
)

Definition at line 2211 of file rpc.c.

2212{
2213 FIXME("%d, %p: stub\n", trace, args);
2214
2215 return TRUE;
2216}
#define trace
Definition: atltest.h:70

◆ get_irot_handle()

static RPC_BINDING_HANDLE get_irot_handle ( void  )
static

Definition at line 273 of file rpc.c.

274{
275 static RPC_BINDING_HANDLE irot_handle;
276
277 if (!irot_handle)
278 {
279 unsigned short protseq[] = IROT_PROTSEQ;
280 unsigned short endpoint[] = IROT_ENDPOINT;
281
282 RPC_BINDING_HANDLE new_handle = get_rpc_handle(protseq, endpoint);
283 if (InterlockedCompareExchangePointer(&irot_handle, new_handle, NULL))
284 /* another thread beat us to it */
285 RpcBindingFree(&new_handle);
286 }
287 return irot_handle;
288}
static RPC_BINDING_HANDLE get_rpc_handle(unsigned short *protseq, unsigned short *endpoint)
Definition: rpc.c:240
Definition: nis.h:10

Referenced by InternalIrotEnumRunning(), InternalIrotGetObject(), InternalIrotGetTimeOfLastChange(), InternalIrotIsRunning(), InternalIrotNoteChangeTime(), InternalIrotRegister(), and InternalIrotRevoke().

◆ get_irpcss_handle()

static RPC_BINDING_HANDLE get_irpcss_handle ( void  )
static

Definition at line 256 of file rpc.c.

257{
258 static RPC_BINDING_HANDLE irpcss_handle;
259
260 if (!irpcss_handle)
261 {
262 unsigned short protseq[] = IRPCSS_PROTSEQ;
263 unsigned short endpoint[] = IRPCSS_ENDPOINT;
264
265 RPC_BINDING_HANDLE new_handle = get_rpc_handle(protseq, endpoint);
266 if (InterlockedCompareExchangePointer(&irpcss_handle, new_handle, NULL))
267 /* another thread beat us to it */
268 RpcBindingFree(&new_handle);
269 }
270 return irpcss_handle;
271}

Referenced by rpc_revoke_local_server(), rpcss_get_class_object(), rpcss_get_next_seqid(), and rpcss_server_register().

◆ get_rpc_endpoint()

static void get_rpc_endpoint ( LPWSTR  endpoint,
const OXID oxid 
)
inlinestatic

Definition at line 80 of file rpc.c.

81{
82 /* FIXME: should get endpoint from rpcss */
83 wsprintfW(endpoint, L"\\pipe\\OLE_%016I64x", *oxid);
84}
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

Referenced by rpc_create_clientchannel(), and rpc_start_remoting().

◆ get_rpc_handle()

static RPC_BINDING_HANDLE get_rpc_handle ( unsigned short protseq,
unsigned short endpoint 
)
static

Definition at line 240 of file rpc.c.

241{
245
247 if (status == RPC_S_OK)
248 {
251 }
252
253 return handle;
254}
static RPC_BINDING_HANDLE binding
Definition: server.c:166
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:862
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:493
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:181

Referenced by get_irot_handle(), and get_irpcss_handle().

◆ InternalIrotEnumRunning()

HRESULT WINAPI InternalIrotEnumRunning ( PInterfaceList *  list)

Definition at line 353 of file rpc.c.

354{
358}
Definition: list.h:37
static RPC_BINDING_HANDLE get_irot_handle(void)
Definition: rpc.c:273
#define RPCSS_CALL_START
Definition: rpc.c:290
#define RPCSS_CALL_END
Definition: rpc.c:295
HRESULT __cdecl IrotEnumRunning(IrotHandle h, PInterfaceList *list)
Definition: irotp.c:315

Referenced by RunningObjectTableImpl_EnumRunning().

◆ InternalIrotGetObject()

HRESULT WINAPI InternalIrotGetObject ( const MonikerComparisonData moniker_data,
PInterfaceData *  obj,
IrotCookie *  cookie 
)

Definition at line 331 of file rpc.c.

333{
335 hr = IrotGetObject(get_irot_handle(), moniker_data, obj, cookie);
337}
HRESULT __cdecl IrotGetObject(IrotHandle h, const MonikerComparisonData *moniker_data, PInterfaceData *obj, IrotCookie *cookie)
Definition: irotp.c:221

Referenced by RunningObjectTableImpl_GetObject().

◆ InternalIrotGetTimeOfLastChange()

HRESULT WINAPI InternalIrotGetTimeOfLastChange ( const MonikerComparisonData moniker_data,
FILETIME time 
)

Definition at line 346 of file rpc.c.

347{
351}
HRESULT __cdecl IrotGetTimeOfLastChange(IrotHandle h, const MonikerComparisonData *moniker_data, FILETIME *time)
Definition: irotp.c:287
__u16 time
Definition: mkdosfs.c:8

Referenced by RunningObjectTableImpl_GetTimeOfLastChange().

◆ InternalIrotIsRunning()

HRESULT WINAPI InternalIrotIsRunning ( const MonikerComparisonData moniker_data)

Definition at line 324 of file rpc.c.

325{
327 hr = IrotIsRunning(get_irot_handle(), moniker_data);
329}
HRESULT __cdecl IrotIsRunning(IrotHandle h, const MonikerComparisonData *data)
Definition: irotp.c:196

Referenced by RunningObjectTableImpl_IsRunning().

◆ InternalIrotNoteChangeTime()

HRESULT WINAPI InternalIrotNoteChangeTime ( IrotCookie  cookie,
const FILETIME time 
)

Definition at line 339 of file rpc.c.

340{
344}
HRESULT __cdecl IrotNoteChangeTime(IrotHandle h, IrotCookie cookie, const FILETIME *last_modified_time)
Definition: irotp.c:263

Referenced by RunningObjectTableImpl_NoteChangeTime().

◆ InternalIrotRegister()

HRESULT WINAPI InternalIrotRegister ( const MonikerComparisonData moniker_data,
const InterfaceData *  object,
const InterfaceData *  moniker,
const FILETIME time,
DWORD  flags,
IrotCookie *  cookie,
IrotContextHandle *  ctxt_handle 
)

Definition at line 315 of file rpc.c.

318{
320 hr = IrotRegister(get_irot_handle(), moniker_data, object, moniker, time, flags, cookie, ctxt_handle);
322}
GLbitfield flags
Definition: glext.h:7161
HRESULT __cdecl IrotRegister(IrotHandle h, const MonikerComparisonData *data, const InterfaceData *obj, const InterfaceData *mk, const FILETIME *time, DWORD grfFlags, IrotCookie *cookie, IrotContextHandle *ctxt_handle)
Definition: irotp.c:71
Definition: main.c:40

Referenced by RunningObjectTableImpl_Register().

◆ InternalIrotRevoke()

HRESULT WINAPI InternalIrotRevoke ( IrotCookie  cookie,
IrotContextHandle *  ctxt_handle,
PInterfaceData *  object,
PInterfaceData *  moniker 
)

Definition at line 360 of file rpc.c.

362{
364 hr = IrotRevoke(get_irot_handle(), cookie, ctxt_handle, object, moniker);
366}
HRESULT __cdecl IrotRevoke(IrotHandle h, IrotCookie cookie, IrotContextHandle *ctxt_handle, PInterfaceData *obj, PInterfaceData *mk)
Definition: irotp.c:149

Referenced by rot_entry_delete().

◆ MIDL_user_allocate()

void *__RPC_USER MIDL_user_allocate ( SIZE_T  size)

Definition at line 174 of file rpc.c.

175{
176 return malloc(size);
177}

◆ MIDL_user_free()

void __RPC_USER MIDL_user_free ( void p)

Definition at line 179 of file rpc.c.

180{
181 free(p);
182}
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by rpc_get_local_class_object().

◆ rpc_create_clientchannel()

HRESULT rpc_create_clientchannel ( const OXID oxid,
const IPID ipid,
const OXID_INFO *  oxid_info,
const IID iid,
DWORD  dest_context,
void dest_context_data,
IRpcChannelBuffer **  chan,
struct apartment apt 
)

Definition at line 1642 of file rpc.c.

1646{
1648 WCHAR endpoint[200];
1651 LPWSTR string_binding;
1652
1653 /* FIXME: get the endpoint from oxid_info->psa instead */
1655
1656 TRACE("proxy pipe: connecting to endpoint: %s\n", debugstr_w(endpoint));
1657
1659 NULL,
1661 NULL,
1662 endpoint,
1663 NULL,
1664 &string_binding);
1665
1666 if (status == RPC_S_OK)
1667 {
1668 status = RpcBindingFromStringBindingW(string_binding, &bind);
1669
1670 if (status == RPC_S_OK)
1671 {
1672 IPID ipid2 = *ipid; /* why can't RpcBindingSetObject take a const? */
1673 status = RpcBindingSetObject(bind, &ipid2);
1674 if (status != RPC_S_OK)
1676 }
1677
1678 RpcStringFreeW(&string_binding);
1679 }
1680
1681 if (status != RPC_S_OK)
1682 {
1683 ERR("Couldn't get binding for endpoint %s, status = %ld\n", debugstr_w(endpoint), status);
1684 return HRESULT_FROM_WIN32(status);
1685 }
1686
1687 This = malloc(sizeof(*This));
1688 if (!This)
1689 {
1691 return E_OUTOFMEMORY;
1692 }
1693
1694 This->super.IRpcChannelBuffer_iface.lpVtbl = &ClientRpcChannelBufferVtbl;
1695 This->super.refs = 1;
1696 This->super.dest_context = dest_context;
1697 This->super.dest_context_data = dest_context_data;
1698 This->bind = bind;
1699 This->oxid = apartment_getoxid(apt);
1700 This->server_pid = oxid_info->dwPid;
1701 This->event = NULL;
1702 This->iid = *iid;
1703
1704 *chan = &This->super.IRpcChannelBuffer_iface;
1705
1706 return S_OK;
1707}
static void get_rpc_endpoint(LPWSTR endpoint, const OXID *oxid)
Definition: rpc.c:80
static const IRpcChannelBufferVtbl ClientRpcChannelBufferVtbl
Definition: rpc.c:1617
static WCHAR rpctransportW[]
Definition: rpc.c:70
RPC_STATUS WINAPI RpcBindingSetObject(RPC_BINDING_HANDLE Binding, UUID *ObjectUuid)
Definition: rpc_binding.c:810
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36

Referenced by unmarshal_object().

◆ rpc_create_serverchannel()

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

Definition at line 1709 of file rpc.c.

1710{
1711 RpcChannelBuffer *This = malloc(sizeof(*This));
1712 if (!This)
1713 return E_OUTOFMEMORY;
1714
1715 This->IRpcChannelBuffer_iface.lpVtbl = &ServerRpcChannelBufferVtbl;
1716 This->refs = 1;
1717 This->dest_context = dest_context;
1718 This->dest_context_data = dest_context_data;
1719
1720 *chan = &This->IRpcChannelBuffer_iface;
1721
1722 return S_OK;
1723}
static const IRpcChannelBufferVtbl ServerRpcChannelBufferVtbl
Definition: rpc.c:1629

Referenced by stub_manager_new_ifstub().

◆ rpc_execute_call()

void rpc_execute_call ( struct dispatch_params params)

Definition at line 1874 of file rpc.c.

1875{
1877 RPC_MESSAGE *msg = (RPC_MESSAGE *)params->msg;
1878 char *original_buffer = msg->Buffer;
1879 ORPCTHIS orpcthis;
1880 ORPC_EXTENT_ARRAY orpc_ext_array;
1881 WIRE_ORPC_EXTENT *first_wire_orpc_extent;
1882 GUID old_causality_id;
1883 struct tlsdata *tlsdata;
1884 struct apartment *apt;
1885
1887 return;
1888
1889 apt = com_get_current_apt();
1890
1891 /* handle ORPCTHIS and server extensions */
1892
1893 params->hr = unmarshal_ORPCTHIS(msg, &orpcthis, &orpc_ext_array, &first_wire_orpc_extent);
1894 if (params->hr != S_OK)
1895 {
1896 msg->Buffer = original_buffer;
1897 goto exit;
1898 }
1899
1901 if (!message_state)
1902 {
1903 params->hr = E_OUTOFMEMORY;
1904 msg->Buffer = original_buffer;
1905 goto exit;
1906 }
1907
1908 message_state->prefix_data_len = (char *)msg->Buffer - original_buffer;
1909 message_state->binding_handle = msg->Handle;
1910 message_state->bypass_rpcrt = params->bypass_rpcrt;
1911
1914 message_state->channel_hook_info.uCausality = orpcthis.cid;
1916 message_state->channel_hook_info.iMethod = msg->ProcNum;
1917 message_state->channel_hook_info.pObject = params->iface;
1918
1919 if (orpcthis.extensions && first_wire_orpc_extent &&
1920 orpcthis.extensions->size)
1921 ChannelHooks_ServerNotify(&message_state->channel_hook_info, msg->DataRepresentation, first_wire_orpc_extent, orpcthis.extensions->size);
1922
1923 msg->Handle = message_state;
1924 msg->BufferLength -= message_state->prefix_data_len;
1925
1926 /* call message filter */
1927
1928 if (apt->filter)
1929 {
1930 DWORD handlecall;
1931 INTERFACEINFO interface_info;
1932 CALLTYPE calltype;
1933
1934 interface_info.pUnk = params->iface;
1935 interface_info.iid = params->iid;
1936 interface_info.wMethod = msg->ProcNum;
1937
1938 if (IsEqualGUID(&orpcthis.cid, &tlsdata->causality_id))
1939 calltype = CALLTYPE_NESTED;
1940 else if (tlsdata->pending_call_count_server == 0)
1941 calltype = CALLTYPE_TOPLEVEL;
1942 else
1943 calltype = CALLTYPE_TOPLEVEL_CALLPENDING;
1944
1945 handlecall = IMessageFilter_HandleInComingCall(apt->filter,
1946 calltype,
1948 0 /* FIXME */,
1950 TRACE("IMessageFilter_HandleInComingCall returned %ld\n", handlecall);
1951 switch (handlecall)
1952 {
1953 case SERVERCALL_REJECTED:
1955 goto exit_reset_state;
1956 case SERVERCALL_RETRYLATER:
1957#if 0 /* FIXME: handle retries on the client side before enabling this code */
1958 params->hr = RPC_E_RETRY;
1959 goto exit_reset_state;
1960#else
1961 FIXME("retry call later not implemented\n");
1962 break;
1963#endif
1964 case SERVERCALL_ISHANDLED:
1965 default:
1966 break;
1967 }
1968 }
1969
1970 /* invoke the method */
1971
1972 /* save the old causality ID - note: any calls executed while processing
1973 * messages received during the SendReceive will appear to originate from
1974 * this call - this should be checked with what Windows does */
1975 old_causality_id = tlsdata->causality_id;
1976 tlsdata->causality_id = orpcthis.cid;
1978 params->hr = IRpcStubBuffer_Invoke(params->stub, params->msg, params->chan);
1980 tlsdata->causality_id = old_causality_id;
1981
1982 /* the invoke allocated a new buffer, so free the old one */
1983 if (message_state->bypass_rpcrt && original_buffer != msg->Buffer)
1984 free(original_buffer);
1985
1986exit_reset_state:
1987 message_state = msg->Handle;
1988 msg->Handle = message_state->binding_handle;
1989 msg->Buffer = (char *)msg->Buffer - message_state->prefix_data_len;
1990 msg->BufferLength += message_state->prefix_data_len;
1991
1992exit:
1994 if (params->handle) SetEvent(params->handle);
1995}
#define UlongToHandle(ul)
Definition: basetsd.h:91
static struct apartment * com_get_current_apt(void)
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:1780
static void ChannelHooks_ServerNotify(SChannelHookCallInfo *info, DWORD lDataRep, WIRE_ORPC_EXTENT *first_wire_orpc_extent, ULONG extension_count)
Definition: rpc.c:821
#define exit(n)
Definition: config.h:202
BOOL bypass_rpcrt
Definition: rpc.c:124
LONG pending_call_count_server
GUID causality_id
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1156
#define RPC_E_RETRY
Definition: winerror.h:3557
#define RPC_E_CALL_REJECTED
Definition: winerror.h:3530

Referenced by apartment_wndproc(), and dispatch_rpc().

◆ rpc_filter()

◆ rpc_get_local_class_object()

HRESULT rpc_get_local_class_object ( REFCLSID  rclsid,
REFIID  riid,
void **  obj 
)

Definition at line 629 of file rpc.c.

630{
631 PMInterfacePointer objref = NULL;
634 ULARGE_INTEGER newpos;
636 int tries = 0;
638 HRESULT hr;
639 static const int MAXTRIES = 30; /* 30 seconds */
640
641 TRACE("clsid %s, riid %s\n", debugstr_guid(rclsid), debugstr_guid(riid));
642
643 while (tries++ < MAXTRIES)
644 {
645 DWORD index, start_ticks;
646 HANDLE process = 0;
647
648 if (SUCCEEDED(hr = rpcss_get_class_object(rclsid, &objref)))
649 break;
650
651 if (tries == 1)
652 {
653 if ((hr = create_local_service(rclsid)) && (hr = create_server(rclsid, &process)) &&
654 (hr = create_surrogate_server(rclsid, &process)) )
655 return hr;
656 }
657
658 /* Wait for one second, even if messages arrive. */
659 start_ticks = GetTickCount();
660 do
661 {
662 if (SUCCEEDED(CoWaitForMultipleHandles(0, 1000, (process != 0), &process, &index)) && process && !index)
663 {
664 WARN("Server for %s failed to start.\n", debugstr_guid(rclsid));
666 return E_NOINTERFACE;
667 }
668 } while (GetTickCount() - start_ticks < 1000);
669
671 }
672
673 if (!objref || tries >= MAXTRIES)
674 return E_NOINTERFACE;
675
677 hr = IStream_Write(stream, objref->abData, objref->ulCntData, &length);
678
679 MIDL_user_free(objref);
680
681 if (SUCCEEDED(hr))
682 {
683 seekto.QuadPart = 0;
684 IStream_Seek(stream, seekto, STREAM_SEEK_SET, &newpos);
685
686 TRACE("Unmarshalling local server.\n");
687 hr = CoUnmarshalInterface(stream, &IID_IServiceProvider, (void **)&local_server);
688 if (SUCCEEDED(hr))
689 {
690 hr = IServiceProvider_QueryService(local_server, rclsid, riid, obj);
691 IServiceProvider_Release(local_server);
692 }
693 }
694
695 if (stream)
696 IStream_Release(stream);
697
698 return hr;
699}
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
HRESULT WINAPI CoUnmarshalInterface(IStream *stream, REFIID riid, void **ppv)
Definition: marshal.c:793
static HRESULT create_server(REFCLSID rclsid, HANDLE *process)
Definition: rpc.c:480
static HRESULT create_local_service(REFCLSID rclsid)
Definition: rpc.c:428
static HRESULT create_surrogate_server(REFCLSID rclsid, HANDLE *process)
Definition: rpc.c:550
void __RPC_USER MIDL_user_free(void *p)
Definition: rpc.c:179
static HRESULT rpcss_get_class_object(REFCLSID rclsid, PMInterfacePointer *objref)
Definition: rpc.c:382
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define seekto(pos, errstr)
Definition: mkdosfs.c:1613
Definition: parse.h:23
#define E_NOINTERFACE
Definition: winerror.h:3479

Referenced by com_get_class_object().

◆ rpc_register_channel_hook()

HRESULT rpc_register_channel_hook ( REFGUID  rguid,
IChannelHook hook 
)

Definition at line 971 of file rpc.c.

972{
974
975 entry = malloc(sizeof(*entry));
976 if (!entry)
977 return E_OUTOFMEMORY;
978
979 entry->id = *rguid;
980 entry->hook = hook;
981 IChannelHook_AddRef(hook);
982
986
987 return S_OK;
988}
@ hook
Definition: SystemMenu.c:35
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83

Referenced by CoRegisterChannelHook().

◆ rpc_register_interface()

HRESULT rpc_register_interface ( REFIID  riid)

Definition at line 2086 of file rpc.c.

2087{
2088 struct registered_if *rif;
2089 BOOL found = FALSE;
2090 HRESULT hr = S_OK;
2091
2092 TRACE("(%s)\n", debugstr_guid(riid));
2093
2096 {
2098 {
2099 rif->refs++;
2100 found = TRUE;
2101 break;
2102 }
2103 }
2104 if (!found)
2105 {
2106 TRACE("Creating new interface\n");
2107
2108 rif = calloc(1, sizeof(*rif));
2109 if (rif)
2110 {
2112
2113 rif->refs = 1;
2114 rif->If.Length = sizeof(RPC_SERVER_INTERFACE);
2115 /* RPC interface ID = COM interface ID */
2116 rif->If.InterfaceId.SyntaxGUID = *riid;
2118 /* all other fields are 0, including the version asCOM objects
2119 * always have a version of 0.0 */
2121 (RPC_IF_HANDLE)&rif->If,
2122 NULL, NULL,
2125 NULL);
2126 if (status == RPC_S_OK)
2128 else
2129 {
2130 ERR("RpcServerRegisterIfEx failed with error %ld\n", status);
2131 free(rif);
2133 }
2134 }
2135 else
2136 hr = E_OUTOFMEMORY;
2137 }
2139 return hr;
2140}
static RPC_DISPATCH_TABLE rpc_dispatch
Definition: rpc.c:48
static CRITICAL_SECTION csRegIf
Definition: rpc.c:51
static struct list registered_interfaces
Definition: rpc.c:50
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:1125
#define RPC_C_LISTEN_MAX_CALLS_DEFAULT
Definition: rpcdce.h:122
#define RPC_IF_AUTOLISTEN
Definition: rpcdce.h:313
#define RPC_IF_OLE
Definition: rpcdce.h:314
struct _RPC_SERVER_INTERFACE RPC_SERVER_INTERFACE
unsigned int Length
Definition: rpcdcep.h:103
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:104
PRPC_DISPATCH_TABLE DispatchTable
Definition: rpcdcep.h:106
DWORD refs
Definition: rpc.c:75
struct list entry
Definition: rpc.c:74
RPC_SERVER_INTERFACE If
Definition: rpc.c:76

Referenced by marshal_object().

◆ rpc_register_local_server()

HRESULT rpc_register_local_server ( REFCLSID  clsid,
IStream stream,
DWORD  flags,
unsigned int cookie 
)

Definition at line 701 of file rpc.c.

702{
703 MInterfacePointer *obj;
704 const void *ptr;
705 HGLOBAL hmem;
706 SIZE_T size;
707 HRESULT hr;
708
709 TRACE("%s, %#lx\n", debugstr_guid(clsid), flags);
710
712 if (FAILED(hr)) return hr;
713
714 size = GlobalSize(hmem);
715 if (!(obj = malloc(FIELD_OFFSET(MInterfacePointer, abData[size]))))
716 return E_OUTOFMEMORY;
717 obj->ulCntData = size;
718 ptr = GlobalLock(hmem);
719 memcpy(obj->abData, ptr, size);
720 GlobalUnlock(hmem);
721
723
724 free(obj);
725
726 return hr;
727}
HRESULT WINAPI GetHGlobalFromStream(IStream *stream, HGLOBAL *phglobal)
static HRESULT rpcss_server_register(REFCLSID clsid, DWORD flags, MInterfacePointer *obj, unsigned int *cookie)
Definition: rpc.c:368
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
const CLSID * clsid
Definition: msctf.cpp:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by CoRegisterClassObject().

◆ rpc_resolve_oxid()

HRESULT rpc_resolve_oxid ( OXID  oxid,
OXID_INFO *  oxid_info 
)

Definition at line 2165 of file rpc.c.

2166{
2167 TRACE("%s\n", wine_dbgstr_longlong(oxid));
2168
2169 oxid_info->dwTid = 0;
2170 oxid_info->dwPid = 0;
2171 oxid_info->dwAuthnHint = RPC_C_AUTHN_LEVEL_NONE;
2172 /* FIXME: this is a hack around not having an OXID resolver yet -
2173 * this function should contact the machine's OXID resolver and then it
2174 * should give us the IPID of the IRemUnknown interface */
2175 oxid_info->ipidRemUnknown.Data1 = 0xffffffff;
2176 oxid_info->ipidRemUnknown.Data2 = 0xffff;
2177 oxid_info->ipidRemUnknown.Data3 = 0xffff;
2178 memcpy(oxid_info->ipidRemUnknown.Data4, &oxid, sizeof(OXID));
2179 oxid_info->psa = NULL /* FIXME */;
2180
2181 return S_OK;
2182}
UINT64 OXID
Definition: marshal.c:86
#define RPC_C_AUTHN_LEVEL_NONE
Definition: rpcdce.h:146

Referenced by proxy_manager_construct().

◆ rpc_revoke_local_server()

HRESULT rpc_revoke_local_server ( unsigned int  cookie)

Definition at line 375 of file rpc.c.

376{
380}
static RPC_BINDING_HANDLE get_irpcss_handle(void)
Definition: rpc.c:256
HRESULT __cdecl irpcss_server_revoke(handle_t h, unsigned int cookie)
Definition: rpcss_main.c:92

Referenced by com_revoke_class_object().

◆ rpc_sendreceive_thread()

static DWORD WINAPI rpc_sendreceive_thread ( LPVOID  param)
static

Definition at line 1336 of file rpc.c.

1337{
1338 struct dispatch_params *data = param;
1339
1340 /* Note: I_RpcSendReceive doesn't raise exceptions like the higher-level
1341 * RPC functions do */
1342 data->status = I_RpcSendReceive((RPC_MESSAGE *)data->msg);
1343
1344 TRACE("completed with status %#lx\n", data->status);
1345
1346 SetEvent(data->handle);
1347
1348 return 0;
1349}
GLfloat param
Definition: glext.h:5796
RPC_STATUS WINAPI I_RpcSendReceive(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1914

Referenced by ClientRpcChannelBuffer_SendReceive().

◆ rpc_start_remoting()

void rpc_start_remoting ( struct apartment apt)

Definition at line 2186 of file rpc.c.

2187{
2189 {
2190 WCHAR endpoint[200];
2192
2194
2198 endpoint,
2199 NULL);
2200 if (status != RPC_S_OK)
2201 ERR("Couldn't register endpoint %s\n", debugstr_w(endpoint));
2202
2203 /* FIXME: move remote unknown exporting into this function */
2204 }
2206}
#define InterlockedExchange
Definition: armddk.h:54
HRESULT start_apartment_remote_unknown(struct apartment *apt)
Definition: stubmanager.c:838
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927
#define RPC_C_PROTSEQ_MAX_REQS_DEFAULT
Definition: rpcdce.h:123
LONG remoting_started

Referenced by StdMarshalImpl_MarshalInterface().

◆ rpc_unregister_channel_hooks()

void rpc_unregister_channel_hooks ( void  )

Definition at line 990 of file rpc.c.

991{
993 struct channel_hook_entry *cursor2;
994
997 free(cursor);
1001}
const char cursor[]
Definition: icontest.c:13
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by DllMain().

◆ rpc_unregister_interface()

void rpc_unregister_interface ( REFIID  riid,
BOOL  wait 
)

Definition at line 2143 of file rpc.c.

2144{
2145 struct registered_if *rif;
2148 {
2150 {
2151 if (!--rif->refs)
2152 {
2154 list_remove(&rif->entry);
2155 free(rif);
2156 }
2157 break;
2158 }
2159 }
2161}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
RPC_STATUS WINAPI RpcServerUnregisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, UINT WaitForCallsToComplete)
Definition: rpc_server.c:1202

Referenced by stub_manager_delete_ifstub(), and stub_manager_disconnect().

◆ RpcChannelBuffer_AddRef()

static ULONG WINAPI RpcChannelBuffer_AddRef ( LPRPCCHANNELBUFFER  iface)
static

Definition at line 1017 of file rpc.c.

1018{
1020 return InterlockedIncrement(&This->refs);
1021}
#define InterlockedIncrement
Definition: armddk.h:53

◆ RpcChannelBuffer_IsConnected()

static HRESULT WINAPI RpcChannelBuffer_IsConnected ( LPRPCCHANNELBUFFER  iface)
static

Definition at line 1610 of file rpc.c.

1611{
1612 TRACE("()\n");
1613 /* native does nothing too */
1614 return S_OK;
1615}

◆ RpcChannelBuffer_QueryInterface()

static HRESULT WINAPI RpcChannelBuffer_QueryInterface ( IRpcChannelBuffer iface,
REFIID  riid,
LPVOID ppv 
)
static

Definition at line 1005 of file rpc.c.

1006{
1007 *ppv = NULL;
1008 if (IsEqualIID(riid,&IID_IRpcChannelBuffer) || IsEqualIID(riid,&IID_IUnknown))
1009 {
1010 *ppv = iface;
1011 IRpcChannelBuffer_AddRef(iface);
1012 return S_OK;
1013 }
1014 return E_NOINTERFACE;
1015}
const GUID IID_IUnknown
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ rpcss_get_class_object()

static HRESULT rpcss_get_class_object ( REFCLSID  rclsid,
PMInterfacePointer *  objref 
)
static

Definition at line 382 of file rpc.c.

383{
385 hr = irpcss_get_class_object(get_irpcss_handle(), rclsid, objref);
387}
HRESULT __cdecl irpcss_get_class_object(handle_t h, const GUID *clsid, PMInterfacePointer *object)
Definition: rpcss_main.c:112

Referenced by rpc_get_local_class_object().

◆ rpcss_get_next_seqid()

HRESULT rpcss_get_next_seqid ( DWORD id)

Definition at line 308 of file rpc.c.

309{
313}
HRESULT __cdecl irpcss_get_thread_seq_id(handle_t h, DWORD *id)
Definition: rpcss_main.c:144

Referenced by CoGetCurrentProcess().

◆ rpcss_server_register()

static HRESULT rpcss_server_register ( REFCLSID  clsid,
DWORD  flags,
MInterfacePointer *  obj,
unsigned int cookie 
)
static

Definition at line 368 of file rpc.c.

369{
373}
HRESULT __cdecl irpcss_server_register(handle_t h, const GUID *clsid, unsigned int flags, PMInterfacePointer object, unsigned int *cookie)
Definition: rpcss_main.c:58

Referenced by rpc_register_local_server().

◆ ServerRpcChannelBuffer_FreeBuffer()

static HRESULT WINAPI ServerRpcChannelBuffer_FreeBuffer ( LPRPCCHANNELBUFFER  iface,
RPCOLEMESSAGE *  olemsg 
)
static

Definition at line 1521 of file rpc.c.

1522{
1523 RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg;
1526
1527 TRACE("(%p)\n", msg);
1528
1529 message_state = msg->Handle;
1530 /* restore the binding handle and the real start of data */
1531 msg->Handle = message_state->binding_handle;
1532 msg->Buffer = (char *)msg->Buffer - message_state->prefix_data_len;
1533 msg->BufferLength += message_state->prefix_data_len;
1535
1537 {
1538 free(msg->Buffer);
1539 status = RPC_S_OK;
1540 }
1541 else
1543
1544 msg->Handle = message_state;
1545
1546 TRACE("-- %ld\n", status);
1547
1548 return HRESULT_FROM_WIN32(status);
1549}

◆ ServerRpcChannelBuffer_GetBuffer()

static HRESULT WINAPI ServerRpcChannelBuffer_GetBuffer ( LPRPCCHANNELBUFFER  iface,
RPCOLEMESSAGE *  olemsg,
REFIID  riid 
)
static

Definition at line 1051 of file rpc.c.

1052{
1054 RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg;
1056 ORPCTHAT *orpcthat;
1058 ULONG extensions_size;
1059 struct channel_hook_buffer_data *channel_hook_data;
1060 unsigned int channel_hook_count;
1061 ULONG extension_count;
1062
1063 TRACE("(%p)->(%p,%s)\n", This, olemsg, debugstr_guid(riid));
1064
1065 message_state = msg->Handle;
1066 /* restore the binding handle and the real start of data */
1067 msg->Handle = message_state->binding_handle;
1068 msg->Buffer = (char *)msg->Buffer - message_state->prefix_data_len;
1069
1071 &channel_hook_data, &channel_hook_count, &extension_count);
1072
1073 msg->BufferLength += FIELD_OFFSET(WIRE_ORPCTHAT, extensions) + sizeof(DWORD);
1074 if (extensions_size)
1075 {
1076 msg->BufferLength += FIELD_OFFSET(WIRE_ORPC_EXTENT_ARRAY, extent[2*sizeof(DWORD) + extensions_size]);
1077 if (extension_count & 1)
1078 msg->BufferLength += FIELD_OFFSET(WIRE_ORPC_EXTENT, data[0]);
1079 }
1080
1082 {
1083 msg->Buffer = malloc(msg->BufferLength);
1084 if (msg->Buffer)
1085 status = RPC_S_OK;
1086 else
1087 {
1088 free(channel_hook_data);
1089 return E_OUTOFMEMORY;
1090 }
1091 }
1092 else
1094
1095 orpcthat = msg->Buffer;
1096 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPCTHAT, extensions);
1097
1098 orpcthat->flags = ORPCF_NULL /* FIXME? */;
1099
1100 /* NDR representation of orpcthat->extensions */
1101 *(DWORD *)msg->Buffer = extensions_size ? 1 : 0;
1102 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1103
1104 if (extensions_size)
1105 {
1106 WIRE_ORPC_EXTENT_ARRAY *orpc_extent_array = msg->Buffer;
1107 orpc_extent_array->size = extension_count;
1108 orpc_extent_array->reserved = 0;
1109 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPC_EXTENT_ARRAY, extent);
1110 /* NDR representation of orpc_extent_array->extent */
1111 *(DWORD *)msg->Buffer = 1;
1112 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1113 /* NDR representation of [size_is] attribute of orpc_extent_array->extent */
1114 *(DWORD *)msg->Buffer = (extension_count + 1) & ~1;
1115 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1116
1118 msg->Buffer, channel_hook_data, channel_hook_count);
1119
1120 /* we must add a dummy extension if there is an odd extension
1121 * count to meet the contract specified by the size_is attribute */
1122 if (extension_count & 1)
1123 {
1124 WIRE_ORPC_EXTENT *wire_orpc_extent = msg->Buffer;
1125 wire_orpc_extent->conformance = 0;
1126 wire_orpc_extent->id = GUID_NULL;
1127 wire_orpc_extent->size = 0;
1128 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPC_EXTENT, data[0]);
1129 }
1130 }
1131
1132 free(channel_hook_data);
1133
1134 /* store the prefixed data length so that we can restore the real buffer
1135 * later */
1136 message_state->prefix_data_len = (char *)msg->Buffer - (char *)orpcthat;
1137 msg->BufferLength -= message_state->prefix_data_len;
1138 /* save away the message state again */
1139 msg->Handle = message_state;
1140
1141 TRACE("-- %ld\n", status);
1142
1143 return HRESULT_FROM_WIN32(status);
1144}
static ULONG ChannelHooks_ServerGetSize(SChannelHookCallInfo *info, struct channel_hook_buffer_data **data, unsigned int *hook_count, ULONG *extension_count)
Definition: rpc.c:851
static unsigned char * ChannelHooks_ServerFillBuffer(SChannelHookCallInfo *info, unsigned char *buffer, struct channel_hook_buffer_data *data, unsigned int hook_count)
Definition: rpc.c:900

◆ ServerRpcChannelBuffer_GetDestCtx()

static HRESULT WINAPI ServerRpcChannelBuffer_GetDestCtx ( LPRPCCHANNELBUFFER  iface,
DWORD dest_context,
void **  dest_context_data 
)
static

Definition at line 1599 of file rpc.c.

1600{
1602
1603 TRACE("(%p,%p)\n", dest_context, dest_context_data);
1604
1605 *dest_context = This->dest_context;
1606 *dest_context_data = This->dest_context_data;
1607 return S_OK;
1608}

◆ ServerRpcChannelBuffer_Release()

static ULONG WINAPI ServerRpcChannelBuffer_Release ( LPRPCCHANNELBUFFER  iface)
static

Definition at line 1023 of file rpc.c.

1024{
1026 ULONG ref;
1027
1028 ref = InterlockedDecrement(&This->refs);
1029 if (ref)
1030 return ref;
1031
1032 free(This);
1033 return 0;
1034}

◆ ServerRpcChannelBuffer_SendReceive()

static HRESULT WINAPI ServerRpcChannelBuffer_SendReceive ( LPRPCCHANNELBUFFER  iface,
RPCOLEMESSAGE *  olemsg,
ULONG pstatus 
)
static

Definition at line 1329 of file rpc.c.

1330{
1331 FIXME("stub\n");
1332 return E_NOTIMPL;
1333}

◆ start_local_service()

static DWORD start_local_service ( const WCHAR name,
DWORD  num,
LPCWSTR params 
)
static

Definition at line 389 of file rpc.c.

390{
391 SC_HANDLE handle, hsvc;
393
394 TRACE("Starting service %s %ld params\n", debugstr_w(name), num);
395
397 if (!handle)
398 return r;
400 if (hsvc)
401 {
402 if(StartServiceW(hsvc, num, params))
404 else
405 r = GetLastError();
408 CloseServiceHandle(hsvc);
409 }
410 else
411 r = GetLastError();
413
414 TRACE("StartService returned error %lu (%s)\n", r, (r == ERROR_SUCCESS) ? "ok":"failed");
415
416 return r;
417}
GLuint GLuint num
Definition: glext.h:9618
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2107
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2199
BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs, LPCWSTR *lpServiceArgVectors)
Definition: scm.c:3019
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
Definition: name.c:39
#define ERROR_SERVICE_ALREADY_RUNNING
Definition: winerror.h:931
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:1333
#define SERVICE_START
Definition: winsvc.h:63
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14

Referenced by create_local_service().

◆ start_rpcss()

static BOOL start_rpcss ( void  )
static

Definition at line 189 of file rpc.c.

190{
192 SC_HANDLE scm, service;
193 BOOL ret = FALSE;
194
195 TRACE("\n");
196
197 if (!(scm = OpenSCManagerW(NULL, NULL, 0)))
198 {
199 ERR("Failed to open service manager\n");
200 return FALSE;
201 }
202
203 if (!(service = OpenServiceW(scm, L"RpcSs", SERVICE_START | SERVICE_QUERY_STATUS)))
204 {
205 ERR("Failed to open RpcSs service\n");
206 CloseServiceHandle( scm );
207 return FALSE;
208 }
209
211 {
212 ULONGLONG start_time = GetTickCount64();
213 do
214 {
215 DWORD dummy;
216
217 if (!QueryServiceStatusEx(service, SC_STATUS_PROCESS_INFO, (BYTE *)&status, sizeof(status), &dummy))
218 break;
219 if (status.dwCurrentState == SERVICE_RUNNING)
220 {
221 ret = TRUE;
222 break;
223 }
224 if (GetTickCount64() - start_time > 30000) break;
225 Sleep( 100 );
226
227 } while (status.dwCurrentState == SERVICE_START_PENDING);
228
229 if (status.dwCurrentState != SERVICE_RUNNING)
230 WARN("RpcSs failed to start %lu\n", status.dwCurrentState);
231 }
232 else
233 ERR("Failed to start RpcSs service\n");
234
235 CloseServiceHandle(service);
237 return ret;
238}
ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
Definition: sync.c:192
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2926
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
uint64_t ULONGLONG
Definition: typedefs.h:67
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:61
@ SC_STATUS_PROCESS_INFO
Definition: winsvc.h:125
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24
unsigned char BYTE
Definition: xxhash.c:193

◆ unmarshal_ORPC_EXTENT_ARRAY()

static HRESULT unmarshal_ORPC_EXTENT_ARRAY ( RPC_MESSAGE msg,
const char end,
ORPC_EXTENT_ARRAY *  extensions,
WIRE_ORPC_EXTENT **  first_wire_orpc_extent 
)
static

Definition at line 1727 of file rpc.c.

1730{
1731 DWORD pointer_id;
1732 DWORD i;
1733
1734 memcpy(extensions, msg->Buffer, FIELD_OFFSET(WIRE_ORPC_EXTENT_ARRAY, extent));
1735 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPC_EXTENT_ARRAY, extent);
1736
1737 if ((const char *)msg->Buffer + 2 * sizeof(DWORD) > end)
1738 return RPC_E_INVALID_HEADER;
1739
1740 pointer_id = *(DWORD *)msg->Buffer;
1741 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1742 extensions->extent = NULL;
1743
1744 if (pointer_id)
1745 {
1746 WIRE_ORPC_EXTENT *wire_orpc_extent;
1747
1748 /* conformance */
1749 if (*(DWORD *)msg->Buffer != ((extensions->size+1)&~1))
1750 return RPC_S_INVALID_BOUND;
1751
1752 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1753
1754 /* arbitrary limit for security (don't know what native does) */
1755 if (extensions->size > 256)
1756 {
1757 ERR("too many extensions: %ld\n", extensions->size);
1758 return RPC_S_INVALID_BOUND;
1759 }
1760
1761 *first_wire_orpc_extent = wire_orpc_extent = msg->Buffer;
1762 for (i = 0; i < ((extensions->size+1)&~1); i++)
1763 {
1764 if ((const char *)&wire_orpc_extent->data[0] > end)
1765 return RPC_S_INVALID_BOUND;
1766 if (wire_orpc_extent->conformance != ((wire_orpc_extent->size+7)&~7))
1767 return RPC_S_INVALID_BOUND;
1768 if ((const char *)&wire_orpc_extent->data[wire_orpc_extent->conformance] > end)
1769 return RPC_S_INVALID_BOUND;
1770 TRACE("size %lu, guid %s\n", wire_orpc_extent->size, debugstr_guid(&wire_orpc_extent->id));
1771 wire_orpc_extent = (WIRE_ORPC_EXTENT *)&wire_orpc_extent->data[wire_orpc_extent->conformance];
1772 }
1773 msg->Buffer = wire_orpc_extent;
1774 }
1775
1776 return S_OK;
1777}
GLuint GLuint end
Definition: gl.h:1545
#define RPC_E_INVALID_HEADER
Definition: winerror.h:3565
#define RPC_S_INVALID_BOUND
Definition: winerror.h:1400

Referenced by unmarshal_ORPCTHAT(), and unmarshal_ORPCTHIS().

◆ unmarshal_ORPCTHAT()

static HRESULT unmarshal_ORPCTHAT ( RPC_MESSAGE msg,
ORPCTHAT *  orpcthat,
ORPC_EXTENT_ARRAY *  orpc_ext_array,
WIRE_ORPC_EXTENT **  first_wire_orpc_extent 
)
static

Definition at line 1831 of file rpc.c.

1833{
1834 const char *end = (char *)msg->Buffer + msg->BufferLength;
1835
1836 *first_wire_orpc_extent = NULL;
1837
1838 if (msg->BufferLength < FIELD_OFFSET(WIRE_ORPCTHAT, extensions) + sizeof(DWORD))
1839 {
1840 ERR("invalid buffer length\n");
1841 return RPC_E_INVALID_HEADER;
1842 }
1843
1844 memcpy(orpcthat, msg->Buffer, FIELD_OFFSET(WIRE_ORPCTHAT, extensions));
1845 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPCTHAT, extensions);
1846
1847 if ((const char *)msg->Buffer + sizeof(DWORD) > end)
1848 return RPC_E_INVALID_HEADER;
1849
1850 if (*(DWORD *)msg->Buffer)
1851 orpcthat->extensions = orpc_ext_array;
1852 else
1853 orpcthat->extensions = NULL;
1854
1855 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1856
1857 if (orpcthat->extensions)
1858 {
1859 HRESULT hr = unmarshal_ORPC_EXTENT_ARRAY(msg, end, orpc_ext_array,
1860 first_wire_orpc_extent);
1861 if (FAILED(hr))
1862 return hr;
1863 }
1864
1865 if (orpcthat->flags & ~(ORPCF_LOCAL|ORPCF_RESERVED1|ORPCF_RESERVED2|ORPCF_RESERVED3|ORPCF_RESERVED4))
1866 {
1867 ERR("invalid flags %#lx\n", orpcthat->flags & ~(ORPCF_LOCAL|ORPCF_RESERVED1|ORPCF_RESERVED2|ORPCF_RESERVED3|ORPCF_RESERVED4));
1868 return RPC_E_INVALID_HEADER;
1869 }
1870
1871 return S_OK;
1872}
static HRESULT unmarshal_ORPC_EXTENT_ARRAY(RPC_MESSAGE *msg, const char *end, ORPC_EXTENT_ARRAY *extensions, WIRE_ORPC_EXTENT **first_wire_orpc_extent)
Definition: rpc.c:1727

Referenced by ClientRpcChannelBuffer_SendReceive().

◆ unmarshal_ORPCTHIS()

static HRESULT unmarshal_ORPCTHIS ( RPC_MESSAGE msg,
ORPCTHIS *  orpcthis,
ORPC_EXTENT_ARRAY *  orpc_ext_array,
WIRE_ORPC_EXTENT **  first_wire_orpc_extent 
)
static

Definition at line 1780 of file rpc.c.

1782{
1783 const char *end = (char *)msg->Buffer + msg->BufferLength;
1784
1785 *first_wire_orpc_extent = NULL;
1786
1787 if (msg->BufferLength < FIELD_OFFSET(WIRE_ORPCTHIS, extensions) + sizeof(DWORD))
1788 {
1789 ERR("invalid buffer length\n");
1790 return RPC_E_INVALID_HEADER;
1791 }
1792
1793 memcpy(orpcthis, msg->Buffer, FIELD_OFFSET(WIRE_ORPCTHIS, extensions));
1794 msg->Buffer = (char *)msg->Buffer + FIELD_OFFSET(WIRE_ORPCTHIS, extensions);
1795
1796 if ((const char *)msg->Buffer + sizeof(DWORD) > end)
1797 return RPC_E_INVALID_HEADER;
1798
1799 if (*(DWORD *)msg->Buffer)
1800 orpcthis->extensions = orpc_ext_array;
1801 else
1802 orpcthis->extensions = NULL;
1803
1804 msg->Buffer = (char *)msg->Buffer + sizeof(DWORD);
1805
1806 if (orpcthis->extensions)
1807 {
1808 HRESULT hr = unmarshal_ORPC_EXTENT_ARRAY(msg, end, orpc_ext_array,
1809 first_wire_orpc_extent);
1810 if (FAILED(hr))
1811 return hr;
1812 }
1813
1814 if ((orpcthis->version.MajorVersion != COM_MAJOR_VERSION) ||
1815 (orpcthis->version.MinorVersion > COM_MINOR_VERSION))
1816 {
1817 ERR("COM version {%d, %d} not supported\n",
1818 orpcthis->version.MajorVersion, orpcthis->version.MinorVersion);
1820 }
1821
1822 if (orpcthis->flags & ~(ORPCF_LOCAL|ORPCF_RESERVED1|ORPCF_RESERVED2|ORPCF_RESERVED3|ORPCF_RESERVED4))
1823 {
1824 ERR("invalid flags %#lx\n", orpcthis->flags & ~(ORPCF_LOCAL|ORPCF_RESERVED1|ORPCF_RESERVED2|ORPCF_RESERVED3|ORPCF_RESERVED4));
1825 return RPC_E_INVALID_HEADER;
1826 }
1827
1828 return S_OK;
1829}
#define RPC_E_VERSION_MISMATCH
Definition: winerror.h:3564

Referenced by rpc_execute_call().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ channel_hooks

◆ ClientRpcChannelBufferVtbl

const IRpcChannelBufferVtbl ClientRpcChannelBufferVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ClientRpcChannelBuffer_GetDestCtx(LPRPCCHANNELBUFFER iface, DWORD *pdwDestContext, void **ppvDestContext)
Definition: rpc.c:1587
static HRESULT WINAPI RpcChannelBuffer_QueryInterface(IRpcChannelBuffer *iface, REFIID riid, LPVOID *ppv)
Definition: rpc.c:1005
static HRESULT WINAPI RpcChannelBuffer_IsConnected(LPRPCCHANNELBUFFER iface)
Definition: rpc.c:1610
static ULONG WINAPI ClientRpcChannelBuffer_Release(LPRPCCHANNELBUFFER iface)
Definition: rpc.c:1036
static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, REFIID riid)
Definition: rpc.c:1164
static HRESULT WINAPI ClientRpcChannelBuffer_FreeBuffer(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg)
Definition: rpc.c:1551
static ULONG WINAPI RpcChannelBuffer_AddRef(LPRPCCHANNELBUFFER iface)
Definition: rpc.c:1017
static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus)
Definition: rpc.c:1360

Definition at line 1617 of file rpc.c.

Referenced by rpc_create_clientchannel().

◆ csChannelHook

◆ csChannelHook_debug

CRITICAL_SECTION_DEBUG csChannelHook_debug
static
Initial value:
=
{
0, 0, &csChannelHook,
0, 0, { (DWORD_PTR)(__FILE__ ": channel hooks") }
}
static CRITICAL_SECTION_DEBUG csChannelHook_debug
Definition: rpc.c:62
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 62 of file rpc.c.

◆ csRegIf

static CRITICAL_SECTION csRegIf = { &csRegIf_debug, -1, 0, 0, 0, 0 }
static

◆ csRegIf_debug

CRITICAL_SECTION_DEBUG csRegIf_debug
static
Initial value:
=
{
0, 0, &csRegIf,
0, 0, { (DWORD_PTR)(__FILE__ ": dcom registered server interfaces") }
}
static CRITICAL_SECTION_DEBUG csRegIf_debug
Definition: rpc.c:52

Definition at line 52 of file rpc.c.

◆ registered_interfaces

struct list registered_interfaces = LIST_INIT(registered_interfaces)
static

Definition at line 50 of file rpc.c.

Referenced by rpc_register_interface(), rpc_unregister_interface(), and uacpi_install_interface().

◆ rpc_dispatch

RPC_DISPATCH_TABLE rpc_dispatch = { 1, rpc_dispatch_table }
static

Definition at line 48 of file rpc.c.

Referenced by rpc_register_interface().

◆ rpc_dispatch_table

RPC_DISPATCH_FUNCTION rpc_dispatch_table[1] = { dispatch_rpc }
static

Definition at line 47 of file rpc.c.

◆ rpctransportW

WCHAR rpctransportW[] = L"ncalrpc"
static

Definition at line 70 of file rpc.c.

Referenced by rpc_create_clientchannel(), and rpc_start_remoting().

◆ ServerRpcChannelBufferVtbl

const IRpcChannelBufferVtbl ServerRpcChannelBufferVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ServerRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus)
Definition: rpc.c:1329
static HRESULT WINAPI ServerRpcChannelBuffer_GetDestCtx(LPRPCCHANNELBUFFER iface, DWORD *dest_context, void **dest_context_data)
Definition: rpc.c:1599
static ULONG WINAPI ServerRpcChannelBuffer_Release(LPRPCCHANNELBUFFER iface)
Definition: rpc.c:1023
static HRESULT WINAPI ServerRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, REFIID riid)
Definition: rpc.c:1051
static HRESULT WINAPI ServerRpcChannelBuffer_FreeBuffer(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg)
Definition: rpc.c:1521

Definition at line 1629 of file rpc.c.

Referenced by rpc_create_serverchannel().