* Sync with Wine 1.7.1.
[PSDK]
* Update rpcdce.h, rpcdcep.h and rpcndr.h.
CORE-7469

svn path=/trunk/; revision=61237
This commit is contained in:
Amine Khaldi 2013-12-06 23:26:11 +00:00
parent 93465c41a9
commit e1f0a94aa4
20 changed files with 827 additions and 386 deletions

View file

@ -375,7 +375,7 @@ HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface,
if (IsEqualIID(&IID_IUnknown, riid) || if (IsEqualIID(&IID_IUnknown, riid) ||
IsEqualIID(&IID_IRpcStubBuffer, riid)) IsEqualIID(&IID_IRpcStubBuffer, riid))
{ {
IUnknown_AddRef(iface); IRpcStubBuffer_AddRef(iface);
*obj = iface; *obj = iface;
return S_OK; return S_OK;
} }

View file

@ -351,9 +351,9 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS) if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
{ {
const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0]; const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
stack_size = pProcHeader->stack_size; stack_size = header_rpc->stack_size;
pEsMsg->ProcNumber = pProcHeader->proc_num; pEsMsg->ProcNumber = header_rpc->proc_num;
pFormat += sizeof(NDR_PROC_HEADER_RPC); pFormat += sizeof(NDR_PROC_HEADER_RPC);
} }
else else

View file

@ -1179,7 +1179,8 @@ static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
while (pFormat[0] != RPC_FC_END) { while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) { switch (pFormat[0]) {
default: default:
FIXME("unknown repeat type %d\n", pFormat[0]); FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
case RPC_FC_NO_REPEAT: case RPC_FC_NO_REPEAT:
rep = 1; rep = 1;
stride = 0; stride = 0;
@ -1259,7 +1260,8 @@ static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
TRACE("pFormat[0] = 0x%x\n", pFormat[0]); TRACE("pFormat[0] = 0x%x\n", pFormat[0]);
switch (pFormat[0]) { switch (pFormat[0]) {
default: default:
FIXME("unknown repeat type %d\n", pFormat[0]); FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
case RPC_FC_NO_REPEAT: case RPC_FC_NO_REPEAT:
rep = 1; rep = 1;
stride = 0; stride = 0;
@ -1333,7 +1335,8 @@ static void EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
while (pFormat[0] != RPC_FC_END) { while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) { switch (pFormat[0]) {
default: default:
FIXME("unknown repeat type %d\n", pFormat[0]); FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
case RPC_FC_NO_REPEAT: case RPC_FC_NO_REPEAT:
rep = 1; rep = 1;
stride = 0; stride = 0;
@ -1405,7 +1408,8 @@ static ULONG EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
while (pFormat[0] != RPC_FC_END) { while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) { switch (pFormat[0]) {
default: default:
FIXME("unknown repeat type %d\n", pFormat[0]); FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
case RPC_FC_NO_REPEAT: case RPC_FC_NO_REPEAT:
rep = 1; rep = 1;
stride = 0; stride = 0;
@ -1463,7 +1467,8 @@ static void EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
while (pFormat[0] != RPC_FC_END) { while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) { switch (pFormat[0]) {
default: default:
FIXME("unknown repeat type %d\n", pFormat[0]); FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
case RPC_FC_NO_REPEAT: case RPC_FC_NO_REPEAT:
rep = 1; rep = 1;
stride = 0; stride = 0;

View file

@ -152,6 +152,15 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
DWORD size; DWORD size;
switch(*pFormat) switch(*pFormat)
{ {
case RPC_FC_RP:
if (pFormat[1] & RPC_FC_P_SIMPLEPOINTER)
{
FIXME("Simple reference pointer (type %#x).\n", pFormat[2]);
size = sizeof(void *);
break;
}
size = calc_arg_size(pStubMsg, &pFormat[2] + *(const SHORT*)&pFormat[2]);
break;
case RPC_FC_STRUCT: case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT: case RPC_FC_PSTRUCT:
size = *(const WORD*)(pFormat + 2); size = *(const WORD*)(pFormat + 2);
@ -206,7 +215,7 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
default: default:
FIXME("Unhandled type %02x\n", *pFormat); FIXME("Unhandled type %02x\n", *pFormat);
/* fallthrough */ /* fallthrough */
case RPC_FC_RP: case RPC_FC_IP:
size = sizeof(void *); size = sizeof(void *);
break; break;
} }
@ -620,9 +629,9 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS) if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
{ {
const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0]; const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
stack_size = pProcHeader->stack_size; stack_size = header_rpc->stack_size;
procedure_number = pProcHeader->proc_num; procedure_number = header_rpc->proc_num;
pFormat += sizeof(NDR_PROC_HEADER_RPC); pFormat += sizeof(NDR_PROC_HEADER_RPC);
} }
else else
@ -809,7 +818,7 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
} }
} }
/* convert strings, floating point values and endianess into our /* convert strings, floating point values and endianness into our
* preferred format */ * preferred format */
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION) if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
NdrConvert(&stubMsg, pFormat); NdrConvert(&stubMsg, pFormat);
@ -847,7 +856,7 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
if (comm_fault_offsets->FaultOffset == -1) if (comm_fault_offsets->FaultOffset == -1)
fault_status = (ULONG *)&RetVal; fault_status = (ULONG *)&RetVal;
else if (comm_fault_offsets->FaultOffset >= 0) else if (comm_fault_offsets->FaultOffset >= 0)
fault_status = *(ULONG **)ARG_FROM_OFFSET(stubMsg.StackTop, comm_fault_offsets->CommOffset); fault_status = *(ULONG **)ARG_FROM_OFFSET(stubMsg.StackTop, comm_fault_offsets->FaultOffset);
else else
fault_status = NULL; fault_status = NULL;
@ -1226,8 +1235,8 @@ LONG WINAPI NdrStubCall2(
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS) if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
{ {
const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0]; const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
stack_size = pProcHeader->stack_size; stack_size = header_rpc->stack_size;
pFormat += sizeof(NDR_PROC_HEADER_RPC); pFormat += sizeof(NDR_PROC_HEADER_RPC);
} }
@ -1341,7 +1350,7 @@ LONG WINAPI NdrStubCall2(
NdrCorrCache, sizeof(NdrCorrCache), &number_of_params ); NdrCorrCache, sizeof(NdrCorrCache), &number_of_params );
} }
/* convert strings, floating point values and endianess into our /* convert strings, floating point values and endianness into our
* preferred format */ * preferred format */
if ((pRpcMsg->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION) if ((pRpcMsg->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
NdrConvert(&stubMsg, pFormat); NdrConvert(&stubMsg, pFormat);
@ -1514,9 +1523,9 @@ LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS) if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
{ {
const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0]; const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
async_call_data->stack_size = pProcHeader->stack_size; async_call_data->stack_size = header_rpc->stack_size;
procedure_number = pProcHeader->proc_num; procedure_number = header_rpc->proc_num;
pFormat += sizeof(NDR_PROC_HEADER_RPC); pFormat += sizeof(NDR_PROC_HEADER_RPC);
} }
else else

View file

@ -79,6 +79,7 @@ static RPC_STATUS RpcAssoc_Alloc(LPCSTR Protseq, LPCSTR NetworkAddr,
list_init(&assoc->free_connection_pool); list_init(&assoc->free_connection_pool);
list_init(&assoc->context_handle_list); list_init(&assoc->context_handle_list);
InitializeCriticalSection(&assoc->cs); InitializeCriticalSection(&assoc->cs);
assoc->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcAssoc.cs");
assoc->Protseq = RPCRT4_strdupA(Protseq); assoc->Protseq = RPCRT4_strdupA(Protseq);
assoc->NetworkAddr = RPCRT4_strdupA(NetworkAddr); assoc->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
assoc->Endpoint = RPCRT4_strdupA(Endpoint); assoc->Endpoint = RPCRT4_strdupA(Endpoint);
@ -207,7 +208,7 @@ ULONG RpcAssoc_Release(RpcAssoc *assoc)
LIST_FOR_EACH_ENTRY_SAFE(Connection, cursor2, &assoc->free_connection_pool, RpcConnection, conn_pool_entry) LIST_FOR_EACH_ENTRY_SAFE(Connection, cursor2, &assoc->free_connection_pool, RpcConnection, conn_pool_entry)
{ {
list_remove(&Connection->conn_pool_entry); list_remove(&Connection->conn_pool_entry);
RPCRT4_DestroyConnection(Connection); RPCRT4_ReleaseConnection(Connection);
} }
LIST_FOR_EACH_ENTRY_SAFE(context_handle, context_handle_cursor, &assoc->context_handle_list, RpcContextHandle, entry) LIST_FOR_EACH_ENTRY_SAFE(context_handle, context_handle_cursor, &assoc->context_handle_list, RpcContextHandle, entry)
@ -218,6 +219,7 @@ ULONG RpcAssoc_Release(RpcAssoc *assoc)
HeapFree(GetProcessHeap(), 0, assoc->NetworkAddr); HeapFree(GetProcessHeap(), 0, assoc->NetworkAddr);
HeapFree(GetProcessHeap(), 0, assoc->Protseq); HeapFree(GetProcessHeap(), 0, assoc->Protseq);
assoc->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&assoc->cs); DeleteCriticalSection(&assoc->cs);
HeapFree(GetProcessHeap(), 0, assoc); HeapFree(GetProcessHeap(), 0, assoc);
@ -392,7 +394,7 @@ static RpcConnection *RpcAssoc_GetIdleConnection(RpcAssoc *assoc,
RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc, RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
const RPC_SYNTAX_IDENTIFIER *InterfaceId, const RPC_SYNTAX_IDENTIFIER *InterfaceId,
const RPC_SYNTAX_IDENTIFIER *TransferSyntax, RpcAuthInfo *AuthInfo, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, RpcAuthInfo *AuthInfo,
RpcQualityOfService *QOS, RpcConnection **Connection) RpcQualityOfService *QOS, LPCWSTR CookieAuth, RpcConnection **Connection)
{ {
RpcConnection *NewConnection; RpcConnection *NewConnection;
RPC_STATUS status; RPC_STATUS status;
@ -405,7 +407,7 @@ RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
status = RPCRT4_CreateConnection(&NewConnection, FALSE /* is this a server connection? */, status = RPCRT4_CreateConnection(&NewConnection, FALSE /* is this a server connection? */,
assoc->Protseq, assoc->NetworkAddr, assoc->Protseq, assoc->NetworkAddr,
assoc->Endpoint, assoc->NetworkOptions, assoc->Endpoint, assoc->NetworkOptions,
AuthInfo, QOS); AuthInfo, QOS, CookieAuth);
if (status != RPC_S_OK) if (status != RPC_S_OK)
return status; return status;
@ -413,14 +415,14 @@ RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
status = RPCRT4_OpenClientConnection(NewConnection); status = RPCRT4_OpenClientConnection(NewConnection);
if (status != RPC_S_OK) if (status != RPC_S_OK)
{ {
RPCRT4_DestroyConnection(NewConnection); RPCRT4_ReleaseConnection(NewConnection);
return status; return status;
} }
status = RpcAssoc_BindConnection(assoc, NewConnection, InterfaceId, TransferSyntax); status = RpcAssoc_BindConnection(assoc, NewConnection, InterfaceId, TransferSyntax);
if (status != RPC_S_OK) if (status != RPC_S_OK)
{ {
RPCRT4_DestroyConnection(NewConnection); RPCRT4_ReleaseConnection(NewConnection);
return status; return status;
} }

View file

@ -47,7 +47,9 @@ typedef struct _RpcAssoc
} RpcAssoc; } RpcAssoc;
RPC_STATUS RPCRT4_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAssoc **assoc) DECLSPEC_HIDDEN; 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, RpcConnection **Connection) 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;
void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection) DECLSPEC_HIDDEN; void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection) DECLSPEC_HIDDEN;
ULONG RpcAssoc_Release(RpcAssoc *assoc) 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; RPC_STATUS RpcServerAssoc_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, ULONG assoc_gid, RpcAssoc **assoc_out) DECLSPEC_HIDDEN;

View file

