[RPCRT4] Sync with Wine Staging 4.0. CORE-15682

This commit is contained in:
Amine Khaldi 2019-01-30 12:31:33 +01:00
parent bb33692400
commit b6fdb56b9a
23 changed files with 2455 additions and 1082 deletions

View file

@ -2,9 +2,21 @@
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
add_definitions(
-D__WINESRC__
-D_RPCRT4_
-DCOM_NO_WINDOWS_H
-DMSWMSG)
include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(rpcrt4.dll rpcrt4.spec ADD_IMPORTLIB)
add_rpc_files(client epm.idl)
add_idl_headers(ndr_types_header ndr_types.idl)
set(IDL_FLAGS ${IDL_FLAGS} -Oicf)
add_rpcproxy_files(ndr_types.idl)
unset(IDL_FLAGS)
list(APPEND SOURCE
cproxy.c
@ -29,21 +41,15 @@ list(APPEND SOURCE
precomp.h
${CMAKE_CURRENT_BINARY_DIR}/epm_c.c)
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
add_definitions(
-D__WINESRC__
-D_RPCRT4_
-DCOM_NO_WINDOWS_H
-DMSWMSG)
if(MSVC AND NOT ARCH STREQUAL "arm")
add_asm_files(rpcrt4_asm msvc.S)
endif()
add_library(rpcrt4 SHARED
${SOURCE}
ndr_typelib.c
${CMAKE_CURRENT_BINARY_DIR}/ndr_types_p.c
${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c
${rpcrt4_asm}
rpcrt4.rc
${CMAKE_CURRENT_BINARY_DIR}/rpcrt4_stubs.c
@ -51,7 +57,8 @@ add_library(rpcrt4 SHARED
set_module_type(rpcrt4 win32dll)
target_link_libraries(rpcrt4 wine uuid ${PSEH_LIB})
add_delay_importlibs(rpcrt4 iphlpapi wininet secur32 user32)
add_delay_importlibs(rpcrt4 iphlpapi wininet secur32 user32 oleaut32)
add_importlibs(rpcrt4 advapi32 advapi32_vista kernel32_vista ws2_32 msvcrt kernel32 ntdll)
add_dependencies(rpcrt4 ndr_types_header)
add_pch(rpcrt4 precomp.h SOURCE)
add_cd_file(TARGET rpcrt4 DESTINATION reactos/system32 FOR all)

View file

@ -17,8 +17,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* TODO: Handle non-i386 architectures
*/
#include "config.h"
@ -42,21 +40,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
/* I don't know what MS's std proxy structure looks like,
so this probably doesn't match, but that shouldn't matter */
typedef struct {
IRpcProxyBuffer IRpcProxyBuffer_iface;
LPVOID *PVtbl;
LONG RefCount;
const IID* piid;
LPUNKNOWN pUnkOuter;
IUnknown *base_object; /* must be at offset 0x10 from PVtbl */
IRpcProxyBuffer *base_proxy;
PCInterfaceName name;
LPPSFACTORYBUFFER pPSFactory;
LPRPCCHANNELBUFFER pChannel;
} StdProxyImpl;
static const IRpcProxyBufferVtbl StdProxy_Vtbl;
static inline StdProxyImpl *impl_from_IRpcProxyBuffer(IRpcProxyBuffer *iface)
@ -79,7 +62,10 @@ __ASM_GLOBAL_FUNC(call_stubless_func,
"movl 8(%ecx),%edx\n\t" /* info->FormatStringOffset */
"movzwl (%edx,%eax,2),%edx\n\t" /* FormatStringOffset[index] */
"addl 4(%ecx),%edx\n\t" /* info->ProcFormatString + offset */
"movzwl 8(%edx),%eax\n\t" /* arguments size */
"movzbl 1(%edx),%eax\n\t" /* Oi_flags */
"andl $0x08,%eax\n\t" /* Oi_HAS_RPCFLAGS */
"shrl $1,%eax\n\t"
"movzwl 4(%edx,%eax),%eax\n\t" /* arguments size */
"pushl %eax\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"leal 8(%esp),%eax\n\t" /* &This */
@ -171,24 +157,43 @@ static inline void init_thunk( struct thunk *thunk, unsigned int index )
extern void call_stubless_func(void);
__ASM_GLOBAL_FUNC(call_stubless_func,
"DCD 0xDEFC\n\t" // _assertfail
"" );
"push {r0-r3}\n\t"
"mov r2, sp\n\t" /* stack_top */
"push {fp,lr}\n\t"
"mov fp, sp\n\t"
"ldr r0, [r0]\n\t" /* This->lpVtbl */
"ldr r0, [r0,#-8]\n\t" /* MIDL_STUBLESS_PROXY_INFO */
"ldr r1, [r0,#8]\n\t" /* info->FormatStringOffset */
"ldrh r1, [r1,ip]\n\t" /* info->FormatStringOffset[index] */
"ldr ip, [r0,#4]\n\t" /* info->ProcFormatString */
"add r1, ip\n\t" /* info->ProcFormatString + offset */
"ldr r0, [r0]\n\t" /* info->pStubDesc */
#ifdef __SOFTFP__
"mov r3, #0\n\t"
#else
"vpush {s0-s15}\n\t" /* store the s0-s15/d0-d7 arguments */
"mov r3, sp\n\t" /* fpu_stack */
#endif
"bl " __ASM_NAME("ndr_client_call") "\n\t"
"mov sp, fp\n\t"
"pop {fp,lr}\n\t"
"add sp, #16\n\t"
"bx lr" );
#include "pshpack1.h"
struct thunk
{
DWORD assertfail;
};
#include "poppack.h"
static const struct thunk thunk_template =
{
{ 0xDEFC } /* _assertfail */
DWORD ldr_ip; /* ldr ip,[pc] */
DWORD ldr_pc; /* ldr pc,[pc] */
DWORD index;
void *func;
};
static inline void init_thunk( struct thunk *thunk, unsigned int index )
{
*thunk = thunk_template;
thunk->ldr_ip = 0xe59fc000; /* ldr ip,[pc] */
thunk->ldr_pc = 0xe59ff000; /* ldr pc,[pc] */
thunk->index = index * sizeof(unsigned short);
thunk->func = call_stubless_func;
}
#else /* __i386__ */
@ -233,7 +238,7 @@ static const struct thunk *allocate_block( unsigned int num )
return block;
}
static BOOL fill_stubless_table( IUnknownVtbl *vtbl, DWORD num )
BOOL fill_stubless_table( IUnknownVtbl *vtbl, DWORD num )
{
const void **entry = (const void **)(vtbl + 1);
DWORD i, j;
@ -317,9 +322,7 @@ HRESULT StdProxy_Construct(REFIID riid,
return S_OK;
}
static HRESULT WINAPI StdProxy_QueryInterface(LPRPCPROXYBUFFER iface,
REFIID riid,
LPVOID *obj)
HRESULT WINAPI StdProxy_QueryInterface(IRpcProxyBuffer *iface, REFIID riid, void **obj)
{
StdProxyImpl *This = impl_from_IRpcProxyBuffer(iface);
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
@ -340,7 +343,7 @@ static HRESULT WINAPI StdProxy_QueryInterface(LPRPCPROXYBUFFER iface,
return E_NOINTERFACE;
}
static ULONG WINAPI StdProxy_AddRef(LPRPCPROXYBUFFER iface)
ULONG WINAPI StdProxy_AddRef(IRpcProxyBuffer *iface)
{
StdProxyImpl *This = impl_from_IRpcProxyBuffer(iface);
TRACE("(%p)->AddRef()\n",This);
@ -370,8 +373,7 @@ static ULONG WINAPI StdProxy_Release(LPRPCPROXYBUFFER iface)
return refs;
}
static HRESULT WINAPI StdProxy_Connect(LPRPCPROXYBUFFER iface,
LPRPCCHANNELBUFFER pChannel)
HRESULT WINAPI StdProxy_Connect(IRpcProxyBuffer *iface, IRpcChannelBuffer *pChannel)
{
StdProxyImpl *This = impl_from_IRpcProxyBuffer(iface);
TRACE("(%p)->Connect(%p)\n",This,pChannel);
@ -382,7 +384,7 @@ static HRESULT WINAPI StdProxy_Connect(LPRPCPROXYBUFFER iface,
return S_OK;
}
static VOID WINAPI StdProxy_Disconnect(LPRPCPROXYBUFFER iface)
void WINAPI StdProxy_Disconnect(IRpcProxyBuffer *iface)
{
StdProxyImpl *This = impl_from_IRpcProxyBuffer(iface);
TRACE("(%p)->Disconnect()\n",This);
@ -551,45 +553,3 @@ HRESULT WINAPI NdrProxyErrorHandler(DWORD dwExceptionCode)
else
return HRESULT_FROM_WIN32(dwExceptionCode);
}
HRESULT WINAPI
CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo, LPUNKNOWN pUnkOuter, REFIID riid,
LPRPCPROXYBUFFER *ppProxy, LPVOID *ppv )
{
typedef INT (WINAPI *MessageBoxA)(HWND,LPCSTR,LPCSTR,UINT);
HMODULE hUser32 = LoadLibraryA("user32");
MessageBoxA pMessageBoxA = (void *)GetProcAddress(hUser32, "MessageBoxA");
FIXME("%p %p %s %p %p\n", pTypeInfo, pUnkOuter, debugstr_guid(riid), ppProxy, ppv);
if (pMessageBoxA)
{
pMessageBoxA(NULL,
"The native implementation of OLEAUT32.DLL cannot be used "
"with Wine's RPCRT4.DLL. Remove OLEAUT32.DLL and try again.\n",
"Wine: Unimplemented CreateProxyFromTypeInfo",
0x10);
ExitProcess(1);
}
return E_NOTIMPL;
}
HRESULT WINAPI
CreateStubFromTypeInfo(ITypeInfo *pTypeInfo, REFIID riid, IUnknown *pUnkServer,
IRpcStubBuffer **ppStub )
{
typedef INT (WINAPI *MessageBoxA)(HWND,LPCSTR,LPCSTR,UINT);
HMODULE hUser32 = LoadLibraryA("user32");
MessageBoxA pMessageBoxA = (void *)GetProcAddress(hUser32, "MessageBoxA");
FIXME("%p %s %p %p\n", pTypeInfo, debugstr_guid(riid), pUnkServer, ppStub);
if (pMessageBoxA)
{
pMessageBoxA(NULL,
"The native implementation of OLEAUT32.DLL cannot be used "
"with Wine's RPCRT4.DLL. Remove OLEAUT32.DLL and try again.\n",
"Wine: Unimplemented CreateProxyFromTypeInfo",
0x10);
ExitProcess(1);
}
return E_NOTIMPL;
}

View file

@ -279,7 +279,7 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
/* register clsid to point to module */
strcpyW( keyname, clsidW );
strcatW( keyname, clsid );
len = GetModuleFileNameW(hDll, module, sizeof(module)/sizeof(WCHAR));
len = GetModuleFileNameW(hDll, module, ARRAY_SIZE(module));
if (len && len < sizeof(module)) {
TRACE("registering CLSID %s => %s\n", debugstr_w(clsid), debugstr_w(module));
if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) {

View file

@ -21,9 +21,36 @@
#ifndef __WINE_CPSF_H
#define __WINE_CPSF_H
typedef struct
{
IRpcProxyBuffer IRpcProxyBuffer_iface;
void **PVtbl;
LONG RefCount;
const IID *piid;
IUnknown *pUnkOuter;
/* offset of base_object from PVtbl must match assembly thunks; see
* fill_delegated_proxy_table() */
IUnknown *base_object;
IRpcProxyBuffer *base_proxy;
PCInterfaceName name;
IPSFactoryBuffer *pPSFactory;
IRpcChannelBuffer *pChannel;
} StdProxyImpl;
typedef struct
{
IUnknownVtbl *base_obj;
IRpcStubBuffer *base_stub;
CStdStubBuffer stub_buffer;
} cstdstubbuffer_delegating_t;
HRESULT StdProxy_Construct(REFIID riid, LPUNKNOWN pUnkOuter, const ProxyFileInfo *ProxyInfo,
int Index, LPPSFACTORYBUFFER pPSFactory, LPRPCPROXYBUFFER *ppProxy,
LPVOID *ppvObj) DECLSPEC_HIDDEN;
HRESULT WINAPI StdProxy_QueryInterface(IRpcProxyBuffer *iface, REFIID iid, void **obj) DECLSPEC_HIDDEN;
ULONG WINAPI StdProxy_AddRef(IRpcProxyBuffer *iface) DECLSPEC_HIDDEN;
HRESULT WINAPI StdProxy_Connect(IRpcProxyBuffer *iface, IRpcChannelBuffer *channel) DECLSPEC_HIDDEN;
void WINAPI StdProxy_Disconnect(IRpcProxyBuffer *iface) DECLSPEC_HIDDEN;
HRESULT CStdStubBuffer_Construct(REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name,
CInterfaceStubVtbl *vtbl, LPPSFACTORYBUFFER pPSFactory,
@ -41,5 +68,8 @@ extern const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl DECLSPEC_HIDDEN;
BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num) DECLSPEC_HIDDEN;
HRESULT create_proxy(REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy, void **ppv) DECLSPEC_HIDDEN;
HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub) DECLSPEC_HIDDEN;
BOOL fill_stubless_table(IUnknownVtbl *vtbl, DWORD num) DECLSPEC_HIDDEN;
IUnknownVtbl *get_delegating_vtbl(DWORD num_methods) DECLSPEC_HIDDEN;
void release_delegating_vtbl(IUnknownVtbl *vtbl) DECLSPEC_HIDDEN;
#endif /* __WINE_CPSF_H */

View file

@ -50,13 +50,6 @@ static LONG WINAPI stub_filter(EXCEPTION_POINTERS *eptr)
return EXCEPTION_EXECUTE_HANDLER;
}
typedef struct
{
IUnknownVtbl *base_obj;
IRpcStubBuffer *base_stub;
CStdStubBuffer stub_buffer;
} cstdstubbuffer_delegating_t;
static inline cstdstubbuffer_delegating_t *impl_from_delegating( IRpcStubBuffer *iface )
{
return CONTAINING_RECORD((void *)iface, cstdstubbuffer_delegating_t, stub_buffer);
@ -175,11 +168,23 @@ typedef struct
static const BYTE opcodes[16] = { 0x48, 0x8b, 0x49, 0x20, 0x48, 0x8b, 0x01,
0xff, 0xa0, 0, 0, 0, 0, 0x48, 0x8d, 0x36 };
#elif defined(__arm__)
static const DWORD opcodes[] =
{
0xe52d4004, /* push {r4} */
0xe5900010, /* ldr r0, [r0, #16] */
0xe5904000, /* ldr r4, [r0] */
0xe59fc008, /* ldr ip, [pc, #8] */
0xe08cc004, /* add ip, ip, r4 */
0xe49d4004, /* pop {r4} */
0xe59cf000 /* ldr pc, [ip] */
};
typedef struct
{
DWORD opcodes[ARRAY_SIZE(opcodes)];
DWORD offset;
} vtbl_method_t;
static const BYTE opcodes[1];
#else
@ -267,7 +272,7 @@ BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num)
return TRUE;
}
static IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
{
IUnknownVtbl *ret;
@ -303,7 +308,7 @@ static IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
return ret;
}
static void release_delegating_vtbl(IUnknownVtbl *vtbl)
void release_delegating_vtbl(IUnknownVtbl *vtbl)
{
ref_counted_vtbl *table = (ref_counted_vtbl*)((DWORD *)vtbl - 1);

View file

@ -23,8 +23,6 @@
#include "rpc_assoc.h"
#include "rpcndr.h"
#include "wine/rpcfc.h"
#include "wine/debug.h"
#include "wine/list.h"

View file

@ -32,7 +32,6 @@
#include "ndr_stubless.h"
#include "wine/debug.h"
#include "wine/rpcfc.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
@ -424,7 +423,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
client_interface = pStubDesc->RpcInterfaceInformation;
pEsMsg->InterfaceId = client_interface->InterfaceId;
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
{
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
stack_size = header_rpc->stack_size;
@ -438,17 +437,17 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
pFormat += sizeof(NDR_PROC_HEADER);
}
if (pProcHeader->handle_type == RPC_FC_BIND_EXPLICIT)
if (pProcHeader->handle_type == 0)
{
switch (*pFormat) /* handle_type */
{
case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
case FC_BIND_PRIMITIVE: /* explicit primitive */
pFormat += sizeof(NDR_EHD_PRIMITIVE);
break;
case RPC_FC_BIND_GENERIC: /* explicit generic */
case FC_BIND_GENERIC: /* explicit generic */
pFormat += sizeof(NDR_EHD_GENERIC);
break;
case RPC_FC_BIND_CONTEXT: /* explicit context */
case FC_BIND_CONTEXT: /* explicit context */
pFormat += sizeof(NDR_EHD_CONTEXT);
break;
default:
@ -467,7 +466,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
pEsMsg->StubMsg.pfnFree = pStubDesc->pfnFree;
/* create the full pointer translation tables, if requested */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
pEsMsg->StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
@ -510,7 +509,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
return;
}
/* free the full pointer translation tables */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
NdrFullPointerXlatFree(pEsMsg->StubMsg.FullPtrXlatTables);
}

File diff suppressed because it is too large Load diff

View file

@ -36,8 +36,8 @@
#include "ndr_misc.h"
#include "rpcndr.h"
#include "ndrtypes.h"
#include "rpcproxy.h"
#include "wine/rpcfc.h"
#include "cpsf.h"
#include "wine/debug.h"
@ -288,8 +288,8 @@ static const IID* get_ip_iid(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory
const IID *riid;
if (!pFormat) return &IID_IUnknown;
TRACE("format=%02x %02x\n", pFormat[0], pFormat[1]);
if (pFormat[0] != RPC_FC_IP) FIXME("format=%d\n", pFormat[0]);
if (pFormat[1] == RPC_FC_CONSTANT_IID) {
if (pFormat[0] != FC_IP) FIXME("format=%d\n", pFormat[0]);
if (pFormat[1] == FC_CONSTANT_IID) {
riid = (const IID *)&pFormat[2];
} else {
ComputeConformance(pStubMsg, pMemory, pFormat+2, 0);
@ -338,19 +338,25 @@ unsigned char * WINAPI NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
PFORMAT_STRING pFormat,
unsigned char fMustAlloc)
{
IUnknown **unk = (IUnknown **)ppMemory;
LPSTREAM stream;
HRESULT hr;
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
if (!LoadCOM()) return NULL;
*(LPVOID*)ppMemory = NULL;
/* Avoid reference leaks for [in, out] pointers. */
if (pStubMsg->IsClient && *unk)
IUnknown_Release(*unk);
*unk = NULL;
if (pStubMsg->Buffer + sizeof(DWORD) < (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) {
ULONG size;
hr = RpcStream_Create(pStubMsg, FALSE, &size, &stream);
if (hr == S_OK) {
if (size != 0)
hr = COM_UnmarshalInterface(stream, &IID_NULL, (LPVOID*)ppMemory);
hr = COM_UnmarshalInterface(stream, &IID_NULL, (void **)unk);
IStream_Release(stream);
}

View file

@ -40,7 +40,6 @@
#include "wine/exception.h"
#include "wine/debug.h"
#include "wine/rpcfc.h"
#include "cpsf.h"
#include "ndr_misc.h"
@ -154,61 +153,60 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
DWORD size;
switch(*pFormat)
{
case RPC_FC_RP:
if (pFormat[1] & RPC_FC_P_SIMPLEPOINTER)
case FC_RP:
if (pFormat[1] & FC_SIMPLE_POINTER)
{
FIXME("Simple reference pointer (type %#x).\n", pFormat[2]);
size = sizeof(void *);
size = 0;
break;
}
size = calc_arg_size(pStubMsg, &pFormat[2] + *(const SHORT*)&pFormat[2]);
break;
case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT:
case FC_STRUCT:
case FC_PSTRUCT:
size = *(const WORD*)(pFormat + 2);
break;
case RPC_FC_BOGUS_STRUCT:
case FC_BOGUS_STRUCT:
size = *(const WORD*)(pFormat + 2);
if(*(const WORD*)(pFormat + 4))
FIXME("Unhandled conformant description\n");
break;
case RPC_FC_CARRAY:
case RPC_FC_CVARRAY:
case FC_CARRAY:
case FC_CVARRAY:
size = *(const WORD*)(pFormat + 2);
ComputeConformance(pStubMsg, NULL, pFormat + 4, 0);
size *= pStubMsg->MaxCount;
break;
case RPC_FC_SMFARRAY:
case RPC_FC_SMVARRAY:
case FC_SMFARRAY:
case FC_SMVARRAY:
size = *(const WORD*)(pFormat + 2);
break;
case RPC_FC_LGFARRAY:
case RPC_FC_LGVARRAY:
case FC_LGFARRAY:
case FC_LGVARRAY:
size = *(const DWORD*)(pFormat + 2);
break;
case RPC_FC_BOGUS_ARRAY:
case FC_BOGUS_ARRAY:
pFormat = ComputeConformance(pStubMsg, NULL, pFormat + 4, *(const WORD*)&pFormat[2]);
TRACE("conformance = %ld\n", pStubMsg->MaxCount);
pFormat = ComputeVariance(pStubMsg, NULL, pFormat, pStubMsg->MaxCount);
size = ComplexStructSize(pStubMsg, pFormat);
size *= pStubMsg->MaxCount;
break;
case RPC_FC_USER_MARSHAL:
case FC_USER_MARSHAL:
size = *(const WORD*)(pFormat + 4);
break;
case RPC_FC_CSTRING:
case FC_CSTRING:
size = *(const WORD*)(pFormat + 2);
break;
case RPC_FC_WSTRING:
case FC_WSTRING:
size = *(const WORD*)(pFormat + 2) * sizeof(WCHAR);
break;
case RPC_FC_C_CSTRING:
case RPC_FC_C_WSTRING:
if (*pFormat == RPC_FC_C_CSTRING)
case FC_C_CSTRING:
case FC_C_WSTRING:
if (*pFormat == FC_C_CSTRING)
size = sizeof(CHAR);
else
size = sizeof(WCHAR);
if (pFormat[1] == RPC_FC_STRING_SIZED)
if (pFormat[1] == FC_STRING_SIZED)
ComputeConformance(pStubMsg, NULL, pFormat + 2, 0);
else
pStubMsg->MaxCount = 0;
@ -217,7 +215,10 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
default:
FIXME("Unhandled type %02x\n", *pFormat);
/* fallthrough */
case RPC_FC_IP:
case FC_UP:
case FC_OP:
case FC_FP:
case FC_IP:
size = sizeof(void *);
break;
}
@ -279,10 +280,10 @@ static PFORMAT_STRING client_get_handle(
switch (pProcHeader->handle_type)
{
/* explicit binding: parse additional section */
case RPC_FC_BIND_EXPLICIT:
case 0:
switch (*pFormat) /* handle_type */
{
case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
case FC_BIND_PRIMITIVE: /* explicit primitive */
{
const NDR_EHD_PRIMITIVE *pDesc = (const NDR_EHD_PRIMITIVE *)pFormat;
@ -294,7 +295,7 @@ static PFORMAT_STRING client_get_handle(
*phBinding = *(handle_t *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
return pFormat + sizeof(NDR_EHD_PRIMITIVE);
}
case RPC_FC_BIND_GENERIC: /* explicit generic */
case FC_BIND_GENERIC: /* explicit generic */
{
const NDR_EHD_GENERIC *pDesc = (const NDR_EHD_GENERIC *)pFormat;
void *pObject = NULL;
@ -312,7 +313,7 @@ static PFORMAT_STRING client_get_handle(
*phBinding = pGenPair->pfnBind(pObject);
return pFormat + sizeof(NDR_EHD_GENERIC);
}
case RPC_FC_BIND_CONTEXT: /* explicit context */
case FC_BIND_CONTEXT: /* explicit context */
{
const NDR_EHD_CONTEXT *pDesc = (const NDR_EHD_CONTEXT *)pFormat;
NDR_CCONTEXT context_handle;
@ -340,22 +341,22 @@ static PFORMAT_STRING client_get_handle(
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
break;
case RPC_FC_BIND_GENERIC: /* implicit generic */
FIXME("RPC_FC_BIND_GENERIC\n");
case FC_BIND_GENERIC: /* implicit generic */
FIXME("FC_BIND_GENERIC\n");
RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
break;
case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
case FC_BIND_PRIMITIVE: /* implicit primitive */
TRACE("Implicit primitive handle\n");
*phBinding = *pStubMsg->StubDesc->IMPLICIT_HANDLE_INFO.pPrimitiveHandle;
break;
case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
TRACE("RPC_FC_CALLBACK_HANDLE\n");
case FC_CALLBACK_HANDLE: /* implicit callback */
TRACE("FC_CALLBACK_HANDLE\n");
/* server calls callback procedures only in response to remote call, and most recent
binding handle is used. Calling back to a client can potentially result in another
callback with different current handle. */
*phBinding = I_RpcGetCurrentCallHandle();
break;
case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
case FC_AUTO_HANDLE: /* implicit auto handle */
/* strictly speaking, it isn't necessary to set hBinding here
* since it isn't actually used (hence the automatic in its name),
* but then why does MIDL generate a valid entry in the
@ -378,10 +379,10 @@ static void client_free_handle(
switch (pProcHeader->handle_type)
{
/* explicit binding: parse additional section */
case RPC_FC_BIND_EXPLICIT:
case 0:
switch (*pFormat) /* handle_type */
{
case RPC_FC_BIND_GENERIC: /* explicit generic */
case FC_BIND_GENERIC: /* explicit generic */
{
const NDR_EHD_GENERIC *pDesc = (const NDR_EHD_GENERIC *)pFormat;
void *pObject = NULL;
@ -399,21 +400,21 @@ static void client_free_handle(
pGenPair->pfnUnbind(pObject, hBinding);
break;
}
case RPC_FC_BIND_CONTEXT: /* explicit context */
case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
case FC_BIND_CONTEXT: /* explicit context */
case FC_BIND_PRIMITIVE: /* explicit primitive */
break;
default:
ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
break;
case RPC_FC_BIND_GENERIC: /* implicit generic */
FIXME("RPC_FC_BIND_GENERIC\n");
case FC_BIND_GENERIC: /* implicit generic */
FIXME("FC_BIND_GENERIC\n");
RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
break;
case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
case FC_CALLBACK_HANDLE: /* implicit callback */
case FC_BIND_PRIMITIVE: /* implicit primitive */
case FC_AUTO_HANDLE: /* implicit auto handle */
break;
default:
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
@ -421,6 +422,50 @@ static void client_free_handle(
}
}
static inline BOOL param_needs_alloc( PARAM_ATTRIBUTES attr )
{
return attr.IsOut && !attr.IsIn && !attr.IsBasetype && !attr.IsByValue;
}
static inline BOOL param_is_out_basetype( PARAM_ATTRIBUTES attr )
{
return attr.IsOut && !attr.IsIn && attr.IsBasetype && attr.IsSimpleRef;
}
static size_t basetype_arg_size( unsigned char fc )
{
switch (fc)
{
case FC_BYTE:
case FC_CHAR:
case FC_SMALL:
case FC_USMALL:
return sizeof(char);
case FC_WCHAR:
case FC_SHORT:
case FC_USHORT:
return sizeof(short);
case FC_LONG:
case FC_ULONG:
case FC_ENUM16:
case FC_ENUM32:
case FC_ERROR_STATUS_T:
return sizeof(int);
case FC_FLOAT:
return sizeof(float);
case FC_HYPER:
return sizeof(LONGLONG);
case FC_DOUBLE:
return sizeof(double);
case FC_INT3264:
case FC_UINT3264:
return sizeof(INT_PTR);
default:
FIXME("Unhandled basetype %#x.\n", fc);
return 0;
}
}
void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase,
void **fpu_args, unsigned short number_of_params, unsigned char *pRetVal )
{
@ -436,7 +481,7 @@ void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum s
float f;
if (params[i].attr.IsBasetype &&
params[i].u.type_format_char == RPC_FC_FLOAT &&
params[i].u.type_format_char == FC_FLOAT &&
!params[i].attr.IsSimpleRef &&
!fpu_args)
{
@ -452,10 +497,12 @@ void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum s
switch (phase)
{
case STUBLESS_INITOUT:
if (!params[i].attr.IsBasetype && params[i].attr.IsOut &&
!params[i].attr.IsIn && !params[i].attr.IsByValue)
if (*(unsigned char **)pArg)
{
memset( *(unsigned char **)pArg, 0, calc_arg_size( pStubMsg, pTypeFormat ));
if (param_needs_alloc(params[i].attr))
memset( *(unsigned char **)pArg, 0, calc_arg_size( pStubMsg, pTypeFormat ));
else if (param_is_out_basetype(params[i].attr))
memset( *(unsigned char **)pArg, 0, basetype_arg_size( params[i].u.type_format_char ));
}
break;
case STUBLESS_CALCSIZE:
@ -487,26 +534,26 @@ static unsigned int type_stack_size(unsigned char fc)
{
switch (fc)
{
case RPC_FC_BYTE:
case RPC_FC_CHAR:
case RPC_FC_SMALL:
case RPC_FC_USMALL:
case RPC_FC_WCHAR:
case RPC_FC_SHORT:
case RPC_FC_USHORT:
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_INT3264:
case RPC_FC_UINT3264:
case RPC_FC_ENUM16:
case RPC_FC_ENUM32:
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
case RPC_FC_IGNORE:
case FC_BYTE:
case FC_CHAR:
case FC_SMALL:
case FC_USMALL:
case FC_WCHAR:
case FC_SHORT:
case FC_USHORT:
case FC_LONG:
case FC_ULONG:
case FC_INT3264:
case FC_UINT3264:
case FC_ENUM16:
case FC_ENUM32:
case FC_FLOAT:
case FC_ERROR_STATUS_T:
case FC_IGNORE:
return sizeof(void *);
case RPC_FC_DOUBLE:
case FC_DOUBLE:
return sizeof(double);
case RPC_FC_HYPER:
case FC_HYPER:
return sizeof(ULONGLONG);
default:
ERR("invalid base type 0x%x\n", fc);
@ -518,13 +565,13 @@ static BOOL is_by_value( PFORMAT_STRING format )
{
switch (*format)
{
case RPC_FC_USER_MARSHAL:
case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_CPSTRUCT:
case RPC_FC_CVSTRUCT:
case RPC_FC_BOGUS_STRUCT:
case FC_USER_MARSHAL:
case FC_STRUCT:
case FC_PSTRUCT:
case FC_CSTRUCT:
case FC_CPSTRUCT:
case FC_CVSTRUCT:
case FC_BOGUS_STRUCT:
return TRUE;
default:
return FALSE;
@ -554,32 +601,32 @@ PFORMAT_STRING convert_old_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFo
switch (param->param_direction)
{
case RPC_FC_IN_PARAM_BASETYPE:
case FC_IN_PARAM_BASETYPE:
args[i].attr.IsIn = 1;
args[i].attr.IsBasetype = 1;
break;
case RPC_FC_RETURN_PARAM_BASETYPE:
case FC_RETURN_PARAM_BASETYPE:
args[i].attr.IsOut = 1;
args[i].attr.IsReturn = 1;
args[i].attr.IsBasetype = 1;
break;
case RPC_FC_IN_PARAM:
case FC_IN_PARAM:
args[i].attr.IsIn = 1;
args[i].attr.MustFree = 1;
break;
case RPC_FC_IN_PARAM_NO_FREE_INST:
case FC_IN_PARAM_NO_FREE_INST:
args[i].attr.IsIn = 1;
args[i].attr.IsDontCallFreeInst = 1;
break;
case RPC_FC_IN_OUT_PARAM:
case FC_IN_OUT_PARAM:
args[i].attr.IsIn = 1;
args[i].attr.IsOut = 1;
args[i].attr.MustFree = 1;
break;
case RPC_FC_OUT_PARAM:
case FC_OUT_PARAM:
args[i].attr.IsOut = 1;
break;
case RPC_FC_RETURN_PARAM:
case FC_RETURN_PARAM:
args[i].attr.IsOut = 1;
args[i].attr.IsReturn = 1;
break;
@ -633,7 +680,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
TRACE("NDR Version: 0x%x\n", pStubDesc->Version);
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
{
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
stack_size = header_rpc->stack_size;
@ -650,10 +697,10 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
TRACE("proc num: %d\n", procedure_number);
/* create the full pointer translation tables, if requested */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
/* object is always the first argument */
This = stack_top[0];
@ -669,7 +716,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
pHandleFormat = pFormat;
/* we only need a handle if this isn't an object method */
if (!(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT))
if (!(pProcHeader->Oi_flags & Oi_OBJECT_PROC))
{
pFormat = client_get_handle(&stubMsg, pProcHeader, pHandleFormat, &hBinding);
if (!pFormat) goto done;
@ -710,7 +757,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
else
{
pFormat = convert_old_args( &stubMsg, pFormat, stack_size,
pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT,
pProcHeader->Oi_flags & Oi_OBJECT_PROC,
/* reuse the correlation cache, it's not needed for v1 format */
NdrCorrCache, sizeof(NdrCorrCache), &number_of_params );
}
@ -718,11 +765,11 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
stubMsg.BufferLength = 0;
/* store the RPC flags away */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
rpcMsg.RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
/* use alternate memory allocation routines */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED)
NdrRpcSmSetClientToOsf(&stubMsg);
if (Oif_flags.HasPipes)
@ -749,11 +796,11 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
* 6. UNMARSHAL - unmarshal [out] params from buffer
* 7. FREE - clear [out] parameters (for proxies, and only on error)
*/
if ((pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT) ||
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_HAS_COMM_OR_FAULT))
if ((pProcHeader->Oi_flags & Oi_OBJECT_PROC) ||
(pProcHeader->Oi_flags & Oi_HAS_COMM_OR_FAULT))
{
/* 1. INITOUT */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
TRACE( "INITOUT\n" );
client_do_args(&stubMsg, pFormat, STUBLESS_INITOUT, fpu_stack,
@ -769,7 +816,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
/* 3. GETBUFFER */
TRACE( "GETBUFFER\n" );
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
/* allocate the buffer */
NdrProxyGetBuffer(This, &stubMsg);
@ -782,7 +829,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
FIXME("pipes not supported yet\n");
else
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
#if 0
NdrNsGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
#else
@ -800,7 +847,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
/* 5. SENDRECEIVE */
TRACE( "SENDRECEIVE\n" );
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
/* send the [in] params and receive the [out] and [retval]
* params */
@ -815,7 +862,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
FIXME("pipes not supported yet\n");
else
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
#if 0
NdrNsSendReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
#else
@ -838,7 +885,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
}
__EXCEPT_ALL
{
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
/* 7. FREE */
TRACE( "FREE\n" );
@ -888,7 +935,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
FIXME("pipes not supported yet\n");
else
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
#if 0
NdrNsGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
#else
@ -910,7 +957,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
FIXME("pipes not supported yet\n");
else
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
#if 0
NdrNsSendReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
#else
@ -943,11 +990,11 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM
}
/* free the full pointer translation tables */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables);
/* free marshalling buffer */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
NdrProxyFreeBuffer(This, &stubMsg);
else
{
@ -1137,11 +1184,6 @@ LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, uns
}
#endif
static inline BOOL param_needs_alloc( PARAM_ATTRIBUTES attr )
{
return attr.IsOut && !attr.IsIn && !attr.IsBasetype && !attr.IsByValue;
}
static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
PFORMAT_STRING pFormat, enum stubless_phase phase,
unsigned short number_of_params)
@ -1180,13 +1222,13 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
else if (param_needs_alloc(params[i].attr) &&
(!params[i].attr.MustFree || params[i].attr.IsSimpleRef))
{
if (*pTypeFormat != RPC_FC_BIND_CONTEXT) pStubMsg->pfnFree(*(void **)pArg);
if (*pTypeFormat != FC_BIND_CONTEXT) pStubMsg->pfnFree(*(void **)pArg);
}
break;
case STUBLESS_INITOUT:
if (param_needs_alloc(params[i].attr) && !params[i].attr.ServerAllocSize)
{
if (*pTypeFormat == RPC_FC_BIND_CONTEXT)
if (*pTypeFormat == FC_BIND_CONTEXT)
{
NDR_SCONTEXT ctxt = NdrContextHandleInitialize(pStubMsg, pTypeFormat);
*(void **)pArg = NDRSContextValue(ctxt);
@ -1276,7 +1318,7 @@ LONG WINAPI NdrStubCall2(
TRACE("NDR Version: 0x%x\n", pStubDesc->Version);
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
{
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
stack_size = header_rpc->stack_size;
@ -1295,16 +1337,16 @@ LONG WINAPI NdrStubCall2(
switch (pProcHeader->handle_type)
{
/* explicit binding: parse additional section */
case RPC_FC_BIND_EXPLICIT:
case 0:
switch (*pFormat) /* handle_type */
{
case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
case FC_BIND_PRIMITIVE: /* explicit primitive */
pFormat += sizeof(NDR_EHD_PRIMITIVE);
break;
case RPC_FC_BIND_GENERIC: /* explicit generic */
case FC_BIND_GENERIC: /* explicit generic */
pFormat += sizeof(NDR_EHD_GENERIC);
break;
case RPC_FC_BIND_CONTEXT: /* explicit context */
case FC_BIND_CONTEXT: /* explicit context */
pFormat += sizeof(NDR_EHD_CONTEXT);
break;
default:
@ -1312,31 +1354,31 @@ LONG WINAPI NdrStubCall2(
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
break;
case RPC_FC_BIND_GENERIC: /* implicit generic */
case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
case FC_BIND_GENERIC: /* implicit generic */
case FC_BIND_PRIMITIVE: /* implicit primitive */
case FC_CALLBACK_HANDLE: /* implicit callback */
case FC_AUTO_HANDLE: /* implicit auto handle */
break;
default:
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel);
else
NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc);
/* create the full pointer translation tables, if requested */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER);
/* store the RPC flags away */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
/* use alternate memory allocation routines */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED)
#if 0
NdrRpcSsEnableAllocate(&stubMsg);
#else
@ -1389,7 +1431,7 @@ LONG WINAPI NdrStubCall2(
else
{
pFormat = convert_old_args( &stubMsg, pFormat, stack_size,
pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT,
pProcHeader->Oi_flags & Oi_OBJECT_PROC,
/* reuse the correlation cache, it's not needed for v1 format */
NdrCorrCache, sizeof(NdrCorrCache), &number_of_params );
}
@ -1413,7 +1455,7 @@ LONG WINAPI NdrStubCall2(
SERVER_ROUTINE func;
LONG_PTR retval;
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
SERVER_ROUTINE *vtbl = *(SERVER_ROUTINE **)((CStdStubBuffer *)pThis)->pvServerObject;
func = vtbl[pRpcMsg->ProcNum];
@ -1438,7 +1480,7 @@ LONG WINAPI NdrStubCall2(
break;
case STUBLESS_GETBUFFER:
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
NdrStubGetBuffer(pThis, pChannel, &stubMsg);
else
{
@ -1480,7 +1522,7 @@ LONG WINAPI NdrStubCall2(
}
/* free the full pointer translation tables */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables);
/* free server function stack */
@ -1565,7 +1607,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc,
async_call_data->pStubMsg = pStubMsg = (PMIDL_STUB_MESSAGE)(async_call_data + 1);
pRpcMsg = (PRPC_MESSAGE)(pStubMsg + 1);
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
{
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
async_call_data->stack_size = header_rpc->stack_size;
@ -1582,10 +1624,10 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc,
TRACE("proc num: %d\n", procedure_number);
/* create the full pointer translation tables, if requested */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
pStubMsg->FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
ERR("objects not supported\n");
I_RpcFree(async_call_data);
@ -1631,7 +1673,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc,
else
{
pFormat = convert_old_args( pStubMsg, pFormat, async_call_data->stack_size,
pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT,
pProcHeader->Oi_flags & Oi_OBJECT_PROC,
async_call_data->NdrCorrCache, sizeof(async_call_data->NdrCorrCache),
&async_call_data->number_of_params );
}
@ -1641,11 +1683,11 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc,
pStubMsg->BufferLength = 0;
/* store the RPC flags away */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
/* use alternate memory allocation routines */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED)
NdrRpcSmSetClientToOsf(pStubMsg);
if (Oif_flags.HasPipes)
@ -1684,7 +1726,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc,
FIXME("pipes not supported yet\n");
else
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
#if 0
NdrNsGetBuffer(pStubMsg, pStubMsg->BufferLength, async_call_data->hBinding);
#else
@ -1711,7 +1753,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc,
FIXME("pipes not supported yet\n");
else
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
#if 0
NdrNsSend(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
#else
@ -1761,7 +1803,7 @@ RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply)
TRACE( "RECEIVE\n" );
pStubMsg->RpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
/* receive the [out] params */
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
#if 0
NdrNsReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
#else
@ -1798,7 +1840,7 @@ cleanup:
}
/* free the full pointer translation tables */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
NdrFullPointerXlatFree(pStubMsg->FullPtrXlatTables);
/* free marshalling buffer */

View file

@ -28,16 +28,16 @@
typedef struct _NDR_PROC_HEADER
{
/* type of handle to use:
* RPC_FC_BIND_EXPLICIT = 0 - Explicit handle.
* 0 - Explicit handle.
* Handle is passed as a parameter to the function.
* Indicates that explicit handle information follows the header,
* which actually describes the handle.
* RPC_FC_BIND_GENERIC = 31 - Implicit handle with custom binding routines
* FC_BIND_GENERIC = 31 - Implicit handle with custom binding routines
* (MIDL_STUB_DESC::IMPLICIT_HANDLE_INFO::pGenericBindingInfo)
* RPC_FC_BIND_PRIMITIVE = 32 - Implicit handle using handle_t created by
* FC_BIND_PRIMITIVE = 32 - Implicit handle using handle_t created by
* calling application
* RPC_FC_AUTO_HANDLE = 33 - Automatic handle
* RPC_FC_CALLBACK_HANDLE = 34 - Implicit handle used for a callback: current handle
* FC_AUTO_HANDLE = 33 - Automatic handle
* FC_CALLBACK_HANDLE = 34 - Implicit handle used for a callback: current handle
* from last remote call
*/
unsigned char handle_type;
@ -97,13 +97,11 @@ typedef struct _NDR_PROC_HEADER_RPC
typedef struct _NDR_PROC_PARTIAL_OIF_HEADER
{
/* the pre-computed client buffer size so that interpreter can skip all
* or some (if the flag RPC_FC_PROC_OI2F_CLTMUSTSIZE is specified) of the
* sizing pass */
* or some (if the flag ClientMustSize is specified) of the sizing pass */
unsigned short constant_client_buffer_size;
/* the pre-computed server buffer size so that interpreter can skip all
* or some (if the flag RPC_FC_PROC_OI2F_SRVMUSTSIZE is specified) of the
* sizing pass */
* or some (if the flag ServerMustSize is specified) of the sizing pass */
unsigned short constant_server_buffer_size;
INTERPRETER_OPT_FLAGS Oi2Flags;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,30 @@
/*
* Copyright 2018 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma makedep proxy
import "oaidl.idl";
[
object,
uuid(bfc61495-76bb-4855-8c2f-3764fd42523a)
]
interface dummy : IUnknown
{
void dummy( BSTR a, IUnknown *b, IDispatch *c, VARIANT d, LPSAFEARRAY e, BSTR *last );
}

View file

@ -80,6 +80,7 @@ static RPC_STATUS RpcAssoc_Alloc(LPCSTR Protseq, LPCSTR NetworkAddr,
assoc->Endpoint = RPCRT4_strdupA(Endpoint);
assoc->NetworkOptions = NetworkOptions ? RPCRT4_strdupW(NetworkOptions) : NULL;
assoc->assoc_group_id = 0;
assoc->connection_cnt = 0;
UuidCreate(&assoc->http_uuid);
list_init(&assoc->entry);
*assoc_out = assoc;
@ -390,14 +391,18 @@ static RpcConnection *RpcAssoc_GetIdleConnection(RpcAssoc *assoc,
RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
const RPC_SYNTAX_IDENTIFIER *InterfaceId,
const RPC_SYNTAX_IDENTIFIER *TransferSyntax, RpcAuthInfo *AuthInfo,
RpcQualityOfService *QOS, LPCWSTR CookieAuth, RpcConnection **Connection)
RpcQualityOfService *QOS, LPCWSTR CookieAuth,
RpcConnection **Connection, BOOL *from_cache)
{
RpcConnection *NewConnection;
RPC_STATUS status;
*Connection = RpcAssoc_GetIdleConnection(assoc, InterfaceId, TransferSyntax, AuthInfo, QOS);
if (*Connection)
if (*Connection) {
TRACE("return idle connection %p for association %p\n", *Connection, assoc);
if (from_cache) *from_cache = TRUE;
return RPC_S_OK;
}
/* create a new connection */
status = RPCRT4_CreateConnection(&NewConnection, FALSE /* is this a server connection? */,
@ -422,8 +427,11 @@ RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
return status;
}
*Connection = NewConnection;
InterlockedIncrement(&assoc->connection_cnt);
TRACE("return new connection %p for association %p\n", *Connection, assoc);
*Connection = NewConnection;
if (from_cache) *from_cache = FALSE;
return RPC_S_OK;
}
@ -437,6 +445,15 @@ void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection)
LeaveCriticalSection(&assoc->cs);
}
void RpcAssoc_ConnectionReleased(RpcAssoc *assoc)
{
if (InterlockedDecrement(&assoc->connection_cnt))
return;
TRACE("Last %p connection released\n", assoc);
assoc->assoc_group_id = 0;
}
RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard,
NDR_SCONTEXT *SContext)
{

View file

@ -43,6 +43,7 @@ typedef struct _RpcAssoc
/* client-only */
/* connections available to be used (protected by cs) */
struct list free_connection_pool;
LONG connection_cnt;
/* server-only */
struct list context_handle_list; /* protected by cs */
@ -51,7 +52,7 @@ typedef struct _RpcAssoc
RPC_STATUS RPCRT4_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAssoc **assoc) DECLSPEC_HIDDEN;
RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc, const RPC_SYNTAX_IDENTIFIER *InterfaceId,
const RPC_SYNTAX_IDENTIFIER *TransferSyntax, RpcAuthInfo *AuthInfo, RpcQualityOfService *QOS,
LPCWSTR CookieAuth, RpcConnection **Connection) DECLSPEC_HIDDEN;
LPCWSTR CookieAuth, RpcConnection **Connection, BOOL *from_cache) DECLSPEC_HIDDEN;
void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection) DECLSPEC_HIDDEN;
ULONG RpcAssoc_Release(RpcAssoc *assoc) DECLSPEC_HIDDEN;
RPC_STATUS RpcServerAssoc_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, ULONG assoc_gid, RpcAssoc **assoc_out) DECLSPEC_HIDDEN;
@ -61,3 +62,4 @@ RPC_STATUS RpcServerAssoc_UpdateContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SCon
unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, BOOL release_lock) DECLSPEC_HIDDEN;
void RpcContextHandle_GetUuid(NDR_SCONTEXT SContext, UUID *uuid) DECLSPEC_HIDDEN;
BOOL RpcContextHandle_IsGuardCorrect(NDR_SCONTEXT SContext, void *CtxGuard) DECLSPEC_HIDDEN;
void RpcAssoc_ConnectionReleased(RpcAssoc *assoc) DECLSPEC_HIDDEN;

View file

@ -272,13 +272,13 @@ RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding)
RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
const RPC_SYNTAX_IDENTIFIER *TransferSyntax,
const RPC_SYNTAX_IDENTIFIER *InterfaceId)
const RPC_SYNTAX_IDENTIFIER *InterfaceId, BOOL *from_cache)
{
TRACE("(Binding == ^%p)\n", Binding);
if (!Binding->server) {
return RpcAssoc_GetClientConnection(Binding->Assoc, InterfaceId,
TransferSyntax, Binding->AuthInfo, Binding->QOS, Binding->CookieAuth, Connection);
TransferSyntax, Binding->AuthInfo, Binding->QOS, Binding->CookieAuth, Connection, from_cache);
} else {
/* we already have a connection with acceptable binding, so use it */
if (Binding->FromConn) {

View file

@ -174,7 +174,8 @@ RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection) D
void RPCRT4_AddRefBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId) DECLSPEC_HIDDEN;
const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId,
BOOL *from_cache) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection) DECLSPEC_HIDDEN;
void rpcrt4_conn_release_and_wait(RpcConnection *connection) DECLSPEC_HIDDEN;

View file

@ -148,7 +148,7 @@ static RPC_STATUS get_epm_handle_client(RPC_BINDING_HANDLE handle, RPC_BINDING_H
if (bind->server)
return RPC_S_INVALID_BINDING;
for (i = 0; i < sizeof(epm_endpoints)/sizeof(epm_endpoints[0]); i++)
for (i = 0; i < ARRAY_SIZE(epm_endpoints); i++)
if (!strcmp(bind->Protseq, epm_endpoints[i].protseq))
pszEndpoint = epm_endpoints[i].endpoint;
@ -469,7 +469,7 @@ RPC_STATUS WINAPI RpcEpResolveBinding( RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE
{
__TRY
{
ept_map(handle, &uuid, tower, &entry_handle, sizeof(towers)/sizeof(towers[0]), &num_towers, towers, &status2);
ept_map(handle, &uuid, tower, &entry_handle, ARRAY_SIZE(towers), &num_towers, towers, &status2);
/* FIXME: translate status2? */
}
__EXCEPT(rpc_filter)

View file

@ -38,6 +38,7 @@
#include "rpc_binding.h"
#include "rpc_defs.h"
#include "rpc_message.h"
#include "rpc_assoc.h"
#include "ncastatus.h"
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
@ -62,8 +63,8 @@ DWORD RPCRT4_GetHeaderSize(const RpcPktHdr *Header)
0, 0, sizeof(Header->auth3), 0, 0, 0, sizeof(Header->http)
};
ULONG ret = 0;
if (Header->common.ptype < sizeof(header_sizes) / sizeof(header_sizes[0])) {
if (Header->common.ptype < ARRAY_SIZE(header_sizes)) {
ret = header_sizes[Header->common.ptype];
if (ret == 0)
FIXME("unhandled packet type %u\n", Header->common.ptype);
@ -690,7 +691,7 @@ RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection,
SECURITY_STATUS sec_status;
message.ulVersion = SECBUFFER_VERSION;
message.cBuffers = sizeof(buffers)/sizeof(buffers[0]);
message.cBuffers = ARRAY_SIZE(buffers);
message.pBuffers = buffers;
buffers[0].cbBuffer = hdr_size;
@ -1598,7 +1599,7 @@ RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax(PRPC_MESSAGE pMsg)
}
status = RPCRT4_OpenBinding(bind, &conn, &cif->TransferSyntax,
&cif->InterfaceId);
&cif->InterfaceId, NULL);
if (status == RPC_S_OK)
{
@ -1789,26 +1790,39 @@ static DWORD WINAPI async_notifier_proc(LPVOID p)
RPC_STATUS WINAPI I_RpcSend(PRPC_MESSAGE pMsg)
{
RpcBinding* bind = pMsg->Handle;
RPC_CLIENT_INTERFACE *cif;
RpcConnection* conn;
RPC_STATUS status;
RpcPktHdr *hdr;
BOOL from_cache = TRUE;
TRACE("(%p)\n", pMsg);
if (!bind || bind->server || !pMsg->ReservedForRuntime) return RPC_S_INVALID_BINDING;
conn = pMsg->ReservedForRuntime;
for (;;)
{
conn = pMsg->ReservedForRuntime;
hdr = RPCRT4_BuildRequestHeader(pMsg->DataRepresentation,
pMsg->BufferLength,
pMsg->ProcNum & ~RPC_FLAGS_VALID_BIT,
&bind->ObjectUuid);
if (!hdr)
return ERROR_OUTOFMEMORY;
hdr = RPCRT4_BuildRequestHeader(pMsg->DataRepresentation,
pMsg->BufferLength,
pMsg->ProcNum & ~RPC_FLAGS_VALID_BIT,
&bind->ObjectUuid);
if (!hdr)
return ERROR_OUTOFMEMORY;
hdr->common.call_id = conn->NextCallId++;
hdr->common.call_id = conn->NextCallId++;
status = RPCRT4_Send(conn, hdr, pMsg->Buffer, pMsg->BufferLength);
RPCRT4_FreeHeader(hdr);
if (status == RPC_S_OK || conn->server || !from_cache)
break;
status = RPCRT4_Send(conn, hdr, pMsg->Buffer, pMsg->BufferLength);
RPCRT4_FreeHeader(hdr);
WARN("Send failed, trying to reconnect\n");
cif = pMsg->RpcInterfaceInformation;
RPCRT4_ReleaseConnection(conn);
pMsg->ReservedForRuntime = NULL;
status = RPCRT4_OpenBinding(bind, &conn, &cif->TransferSyntax, &cif->InterfaceId, &from_cache);
if (status != RPC_S_OK) break;
pMsg->ReservedForRuntime = conn;
}
if (status == RPC_S_OK && pMsg->RpcFlags & RPC_BUFFER_ASYNC)
{

View file

@ -35,8 +35,6 @@
#include <string.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
@ -59,9 +57,6 @@
#define DEFAULT_NCACN_HTTP_TIMEOUT (60 * 1000)
#undef ARRAYSIZE
#define ARRAYSIZE(a) (sizeof((a)) / sizeof((a)[0]))
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
#ifdef __REACTOS__ /* FIXME: Inspect */
@ -258,24 +253,40 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq
return r;
}
#ifdef __REACTOS__
static char *ncacn_pipe_name(const char *server, const char *endpoint)
#else
static char *ncacn_pipe_name(const char *endpoint)
#endif
{
#ifdef __REACTOS__
static const char prefix[] = "\\\\";
static const char local[] = ".";
char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
#else
static const char prefix[] = "\\\\.";
#endif
char *pipe_name;
#ifdef __REACTOS__
DWORD bufLen = ARRAYSIZE(ComputerName);
GetComputerNameA(ComputerName, &bufLen);
if (server == NULL || *server == 0 || stricmp(ComputerName, server) == 0)
server = local;
#endif
/* protseq=ncacn_np: named pipes */
#ifdef __REACTOS__
pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(server) + strlen(endpoint));
strcpy(pipe_name, prefix);
strcat(pipe_name, server);
strcat(pipe_name, endpoint);
#else
pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
strcat(strcpy(pipe_name, prefix), endpoint);
#endif
return pipe_name;
}
@ -289,7 +300,11 @@ static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
if (npc->pipe)
return RPC_S_OK;
#ifdef __REACTOS__
pname = ncacn_pipe_name(Connection->NetworkAddr, Connection->Endpoint);
#else
pname = ncacn_pipe_name(Connection->Endpoint);
#endif
r = rpcrt4_conn_open_pipe(Connection, pname, FALSE);
I_RpcFree(pname);
@ -317,7 +332,11 @@ static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protse
if (r != RPC_S_OK)
return r;
#ifdef __REACTOS__
((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(NULL, Connection->Endpoint);
#else
((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(Connection->Endpoint);
#endif
r = rpcrt4_conn_create_pipe(Connection);
EnterCriticalSection(&protseq->cs);
@ -368,7 +387,11 @@ static RPC_STATUS rpcrt4_ncacn_np_is_server_listening(const char *endpoint)
char *pipe_name;
RPC_STATUS status;
#ifdef __REACTOS__
pipe_name = ncacn_pipe_name(NULL, endpoint);
#else
pipe_name = ncacn_pipe_name(endpoint);
#endif
status = is_pipe_listening(pipe_name);
I_RpcFree(pipe_name);
return status;
@ -1958,9 +1981,9 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
if (!strncmpiW(option, wszRpcProxy, sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1))
if (!strncmpiW(option, wszRpcProxy, ARRAY_SIZE(wszRpcProxy)-1))
{
const WCHAR *value_start = option + sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1;
const WCHAR *value_start = option + ARRAY_SIZE(wszRpcProxy)-1;
const WCHAR *value_end;
const WCHAR *p;
@ -1977,9 +2000,9 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
servername = RPCRT4_strndupW(value_start, value_end-value_start);
}
else if (!strncmpiW(option, wszHttpProxy, sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1))
else if (!strncmpiW(option, wszHttpProxy, ARRAY_SIZE(wszHttpProxy)-1))
{
const WCHAR *value_start = option + sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1;
const WCHAR *value_start = option + ARRAY_SIZE(wszHttpProxy)-1;
const WCHAR *value_end;
value_end = strchrW(option, ',');
@ -2107,7 +2130,7 @@ static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
{
static const WCHAR fmtW[] =
{'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
WCHAR header[sizeof(fmtW) / sizeof(fmtW[0]) + 10];
WCHAR header[ARRAY_SIZE(fmtW) + 10];
sprintfW(header, fmtW, len);
if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD))) return RPC_S_OK;
@ -2436,18 +2459,17 @@ static const struct
}
auth_schemes[] =
{
{ basicW, ARRAYSIZE(basicW) - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC },
{ ntlmW, ARRAYSIZE(ntlmW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM },
{ passportW, ARRAYSIZE(passportW) - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT },
{ digestW, ARRAYSIZE(digestW) - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST },
{ negotiateW, ARRAYSIZE(negotiateW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE }
{ basicW, ARRAY_SIZE(basicW) - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC },
{ ntlmW, ARRAY_SIZE(ntlmW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM },
{ passportW, ARRAY_SIZE(passportW) - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT },
{ digestW, ARRAY_SIZE(digestW) - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST },
{ negotiateW, ARRAY_SIZE(negotiateW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE }
};
static const unsigned int num_auth_schemes = sizeof(auth_schemes)/sizeof(auth_schemes[0]);
static DWORD auth_scheme_from_header( const WCHAR *header )
{
unsigned int i;
for (i = 0; i < num_auth_schemes; i++)
for (i = 0; i < ARRAY_SIZE(auth_schemes); i++)
{
if (!strncmpiW( header, auth_schemes[i].str, auth_schemes[i].len ) &&
(header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
@ -2621,7 +2643,7 @@ static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, c
static const WCHAR basicW[] = {'B','a','s','i','c',' '};
static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
static const WCHAR ntlmW[] = {'N','T','L','M',' '};
int scheme_len, auth_len = sizeof(authW) / sizeof(authW[0]), len = ((data_len + 2) * 4) / 3;
int scheme_len, auth_len = ARRAY_SIZE(authW), len = ((data_len + 2) * 4) / 3;
const WCHAR *scheme_str;
WCHAR *header, *ptr;
RPC_STATUS status = RPC_S_SERVER_UNAVAILABLE;
@ -2630,15 +2652,15 @@ static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, c
{
case RPC_C_HTTP_AUTHN_SCHEME_BASIC:
scheme_str = basicW;
scheme_len = sizeof(basicW) / sizeof(basicW[0]);
scheme_len = ARRAY_SIZE(basicW);
break;
case RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE:
scheme_str = negotiateW;
scheme_len = sizeof(negotiateW) / sizeof(negotiateW[0]);
scheme_len = ARRAY_SIZE(negotiateW);
break;
case RPC_C_HTTP_AUTHN_SCHEME_NTLM:
scheme_str = ntlmW;
scheme_len = sizeof(ntlmW) / sizeof(ntlmW[0]);
scheme_len = ARRAY_SIZE(ntlmW);
break;
default:
ERR("unknown scheme %u\n", scheme);
@ -2819,7 +2841,8 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
if (!url)
return RPC_S_OUT_OF_MEMORY;
memcpy(url, wszRpcProxyPrefix, sizeof(wszRpcProxyPrefix));
MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+sizeof(wszRpcProxyPrefix)/sizeof(wszRpcProxyPrefix[0])-1, strlen(Connection->NetworkAddr)+1);
MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+ARRAY_SIZE(wszRpcProxyPrefix)-1,
strlen(Connection->NetworkAddr)+1);
strcatW(url, wszColon);
MultiByteToWideChar(CP_ACP, 0, Connection->Endpoint, -1, url+strlenW(url), strlen(Connection->Endpoint)+1);
@ -3299,7 +3322,7 @@ static const struct protseq_ops protseq_list[] =
const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq)
{
unsigned int i;
for(i=0; i<ARRAYSIZE(protseq_list); i++)
for(i = 0; i < ARRAY_SIZE(protseq_list); i++)
if (!strcmp(protseq_list[i].name, protseq))
return &protseq_list[i];
return NULL;
@ -3308,7 +3331,7 @@ const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq)
static const struct connection_ops *rpcrt4_get_conn_protseq_ops(const char *protseq)
{
unsigned int i;
for(i=0; i<ARRAYSIZE(conn_protseq_list); i++)
for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
if (!strcmp(conn_protseq_list[i].name, protseq))
return &conn_protseq_list[i];
return NULL;
@ -3458,6 +3481,7 @@ void RPCRT4_ReleaseConnection(RpcConnection *connection)
/* server-only */
if (connection->server_binding) RPCRT4_ReleaseBinding(connection->server_binding);
else if (connection->assoc) RpcAssoc_ConnectionReleased(connection->assoc);
if (connection->wait_release) SetEvent(connection->wait_release);
@ -3545,7 +3569,7 @@ RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data,
(floor4->count_lhs != sizeof(floor4->protid)))
return EPT_S_NOT_REGISTERED;
for(i = 0; i < ARRAYSIZE(conn_protseq_list); i++)
for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
if ((protocol_floor->protid == conn_protseq_list[i].epm_protocols[0]) &&
(floor4->protid == conn_protseq_list[i].epm_protocols[1]))
{
@ -3651,12 +3675,12 @@ RPC_STATUS WINAPI RpcNetworkInqProtseqsW( RPC_PROTSEQ_VECTORW** protseqs )
TRACE("(%p)\n", protseqs);
*protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAYSIZE(protseq_list)));
*protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAY_SIZE(protseq_list)));
if (!*protseqs)
goto end;
pvector = *protseqs;
pvector->Count = 0;
for (i = 0; i < ARRAYSIZE(protseq_list); i++)
for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
{
pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short));
if (pvector->Protseq[i] == NULL)
@ -3684,12 +3708,12 @@ RPC_STATUS WINAPI RpcNetworkInqProtseqsA(RPC_PROTSEQ_VECTORA** protseqs)
TRACE("(%p)\n", protseqs);
*protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAYSIZE(protseq_list)));
*protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAY_SIZE(protseq_list)));
if (!*protseqs)
goto end;
pvector = *protseqs;
pvector->Count = 0;
for (i = 0; i < ARRAYSIZE(protseq_list); i++)
for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
{
pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1);
if (pvector->Protseq[i] == NULL)

View file

@ -44,7 +44,7 @@
44 stub I_RpcConnectionSetSockBuffSize
45 stub I_RpcDeleteMutex
46 stub I_RpcEnableWmiTrace
47 stdcall I_RpcExceptionFilter(long)
47 stdcall I_RpcExceptionFilter(long) RpcExceptionFilter
48 stdcall I_RpcFree(ptr)
49 stdcall I_RpcFreeBuffer(ptr)
50 stub I_RpcFreePipeBuffer

View file

@ -854,9 +854,10 @@ LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status)
}
/******************************************************************************
* RpcExceptionFilter (rpcrt4.@)
* I_RpcExceptionFilter (rpcrt4.@)
*/
int WINAPI I_RpcExceptionFilter(ULONG ExceptionCode)
int WINAPI RpcExceptionFilter(ULONG ExceptionCode)
{
TRACE("0x%x\n", ExceptionCode);
switch (ExceptionCode)

View file

@ -160,7 +160,7 @@ reactos/dll/win32/rasapi32 # Synced to WineStaging-3.3
reactos/dll/win32/resutils # Synced to WineStaging-3.3
reactos/dll/win32/riched20 # Synced to WineStaging-3.9
reactos/dll/win32/riched32 # Synced to WineStaging-3.3
reactos/dll/win32/rpcrt4 # Synced to WineStaging-3.9
reactos/dll/win32/rpcrt4 # Synced to WineStaging-4.0
reactos/dll/win32/rsabase # Synced to WineStaging-3.3
reactos/dll/win32/rsaenh # Synced to WineStaging-2.9
reactos/dll/win32/sccbase # Synced to WineStaging-3.3