@ -266,6 +266,7 @@ RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding)
RPCRT4_strfree(Binding->NetworkAddr); RPCRT4_strfree(Binding->NetworkAddr);
RPCRT4_strfree(Binding->Protseq); RPCRT4_strfree(Binding->Protseq);
HeapFree(GetProcessHeap(), 0, Binding->NetworkOptions); HeapFree(GetProcessHeap(), 0, Binding->NetworkOptions);
HeapFree(GetProcessHeap(), 0, Binding->CookieAuth);
if (Binding->AuthInfo) RpcAuthInfo_Release(Binding->AuthInfo); if (Binding->AuthInfo) RpcAuthInfo_Release(Binding->AuthInfo);
if (Binding->QOS) RpcQualityOfService_Release(Binding->QOS); if (Binding->QOS) RpcQualityOfService_Release(Binding->QOS);
HeapFree(GetProcessHeap(), 0, Binding); HeapFree(GetProcessHeap(), 0, Binding);
@ -280,7 +281,7 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
if (!Binding->server) { if (!Binding->server) {
return RpcAssoc_GetClientConnection(Binding->Assoc, InterfaceId, return RpcAssoc_GetClientConnection(Binding->Assoc, InterfaceId,
TransferSyntax, Binding->AuthInfo, Binding->QOS, Connection); TransferSyntax, Binding->AuthInfo, Binding->QOS, Binding->CookieAuth, Connection);
} else { } else {
/* we already have a connection with acceptable binding, so use it */ /* we already have a connection with acceptable binding, so use it */
if (Binding->FromConn) { if (Binding->FromConn) {
@ -301,7 +302,7 @@ RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection)
/* don't destroy a connection that is cached in the binding */ /* don't destroy a connection that is cached in the binding */
if (Binding->FromConn == Connection) if (Binding->FromConn == Connection)
return RPC_S_OK; return RPC_S_OK;
return RPCRT4_DestroyConnection(Connection); return RPCRT4_ReleaseConnection(Connection);
} }
else { else {
RpcAssoc_ReleaseIdleConnection(Binding->Assoc, Connection); RpcAssoc_ReleaseIdleConnection(Binding->Assoc, Connection);
@ -854,10 +855,16 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingA( RPC_CSTR StringBinding, RPC_BIND
if (ret == RPC_S_OK) if (ret == RPC_S_OK)
ret = RPCRT4_CreateBindingA(&bind, FALSE, (char*)Protseq); ret = RPCRT4_CreateBindingA(&bind, FALSE, (char*)Protseq);
if (ret != RPC_S_OK) return ret; if (ret == RPC_S_OK) {
ret = RPCRT4_SetBindingObject(bind, &Uuid); ret = RPCRT4_SetBindingObject(bind, &Uuid);
if (ret == RPC_S_OK) if (ret == RPC_S_OK)
ret = RPCRT4_CompleteBindingA(bind, (char*)NetworkAddr, (char*)Endpoint, (char*)Options); ret = RPCRT4_CompleteBindingA(bind, (char*)NetworkAddr, (char*)Endpoint, (char*)Options);
if (ret == RPC_S_OK)
*Binding = (RPC_BINDING_HANDLE)bind;
else
RPCRT4_ReleaseBinding(bind);
}
RpcStringFreeA(&Options); RpcStringFreeA(&Options);
RpcStringFreeA(&Endpoint); RpcStringFreeA(&Endpoint);
@ -865,11 +872,6 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingA( RPC_CSTR StringBinding, RPC_BIND
RpcStringFreeA(&Protseq); RpcStringFreeA(&Protseq);
RpcStringFreeA(&ObjectUuid); RpcStringFreeA(&ObjectUuid);
if (ret == RPC_S_OK)
*Binding = (RPC_BINDING_HANDLE)bind;
else
RPCRT4_ReleaseBinding(bind);
return ret; return ret;
} }
@ -893,10 +895,16 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingW( RPC_WSTR StringBinding, RPC_BIND
if (ret == RPC_S_OK) if (ret == RPC_S_OK)
ret = RPCRT4_CreateBindingW(&bind, FALSE, Protseq); ret = RPCRT4_CreateBindingW(&bind, FALSE, Protseq);
if (ret != RPC_S_OK) return ret; if (ret == RPC_S_OK) {
ret = RPCRT4_SetBindingObject(bind, &Uuid); ret = RPCRT4_SetBindingObject(bind, &Uuid);
if (ret == RPC_S_OK) if (ret == RPC_S_OK)
ret = RPCRT4_CompleteBindingW(bind, NetworkAddr, Endpoint, Options); ret = RPCRT4_CompleteBindingW(bind, NetworkAddr, Endpoint, Options);
if (ret == RPC_S_OK)
*Binding = (RPC_BINDING_HANDLE)bind;
else
RPCRT4_ReleaseBinding(bind);
}
RpcStringFreeW(&Options); RpcStringFreeW(&Options);
RpcStringFreeW(&Endpoint); RpcStringFreeW(&Endpoint);
@ -904,11 +912,6 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingW( RPC_WSTR StringBinding, RPC_BIND
RpcStringFreeW(&Protseq); RpcStringFreeW(&Protseq);
RpcStringFreeW(&ObjectUuid); RpcStringFreeW(&ObjectUuid);
if (ret == RPC_S_OK)
*Binding = (RPC_BINDING_HANDLE)bind;
else
RPCRT4_ReleaseBinding(bind);
return ret; return ret;
} }
@ -1003,6 +1006,7 @@ RPC_STATUS RPC_ENTRY RpcBindingCopy(
DestBinding->NetworkAddr = RPCRT4_strndupA(SrcBinding->NetworkAddr, -1); DestBinding->NetworkAddr = RPCRT4_strndupA(SrcBinding->NetworkAddr, -1);
DestBinding->Endpoint = RPCRT4_strndupA(SrcBinding->Endpoint, -1); DestBinding->Endpoint = RPCRT4_strndupA(SrcBinding->Endpoint, -1);
DestBinding->NetworkOptions = RPCRT4_strdupW(SrcBinding->NetworkOptions); DestBinding->NetworkOptions = RPCRT4_strdupW(SrcBinding->NetworkOptions);
DestBinding->CookieAuth = RPCRT4_strdupW(SrcBinding->CookieAuth);
if (SrcBinding->Assoc) SrcBinding->Assoc->refs++; if (SrcBinding->Assoc) SrcBinding->Assoc->refs++;
DestBinding->Assoc = SrcBinding->Assoc; DestBinding->Assoc = SrcBinding->Assoc;
@ -1415,7 +1419,18 @@ BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQuali
if (http_credentials1->AuthenticationTarget != http_credentials2->AuthenticationTarget) if (http_credentials1->AuthenticationTarget != http_credentials2->AuthenticationTarget)
return FALSE; return FALSE;
/* authentication schemes and server certificate subject not currently used */ if (http_credentials1->NumberOfAuthnSchemes != http_credentials2->NumberOfAuthnSchemes)
return FALSE;
if ((!http_credentials1->AuthnSchemes && http_credentials2->AuthnSchemes) ||
(http_credentials1->AuthnSchemes && !http_credentials2->AuthnSchemes))
return FALSE;
if (memcmp(http_credentials1->AuthnSchemes, http_credentials2->AuthnSchemes,
http_credentials1->NumberOfAuthnSchemes * sizeof(http_credentials1->AuthnSchemes[0])))
return FALSE;
/* server certificate subject not currently used */
if (http_credentials1->TransportCredentials != http_credentials2->TransportCredentials) if (http_credentials1->TransportCredentials != http_credentials2->TransportCredentials)
{ {
@ -1653,12 +1668,13 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName,
const RPC_SECURITY_QOS_V2_A *SecurityQos2 = (const RPC_SECURITY_QOS_V2_A *)SecurityQos; const RPC_SECURITY_QOS_V2_A *SecurityQos2 = (const RPC_SECURITY_QOS_V2_A *)SecurityQos;
TRACE(", AdditionalSecurityInfoType=%d", SecurityQos2->AdditionalSecurityInfoType); TRACE(", AdditionalSecurityInfoType=%d", SecurityQos2->AdditionalSecurityInfoType);
if (SecurityQos2->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP) if (SecurityQos2->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP)
TRACE(", { %p, 0x%x, %d, %d, %p, %s }", TRACE(", { %p, 0x%x, %d, %d, %p(%u), %s }",
SecurityQos2->u.HttpCredentials->TransportCredentials, SecurityQos2->u.HttpCredentials->TransportCredentials,
SecurityQos2->u.HttpCredentials->Flags, SecurityQos2->u.HttpCredentials->Flags,
SecurityQos2->u.HttpCredentials->AuthenticationTarget, SecurityQos2->u.HttpCredentials->AuthenticationTarget,
SecurityQos2->u.HttpCredentials->NumberOfAuthnSchemes, SecurityQos2->u.HttpCredentials->NumberOfAuthnSchemes,
SecurityQos2->u.HttpCredentials->AuthnSchemes, SecurityQos2->u.HttpCredentials->AuthnSchemes,
SecurityQos2->u.HttpCredentials->AuthnSchemes ? *SecurityQos2->u.HttpCredentials->AuthnSchemes : 0,
SecurityQos2->u.HttpCredentials->ServerCertificateSubject); SecurityQos2->u.HttpCredentials->ServerCertificateSubject);
} }
TRACE("}\n"); TRACE("}\n");
@ -1730,7 +1746,7 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName,
if (r == RPC_S_OK) if (r == RPC_S_OK)
{ {
new_auth_info->server_principal_name = RPCRT4_strdupAtoW((char *)ServerPrincName); new_auth_info->server_principal_name = RPCRT4_strdupAtoW((char *)ServerPrincName);
if (new_auth_info->server_principal_name) if (!ServerPrincName || new_auth_info->server_principal_name)
{ {
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo); if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
bind->AuthInfo = new_auth_info; bind->AuthInfo = new_auth_info;
@ -1783,12 +1799,13 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName,
const RPC_SECURITY_QOS_V2_W *SecurityQos2 = (const RPC_SECURITY_QOS_V2_W *)SecurityQos; const RPC_SECURITY_QOS_V2_W *SecurityQos2 = (const RPC_SECURITY_QOS_V2_W *)SecurityQos;
TRACE(", AdditionalSecurityInfoType=%d", SecurityQos2->AdditionalSecurityInfoType); TRACE(", AdditionalSecurityInfoType=%d", SecurityQos2->AdditionalSecurityInfoType);
if (SecurityQos2->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP) if (SecurityQos2->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP)
TRACE(", { %p, 0x%x, %d, %d, %p, %s }", TRACE(", { %p, 0x%x, %d, %d, %p(%u), %s }",
SecurityQos2->u.HttpCredentials->TransportCredentials, SecurityQos2->u.HttpCredentials->TransportCredentials,
SecurityQos2->u.HttpCredentials->Flags, SecurityQos2->u.HttpCredentials->Flags,
SecurityQos2->u.HttpCredentials->AuthenticationTarget, SecurityQos2->u.HttpCredentials->AuthenticationTarget,
SecurityQos2->u.HttpCredentials->NumberOfAuthnSchemes, SecurityQos2->u.HttpCredentials->NumberOfAuthnSchemes,
SecurityQos2->u.HttpCredentials->AuthnSchemes, SecurityQos2->u.HttpCredentials->AuthnSchemes,
SecurityQos2->u.HttpCredentials->AuthnSchemes ? *SecurityQos2->u.HttpCredentials->AuthnSchemes : 0,
debugstr_w(SecurityQos2->u.HttpCredentials->ServerCertificateSubject)); debugstr_w(SecurityQos2->u.HttpCredentials->ServerCertificateSubject));
} }
TRACE("}\n"); TRACE("}\n");
@ -1911,6 +1928,27 @@ RpcBindingSetAuthInfoW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, UL
*/ */
RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Option, ULONG_PTR OptionValue) RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Option, ULONG_PTR OptionValue)
{ {
FIXME("(%p, %d, %ld): stub\n", BindingHandle, Option, OptionValue); TRACE("(%p, %d, %ld)\n", BindingHandle, Option, OptionValue);
switch (Option)
{
case RPC_C_OPT_COOKIE_AUTH:
{
RPC_C_OPT_COOKIE_AUTH_DESCRIPTOR *cookie = (RPC_C_OPT_COOKIE_AUTH_DESCRIPTOR *)OptionValue;
RpcBinding *binding = BindingHandle;
int len = MultiByteToWideChar(CP_ACP, 0, cookie->Buffer, cookie->BufferSize, NULL, 0);
WCHAR *str;
if (!(str = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)))) return ERROR_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, cookie->Buffer, cookie->BufferSize, str, len);
str[len] = 0;
HeapFree(GetProcessHeap(), 0, binding->CookieAuth);
binding->CookieAuth = str;
break;
}
default:
FIXME("option %u not supported\n", Option);
break;
}
return RPC_S_OK; return RPC_S_OK;
} }

View file

@ -61,6 +61,7 @@ struct connection_ops;
typedef struct _RpcConnection typedef struct _RpcConnection
{ {
LONG ref;
BOOL server; BOOL server;
LPSTR NetworkAddr; LPSTR NetworkAddr;
LPSTR Endpoint; LPSTR Endpoint;
@ -77,6 +78,7 @@ typedef struct _RpcConnection
ULONG encryption_auth_len; ULONG encryption_auth_len;
ULONG signature_auth_len; ULONG signature_auth_len;
RpcQualityOfService *QOS; RpcQualityOfService *QOS;
LPWSTR CookieAuth;
/* client-only */ /* client-only */
struct list conn_pool_entry; struct list conn_pool_entry;
@ -133,6 +135,7 @@ typedef struct _RpcBinding
/* authentication */ /* authentication */
RpcAuthInfo *AuthInfo; RpcAuthInfo *AuthInfo;
RpcQualityOfService *QOS; RpcQualityOfService *QOS;
LPWSTR CookieAuth;
} RpcBinding; } RpcBinding;
LPSTR RPCRT4_strndupA(LPCSTR src, INT len) DECLSPEC_HIDDEN; LPSTR RPCRT4_strndupA(LPCSTR src, INT len) DECLSPEC_HIDDEN;
@ -152,8 +155,11 @@ ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN; ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2) DECLSPEC_HIDDEN; BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS) DECLSPEC_HIDDEN; RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq,
RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection) DECLSPEC_HIDDEN; LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo,
RpcQualityOfService *QOS, LPCWSTR CookieAuth) DECLSPEC_HIDDEN;
RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn ) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_ReleaseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection) DECLSPEC_HIDDEN; RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN; RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;

View file

@ -179,11 +179,8 @@ static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *__eptr)
} }
} }
/*********************************************************************** static RPC_STATUS epm_register( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
* RpcEpRegisterA (RPCRT4.@) UUID_VECTOR *UuidVector, RPC_CSTR Annotation, BOOL replace )
*/
RPC_STATUS WINAPI RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
UUID_VECTOR *UuidVector, RPC_CSTR Annotation )
{ {
PRPC_SERVER_INTERFACE If = IfSpec; PRPC_SERVER_INTERFACE If = IfSpec;
ULONG i; ULONG i;
@ -192,7 +189,7 @@ RPC_STATUS WINAPI RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bind
ept_entry_t *entries; ept_entry_t *entries;
handle_t handle; handle_t handle;
TRACE("(%p,%p,%p,%s)\n", IfSpec, BindingVector, UuidVector, debugstr_a((char*)Annotation)); TRACE("(%p,%p,%p,%s) replace=%d\n", IfSpec, BindingVector, UuidVector, debugstr_a((char*)Annotation), replace);
TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID)); TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
for (i=0; i<BindingVector->Count; i++) { for (i=0; i<BindingVector->Count; i++) {
RpcBinding* bind = BindingVector->BindingH[i]; RpcBinding* bind = BindingVector->BindingH[i];
@ -246,7 +243,7 @@ RPC_STATUS WINAPI RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bind
__TRY __TRY
{ {
ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1), ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1),
entries, TRUE, &status2); entries, replace, &status2);
} }
__EXCEPT(rpc_filter) __EXCEPT(rpc_filter)
{ {
@ -279,6 +276,24 @@ RPC_STATUS WINAPI RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bind
return status; return status;
} }
/***********************************************************************
* RpcEpRegisterA (RPCRT4.@)
*/
RPC_STATUS WINAPI RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
UUID_VECTOR *UuidVector, RPC_CSTR Annotation )
{
return epm_register(IfSpec, BindingVector, UuidVector, Annotation, TRUE);
}
/***********************************************************************
* RpcEpRegisterNoReplaceA (RPCRT4.@)
*/
RPC_STATUS WINAPI RpcEpRegisterNoReplaceA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
UUID_VECTOR *UuidVector, RPC_CSTR Annotation )
{
return epm_register(IfSpec, BindingVector, UuidVector, Annotation, FALSE);
}
/*********************************************************************** /***********************************************************************
* RpcEpRegisterW (RPCRT4.@) * RpcEpRegisterW (RPCRT4.@)
*/ */
@ -288,7 +303,22 @@ RPC_STATUS WINAPI RpcEpRegisterW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bind
LPSTR annA = RPCRT4_strdupWtoA(Annotation); LPSTR annA = RPCRT4_strdupWtoA(Annotation);
RPC_STATUS status; RPC_STATUS status;
status = RpcEpRegisterA(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA); status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, TRUE);
HeapFree(GetProcessHeap(), 0, annA);
return status;
}
/***********************************************************************
* RpcEpRegisterNoReplaceW (RPCRT4.@)
*/
RPC_STATUS WINAPI RpcEpRegisterNoReplaceW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
UUID_VECTOR *UuidVector, RPC_WSTR Annotation )
{
LPSTR annA = RPCRT4_strdupWtoA(Annotation);
RPC_STATUS status;
status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, FALSE);
HeapFree(GetProcessHeap(), 0, annA); HeapFree(GetProcessHeap(), 0, annA);
return status; return status;

View file

@ -342,7 +342,7 @@ RpcPktHdr *RPCRT4_BuildHttpHeader(ULONG DataRepresentation,
(payload) += sizeof(UUID); \ (payload) += sizeof(UUID); \
} while (0) } while (0)
RpcPktHdr *RPCRT4_BuildHttpConnectHeader(unsigned short flags, int out_pipe, RpcPktHdr *RPCRT4_BuildHttpConnectHeader(int out_pipe,
const UUID *connection_uuid, const UUID *connection_uuid,
const UUID *pipe_uuid, const UUID *pipe_uuid,
const UUID *association_uuid) const UUID *association_uuid)
@ -355,7 +355,7 @@ RpcPktHdr *RPCRT4_BuildHttpConnectHeader(unsigned short flags, int out_pipe,
if (!out_pipe) if (!out_pipe)
size += 8 + 4 + sizeof(UUID); size += 8 + 4 + sizeof(UUID);
header = RPCRT4_BuildHttpHeader(NDR_LOCAL_DATA_REPRESENTATION, flags, header = RPCRT4_BuildHttpHeader(NDR_LOCAL_DATA_REPRESENTATION, 0,
out_pipe ? 4 : 6, size); out_pipe ? 4 : 6, size);
if (!header) return NULL; if (!header) return NULL;
payload = (char *)(&header->http+1); payload = (char *)(&header->http+1);
@ -1877,7 +1877,7 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
fail: fail:
RPCRT4_FreeHeader(hdr); RPCRT4_FreeHeader(hdr);
RPCRT4_DestroyConnection(conn); RPCRT4_ReleaseConnection(conn);
pMsg->ReservedForRuntime = NULL; pMsg->ReservedForRuntime = NULL;
return status; return status;
} }

View file

@ -31,7 +31,7 @@ RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, unsigned short MaxTr
RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, unsigned char RpcVersion, unsigned char RpcVersionMinor, unsigned short RejectReason) DECLSPEC_HIDDEN; RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, unsigned char RpcVersion, unsigned char RpcVersionMinor, unsigned short RejectReason) DECLSPEC_HIDDEN;
RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, LPCSTR ServerAddress, unsigned char ResultCount, const RpcResult *Results) DECLSPEC_HIDDEN; RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, LPCSTR ServerAddress, unsigned char ResultCount, const RpcResult *Results) DECLSPEC_HIDDEN;
RpcPktHdr *RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size) DECLSPEC_HIDDEN; RpcPktHdr *RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size) DECLSPEC_HIDDEN;
RpcPktHdr *RPCRT4_BuildHttpConnectHeader(unsigned short flags, int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid) DECLSPEC_HIDDEN; RpcPktHdr *RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid) DECLSPEC_HIDDEN;
RpcPktHdr *RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid) DECLSPEC_HIDDEN; RpcPktHdr *RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid) DECLSPEC_HIDDEN;
VOID RPCRT4_FreeHeader(RpcPktHdr *Header) DECLSPEC_HIDDEN; VOID RPCRT4_FreeHeader(RpcPktHdr *Header) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength) DECLSPEC_HIDDEN; RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength) DECLSPEC_HIDDEN;

View file

@ -46,6 +46,7 @@
#include "rpc_message.h" #include "rpc_message.h"
//#include "rpc_defs.h" //#include "rpc_defs.h"
#include "ncastatus.h" #include "ncastatus.h"
#include <secext.h>
WINE_DEFAULT_DEBUG_CHANNEL(rpc); WINE_DEFAULT_DEBUG_CHANNEL(rpc);
@ -541,6 +542,7 @@ static DWORD CALLBACK RPCRT4_worker_thread(LPVOID the_arg)
RpcPacket *pkt = the_arg; RpcPacket *pkt = the_arg;
RPCRT4_process_packet(pkt->conn, pkt->hdr, pkt->msg, pkt->auth_data, RPCRT4_process_packet(pkt->conn, pkt->hdr, pkt->msg, pkt->auth_data,
pkt->auth_length); pkt->auth_length);
RPCRT4_ReleaseConnection(pkt->conn);
HeapFree(GetProcessHeap(), 0, pkt); HeapFree(GetProcessHeap(), 0, pkt);
return 0; return 0;
} }
@ -587,7 +589,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
HeapFree(GetProcessHeap(), 0, auth_data); HeapFree(GetProcessHeap(), 0, auth_data);
goto exit; goto exit;
} }
packet->conn = conn; packet->conn = RPCRT4_GrabConnection( conn );
packet->hdr = hdr; packet->hdr = hdr;
packet->msg = msg; packet->msg = msg;
packet->auth_data = auth_data; packet->auth_data = auth_data;
@ -623,7 +625,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
} }
} }
exit: exit:
RPCRT4_DestroyConnection(conn); RPCRT4_ReleaseConnection(conn);
return 0; return 0;
} }
@ -633,7 +635,7 @@ void RPCRT4_new_client(RpcConnection* conn)
if (!thread) { if (!thread) {
DWORD err = GetLastError(); DWORD err = GetLastError();
ERR("failed to create thread, error=%08x\n", err); ERR("failed to create thread, error=%08x\n", err);
RPCRT4_DestroyConnection(conn); RPCRT4_ReleaseConnection(conn);
} }
/* we could set conn->thread, but then we'd have to make the io_thread wait /* we could set conn->thread, but then we'd have to make the io_thread wait
* for that, otherwise the thread might finish, destroy the connection, and * for that, otherwise the thread might finish, destroy the connection, and
@ -933,6 +935,7 @@ static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcSe
(*ps)->MaxCalls = 0; (*ps)->MaxCalls = 0;
(*ps)->conn = NULL; (*ps)->conn = NULL;
InitializeCriticalSection(&(*ps)->cs); InitializeCriticalSection(&(*ps)->cs);
(*ps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcServerProtseq.cs");
(*ps)->is_listening = FALSE; (*ps)->is_listening = FALSE;
(*ps)->mgr_mutex = NULL; (*ps)->mgr_mutex = NULL;
(*ps)->server_ready_event = NULL; (*ps)->server_ready_event = NULL;
@ -948,6 +951,7 @@ static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcSe
static void destroy_serverprotoseq(RpcServerProtseq *ps) static void destroy_serverprotoseq(RpcServerProtseq *ps)
{ {
RPCRT4_strfree(ps->Protseq); RPCRT4_strfree(ps->Protseq);
ps->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&ps->cs); DeleteCriticalSection(&ps->cs);
CloseHandle(ps->mgr_mutex); CloseHandle(ps->mgr_mutex);
CloseHandle(ps->server_ready_event); CloseHandle(ps->server_ready_event);
@ -1073,9 +1077,15 @@ void RPCRT4_destroy_all_protseqs(void)
EnterCriticalSection(&server_cs); EnterCriticalSection(&server_cs);
LIST_FOR_EACH_ENTRY_SAFE(cps, cursor2, &protseqs, RpcServerProtseq, entry) LIST_FOR_EACH_ENTRY_SAFE(cps, cursor2, &protseqs, RpcServerProtseq, entry)
{ {
#ifndef __REACTOS__
if (listen_count != 0)
RPCRT4_sync_with_server_thread(cps);
#endif
destroy_serverprotoseq(cps); destroy_serverprotoseq(cps);
} }
LeaveCriticalSection(&server_cs); LeaveCriticalSection(&server_cs);
DeleteCriticalSection(&server_cs);
DeleteCriticalSection(&listen_cs);
} }
/*********************************************************************** /***********************************************************************
@ -1319,6 +1329,7 @@ void RPCRT4_ServerFreeAllRegisteredAuthInfo(void)
HeapFree(GetProcessHeap(), 0, auth_info); HeapFree(GetProcessHeap(), 0, auth_info);
} }
LeaveCriticalSection(&server_auth_info_cs); LeaveCriticalSection(&server_auth_info_cs);
DeleteCriticalSection(&server_auth_info_cs);
} }
/*********************************************************************** /***********************************************************************
@ -1451,6 +1462,45 @@ RPC_STATUS WINAPI RpcServerRegisterAuthInfoW( RPC_WSTR ServerPrincName, ULONG Au
return RPC_S_OK; return RPC_S_OK;
} }
/******************************************************************************
* RpcServerInqDefaultPrincNameA (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameA(ULONG AuthnSvc, RPC_CSTR *PrincName)
{
RPC_STATUS ret;
RPC_WSTR principalW;
TRACE("%u, %p\n", AuthnSvc, PrincName);
if ((ret = RpcServerInqDefaultPrincNameW( AuthnSvc, &principalW )) == RPC_S_OK)
{
if (!(*PrincName = (RPC_CSTR)RPCRT4_strdupWtoA( principalW ))) return RPC_S_OUT_OF_MEMORY;
RpcStringFreeW( &principalW );
}
return ret;
}
/******************************************************************************
* RpcServerInqDefaultPrincNameW (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameW(ULONG AuthnSvc, RPC_WSTR *PrincName)
{
ULONG len = 0;
FIXME("%u, %p\n", AuthnSvc, PrincName);
if (AuthnSvc != RPC_C_AUTHN_WINNT) return RPC_S_UNKNOWN_AUTHN_SERVICE;
GetUserNameExW( NameSamCompatible, NULL, &len );
if (GetLastError() != ERROR_MORE_DATA) return RPC_S_INTERNAL_ERROR;
if (!(*PrincName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
return RPC_S_OUT_OF_MEMORY;
GetUserNameExW( NameSamCompatible, *PrincName, &len );
return RPC_S_OK;
}
/*********************************************************************** /***********************************************************************
* RpcServerListen (RPCRT4.@) * RpcServerListen (RPCRT4.@)
*/ */
@ -1617,8 +1667,14 @@ RPC_STATUS WINAPI RpcMgmtEpEltInqBegin(RPC_BINDING_HANDLE Binding, ULONG Inquiry
*/ */
RPC_STATUS WINAPI RpcMgmtIsServerListening(RPC_BINDING_HANDLE Binding) RPC_STATUS WINAPI RpcMgmtIsServerListening(RPC_BINDING_HANDLE Binding)
{ {
FIXME("(%p): stub\n", Binding); RPC_STATUS status = RPC_S_NOT_LISTENING;
return RPC_S_INVALID_BINDING;
TRACE("(%p)\n", Binding);
EnterCriticalSection(&listen_cs);
if (manual_listen_count > 0) status = RPC_S_OK;
LeaveCriticalSection(&listen_cs);
return status;
} }
/*********************************************************************** /***********************************************************************

View file

@ -121,7 +121,7 @@ typedef struct _RpcConnection_np
static RpcConnection *rpcrt4_conn_np_alloc(void) static RpcConnection *rpcrt4_conn_np_alloc(void)
{ {
RpcConnection_np *npc = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcConnection_np)); RpcConnection_np *npc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcConnection_np));
if (npc) if (npc)
{ {
npc->pipe = NULL; npc->pipe = NULL;
@ -290,7 +290,7 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq
} }
r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL, r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL,
endpoint, NULL, NULL, NULL); endpoint, NULL, NULL, NULL, NULL);
if (r != RPC_S_OK) if (r != RPC_S_OK)
return r; return r;
@ -362,7 +362,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protse
} }
r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL, r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL,
endpoint, NULL, NULL, NULL); endpoint, NULL, NULL, NULL, NULL);
if (r != RPC_S_OK) if (r != RPC_S_OK)
return r; return r;
@ -1373,6 +1373,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
if (getsockname(sock, (struct sockaddr *)&sa, &sa_len)) if (getsockname(sock, (struct sockaddr *)&sa, &sa_len))
{ {
WARN("getsockname() failed: %s\n", strerror(errno)); WARN("getsockname() failed: %s\n", strerror(errno));
closesocket(sock);
status = RPC_S_CANT_CREATE_ENDPOINT; status = RPC_S_CANT_CREATE_ENDPOINT;
continue; continue;
} }
@ -1383,13 +1384,14 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
if (ret) if (ret)
{ {
WARN("getnameinfo failed: %s\n", gai_strerror(ret)); WARN("getnameinfo failed: %s\n", gai_strerror(ret));
closesocket(sock);
status = RPC_S_CANT_CREATE_ENDPOINT; status = RPC_S_CANT_CREATE_ENDPOINT;
continue; continue;
} }
create_status = RPCRT4_CreateConnection((RpcConnection **)&tcpc, TRUE, create_status = RPCRT4_CreateConnection((RpcConnection **)&tcpc, TRUE,
protseq->Protseq, NULL, protseq->Protseq, NULL,
service, NULL, NULL, NULL); service, NULL, NULL, NULL, NULL);
if (create_status != RPC_S_OK) if (create_status != RPC_S_OK)
{ {
closesocket(sock); closesocket(sock);
@ -1402,7 +1404,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
if (ret < 0) if (ret < 0)
{ {
WARN("listen failed: %s\n", strerror(errno)); WARN("listen failed: %s\n", strerror(errno));
RPCRT4_DestroyConnection(&tcpc->common); RPCRT4_ReleaseConnection(&tcpc->common);
status = RPC_S_OUT_OF_RESOURCES; status = RPC_S_OUT_OF_RESOURCES;
continue; continue;
} }
@ -1415,7 +1417,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
if (ret < 0) if (ret < 0)
{ {
WARN("couldn't make socket non-blocking, error %d\n", ret); WARN("couldn't make socket non-blocking, error %d\n", ret);
RPCRT4_DestroyConnection(&tcpc->common); RPCRT4_ReleaseConnection(&tcpc->common);
status = RPC_S_OUT_OF_RESOURCES; status = RPC_S_OUT_OF_RESOURCES;
continue; continue;
} }
@ -1872,9 +1874,8 @@ typedef struct _RpcHttpAsyncData
{ {
LONG refs; LONG refs;
HANDLE completion_event; HANDLE completion_event;
WORD async_result;
INTERNET_BUFFERSA inet_buffers; INTERNET_BUFFERSA inet_buffers;
void *destination_buffer; /* the address that inet_buffers.lpvBuffer will be
* copied into when the call completes */
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
} RpcHttpAsyncData; } RpcHttpAsyncData;
@ -1891,12 +1892,49 @@ static ULONG RpcHttpAsyncData_Release(RpcHttpAsyncData *data)
TRACE("destroying async data %p\n", data); TRACE("destroying async data %p\n", data);
CloseHandle(data->completion_event); CloseHandle(data->completion_event);
HeapFree(GetProcessHeap(), 0, data->inet_buffers.lpvBuffer); HeapFree(GetProcessHeap(), 0, data->inet_buffers.lpvBuffer);
data->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&data->cs); DeleteCriticalSection(&data->cs);
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
} }
return refs; return refs;
} }
static void prepare_async_request(RpcHttpAsyncData *async_data)
{
ResetEvent(async_data->completion_event);
RpcHttpAsyncData_AddRef(async_data);
}
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
{
HANDLE handles[2] = { async_data->completion_event, cancel_event };
DWORD res;
if(call_ret) {
RpcHttpAsyncData_Release(async_data);
return RPC_S_OK;
}
if(GetLastError() != ERROR_IO_PENDING) {
RpcHttpAsyncData_Release(async_data);
ERR("Request failed with error %d\n", GetLastError());
return RPC_S_SERVER_UNAVAILABLE;
}
res = WaitForMultipleObjects(2, handles, FALSE, DEFAULT_NCACN_HTTP_TIMEOUT);
if(res != WAIT_OBJECT_0) {
TRACE("Cancelled\n");
return RPC_S_CALL_CANCELLED;
}
if(async_data->async_result) {
ERR("Async request failed with error %d\n", async_data->async_result);
return RPC_S_SERVER_UNAVAILABLE;
}
return RPC_S_OK;
}
typedef struct _RpcConnection_http typedef struct _RpcConnection_http
{ {
RpcConnection common; RpcConnection common;
@ -1932,8 +1970,8 @@ static RpcConnection *rpcrt4_ncacn_http_alloc(void)
httpc->async_data->refs = 1; httpc->async_data->refs = 1;
httpc->async_data->inet_buffers.dwStructSize = sizeof(INTERNET_BUFFERSA); httpc->async_data->inet_buffers.dwStructSize = sizeof(INTERNET_BUFFERSA);
httpc->async_data->inet_buffers.lpvBuffer = NULL; httpc->async_data->inet_buffers.lpvBuffer = NULL;
httpc->async_data->destination_buffer = NULL;
InitializeCriticalSection(&httpc->async_data->cs); InitializeCriticalSection(&httpc->async_data->cs);
httpc->async_data->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcHttpAsyncData.cs");
return &httpc->common; return &httpc->common;
} }
@ -1980,7 +2018,7 @@ static DWORD CALLBACK rpcrt4_http_timer_thread(PVOID param)
timeout = rpcrt4_http_timer_calc_timeout(data.last_sent_time)) timeout = rpcrt4_http_timer_calc_timeout(data.last_sent_time))
{ {
/* are we too soon after last send? */ /* are we too soon after last send? */
if (GetTickCount() - HTTP_IDLE_TIME < *data.last_sent_time) if (GetTickCount() - *data.last_sent_time < HTTP_IDLE_TIME)
continue; continue;
rpcrt4_http_keep_connection_active_timer_proc(data.timer_param, TRUE); rpcrt4_http_keep_connection_active_timer_proc(data.timer_param, TRUE);
} }
@ -2004,20 +2042,9 @@ static VOID WINAPI rpcrt4_http_internet_callback(
TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n"); TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n");
if (async_data) if (async_data)
{ {
if (async_data->inet_buffers.lpvBuffer) INTERNET_ASYNC_RESULT *async_result = lpvStatusInformation;
{
EnterCriticalSection(&async_data->cs); async_data->async_result = async_result->dwResult ? ERROR_SUCCESS : async_result->dwError;
if (async_data->destination_buffer)
{
memcpy(async_data->destination_buffer,
async_data->inet_buffers.lpvBuffer,
async_data->inet_buffers.dwBufferLength);
async_data->destination_buffer = NULL;
}
LeaveCriticalSection(&async_data->cs);
}
HeapFree(GetProcessHeap(), 0, async_data->inet_buffers.lpvBuffer);
async_data->inet_buffers.lpvBuffer = NULL;
SetEvent(async_data->completion_event); SetEvent(async_data->completion_event);
RpcHttpAsyncData_Release(async_data); RpcHttpAsyncData_Release(async_data);
} }
@ -2040,7 +2067,7 @@ static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor)
ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &status_code, &size, &index); ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &status_code, &size, &index);
if (!ret) if (!ret)
return GetLastError(); return GetLastError();
if (status_code < 400) if (status_code == HTTP_STATUS_OK)
return RPC_S_OK; return RPC_S_OK;
index = 0; index = 0;
size = sizeof(buf); size = sizeof(buf);
@ -2067,7 +2094,7 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
LPWSTR password = NULL; LPWSTR password = NULL;
LPWSTR servername = NULL; LPWSTR servername = NULL;
const WCHAR *option; const WCHAR *option;
INTERNET_PORT port = INTERNET_INVALID_PORT_NUMBER; /* use default port */ INTERNET_PORT port;
if (httpc->common.QOS && if (httpc->common.QOS &&
(httpc->common.QOS->qos->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP)) (httpc->common.QOS->qos->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP))
@ -2142,6 +2169,8 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
{ {
HeapFree(GetProcessHeap(), 0, password); HeapFree(GetProcessHeap(), 0, password);
HeapFree(GetProcessHeap(), 0, user); HeapFree(GetProcessHeap(), 0, user);
HeapFree(GetProcessHeap(), 0, proxy);
HeapFree(GetProcessHeap(), 0, servername);
ERR("InternetOpenW failed with error %d\n", GetLastError()); ERR("InternetOpenW failed with error %d\n", GetLastError());
return RPC_S_SERVER_UNAVAILABLE; return RPC_S_SERVER_UNAVAILABLE;
} }
@ -2156,16 +2185,23 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
{ {
HeapFree(GetProcessHeap(), 0, password); HeapFree(GetProcessHeap(), 0, password);
HeapFree(GetProcessHeap(), 0, user); HeapFree(GetProcessHeap(), 0, user);
HeapFree(GetProcessHeap(), 0, proxy);
return RPC_S_OUT_OF_RESOURCES; return RPC_S_OUT_OF_RESOURCES;
} }
MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1); MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1);
} }
port = (httpc->common.QOS &&
(httpc->common.QOS->qos->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP) &&
(httpc->common.QOS->qos->u.HttpCredentials->Flags & RPC_C_HTTP_FLAG_USE_SSL)) ?
INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT;
httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password, httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password,
INTERNET_SERVICE_HTTP, 0, 0); INTERNET_SERVICE_HTTP, 0, 0);
HeapFree(GetProcessHeap(), 0, password); HeapFree(GetProcessHeap(), 0, password);
HeapFree(GetProcessHeap(), 0, user); HeapFree(GetProcessHeap(), 0, user);
HeapFree(GetProcessHeap(), 0, proxy);
HeapFree(GetProcessHeap(), 0, servername); HeapFree(GetProcessHeap(), 0, servername);
if (!httpc->session) if (!httpc->session)
@ -2177,61 +2213,54 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
return RPC_S_OK; return RPC_S_OK;
} }
static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
{
DWORD bytes_read;
BYTE buf[20];
BOOL ret;
RPC_STATUS status;
prepare_async_request(async_data);
ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
status = wait_async_request(async_data, ret, cancel_event);
if (status != RPC_S_OK) return status;
status = rpcrt4_http_check_response(req);
if (status != RPC_S_OK) return status;
InternetReadFile(req, buf, sizeof(buf), &bytes_read);
/* FIXME: do something with retrieved data */
return RPC_S_OK;
}
/* prepare the in pipe for use by RPC packets */ /* prepare the in pipe for use by RPC packets */
static RPC_STATUS rpcrt4_http_prepare_in_pipe(HINTERNET in_request, RpcHttpAsyncData *async_data, static RPC_STATUS rpcrt4_http_prepare_in_pipe(HINTERNET in_request, RpcHttpAsyncData *async_data, HANDLE cancel_event,
const UUID *connection_uuid, const UUID *connection_uuid,
const UUID *in_pipe_uuid, const UUID *in_pipe_uuid,
const UUID *association_uuid) const UUID *association_uuid)
{ {
BYTE packet[44];
BOOL ret; BOOL ret;
RPC_STATUS status; RPC_STATUS status;
RpcPktHdr *hdr; RpcPktHdr *hdr;
INTERNET_BUFFERSW buffers_in; INTERNET_BUFFERSW buffers_in;
DWORD bytes_read, bytes_written; DWORD bytes_written;
/* prepare in pipe */ /* prepare in pipe */
ResetEvent(async_data->completion_event); status = send_echo_request(in_request, async_data, cancel_event);
RpcHttpAsyncData_AddRef(async_data);
ret = HttpSendRequestW(in_request, NULL, 0, NULL, 0);
if (!ret)
{
if (GetLastError() == ERROR_IO_PENDING)
WaitForSingleObject(async_data->completion_event, INFINITE);
else
{
RpcHttpAsyncData_Release(async_data);
ERR("HttpSendRequestW failed with error %d\n", GetLastError());
return RPC_S_SERVER_UNAVAILABLE;
}
}
status = rpcrt4_http_check_response(in_request);
if (status != RPC_S_OK) return status; if (status != RPC_S_OK) return status;
InternetReadFile(in_request, packet, 20, &bytes_read);
/* FIXME: do something with retrieved data */
memset(&buffers_in, 0, sizeof(buffers_in)); memset(&buffers_in, 0, sizeof(buffers_in));
buffers_in.dwStructSize = sizeof(buffers_in); buffers_in.dwStructSize = sizeof(buffers_in);
/* FIXME: get this from the registry */ /* FIXME: get this from the registry */
buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */ buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */
ResetEvent(async_data->completion_event); prepare_async_request(async_data);
RpcHttpAsyncData_AddRef(async_data);
ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0); ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0);
if (!ret) status = wait_async_request(async_data, ret, cancel_event);
{ if (status != RPC_S_OK) return status;
if (GetLastError() == ERROR_IO_PENDING)
WaitForSingleObject(async_data->completion_event, INFINITE);
else
{
RpcHttpAsyncData_Release(async_data);
ERR("HttpSendRequestExW failed with error %d\n", GetLastError());
return RPC_S_SERVER_UNAVAILABLE;
}
}
TRACE("sending HTTP connect header to server\n"); TRACE("sending HTTP connect header to server\n");
hdr = RPCRT4_BuildHttpConnectHeader(0, FALSE, connection_uuid, in_pipe_uuid, association_uuid); hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid);
if (!hdr) return RPC_S_OUT_OF_RESOURCES; if (!hdr) return RPC_S_OUT_OF_RESOURCES;
ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written); ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written);
RPCRT4_FreeHeader(hdr); RPCRT4_FreeHeader(hdr);
@ -2292,57 +2321,30 @@ static RPC_STATUS rpcrt4_http_read_http_packet(HINTERNET request, RpcPktHdr *hdr
/* prepare the out pipe for use by RPC packets */ /* prepare the out pipe for use by RPC packets */
static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request, static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request,
RpcHttpAsyncData *async_data, RpcHttpAsyncData *async_data,
HANDLE cancel_event,
const UUID *connection_uuid, const UUID *connection_uuid,
const UUID *out_pipe_uuid, const UUID *out_pipe_uuid,
ULONG *flow_control_increment) ULONG *flow_control_increment)
{ {
BYTE packet[20];
BOOL ret; BOOL ret;
RPC_STATUS status; RPC_STATUS status;
RpcPktHdr *hdr; RpcPktHdr *hdr;
DWORD bytes_read;
BYTE *data_from_server; BYTE *data_from_server;
RpcPktHdr pkt_from_server; RpcPktHdr pkt_from_server;
ULONG field1, field3; ULONG field1, field3;
ResetEvent(async_data->completion_event); status = send_echo_request(out_request, async_data, cancel_event);
RpcHttpAsyncData_AddRef(async_data);
ret = HttpSendRequestW(out_request, NULL, 0, NULL, 0);
if (!ret)
{
if (GetLastError() == ERROR_IO_PENDING)
WaitForSingleObject(async_data->completion_event, INFINITE);
else
{
RpcHttpAsyncData_Release(async_data);
ERR("HttpSendRequestW failed with error %d\n", GetLastError());
return RPC_S_SERVER_UNAVAILABLE;
}
}
status = rpcrt4_http_check_response(out_request);
if (status != RPC_S_OK) return status; if (status != RPC_S_OK) return status;
InternetReadFile(out_request, packet, 20, &bytes_read); hdr = RPCRT4_BuildHttpConnectHeader(TRUE, connection_uuid, out_pipe_uuid, NULL);
/* FIXME: do something with retrieved data */
hdr = RPCRT4_BuildHttpConnectHeader(0, TRUE, connection_uuid, out_pipe_uuid, NULL);
if (!hdr) return RPC_S_OUT_OF_RESOURCES; if (!hdr) return RPC_S_OUT_OF_RESOURCES;
ResetEvent(async_data->completion_event);
RpcHttpAsyncData_AddRef(async_data); prepare_async_request(async_data);
ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len); ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len);
if (!ret) status = wait_async_request(async_data, ret, cancel_event);
{
if (GetLastError() == ERROR_IO_PENDING)
WaitForSingleObject(async_data->completion_event, INFINITE);
else
{
RpcHttpAsyncData_Release(async_data);
ERR("HttpSendRequestW failed with error %d\n", GetLastError());
RPCRT4_FreeHeader(hdr);
return RPC_S_SERVER_UNAVAILABLE;
}
}
RPCRT4_FreeHeader(hdr); RPCRT4_FreeHeader(hdr);
if (status != RPC_S_OK) return status;
status = rpcrt4_http_check_response(out_request); status = rpcrt4_http_check_response(out_request);
if (status != RPC_S_OK) return status; if (status != RPC_S_OK) return status;
@ -2355,9 +2357,22 @@ static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request,
if (status != RPC_S_OK) return status; if (status != RPC_S_OK) return status;
TRACE("received (%d) from first prepare header\n", field1); TRACE("received (%d) from first prepare header\n", field1);
status = rpcrt4_http_read_http_packet(out_request, &pkt_from_server, for (;;)
&data_from_server); {
if (status != RPC_S_OK) return status; status = rpcrt4_http_read_http_packet(out_request, &pkt_from_server,
&data_from_server);
if (status != RPC_S_OK) return status;
if (pkt_from_server.http.flags != 0x0001) break;
TRACE("http idle packet, waiting for real packet\n");
HeapFree(GetProcessHeap(), 0, data_from_server);
if (pkt_from_server.http.num_data_items != 0)
{
ERR("HTTP idle packet should have no data items instead of %d\n",
pkt_from_server.http.num_data_items);
return RPC_S_PROTOCOL_ERROR;
}
}
status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server, status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server,
&field1, flow_control_increment, &field1, flow_control_increment,
&field3); &field3);
@ -2368,6 +2383,122 @@ static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request,
return RPC_S_OK; return RPC_S_OK;
} }
static UINT encode_base64(const char *bin, unsigned int len, WCHAR *base64)
{
static char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
UINT i = 0, x;
while (len > 0)
{
/* first 6 bits, all from bin[0] */
base64[i++] = enc[(bin[0] & 0xfc) >> 2];
x = (bin[0] & 3) << 4;
/* next 6 bits, 2 from bin[0] and 4 from bin[1] */
if (len == 1)
{
base64[i++] = enc[x];
base64[i++] = '=';
base64[i++] = '=';
break;
}
base64[i++] = enc[x | ((bin[1] & 0xf0) >> 4)];
x = (bin[1] & 0x0f) << 2;
/* next 6 bits 4 from bin[1] and 2 from bin[2] */
if (len == 2)
{
base64[i++] = enc[x];
base64[i++] = '=';
break;
}
base64[i++] = enc[x | ((bin[2] & 0xc0) >> 6)];
/* last 6 bits, all from bin [2] */
base64[i++] = enc[bin[2] & 0x3f];
bin += 3;
len -= 3;
}
base64[i] = 0;
return i;
}
static RPC_STATUS insert_authorization_header(HINTERNET request, RpcQualityOfService *qos)
{
static const WCHAR basicW[] =
{'A','u','t','h','o','r','i','z','a','t','i','o','n',':',' ','B','a','s','i','c',' '};
RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds;
SEC_WINNT_AUTH_IDENTITY_W *id;
int len, datalen, userlen, passlen;
WCHAR *header, *ptr;
char *data;
RPC_STATUS status = RPC_S_SERVER_UNAVAILABLE;
if (!qos || qos->qos->AdditionalSecurityInfoType != RPC_C_AUTHN_INFO_TYPE_HTTP)
return RPC_S_OK;
creds = qos->qos->u.HttpCredentials;
if (creds->AuthenticationTarget != RPC_C_HTTP_AUTHN_TARGET_SERVER || !creds->NumberOfAuthnSchemes)
return RPC_S_OK;
if (creds->AuthnSchemes[0] != RPC_C_HTTP_AUTHN_SCHEME_BASIC)
{
FIXME("scheme %u not supported\n", creds->AuthnSchemes[0]);
return RPC_S_OK;
}
id = creds->TransportCredentials;
if (!id->User || !id->Password) return RPC_S_OK;
userlen = WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, NULL, 0, NULL, NULL);
passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL);
datalen = userlen + passlen + 1;
if (!(data = HeapAlloc(GetProcessHeap(), 0, datalen))) return RPC_S_OUT_OF_MEMORY;
WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, data, userlen, NULL, NULL);
data[userlen] = ':';
WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, data + userlen + 1, passlen, NULL, NULL);
len = ((datalen + 2) * 4) / 3;
if ((header = HeapAlloc(GetProcessHeap(), 0, sizeof(basicW) + (len + 2) * sizeof(WCHAR))))
{
memcpy(header, basicW, sizeof(basicW));
ptr = header + sizeof(basicW) / sizeof(basicW[0]);
len = encode_base64(data, datalen, ptr);
ptr[len++] = '\r';
ptr[len++] = '\n';
ptr[len] = 0;
if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_ADD_IF_NEW))) status = RPC_S_OK;
HeapFree(GetProcessHeap(), 0, header);
}
HeapFree(GetProcessHeap(), 0, data);
return status;
}
static RPC_STATUS insert_cookie_header(HINTERNET request, const WCHAR *value)
{
static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
WCHAR *header, *ptr;
int len;
RPC_STATUS status = RPC_S_SERVER_UNAVAILABLE;
if (!value) return RPC_S_OK;
len = strlenW(value);
if ((header = HeapAlloc(GetProcessHeap(), 0, sizeof(cookieW) + (len + 3) * sizeof(WCHAR))))
{
memcpy(header, cookieW, sizeof(cookieW));
ptr = header + sizeof(cookieW) / sizeof(cookieW[0]);
memcpy(ptr, value, len * sizeof(WCHAR));
ptr[len++] = '\r';
ptr[len++] = '\n';
ptr[len] = 0;
if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_ADD_IF_NEW))) status = RPC_S_OK;
HeapFree(GetProcessHeap(), 0, header);
}
return status;
}
static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection) static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
{ {
RpcConnection_http *httpc = (RpcConnection_http *)Connection; RpcConnection_http *httpc = (RpcConnection_http *)Connection;
@ -2377,6 +2508,7 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
static const WCHAR wszColon[] = {':',0}; static const WCHAR wszColon[] = {':',0};
static const WCHAR wszAcceptType[] = {'a','p','p','l','i','c','a','t','i','o','n','/','r','p','c',0}; static const WCHAR wszAcceptType[] = {'a','p','p','l','i','c','a','t','i','o','n','/','r','p','c',0};
LPCWSTR wszAcceptTypes[] = { wszAcceptType, NULL }; LPCWSTR wszAcceptTypes[] = { wszAcceptType, NULL };
DWORD flags;
WCHAR *url; WCHAR *url;
RPC_STATUS status; RPC_STATUS status;
BOOL secure; BOOL secure;
@ -2416,27 +2548,45 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
(httpc->common.QOS->qos->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP) && (httpc->common.QOS->qos->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP) &&
(httpc->common.QOS->qos->u.HttpCredentials->Flags & RPC_C_HTTP_FLAG_USE_SSL); (httpc->common.QOS->qos->u.HttpCredentials->Flags & RPC_C_HTTP_FLAG_USE_SSL);
httpc->in_request = HttpOpenRequestW(httpc->session, wszVerbIn, url, NULL, NULL, flags = INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE |
wszAcceptTypes, INTERNET_FLAG_NO_AUTO_REDIRECT;
(secure ? INTERNET_FLAG_SECURE : 0)|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_PRAGMA_NOCACHE, if (secure) flags |= INTERNET_FLAG_SECURE;
(DWORD_PTR)httpc->async_data);
httpc->in_request = HttpOpenRequestW(httpc->session, wszVerbIn, url, NULL, NULL, wszAcceptTypes,
flags, (DWORD_PTR)httpc->async_data);
if (!httpc->in_request) if (!httpc->in_request)
{ {
ERR("HttpOpenRequestW failed with error %d\n", GetLastError()); ERR("HttpOpenRequestW failed with error %d\n", GetLastError());
HeapFree(GetProcessHeap(), 0, url);
return RPC_S_SERVER_UNAVAILABLE; return RPC_S_SERVER_UNAVAILABLE;
} }
httpc->out_request = HttpOpenRequestW(httpc->session, wszVerbOut, url, NULL, NULL, status = insert_authorization_header(httpc->in_request, httpc->common.QOS);
wszAcceptTypes, if (status != RPC_S_OK)
(secure ? INTERNET_FLAG_SECURE : 0)|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_PRAGMA_NOCACHE, return status;
(DWORD_PTR)httpc->async_data);
status = insert_cookie_header(httpc->in_request, Connection->CookieAuth);
if (status != RPC_S_OK)
return status;
httpc->out_request = HttpOpenRequestW(httpc->session, wszVerbOut, url, NULL, NULL, wszAcceptTypes,
flags, (DWORD_PTR)httpc->async_data);
HeapFree(GetProcessHeap(), 0, url);
if (!httpc->out_request) if (!httpc->out_request)
{ {
ERR("HttpOpenRequestW failed with error %d\n", GetLastError()); ERR("HttpOpenRequestW failed with error %d\n", GetLastError());
return RPC_S_SERVER_UNAVAILABLE; return RPC_S_SERVER_UNAVAILABLE;
} }
status = insert_authorization_header(httpc->out_request, httpc->common.QOS);
if (status != RPC_S_OK)
return status;
status = insert_cookie_header(httpc->out_request, Connection->CookieAuth);
if (status != RPC_S_OK)
return status;
status = rpcrt4_http_prepare_in_pipe(httpc->in_request, status = rpcrt4_http_prepare_in_pipe(httpc->in_request,
httpc->async_data, httpc->async_data,
httpc->cancel_event,
&httpc->connection_uuid, &httpc->connection_uuid,
&httpc->in_pipe_uuid, &httpc->in_pipe_uuid,
&Connection->assoc->http_uuid); &Connection->assoc->http_uuid);
@ -2445,6 +2595,7 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
status = rpcrt4_http_prepare_out_pipe(httpc->out_request, status = rpcrt4_http_prepare_out_pipe(httpc->out_request,
httpc->async_data, httpc->async_data,
httpc->cancel_event,
&httpc->connection_uuid, &httpc->connection_uuid,
&httpc->out_pipe_uuid, &httpc->out_pipe_uuid,
&httpc->flow_control_increment); &httpc->flow_control_increment);
@ -2484,61 +2635,38 @@ static int rpcrt4_ncacn_http_read(RpcConnection *Connection,
{ {
RpcConnection_http *httpc = (RpcConnection_http *) Connection; RpcConnection_http *httpc = (RpcConnection_http *) Connection;
char *buf = buffer; char *buf = buffer;
BOOL ret = TRUE; BOOL ret;
unsigned int bytes_left = count; unsigned int bytes_left = count;
RPC_STATUS status = RPC_S_OK;
httpc->async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, count);
ResetEvent(httpc->async_data->completion_event);
while (bytes_left) while (bytes_left)
{ {
RpcHttpAsyncData_AddRef(httpc->async_data);
httpc->async_data->inet_buffers.dwBufferLength = bytes_left; httpc->async_data->inet_buffers.dwBufferLength = bytes_left;
httpc->async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, bytes_left); prepare_async_request(httpc->async_data);
httpc->async_data->destination_buffer = buf;
ret = InternetReadFileExA(httpc->out_request, &httpc->async_data->inet_buffers, IRF_ASYNC, 0); ret = InternetReadFileExA(httpc->out_request, &httpc->async_data->inet_buffers, IRF_ASYNC, 0);
if (ret) status = wait_async_request(httpc->async_data, ret, httpc->cancel_event);
{ if(status != RPC_S_OK) {
/* INTERNET_STATUS_REQUEST_COMPLETED won't be sent, so release our if(status == RPC_S_CALL_CANCELLED)
* async ref now */ TRACE("call cancelled\n");
RpcHttpAsyncData_Release(httpc->async_data);
memcpy(buf, httpc->async_data->inet_buffers.lpvBuffer,
httpc->async_data->inet_buffers.dwBufferLength);
HeapFree(GetProcessHeap(), 0, httpc->async_data->inet_buffers.lpvBuffer);
httpc->async_data->inet_buffers.lpvBuffer = NULL;
httpc->async_data->destination_buffer = NULL;
}
else
{
if (GetLastError() == ERROR_IO_PENDING)
{
HANDLE handles[2] = { httpc->async_data->completion_event, httpc->cancel_event };
DWORD result = WaitForMultipleObjects(2, handles, FALSE, DEFAULT_NCACN_HTTP_TIMEOUT);
if (result == WAIT_OBJECT_0)
ret = TRUE;
else
{
TRACE("call cancelled\n");
EnterCriticalSection(&httpc->async_data->cs);
httpc->async_data->destination_buffer = NULL;
LeaveCriticalSection(&httpc->async_data->cs);
break;
}
}
else
{
HeapFree(GetProcessHeap(), 0, httpc->async_data->inet_buffers.lpvBuffer);
httpc->async_data->inet_buffers.lpvBuffer = NULL;
httpc->async_data->destination_buffer = NULL;
RpcHttpAsyncData_Release(httpc->async_data);
break;
}
}
if (!httpc->async_data->inet_buffers.dwBufferLength)
break; break;
}
if(!httpc->async_data->inet_buffers.dwBufferLength)
break;
memcpy(buf, httpc->async_data->inet_buffers.lpvBuffer,
httpc->async_data->inet_buffers.dwBufferLength);
bytes_left -= httpc->async_data->inet_buffers.dwBufferLength; bytes_left -= httpc->async_data->inet_buffers.dwBufferLength;
buf += httpc->async_data->inet_buffers.dwBufferLength; buf += httpc->async_data->inet_buffers.dwBufferLength;
} }
TRACE("%p %p %u -> %s\n", httpc->out_request, buffer, count, ret ? "TRUE" : "FALSE");
return ret ? count : -1; HeapFree(GetProcessHeap(), 0, httpc->async_data->inet_buffers.lpvBuffer);
httpc->async_data->inet_buffers.lpvBuffer = NULL;
TRACE("%p %p %u -> %u\n", httpc->out_request, buffer, count, status);
return status == RPC_S_OK ? count : -1;
} }
static RPC_STATUS rpcrt4_ncacn_http_receive_fragment(RpcConnection *Connection, RpcPktHdr **Header, void **Payload) static RPC_STATUS rpcrt4_ncacn_http_receive_fragment(RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
@ -2746,39 +2874,15 @@ static void rpcrt4_ncacn_http_cancel_call(RpcConnection *Connection)
static int rpcrt4_ncacn_http_wait_for_incoming_data(RpcConnection *Connection) static int rpcrt4_ncacn_http_wait_for_incoming_data(RpcConnection *Connection)
{ {
BOOL ret;
RpcConnection_http *httpc = (RpcConnection_http *) Connection; RpcConnection_http *httpc = (RpcConnection_http *) Connection;
BOOL ret;
RPC_STATUS status;
RpcHttpAsyncData_AddRef(httpc->async_data); prepare_async_request(httpc->async_data);
ret = InternetQueryDataAvailable(httpc->out_request, ret = InternetQueryDataAvailable(httpc->out_request,
&httpc->async_data->inet_buffers.dwBufferLength, IRF_ASYNC, 0); &httpc->async_data->inet_buffers.dwBufferLength, IRF_ASYNC, 0);
if (ret) status = wait_async_request(httpc->async_data, ret, httpc->cancel_event);
{ return status == RPC_S_OK ? 0 : -1;
/* INTERNET_STATUS_REQUEST_COMPLETED won't be sent, so release our
* async ref now */
RpcHttpAsyncData_Release(httpc->async_data);
}
else
{
if (GetLastError() == ERROR_IO_PENDING)
{
HANDLE handles[2] = { httpc->async_data->completion_event, httpc->cancel_event };
DWORD result = WaitForMultipleObjects(2, handles, FALSE, DEFAULT_NCACN_HTTP_TIMEOUT);
if (result != WAIT_OBJECT_0)
{
TRACE("call cancelled\n");
return -1;
}
}
else
{
RpcHttpAsyncData_Release(httpc->async_data);
return -1;
}
}
/* success */
return 0;
} }
static size_t rpcrt4_ncacn_http_get_top_of_tower(unsigned char *tower_data, static size_t rpcrt4_ncacn_http_get_top_of_tower(unsigned char *tower_data,
@ -2958,7 +3062,7 @@ RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection)
RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server,
LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint,
LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS) LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS, LPCWSTR CookieAuth)
{ {
static LONG next_id; static LONG next_id;
const struct connection_ops *ops; const struct connection_ops *ops;
@ -2972,6 +3076,7 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server,
} }
NewConnection = ops->alloc(); NewConnection = ops->alloc();
NewConnection->ref = 1;
NewConnection->Next = NULL; NewConnection->Next = NULL;
NewConnection->server_binding = NULL; NewConnection->server_binding = NULL;
NewConnection->server = server; NewConnection->server = server;
@ -2979,6 +3084,7 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server,
NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr); NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
NewConnection->Endpoint = RPCRT4_strdupA(Endpoint); NewConnection->Endpoint = RPCRT4_strdupA(Endpoint);
NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions); NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions);
NewConnection->CookieAuth = RPCRT4_strdupW(CookieAuth);
NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE; NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE;
memset(&NewConnection->ActiveInterface, 0, sizeof(NewConnection->ActiveInterface)); memset(&NewConnection->ActiveInterface, 0, sizeof(NewConnection->ActiveInterface));
NewConnection->NextCallId = 1; NewConnection->NextCallId = 1;
@ -3007,24 +3113,31 @@ static RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnecti
{ {
RPC_STATUS err; RPC_STATUS err;
err = RPCRT4_CreateConnection(Connection, OldConnection->server, err = RPCRT4_CreateConnection(Connection, OldConnection->server, rpcrt4_conn_get_name(OldConnection),
rpcrt4_conn_get_name(OldConnection), OldConnection->NetworkAddr, OldConnection->Endpoint, NULL,
OldConnection->NetworkAddr, OldConnection->AuthInfo, OldConnection->QOS, OldConnection->CookieAuth);
OldConnection->Endpoint, NULL,
OldConnection->AuthInfo, OldConnection->QOS);
if (err == RPC_S_OK) if (err == RPC_S_OK)
rpcrt4_conn_handoff(OldConnection, *Connection); rpcrt4_conn_handoff(OldConnection, *Connection);
return err; return err;
} }
RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection) RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn )
{ {
TRACE("connection: %p\n", Connection); InterlockedIncrement( &conn->ref );
return conn;
}
RPC_STATUS RPCRT4_ReleaseConnection(RpcConnection* Connection)
{
if (InterlockedDecrement( &Connection->ref ) > 0) return RPC_S_OK;
TRACE("destroying connection %p\n", Connection);
RPCRT4_CloseConnection(Connection); RPCRT4_CloseConnection(Connection);
RPCRT4_strfree(Connection->Endpoint); RPCRT4_strfree(Connection->Endpoint);
RPCRT4_strfree(Connection->NetworkAddr); RPCRT4_strfree(Connection->NetworkAddr);
HeapFree(GetProcessHeap(), 0, Connection->NetworkOptions); HeapFree(GetProcessHeap(), 0, Connection->NetworkOptions);
HeapFree(GetProcessHeap(), 0, Connection->CookieAuth);
if (Connection->AuthInfo) RpcAuthInfo_Release(Connection->AuthInfo); if (Connection->AuthInfo) RpcAuthInfo_Release(Connection->AuthInfo);
if (Connection->QOS) RpcQualityOfService_Release(Connection->QOS); if (Connection->QOS) RpcQualityOfService_Release(Connection->QOS);
@ -3169,7 +3282,7 @@ RPC_STATUS WINAPI RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA **protseqs)
if (*protseqs) if (*protseqs)
{ {
int i; unsigned int i;
for (i = 0; i < (*protseqs)->Count; i++) for (i = 0; i < (*protseqs)->Count; i++)
HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]); HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
HeapFree(GetProcessHeap(), 0, *protseqs); HeapFree(GetProcessHeap(), 0, *protseqs);
@ -3187,7 +3300,7 @@ RPC_STATUS WINAPI RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW **protseqs)
if (*protseqs) if (*protseqs)
{ {
int i; unsigned int i;
for (i = 0; i < (*protseqs)->Count; i++) for (i = 0; i < (*protseqs)->Count; i++)
HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]); HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
HeapFree(GetProcessHeap(), 0, *protseqs); HeapFree(GetProcessHeap(), 0, *protseqs);
@ -3202,7 +3315,7 @@ RPC_STATUS WINAPI RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW **protseqs)
RPC_STATUS WINAPI RpcNetworkInqProtseqsW( RPC_PROTSEQ_VECTORW** protseqs ) RPC_STATUS WINAPI RpcNetworkInqProtseqsW( RPC_PROTSEQ_VECTORW** protseqs )
{ {
RPC_PROTSEQ_VECTORW *pvector; RPC_PROTSEQ_VECTORW *pvector;
int i = 0; unsigned int i;
RPC_STATUS status = RPC_S_OUT_OF_MEMORY; RPC_STATUS status = RPC_S_OUT_OF_MEMORY;
TRACE("(%p)\n", protseqs); TRACE("(%p)\n", protseqs);
@ -3235,7 +3348,7 @@ end:
RPC_STATUS WINAPI RpcNetworkInqProtseqsA(RPC_PROTSEQ_VECTORA** protseqs) RPC_STATUS WINAPI RpcNetworkInqProtseqsA(RPC_PROTSEQ_VECTORA** protseqs)
{ {
RPC_PROTSEQ_VECTORA *pvector; RPC_PROTSEQ_VECTORA *pvector;
int i = 0; unsigned int i;
RPC_STATUS status = RPC_S_OUT_OF_MEMORY; RPC_STATUS status = RPC_S_OUT_OF_MEMORY;
TRACE("(%p)\n", protseqs); TRACE("(%p)\n", protseqs);

View file

@ -369,19 +369,19 @@
@ stub RpcCertGeneratePrincipalNameW @ stub RpcCertGeneratePrincipalNameW
@ stdcall RpcCompleteAsyncCall(ptr ptr) RpcAsyncCompleteCall @ stdcall RpcCompleteAsyncCall(ptr ptr) RpcAsyncCompleteCall
@ stdcall RpcEpRegisterA(ptr ptr ptr str) @ stdcall RpcEpRegisterA(ptr ptr ptr str)
@ stub RpcEpRegisterNoReplaceA @ stdcall RpcEpRegisterNoReplaceA(ptr ptr ptr str)
@ stub RpcEpRegisterNoReplaceW @ stdcall RpcEpRegisterNoReplaceW(ptr ptr ptr wstr)
@ stdcall RpcEpRegisterW(ptr ptr ptr wstr) @ stdcall RpcEpRegisterW(ptr ptr ptr wstr)
@ stdcall RpcEpResolveBinding(ptr ptr) @ stdcall RpcEpResolveBinding(ptr ptr)
@ stdcall RpcEpUnregister(ptr ptr ptr) @ stdcall RpcEpUnregister(ptr ptr ptr)
@ stub RpcErrorAddRecord # wxp @ stub RpcErrorAddRecord # wxp
@ stub RpcErrorClearInformation # wxp @ stub RpcErrorClearInformation # wxp
@ stub RpcErrorEndEnumeration # wxp @ stdcall RpcErrorEndEnumeration(ptr)
@ stub RpcErrorGetNextRecord # wxp @ stdcall RpcErrorGetNextRecord(ptr long ptr)
@ stub RpcErrorLoadErrorInfo # wxp @ stdcall RpcErrorLoadErrorInfo(ptr long ptr)
@ stub RpcErrorNumberOfRecords # wxp @ stub RpcErrorNumberOfRecords # wxp
@ stub RpcErrorResetEnumeration # wxp @ stub RpcErrorResetEnumeration # wxp
@ stub RpcErrorSaveErrorInfo # wxp @ stdcall RpcErrorSaveErrorInfo(ptr ptr ptr)
@ stdcall RpcErrorStartEnumeration(ptr) @ stdcall RpcErrorStartEnumeration(ptr)
@ stub RpcFreeAuthorizationContext # wxp @ stub RpcFreeAuthorizationContext # wxp
@ stdcall RpcGetAsyncCallStatus(ptr) RpcAsyncGetCallStatus @ stdcall RpcGetAsyncCallStatus(ptr) RpcAsyncGetCallStatus
@ -427,8 +427,8 @@
@ stdcall RpcServerInqBindings(ptr) @ stdcall RpcServerInqBindings(ptr)
@ stub RpcServerInqCallAttributesA # wxp @ stub RpcServerInqCallAttributesA # wxp
@ stub RpcServerInqCallAttributesW # wxp @ stub RpcServerInqCallAttributesW # wxp
@ stub RpcServerInqDefaultPrincNameA @ stdcall RpcServerInqDefaultPrincNameA(long ptr)
@ stub RpcServerInqDefaultPrincNameW @ stdcall RpcServerInqDefaultPrincNameW(long ptr)
@ stub RpcServerInqIf @ stub RpcServerInqIf
@ stdcall RpcServerListen(long long long) @ stdcall RpcServerListen(long long long)
@ stdcall RpcServerRegisterAuthInfoA(str long ptr ptr) @ stdcall RpcServerRegisterAuthInfoA(str long ptr ptr)

View file

@ -128,6 +128,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
list_remove(&tdata->entry); list_remove(&tdata->entry);
LeaveCriticalSection(&threaddata_cs); LeaveCriticalSection(&threaddata_cs);
tdata->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&tdata->cs); DeleteCriticalSection(&tdata->cs);
if (tdata->connection) if (tdata->connection)
ERR("tdata->connection should be NULL but is still set to %p\n", tdata->connection); ERR("tdata->connection should be NULL but is still set to %p\n", tdata->connection);
@ -138,8 +139,11 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (lpvReserved) break; /* do nothing if process is shutting down */
RPCRT4_destroy_all_protseqs(); RPCRT4_destroy_all_protseqs();
RPCRT4_ServerFreeAllRegisteredAuthInfo(); RPCRT4_ServerFreeAllRegisteredAuthInfo();
DeleteCriticalSection(&uuid_cs);
DeleteCriticalSection(&threaddata_cs);
break; break;
} }
@ -871,6 +875,42 @@ RPC_STATUS RPC_ENTRY RpcErrorStartEnumeration(RPC_ERROR_ENUM_HANDLE* EnumHandle)
return RPC_S_ENTRY_NOT_FOUND; return RPC_S_ENTRY_NOT_FOUND;
} }
/******************************************************************************
* RpcErrorEndEnumeration (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcErrorEndEnumeration(RPC_ERROR_ENUM_HANDLE* EnumHandle)
{
FIXME("(%p): stub\n", EnumHandle);
return RPC_S_OK;
}
/******************************************************************************
* RpcErrorSaveErrorInfo (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcErrorSaveErrorInfo(RPC_ERROR_ENUM_HANDLE *EnumHandle, void **ErrorBlob, SIZE_T *BlobSize)
{
FIXME("(%p %p %p): stub\n", EnumHandle, ErrorBlob, BlobSize);
return ERROR_CALL_NOT_IMPLEMENTED;
}
/******************************************************************************
* RpcErrorLoadErrorInfo (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcErrorLoadErrorInfo(void *ErrorBlob, SIZE_T BlobSize, RPC_ERROR_ENUM_HANDLE *EnumHandle)
{
FIXME("(%p %lu %p): stub\n", ErrorBlob, BlobSize, EnumHandle);
return ERROR_CALL_NOT_IMPLEMENTED;
}
/******************************************************************************
* RpcErrorGetNextRecord (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcErrorGetNextRecord(RPC_ERROR_ENUM_HANDLE *EnumHandle, BOOL CopyStrings, RPC_EXTENDED_ERROR_INFO *ErrorInfo)
{
FIXME("(%p %x %p): stub\n", EnumHandle, CopyStrings, ErrorInfo);
return RPC_S_ENTRY_NOT_FOUND;
}
/****************************************************************************** /******************************************************************************
* RpcMgmtSetCancelTimeout (rpcrt4.@) * RpcMgmtSetCancelTimeout (rpcrt4.@)
*/ */
@ -889,6 +929,7 @@ static struct threaddata *get_or_create_threaddata(void)
if (!tdata) return NULL; if (!tdata) return NULL;
InitializeCriticalSection(&tdata->cs); InitializeCriticalSection(&tdata->cs);
tdata->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": threaddata.cs");
tdata->thread_id = GetCurrentThreadId(); tdata->thread_id = GetCurrentThreadId();
EnterCriticalSection(&threaddata_cs); EnterCriticalSection(&threaddata_cs);

View file

@ -1,21 +1,19 @@
Index: epm_towers.h diff -prudN e:\Wine\dlls\rpcrt4/epm_towers.h e:\reactos\dll\win32\rpcrt4/epm_towers.h
=================================================================== --- e:\Wine\dlls\rpcrt4/epm_towers.h 2011-09-16 23:22:37.031828000 +0100
--- epm_towers.h (working copy) +++ e:\reactos\dll\win32\rpcrt4/epm_towers.h 2013-01-25 14:13:03.257632500 +0100
+++ epm_towers.h (working copy)
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
* *
*/ */
-#include "epm.h" -#include "epm.h"
+#include "epm_c.h" +#include <epm_c.h>
#define EPM_PROTOCOL_DNET_NSP 0x04 #define EPM_PROTOCOL_DNET_NSP 0x04
#define EPM_PROTOCOL_OSI_TP4 0x05 #define EPM_PROTOCOL_OSI_TP4 0x05
Index: ndr_marshall.c diff -prudN e:\Wine\dlls\rpcrt4/ndr_marshall.c e:\reactos\dll\win32\rpcrt4/ndr_marshall.c
=================================================================== --- e:\Wine\dlls\rpcrt4/ndr_marshall.c 2012-04-02 20:39:58.270363100 +0100
--- ndr_marshall.c (working copy) +++ e:\reactos\dll\win32\rpcrt4/ndr_marshall.c 2013-12-06 20:04:02.897835300 +0100
+++ ndr_marshall.c (working copy) @@ -1211,7 +1211,7 @@ static unsigned char * EmbeddedPointerMa
@@ -1210,7 +1210,7 @@
unsigned char *bufptr = bufbase + *(const SHORT*)&info[2]; unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
unsigned char *saved_memory = pStubMsg->Memory; unsigned char *saved_memory = pStubMsg->Memory;
@ -24,7 +22,7 @@ Index: ndr_marshall.c
PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4); PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
pStubMsg->Memory = saved_memory; pStubMsg->Memory = saved_memory;
} }
@@ -1362,7 +1362,7 @@ @@ -1365,7 +1365,7 @@ static void EmbeddedPointerBufferSize(PM
unsigned char *memptr = membase + *(const SHORT*)&info[0]; unsigned char *memptr = membase + *(const SHORT*)&info[0];
unsigned char *saved_memory = pStubMsg->Memory; unsigned char *saved_memory = pStubMsg->Memory;
@ -33,46 +31,10 @@ Index: ndr_marshall.c
PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4); PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
pStubMsg->Memory = saved_memory; pStubMsg->Memory = saved_memory;
} }
@@ -6159,6 +6159,7 @@ static LONG unmarshall_discriminant(PMID diff -prudN e:\Wine\dlls\rpcrt4/rpc_epmap.c e:\reactos\dll\win32\rpcrt4/rpc_epmap.c
case RPC_FC_WCHAR: --- e:\Wine\dlls\rpcrt4/rpc_epmap.c 2013-03-02 14:18:00.736492500 +0100
case RPC_FC_SHORT: +++ e:\reactos\dll\win32\rpcrt4/rpc_epmap.c 2013-12-06 20:28:21.361553600 +0100
case RPC_FC_USHORT: @@ -162,7 +169,7 @@ static RPC_STATUS get_epm_handle_server(
+ case RPC_FC_ENUM16:
{
USHORT d;
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
Index: ndr_stubless.c
===================================================================
--- ndr_stubless.c (working copy)
+++ ndr_stubless.c (working copy)
@@ -981,11 +981,12 @@ __declspec(naked) LONG_PTR __cdecl call_
__asm
{
push ebp
+ mov ebp, esp
push edi ; Save registers
push esi
- mov ebp, esp
mov eax, [ebp+16] ; Get stack size
sub esp, eax ; Make room in stack for arguments
+ and esp, 0xFFFFFFF0
mov edi, esp
mov ecx, eax
mov esi, [ebp+12]
Index: rpc_epmap.c
===================================================================
--- rpc_epmap.c (working copy)
+++ rpc_epmap.c (working copy)
@@ -32,7 +32,7 @@
#include "wine/exception.h"
#include "rpc_binding.h"
-#include "epm.h"
+#include "epm_c.h"
#include "epm_towers.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
@@ -162,7 +162,7 @@ static RPC_STATUS get_epm_handle_server(
static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *__eptr) static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *__eptr)
{ {
@ -81,24 +43,113 @@ Index: rpc_epmap.c
{ {
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION:
Index: rpc_server.c diff -prudN e:\Wine\dlls\rpcrt4/rpc_server.c e:\reactos\dll\win32\rpcrt4/rpc_server.c
=================================================================== --- e:\Wine\dlls\rpcrt4/rpc_server.c 2012-12-09 09:57:02.680308600 +0100
--- rpc_server.c (working copy) +++ e:\reactos\dll\win32\rpcrt4/rpc_server.c 2013-12-06 23:50:04.564226300 +0100
+++ rpc_server.c (working copy) @@ -1075,8 +1077,10 @@ void RPCRT4_destroy_all_protseqs(void)
@@ -1071,8 +1071,6 @@ void RPCRT4_destroy_all_protseqs(void)
EnterCriticalSection(&server_cs); EnterCriticalSection(&server_cs);
LIST_FOR_EACH_ENTRY_SAFE(cps, cursor2, &protseqs, RpcServerProtseq, entry) LIST_FOR_EACH_ENTRY_SAFE(cps, cursor2, &protseqs, RpcServerProtseq, entry)
{ {
- if (listen_count != 0) +#ifndef __REACTOS__
- RPCRT4_sync_with_server_thread(cps); if (listen_count != 0)
RPCRT4_sync_with_server_thread(cps);
+#endif
destroy_serverprotoseq(cps); destroy_serverprotoseq(cps);
} }
LeaveCriticalSection(&server_cs); LeaveCriticalSection(&server_cs);
Index: rpc_transport.c diff -prudN e:\Wine\dlls\rpcrt4/rpc_transport.c e:\reactos\dll\win32\rpcrt4/rpc_transport.c
=================================================================== --- e:\Wine\dlls\rpcrt4/rpc_transport.c 2013-12-06 20:10:59.302378700 +0100
--- rpc_transport.c (working copy) +++ e:\reactos\dll\win32\rpcrt4/rpc_transport.c 2013-12-06 23:39:38.664465200 +0100
+++ rpc_transport.c (working copy) @@ -111,31 +115,41 @@ typedef struct _RpcConnection_np
@@ -224,6 +224,9 @@ static RPC_STATUS rpcrt4_conn_open_pipe( {
RpcConnection common;
HANDLE pipe;
- HANDLE listen_thread;
+ OVERLAPPED ovl;
BOOL listening;
} RpcConnection_np;
static RpcConnection *rpcrt4_conn_np_alloc(void)
{
RpcConnection_np *npc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcConnection_np));
+ if (npc)
+ {
+ npc->pipe = NULL;
+ memset(&npc->ovl, 0, sizeof(npc->ovl));
+ npc->listening = FALSE;
+ }
return &npc->common;
}
-static DWORD CALLBACK listen_thread(void *arg)
+static RPC_STATUS rpcrt4_conn_listen_pipe(RpcConnection_np *npc)
{
- RpcConnection_np *npc = arg;
+ if (npc->listening)
+ return RPC_S_OK;
+
+ npc->listening = TRUE;
for (;;)
{
- if (ConnectNamedPipe(npc->pipe, NULL))
+ if (ConnectNamedPipe(npc->pipe, &npc->ovl))
return RPC_S_OK;
switch(GetLastError())
{
case ERROR_PIPE_CONNECTED:
+ SetEvent(npc->ovl.hEvent);
+ return RPC_S_OK;
+ case ERROR_IO_PENDING:
+ /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */
return RPC_S_OK;
- case ERROR_HANDLES_CLOSED:
- /* connection closed during listen */
- return RPC_S_NO_CONTEXT_AVAILABLE;
case ERROR_NO_DATA_DETECTED:
/* client has disconnected, retry */
DisconnectNamedPipe( npc->pipe );
@@ -148,28 +162,12 @@ static DWORD CALLBACK listen_thread(void
}
}
-static RPC_STATUS rpcrt4_conn_listen_pipe(RpcConnection_np *npc)
-{
- if (npc->listening)
- return RPC_S_OK;
-
- npc->listening = TRUE;
- npc->listen_thread = CreateThread(NULL, 0, listen_thread, npc, 0, NULL);
- if (!npc->listen_thread)
- {
- npc->listening = FALSE;
- ERR("Couldn't create listen thread (error was %d)\n", GetLastError());
- return RPC_S_OUT_OF_RESOURCES;
- }
- return RPC_S_OK;
-}
-
static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *Connection, LPCSTR pname)
{
RpcConnection_np *npc = (RpcConnection_np *) Connection;
TRACE("listening on %s\n", pname);
- npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX,
+ npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
PIPE_UNLIMITED_INSTANCES,
RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);
@@ -181,6 +179,9 @@ static RPC_STATUS rpcrt4_conn_create_pip
return RPC_S_CANT_CREATE_ENDPOINT;
}
+ memset(&npc->ovl, 0, sizeof(npc->ovl));
+ npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
+
/* Note: we don't call ConnectNamedPipe here because it must be done in the
* server thread as the thread must be alertable */
return RPC_S_OK;
@@ -227,6 +228,9 @@ static RPC_STATUS rpcrt4_conn_open_pipe(
if (err == ERROR_PIPE_BUSY) { if (err == ERROR_PIPE_BUSY) {
TRACE("connection failed, error=%x\n", err); TRACE("connection failed, error=%x\n", err);
return RPC_S_SERVER_TOO_BUSY; return RPC_S_SERVER_TOO_BUSY;
@ -108,7 +159,19 @@ Index: rpc_transport.c
} }
if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) { if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
err = GetLastError(); err = GetLastError();
@@ -305,18 +308,32 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc @@ -236,9 +240,11 @@ static RPC_STATUS rpcrt4_conn_open_pipe(
}
/* success */
+ memset(&npc->ovl, 0, sizeof(npc->ovl));
/* pipe is connected; change to message-read mode. */
dwMode = PIPE_READMODE_MESSAGE;
SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
+ npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
npc->pipe = pipe;
return RPC_S_OK;
@@ -306,18 +312,32 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc
static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection) static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
{ {
RpcConnection_np *npc = (RpcConnection_np *) Connection; RpcConnection_np *npc = (RpcConnection_np *) Connection;
@ -145,7 +208,19 @@ Index: rpc_transport.c
I_RpcFree(pname); I_RpcFree(pname);
return r; return r;
@@ -412,11 +429,17 @@ static int rpcrt4_conn_np_read(RpcConnec @@ -366,9 +386,9 @@ static void rpcrt4_conn_np_handoff(RpcCo
* to the child, then reopen the server binding to continue listening */
new_npc->pipe = old_npc->pipe;
- new_npc->listen_thread = old_npc->listen_thread;
+ new_npc->ovl = old_npc->ovl;
old_npc->pipe = 0;
- old_npc->listen_thread = 0;
+ memset(&old_npc->ovl, 0, sizeof(old_npc->ovl));
old_npc->listening = FALSE;
}
@@ -413,11 +433,17 @@ static int rpcrt4_conn_np_read(RpcConnec
char *buf = buffer; char *buf = buffer;
BOOL ret = TRUE; BOOL ret = TRUE;
unsigned int bytes_left = count; unsigned int bytes_left = count;
@ -164,7 +239,7 @@ Index: rpc_transport.c
if (!ret && GetLastError() == ERROR_MORE_DATA) if (!ret && GetLastError() == ERROR_MORE_DATA)
ret = TRUE; ret = TRUE;
if (!ret || !bytes_read) if (!ret || !bytes_read)
@@ -424,6 +447,7 @@ static int rpcrt4_conn_np_read(RpcConnec @@ -425,6 +451,7 @@ static int rpcrt4_conn_np_read(RpcConnec
bytes_left -= bytes_read; bytes_left -= bytes_read;
buf += bytes_read; buf += bytes_read;
} }
@ -172,7 +247,7 @@ Index: rpc_transport.c
return ret ? count : -1; return ret ? count : -1;
} }
@@ -434,16 +458,23 @@ static int rpcrt4_conn_np_write(RpcConne @@ -435,16 +462,23 @@ static int rpcrt4_conn_np_write(RpcConne
const char *buf = buffer; const char *buf = buffer;
BOOL ret = TRUE; BOOL ret = TRUE;
unsigned int bytes_left = count; unsigned int bytes_left = count;
@ -197,19 +272,61 @@ Index: rpc_transport.c
return ret ? count : -1; return ret ? count : -1;
} }
Index: rpcrt4.spec @@ -456,9 +490,9 @@ static int rpcrt4_conn_np_close(RpcConne
=================================================================== CloseHandle(npc->pipe);
--- rpcrt4.spec (working copy) npc->pipe = 0;
+++ rpcrt4.spec (working copy) }
@@ -53,7 +53,7 @@ - if (npc->listen_thread) {
@ stub I_RpcIfInqTransferSyntaxes - CloseHandle(npc->listen_thread);
@ stub I_RpcLogEvent - npc->listen_thread = 0;
@ stdcall I_RpcMapWin32Status(long) + if (npc->ovl.hEvent) {
-@ stub I_RpcNegotiateTransferSyntax # wxp + CloseHandle(npc->ovl.hEvent);
+@ stdcall I_RpcNegotiateTransferSyntax(ptr) + npc->ovl.hEvent = 0;
@ stub I_RpcNsBindingSetEntryName }
@ stub I_RpcNsBindingSetEntryNameA return 0;
@ stub I_RpcNsBindingSetEntryNameW }
@@ -662,7 +696,7 @@ static void *rpcrt4_protseq_np_get_wait_
conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
while (conn) {
rpcrt4_conn_listen_pipe(conn);
- if (conn->listen_thread)
+ if (conn->ovl.hEvent)
(*count)++;
conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
}
@@ -683,7 +717,7 @@ static void *rpcrt4_protseq_np_get_wait_
*count = 1;
conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
while (conn) {
- if ((objs[*count] = conn->listen_thread))
+ if ((objs[*count] = conn->ovl.hEvent))
(*count)++;
conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
}
@@ -730,18 +764,12 @@ static int rpcrt4_protseq_np_wait_for_ne
EnterCriticalSection(&protseq->cs);
conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
while (conn) {
- if (b_handle == conn->listen_thread) break;
+ if (b_handle == conn->ovl.hEvent) break;
conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
}
cconn = NULL;
if (conn)
- {
- DWORD exit_code;
- if (GetExitCodeThread(conn->listen_thread, &exit_code) && exit_code == RPC_S_OK)
- RPCRT4_SpawnConnection(&cconn, &conn->common);
- CloseHandle(conn->listen_thread);
- conn->listen_thread = 0;
- }
+ RPCRT4_SpawnConnection(&cconn, &conn->common);
else
ERR("failed to locate connection for handle %p\n", b_handle);
LeaveCriticalSection(&protseq->cs);
diff -prudN e:\Wine\dlls\rpcrt4/rpcrt4.spec e:\reactos\dll\win32\rpcrt4/rpcrt4.spec
--- e:\Wine\dlls\rpcrt4/rpcrt4.spec 2012-09-09 19:47:53.677232900 +0100
+++ e:\reactos\dll\win32\rpcrt4/rpcrt4.spec 2013-12-06 20:29:09.804227500 +0100
@@ -266,7 +266,7 @@ @@ -266,7 +266,7 @@
@ stdcall NdrRangeUnmarshall(ptr ptr ptr long) @ stdcall NdrRangeUnmarshall(ptr ptr ptr long)
@ stub NdrRpcSmClientAllocate @ stub NdrRpcSmClientAllocate

View file

@ -85,6 +85,20 @@ typedef struct
ULONG Stats[1]; ULONG Stats[1];
} RPC_STATS_VECTOR; } RPC_STATS_VECTOR;
typedef struct _RPC_PROTSEQ_VECTORA
{
unsigned int Count;
unsigned char *Protseq[1];
} RPC_PROTSEQ_VECTORA;
typedef struct _RPC_PROTSEQ_VECTORW
{
unsigned int Count;
unsigned short *Protseq[1];
} RPC_PROTSEQ_VECTORW;
DECL_WINELIB_TYPE_AW(RPC_PROTSEQ_VECTOR)
typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE; typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE;
#define RPC_C_EP_ALL_ELTS 0 #define RPC_C_EP_ALL_ELTS 0
@ -279,18 +293,6 @@ typedef struct _RPC_SECURITY_QOS_V2_A
} u; } u;
} RPC_SECURITY_QOS_V2_A, *PRPC_SECURITY_QOS_V2_A; } RPC_SECURITY_QOS_V2_A, *PRPC_SECURITY_QOS_V2_A;
typedef struct _RPC_PROTSEQ_VECTORA
{
unsigned int Count;
unsigned char __RPC_FAR * Protseq[1];
} RPC_PROTSEQ_VECTORA;
typedef struct _RPC_PROTSEQ_VECTORW
{
unsigned int Count;
unsigned short __RPC_FAR * Protseq[1];
} RPC_PROTSEQ_VECTORW;
#define _SEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(_SEC_WINNT_AUTH_IDENTITY_) #define _SEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(_SEC_WINNT_AUTH_IDENTITY_)
#define SEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(SEC_WINNT_AUTH_IDENTITY_) #define SEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(SEC_WINNT_AUTH_IDENTITY_)
#define PSEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(PSEC_WINNT_AUTH_IDENTITY_) #define PSEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(PSEC_WINNT_AUTH_IDENTITY_)
@ -303,16 +305,6 @@ typedef struct _RPC_PROTSEQ_VECTORW
#define PRPC_SECURITY_QOS_V2 WINELIB_NAME_AW(PRPC_SECURITY_QOS_V2_) #define PRPC_SECURITY_QOS_V2 WINELIB_NAME_AW(PRPC_SECURITY_QOS_V2_)
#define _RPC_SECURITY_QOS_V2 WINELIB_NAME_AW(_RPC_SECURITY_QOS_V2_) #define _RPC_SECURITY_QOS_V2 WINELIB_NAME_AW(_RPC_SECURITY_QOS_V2_)
#define RPC_PROTSEQ_VECTOR WINELIB_NAME_AW(RPC_PROTSEQ_VECTOR)
#define _RPC_PROTSEQ_VECTOR WINELIB_NAME_AW(_RPC_PROTSEQ_VECTOR)
typedef int
(__RPC_API * RPC_MGMT_AUTHORIZATION_FN) (
IN RPC_BINDING_HANDLE ClientBinding,
IN unsigned long RequestedMgmtOperation,
OUT RPC_STATUS __RPC_FAR * Status
);
/* SEC_WINNT_AUTH Flags */ /* SEC_WINNT_AUTH Flags */
#define SEC_WINNT_AUTH_IDENTITY_ANSI 0x1 #define SEC_WINNT_AUTH_IDENTITY_ANSI 0x1
#define SEC_WINNT_AUTH_IDENTITY_UNICODE 0x2 #define SEC_WINNT_AUTH_IDENTITY_UNICODE 0x2
@ -332,7 +324,7 @@ RPC_STATUS RPC_ENTRY DceErrorInqTextW(RPC_STATUS e, RPC_WSTR buffer);
RPCRTAPI DECLSPEC_NORETURN void RPC_ENTRY RPCRTAPI DECLSPEC_NORETURN void RPC_ENTRY
RpcRaiseException( RPC_STATUS exception ); RpcRaiseException( RPC_STATUS exception );
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
RpcBindingCopy( RPC_BINDING_HANDLE SourceBinding, RPC_BINDING_HANDLE* DestinationBinding ); RpcBindingCopy( RPC_BINDING_HANDLE SourceBinding, RPC_BINDING_HANDLE* DestinationBinding );
@ -415,6 +407,10 @@ RPCRTAPI RPC_STATUS RPC_ENTRY
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
RpcMgmtEnableIdleCleanup( void ); RpcMgmtEnableIdleCleanup( void );
typedef int (__RPC_API *RPC_MGMT_AUTHORIZATION_FN)( RPC_BINDING_HANDLE, ULONG, RPC_STATUS * );
RPCRTAPI RPC_STATUS RPC_ENTRY RpcMgmtSetAuthorizationFn( RPC_MGMT_AUTHORIZATION_FN );
RPCRTAPI RPC_STATUS RPC_ENTRY RpcMgmtSetCancelTimeout(LONG); RPCRTAPI RPC_STATUS RPC_ENTRY RpcMgmtSetCancelTimeout(LONG);
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
@ -565,6 +561,18 @@ RPCRTAPI RPC_STATUS RPC_ENTRY
RpcNetworkIsProtseqValidW( RPC_WSTR protseq ); RpcNetworkIsProtseqValidW( RPC_WSTR protseq );
#define RpcNetworkIsProtseqValid WINELIB_NAME_AW(RpcNetworkIsProtseqValid) #define RpcNetworkIsProtseqValid WINELIB_NAME_AW(RpcNetworkIsProtseqValid)
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcNetworkInqProtseqsA( RPC_PROTSEQ_VECTORA** protseqs );
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcNetworkInqProtseqsW( RPC_PROTSEQ_VECTORW** protseqs );
#define RpcNetworkInqProtseqs WINELIB_NAME_AW(RpcNetworkInqProtseqs)
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcProtseqVectorFreeA( RPC_PROTSEQ_VECTORA** protseqs );
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcProtseqVectorFreeW( RPC_PROTSEQ_VECTORW** protseqs );
#define RpcProtseqVectorFree WINELIB_NAME_AW(RpcProtseqVectorFree)
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
RpcRevertToSelf( void ); RpcRevertToSelf( void );
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
@ -603,6 +611,12 @@ RPCRTAPI unsigned short RPC_ENTRY
RPCRTAPI int RPC_ENTRY RPCRTAPI int RPC_ENTRY
UuidIsNil( UUID* Uuid, RPC_STATUS* Status_ ); UuidIsNil( UUID* Uuid, RPC_STATUS* Status_ );
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcServerInqDefaultPrincNameA( ULONG AuthnSvc, RPC_CSTR *PrincName );
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcServerInqDefaultPrincNameW( ULONG AuthnSvc, RPC_WSTR *PrincName );
#define RpcServerInqDefaultPrincName WINELIB_NAME_AW(RpcServerInqDefaultPrincName)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -124,6 +124,14 @@ typedef struct _RPC_CLIENT_INTERFACE
unsigned int Flags; unsigned int Flags;
} RPC_CLIENT_INTERFACE, *PRPC_CLIENT_INTERFACE; } RPC_CLIENT_INTERFACE, *PRPC_CLIENT_INTERFACE;
#define RPC_C_OPT_COOKIE_AUTH 7
typedef struct _RPC_C_OPT_COOKIE_AUTH_DESCRIPTOR
{
ULONG BufferSize;
char *Buffer;
} RPC_C_OPT_COOKIE_AUTH_DESCRIPTOR;
#define TRANSPORT_TYPE_CN 0x01 #define TRANSPORT_TYPE_CN 0x01
#define TRANSPORT_TYPE_DG 0x02 #define TRANSPORT_TYPE_DG 0x02
#define TRANSPORT_TYPE_LPC 0x04 #define TRANSPORT_TYPE_LPC 0x04

View file

@ -45,19 +45,19 @@ extern "C" {
/* stupid #if can't handle casts... this __stupidity /* stupid #if can't handle casts... this __stupidity
is just a workaround for that limitation */ is just a workaround for that limitation */
#define __NDR_CHAR_REP_MASK 0x000fL #define __NDR_CHAR_REP_MASK 0x000f
#define __NDR_INT_REP_MASK 0x00f0L #define __NDR_INT_REP_MASK 0x00f0
#define __NDR_FLOAT_REP_MASK 0xff00L #define __NDR_FLOAT_REP_MASK 0xff00
#define __NDR_IEEE_FLOAT 0x0000L #define __NDR_IEEE_FLOAT 0x0000
#define __NDR_VAX_FLOAT 0x0100L #define __NDR_VAX_FLOAT 0x0100
#define __NDR_IBM_FLOAT 0x0300L #define __NDR_IBM_FLOAT 0x0300
#define __NDR_ASCII_CHAR 0x0000L #define __NDR_ASCII_CHAR 0x0000
#define __NDR_EBCDIC_CHAR 0x0001L #define __NDR_EBCDIC_CHAR 0x0001
#define __NDR_LITTLE_ENDIAN 0x0010L #define __NDR_LITTLE_ENDIAN 0x0010
#define __NDR_BIG_ENDIAN 0x0000L #define __NDR_BIG_ENDIAN 0x0000
/* Mac's are special */ /* Mac's are special */
#if defined(__RPC_MAC__) #if defined(__RPC_MAC__)

View file

@ -165,7 +165,7 @@ reactos/dll/win32/rasapi32 # Synced to Wine-1.7.1
reactos/dll/win32/resutils # Synced to Wine-1.7.1 reactos/dll/win32/resutils # Synced to Wine-1.7.1
reactos/dll/win32/riched20 # Synced to Wine-1.7.1 reactos/dll/win32/riched20 # Synced to Wine-1.7.1
reactos/dll/win32/riched32 # Synced to Wine-1.7.1 reactos/dll/win32/riched32 # Synced to Wine-1.7.1
reactos/dll/win32/rpcrt4 # Synced to Wine-1.3.26 reactos/dll/win32/rpcrt4 # Synced to Wine-1.7.1
reactos/dll/win32/rsabase # Synced to Wine-1.7.1 reactos/dll/win32/rsabase # Synced to Wine-1.7.1
reactos/dll/win32/rsaenh # Synced to Wine-1.7.1 reactos/dll/win32/rsaenh # Synced to Wine-1.7.1
reactos/dll/win32/sccbase # Synced to Wine-1.7.1 reactos/dll/win32/sccbase # Synced to Wine-1.7.1