- Winesync to Wine-20080118.

svn path=/trunk/; revision=31874
This commit is contained in:
Aleksey Bragin 2008-01-18 17:39:35 +00:00
parent faa2ab3874
commit f1b7277633
23 changed files with 960 additions and 470 deletions

View file

@ -1273,7 +1273,7 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData(
* Return the clipboard data in the storage medium structure
*/
pmedium->tymed = (hData == 0) ? TYMED_NULL : TYMED_HGLOBAL;
pmedium->u.hGlobal = (HGLOBAL)hData;
pmedium->u.hGlobal = hData;
pmedium->pUnkForRelease = NULL;
hr = S_OK;

View file

@ -104,7 +104,7 @@ StdGlobalInterfaceTable_FindEntry(IGlobalInterfaceTable* iface, DWORD cookie)
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface;
StdGITEntry* e;
TRACE("iface=%p, cookie=0x%x\n", iface, (UINT)cookie);
TRACE("iface=%p, cookie=0x%x\n", iface, cookie);
LIST_FOR_EACH_ENTRY(e, &self->list, StdGITEntry, entry) {
if (e->cookie == cookie)
@ -227,7 +227,7 @@ StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(
StdGITEntry* entry;
HRESULT hr;
TRACE("iface=%p, dwCookie=0x%x\n", iface, (UINT)dwCookie);
TRACE("iface=%p, dwCookie=0x%x\n", iface, dwCookie);
EnterCriticalSection(&git_section);

View file

@ -154,7 +154,7 @@ DWORD CDECL IMalloc16_fnGetSize(IMalloc16* iface,SEGPTR pv)
* IMalloc16_DidAlloc [COMPOBJ.507]
*/
INT16 CDECL IMalloc16_fnDidAlloc(IMalloc16* iface,LPVOID pv) {
IMalloc16 *This = (IMalloc16 *)iface;
IMalloc16 *This = iface;
TRACE("(%p)->DidAlloc(%p)\n",This,pv);
return (INT16)-1;
}

View file

@ -1400,7 +1400,7 @@ static LRESULT CALLBACK OLEMenu_CallWndProc(INT code, WPARAM wParam, LPARAM lPar
* If the window has an OLEMenu property we may need to dispatch
* the menu message to its active objects window instead. */
hOleMenu = (HOLEMENU)GetPropA( pMsg->hwnd, "PROP_OLEMenuDescriptor" );
hOleMenu = GetPropA( pMsg->hwnd, "PROP_OLEMenuDescriptor" );
if ( !hOleMenu )
goto NEXTHOOK;
@ -1505,7 +1505,7 @@ static LRESULT CALLBACK OLEMenu_GetMsgProc(INT code, WPARAM wParam, LPARAM lPara
* If the window has an OLEMenu property we may need to dispatch
* the menu message to its active objects window instead. */
hOleMenu = (HOLEMENU)GetPropA( pMsg->hwnd, "PROP_OLEMenuDescriptor" );
hOleMenu = GetPropA( pMsg->hwnd, "PROP_OLEMenuDescriptor" );
if ( !hOleMenu )
goto NEXTHOOK;

View file

@ -1026,8 +1026,13 @@ static HRESULT WINAPI ClientRpcChannelBuffer_GetDestCtx(LPRPCCHANNELBUFFER iface
static HRESULT WINAPI ServerRpcChannelBuffer_GetDestCtx(LPRPCCHANNELBUFFER iface, DWORD* pdwDestContext, void** ppvDestContext)
{
FIXME("(%p,%p), stub!\n", pdwDestContext, ppvDestContext);
return E_FAIL;
WARN("(%p,%p), stub!\n", pdwDestContext, ppvDestContext);
/* FIXME: implement this by storing the dwDestContext and pvDestContext
* values passed into IMarshal_MarshalInterface and returning them here */
*pdwDestContext = MSHCTX_DIFFERENTMACHINE;
*ppvDestContext = NULL;
return S_OK;
}
static HRESULT WINAPI RpcChannelBuffer_IsConnected(LPRPCCHANNELBUFFER iface)

View file

@ -200,7 +200,7 @@ static HRESULT WINAPI IPropertyStorage_fnQueryInterface(
IsEqualGUID(&IID_IPropertyStorage, riid))
{
IPropertyStorage_AddRef(iface);
*ppvObject = (IPropertyStorage*)iface;
*ppvObject = iface;
return S_OK;
}
@ -263,7 +263,7 @@ static PROPVARIANT *PropertyStorage_FindPropertyByName(
if (This->codePage == CP_UNICODE)
{
if (dictionary_find(This->name_to_propid, name, (void **)&propid))
ret = PropertyStorage_FindProperty(This, (PROPID)propid);
ret = PropertyStorage_FindProperty(This, propid);
}
else
{
@ -275,7 +275,7 @@ static PROPVARIANT *PropertyStorage_FindPropertyByName(
{
if (dictionary_find(This->name_to_propid, ansiName,
(void **)&propid))
ret = PropertyStorage_FindProperty(This, (PROPID)propid);
ret = PropertyStorage_FindProperty(This, propid);
CoTaskMemFree(ansiName);
}
}
@ -528,7 +528,7 @@ static HRESULT PropertyStorage_StoreNameWithId(PropertyStorage_impl *This,
assert(srcName);
hr = PropertyStorage_StringCopy((LPCSTR)srcName, cp, &name, This->codePage);
hr = PropertyStorage_StringCopy(srcName, cp, &name, This->codePage);
if (SUCCEEDED(hr))
{
if (This->codePage == CP_UNICODE)
@ -1059,7 +1059,7 @@ static HRESULT PropertyStorage_ReadProperty(PropertyStorage_impl *This,
TRACE("Read char 0x%x ('%c')\n", prop->u.cVal, prop->u.cVal);
break;
case VT_UI1:
prop->u.bVal = *(const UCHAR *)data;
prop->u.bVal = *data;
TRACE("Read byte 0x%x\n", prop->u.bVal);
break;
case VT_I2:

View file

@ -1300,14 +1300,7 @@ static HRESULT WINAPI StorageImpl_CreateStorage(
/*
* Open it to get a pointer to return.
*/
hr = IStorage_OpenStorage(
iface,
(const OLECHAR*)pwcsName,
0,
grfMode,
0,
0,
ppstg);
hr = IStorage_OpenStorage(iface, pwcsName, 0, grfMode, 0, 0, ppstg);
if( (hr != S_OK) || (*ppstg == NULL))
{
@ -2004,9 +1997,7 @@ static HRESULT deleteStorageProperty(
hr = IEnumSTATSTG_Next(elements, 1, &currentElement, NULL);
if (hr==S_OK)
{
destroyHr = StorageImpl_DestroyElement(
(IStorage*)childStorage,
(OLECHAR*)currentElement.pwcsName);
destroyHr = StorageImpl_DestroyElement(childStorage, currentElement.pwcsName);
CoTaskMemFree(currentElement.pwcsName);
}
@ -4053,8 +4044,7 @@ static ULONG IEnumSTATSTGImpl_FindProperty(
currentProperty);
if ( propertyNameCmp(
(const OLECHAR*)currentProperty->name,
(const OLECHAR*)lpszPropName) == 0)
(const OLECHAR*)currentProperty->name, lpszPropName) == 0)
return currentSearchNode;
/*

View file

@ -410,6 +410,7 @@ void WINAPI NdrProxyFreeBuffer(void *This,
PMIDL_STUB_MESSAGE pStubMsg)
{
TRACE("(%p,%p)\n", This, pStubMsg);
if (pStubMsg->fBufferValid)
{
IRpcChannelBuffer_FreeBuffer(pStubMsg->pRpcChannelBuffer,

View file

@ -51,7 +51,7 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE
pRpcMessage, pStubMsg, pStubDesc, ProcNum);
pRpcMessage->Handle = NULL;
pRpcMessage->ProcNum = ProcNum;
pRpcMessage->ProcNum = ProcNum | RPC_FLAGS_VALID_BIT;
pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
pRpcMessage->RpcFlags = 0;
pRpcMessage->ReservedForRuntime = NULL;
@ -216,10 +216,29 @@ RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus( PMIDL_STUB_MESSAGE pStubMsg,
ULONG *pFaultStatus,
RPC_STATUS Status )
{
FIXME("(%p, %p, %p, %ld): stub\n", pStubMsg, pCommStatus, pFaultStatus, Status);
TRACE("(%p, %p, %p, %ld)\n", pStubMsg, pCommStatus, pFaultStatus, Status);
*pCommStatus = 0;
*pFaultStatus = 0;
switch (Status)
{
case ERROR_INVALID_HANDLE:
case RPC_S_INVALID_BINDING:
case RPC_S_UNKNOWN_IF:
case RPC_S_SERVER_UNAVAILABLE:
case RPC_S_SERVER_TOO_BUSY:
case RPC_S_CALL_FAILED_DNE:
case RPC_S_PROTOCOL_ERROR:
case RPC_S_UNSUPPORTED_TRANS_SYN:
case RPC_S_UNSUPPORTED_TYPE:
case RPC_S_PROCNUM_OUT_OF_RANGE:
case EPT_S_NOT_REGISTERED:
case RPC_S_COMM_FAILURE:
*pCommStatus = Status;
*pFaultStatus = 0;
break;
default:
*pCommStatus = 0;
*pFaultStatus = Status;
}
return RPC_S_OK;
}

View file

@ -218,7 +218,8 @@ void WINAPI NDRSContextMarshall(NDR_SCONTEXT SContext,
NDR_RUNDOWN userRunDownIn)
{
TRACE("(%p %p %p)\n", SContext, pBuff, userRunDownIn);
NDRSContextMarshall2(I_RpcGetCurrentCallHandle(), SContext, pBuff, userRunDownIn, NULL, 0);
NDRSContextMarshall2(I_RpcGetCurrentCallHandle(), SContext, pBuff,
userRunDownIn, NULL, RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
}
/***********************************************************************
@ -230,7 +231,8 @@ void WINAPI NDRSContextMarshallEx(RPC_BINDING_HANDLE hBinding,
NDR_RUNDOWN userRunDownIn)
{
TRACE("(%p %p %p %p)\n", hBinding, SContext, pBuff, userRunDownIn);
NDRSContextMarshall2(hBinding, SContext, pBuff, userRunDownIn, NULL, 0);
NDRSContextMarshall2(hBinding, SContext, pBuff, userRunDownIn, NULL,
RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
}
/***********************************************************************
@ -252,6 +254,9 @@ void WINAPI NDRSContextMarshall2(RPC_BINDING_HANDLE hBinding,
if (!binding->server || !binding->Assoc)
RpcRaiseException(ERROR_INVALID_HANDLE);
if (Flags & RPC_CONTEXT_HANDLE_FLAGS)
FIXME("unimplemented flags: 0x%x\n", Flags & RPC_CONTEXT_HANDLE_FLAGS);
if (SContext->userContext)
{
status = RpcServerAssoc_UpdateContextHandle(binding->Assoc, SContext, CtxGuard, userRunDownIn);
@ -287,7 +292,9 @@ NDR_SCONTEXT WINAPI NDRSContextUnmarshall(void *pBuff,
ULONG DataRepresentation)
{
TRACE("(%p %08x)\n", pBuff, DataRepresentation);
return NDRSContextUnmarshall2(I_RpcGetCurrentCallHandle(), pBuff, DataRepresentation, NULL, 0);
return NDRSContextUnmarshall2(I_RpcGetCurrentCallHandle(), pBuff,
DataRepresentation, NULL,
RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
}
/***********************************************************************
@ -298,7 +305,8 @@ NDR_SCONTEXT WINAPI NDRSContextUnmarshallEx(RPC_BINDING_HANDLE hBinding,
ULONG DataRepresentation)
{
TRACE("(%p %p %08x)\n", hBinding, pBuff, DataRepresentation);
return NDRSContextUnmarshall2(hBinding, pBuff, DataRepresentation, NULL, 0);
return NDRSContextUnmarshall2(hBinding, pBuff, DataRepresentation, NULL,
RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
}
/***********************************************************************
@ -320,6 +328,9 @@ NDR_SCONTEXT WINAPI NDRSContextUnmarshall2(RPC_BINDING_HANDLE hBinding,
if (!binding->server || !binding->Assoc)
RpcRaiseException(ERROR_INVALID_HANDLE);
if (Flags & RPC_CONTEXT_HANDLE_FLAGS)
FIXME("unimplemented flags: 0x%x\n", Flags & RPC_CONTEXT_HANDLE_FLAGS);
if (!pBuff || (!context_ndr->attributes &&
UuidIsNil((UUID *)&context_ndr->uuid, &status)))
status = RpcServerAssoc_AllocateContextHandle(binding->Assoc, CtxGuard,

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* TODO:
* - Non-conformant strings
* - String structs
* - Byte count pointers
* - transmit_as/represent as
@ -1528,8 +1527,7 @@ static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
* BufferStart and BufferEnd won't be reset when allocating memory for
* sending the response. we don't have to check for the new buffer here as
* it won't be used a type memory, only for buffer memory */
if (Pointer >= (unsigned char *)pStubMsg->BufferStart &&
Pointer < (unsigned char *)pStubMsg->BufferEnd)
if (Pointer >= pStubMsg->BufferStart && Pointer < pStubMsg->BufferEnd)
goto notfree;
if (attr & RPC_FC_P_ONSTACK) {
@ -3538,6 +3536,7 @@ ULONG WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
SavedMemorySize = pStubMsg->MemorySize;
esize = ComplexStructSize(pStubMsg, pFormat);
MemorySize = safe_multiply(pStubMsg->MaxCount, esize);
count = pStubMsg->ActualCount;
@ -4980,7 +4979,7 @@ static ULONG get_discriminant(unsigned char fc, const unsigned char *pMemory)
case RPC_FC_CHAR:
case RPC_FC_SMALL:
case RPC_FC_USMALL:
return *(const UCHAR *)pMemory;
return *pMemory;
case RPC_FC_WCHAR:
case RPC_FC_SHORT:
case RPC_FC_USHORT:
@ -5800,12 +5799,12 @@ unsigned char *WINAPI NdrRangeUnmarshall(
case RPC_FC_CHAR:
case RPC_FC_SMALL:
RANGE_UNMARSHALL(UCHAR, "%d");
TRACE("value: 0x%02x\n", **(UCHAR **)ppMemory);
TRACE("value: 0x%02x\n", **ppMemory);
break;
case RPC_FC_BYTE:
case RPC_FC_USMALL:
RANGE_UNMARSHALL(CHAR, "%u");
TRACE("value: 0x%02x\n", **(UCHAR **)ppMemory);
TRACE("value: 0x%02x\n", **ppMemory);
break;
case RPC_FC_WCHAR: /* FIXME: valid? */
case RPC_FC_USHORT:
@ -5913,7 +5912,7 @@ static unsigned char *WINAPI NdrBaseTypeMarshall(
case RPC_FC_SMALL:
case RPC_FC_USMALL:
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(UCHAR));
TRACE("value: 0x%02x\n", *(UCHAR *)pMemory);
TRACE("value: 0x%02x\n", *pMemory);
break;
case RPC_FC_WCHAR:
case RPC_FC_SHORT:
@ -5998,7 +5997,7 @@ static unsigned char *WINAPI NdrBaseTypeUnmarshall(
case RPC_FC_SMALL:
case RPC_FC_USMALL:
BASE_TYPE_UNMARSHALL(UCHAR);
TRACE("value: 0x%02x\n", **(UCHAR **)ppMemory);
TRACE("value: 0x%02x\n", **ppMemory);
break;
case RPC_FC_WCHAR:
case RPC_FC_SHORT:
@ -6208,6 +6207,7 @@ static unsigned char *WINAPI NdrContextHandleMarshall(
ERR("invalid format type %x\n", *pFormat);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
}
TRACE("flags: 0x%02x\n", pFormat[1]);
if (pFormat[1] & 0x80)
NdrClientContextMarshall(pStubMsg, *(NDR_CCONTEXT **)pMemory, FALSE);
@ -6226,16 +6226,22 @@ static unsigned char *WINAPI NdrContextHandleUnmarshall(
PFORMAT_STRING pFormat,
unsigned char fMustAlloc)
{
TRACE("pStubMsg %p, ppMemory %p, pFormat %p, fMustAlloc %s\n", pStubMsg,
ppMemory, pFormat, fMustAlloc ? "TRUE": "FALSE");
if (*pFormat != RPC_FC_BIND_CONTEXT)
{
ERR("invalid format type %x\n", *pFormat);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
}
TRACE("flags: 0x%02x\n", pFormat[1]);
**(NDR_CCONTEXT **)ppMemory = NULL;
NdrClientContextUnmarshall(pStubMsg, *(NDR_CCONTEXT **)ppMemory, pStubMsg->RpcMsg->Handle);
/* [out]-only or [ret] param */
if ((pFormat[1] & 0x60) == 0x20)
**(NDR_CCONTEXT **)ppMemory = NULL;
NdrClientContextUnmarshall(pStubMsg, *(NDR_CCONTEXT **)ppMemory, pStubMsg->RpcMsg->Handle);
return NULL;
return NULL;
}
/***********************************************************************
@ -6301,7 +6307,8 @@ void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
}
NDRSContextMarshall2(pStubMsg->RpcMsg->Handle, ContextHandle,
pStubMsg->Buffer, RundownRoutine, NULL, 0);
pStubMsg->Buffer, RundownRoutine, NULL,
RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
pStubMsg->Buffer += cbNDRContext;
}
@ -6323,7 +6330,7 @@ NDR_SCONTEXT WINAPI NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg)
ContextHandle = NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle,
pStubMsg->Buffer,
pStubMsg->RpcMsg->DataRepresentation,
NULL, 0);
NULL, RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
pStubMsg->Buffer += cbNDRContext;
return ContextHandle;
@ -6339,9 +6346,24 @@ void WINAPI NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg,
NDR_SCONTEXT WINAPI NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat)
{
RPC_SYNTAX_IDENTIFIER *if_id = NULL;
ULONG flags = RPC_CONTEXT_HANDLE_DEFAULT_FLAGS;
TRACE("(%p, %p)\n", pStubMsg, pFormat);
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
if (pFormat[1] & NDR_CONTEXT_HANDLE_NO_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
{
RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
if_id = &sif->InterfaceId;
}
return NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle, NULL,
pStubMsg->RpcMsg->DataRepresentation, NULL, 0);
pStubMsg->RpcMsg->DataRepresentation, if_id,
flags);
}
void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
@ -6349,6 +6371,9 @@ void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
NDR_RUNDOWN RundownRoutine,
PFORMAT_STRING pFormat)
{
RPC_SYNTAX_IDENTIFIER *if_id = NULL;
ULONG flags = RPC_CONTEXT_HANDLE_DEFAULT_FLAGS;
TRACE("(%p, %p, %p, %p)\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
ALIGN_POINTER(pStubMsg->Buffer, 4);
@ -6360,9 +6385,18 @@ void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
/* FIXME: do something with pFormat */
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
if (pFormat[1] & NDR_CONTEXT_HANDLE_NO_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
{
RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
if_id = &sif->InterfaceId;
}
NDRSContextMarshall2(pStubMsg->RpcMsg->Handle, ContextHandle,
pStubMsg->Buffer, RundownRoutine, NULL, 0);
pStubMsg->Buffer, RundownRoutine, if_id, flags);
pStubMsg->Buffer += cbNDRContext;
}
@ -6370,6 +6404,8 @@ NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat)
{
NDR_SCONTEXT ContextHandle;
RPC_SYNTAX_IDENTIFIER *if_id = NULL;
ULONG flags = RPC_CONTEXT_HANDLE_DEFAULT_FLAGS;
TRACE("(%p, %p)\n", pStubMsg, pFormat);
@ -6382,12 +6418,74 @@ NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
/* FIXME: do something with pFormat */
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
if (pFormat[1] & NDR_CONTEXT_HANDLE_NO_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
{
RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
if_id = &sif->InterfaceId;
}
ContextHandle = NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle,
pStubMsg->Buffer,
pStubMsg->RpcMsg->DataRepresentation,
NULL, 0);
if_id, flags);
pStubMsg->Buffer += cbNDRContext;
return ContextHandle;
}
/***********************************************************************
* NdrCorrelationInitialize [RPCRT4.@]
*
* Initializes correlation validity checking.
*
* PARAMS
* pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
* pMemory [I] Pointer to memory to use as a cache.
* CacheSize [I] Size of the memory pointed to by pMemory.
* Flags [I] Reserved. Set to zero.
*
* RETURNS
* Nothing.
*/
void WINAPI NdrCorrelationInitialize(PMIDL_STUB_MESSAGE pStubMsg, void *pMemory, ULONG CacheSize, ULONG Flags)
{
FIXME("(%p, %p, %d, 0x%x): stub\n", pStubMsg, pMemory, CacheSize, Flags);
pStubMsg->fHasNewCorrDesc = TRUE;
}
/***********************************************************************
* NdrCorrelationPass [RPCRT4.@]
*
* Performs correlation validity checking.
*
* PARAMS
* pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
*
* RETURNS
* Nothing.
*/
void WINAPI NdrCorrelationPass(PMIDL_STUB_MESSAGE pStubMsg)
{
FIXME("(%p): stub\n", pStubMsg);
}
/***********************************************************************
* NdrCorrelationFree [RPCRT4.@]
*
* Frees any resources used while unmarshalling parameters that need
* correlation validity checking.
*
* PARAMS
* pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
*
* RETURNS
* Nothing.
*/
void WINAPI NdrCorrelationFree(PMIDL_STUB_MESSAGE pStubMsg)
{
FIXME("(%p): stub\n", pStubMsg);
}

View file

@ -112,7 +112,7 @@ static ULONG WINAPI RpcStream_Release(LPSTREAM iface)
RpcStreamImpl *This = (RpcStreamImpl *)iface;
if (!--(This->RefCount)) {
TRACE("size=%d\n", *This->size);
This->pMsg->Buffer = (unsigned char*)This->data + *This->size;
This->pMsg->Buffer = This->data + *This->size;
HeapFree(GetProcessHeap(),0,This);
return 0;
}

View file

@ -37,8 +37,8 @@
#include "objbase.h"
#include "rpc.h"
#include "rpcproxy.h"
#include "ndrtypes.h"
#include "wine/exception.h"
#include "wine/debug.h"
#include "wine/rpcfc.h"
@ -115,11 +115,12 @@ static inline unsigned long call_memory_sizer(PMIDL_STUB_MESSAGE pStubMsg, PFORM
}
#define STUBLESS_UNMARSHAL 1
#define STUBLESS_CALLSERVER 2
#define STUBLESS_CALCSIZE 3
#define STUBLESS_GETBUFFER 4
#define STUBLESS_MARSHAL 5
#define STUBLESS_FREE 6
#define STUBLESS_INITOUT 2
#define STUBLESS_CALLSERVER 3
#define STUBLESS_CALCSIZE 4
#define STUBLESS_GETBUFFER 5
#define STUBLESS_MARSHAL 6
#define STUBLESS_FREE 7
void WINAPI NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage)
{
@ -563,6 +564,8 @@ LONG_PTR WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
/* the pointer to the object when in OLE mode */
void * This = NULL;
PFORMAT_STRING pHandleFormat;
/* correlation cache */
unsigned long NdrCorrCache[256];
TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat);
@ -664,8 +667,7 @@ LONG_PTR WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
if (ext_flags.HasNewCorrDesc)
{
/* initialize extra correlation package */
FIXME("new correlation description not implemented\n");
stubMsg.fHasNewCorrDesc = TRUE;
NdrCorrelationInitialize(&stubMsg, NdrCorrCache, sizeof(NdrCorrCache), 0);
}
/* order of phases:
@ -675,77 +677,130 @@ LONG_PTR WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
* 4. PROXY_SENDRECEIVE - send/receive buffer
* 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
*/
for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
{
TRACE("phase = %d\n", phase);
switch (phase)
__TRY
{
case PROXY_GETBUFFER:
/* allocate the buffer */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
NdrProxyGetBuffer(This, &stubMsg);
else if (Oif_flags.HasPipes)
/* NdrGetPipeBuffer(...) */
FIXME("pipes not supported yet\n");
else
for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
#if 0
NdrNsGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
#else
FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
#endif
else
NdrGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
TRACE("phase = %d\n", phase);
switch (phase)
{
case PROXY_GETBUFFER:
/* allocate the buffer */
NdrProxyGetBuffer(This, &stubMsg);
break;
case PROXY_SENDRECEIVE:
/* send the [in] params and receive the [out] and [retval]
* params */
NdrProxySendReceive(This, &stubMsg);
/* convert strings, floating point values and endianess into our
* preferred format */
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
NdrConvert(&stubMsg, pFormat);
break;
case PROXY_CALCSIZE:
case PROXY_MARSHAL:
case PROXY_UNMARSHAL:
if (bV2Format)
client_do_args(&stubMsg, pFormat, phase, number_of_params,
(unsigned char *)&RetVal);
else
client_do_args_old_format(&stubMsg, pFormat, phase, stack_size,
(unsigned char *)&RetVal,
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT));
break;
default:
ERR("shouldn't reach here. phase %d\n", phase);
break;
}
}
break;
case PROXY_SENDRECEIVE:
/* send the [in] params and receive the [out] and [retval]
* params */
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
NdrProxySendReceive(This, &stubMsg);
else if (Oif_flags.HasPipes)
/* NdrPipesSendReceive(...) */
FIXME("pipes not supported yet\n");
else
}
__EXCEPT(NULL)
{
RetVal = NdrProxyErrorHandler(GetExceptionCode());
}
__ENDTRY
}
else
{
/* order of phases:
* 1. PROXY_CALCSIZE - calculate the buffer size
* 2. PROXY_GETBUFFER - allocate the buffer
* 3. PROXY_MARHSAL - marshal [in] params into the buffer
* 4. PROXY_SENDRECEIVE - send/receive buffer
* 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
*/
for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
{
TRACE("phase = %d\n", phase);
switch (phase)
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
#if 0
NdrNsSendReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
#else
FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
#endif
case PROXY_GETBUFFER:
/* allocate the buffer */
if (Oif_flags.HasPipes)
/* NdrGetPipeBuffer(...) */
FIXME("pipes not supported yet\n");
else
NdrSendReceive(&stubMsg, stubMsg.Buffer);
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
#if 0
NdrNsGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
#else
FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
#endif
else
NdrGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
}
break;
case PROXY_SENDRECEIVE:
/* send the [in] params and receive the [out] and [retval]
* params */
if (Oif_flags.HasPipes)
/* NdrPipesSendReceive(...) */
FIXME("pipes not supported yet\n");
else
{
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
#if 0
NdrNsSendReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
#else
FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
#endif
else
NdrSendReceive(&stubMsg, stubMsg.Buffer);
}
/* convert strings, floating point values and endianess into our
* preferred format */
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
NdrConvert(&stubMsg, pFormat);
break;
case PROXY_CALCSIZE:
case PROXY_MARSHAL:
case PROXY_UNMARSHAL:
if (bV2Format)
client_do_args(&stubMsg, pFormat, phase, number_of_params,
(unsigned char *)&RetVal);
else
client_do_args_old_format(&stubMsg, pFormat, phase, stack_size,
(unsigned char *)&RetVal,
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT));
break;
default:
ERR("shouldn't reach here. phase %d\n", phase);
break;
}
/* convert strings, floating point values and endianess into our
* preferred format */
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
NdrConvert(&stubMsg, pFormat);
break;
case PROXY_CALCSIZE:
case PROXY_MARSHAL:
case PROXY_UNMARSHAL:
if (bV2Format)
client_do_args(&stubMsg, pFormat, phase, number_of_params,
(unsigned char *)&RetVal);
else
client_do_args_old_format(&stubMsg, pFormat, phase, stack_size,
(unsigned char *)&RetVal,
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT));
break;
default:
ERR("shouldn't reach here. phase %d\n", phase);
break;
}
}
if (ext_flags.HasNewCorrDesc)
{
/* free extra correlation package */
/* NdrCorrelationFree(&stubMsg); */
NdrCorrelationFree(&stubMsg);
}
if (Oif_flags.HasPipes)
@ -855,6 +910,7 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
pFormat = ComputeVariance(pStubMsg, NULL, pFormat, pStubMsg->MaxCount);
size = ComplexStructSize(pStubMsg, pFormat);
size *= pStubMsg->MaxCount;
break;
default:
FIXME("Unhandled type %02x\n", *pFormat);
/* fallthrough */
@ -886,7 +942,7 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
unsigned char *pArg;
current_stack_offset = pParam->stack_offset;
pArg = (unsigned char *)(args+current_stack_offset);
pArg = args + current_stack_offset;
TRACE("param[%d]: new format\n", i);
TRACE("\tparam_attributes:"); dump_RPC_FC_PROC_PF(pParam->param_attributes); TRACE("\n");
@ -900,6 +956,10 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
TRACE("\tbase type: 0x%02x\n", *pTypeFormat);
/* make a note of the address of the return value parameter for later */
if (pParam->param_attributes.IsReturn)
retval_ptr = (LONG_PTR *)pArg;
switch (phase)
{
case STUBLESS_MARSHAL:
@ -915,6 +975,8 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
if (pParam->param_attributes.ServerAllocSize)
HeapFree(GetProcessHeap(), 0, *(void **)pArg);
break;
case STUBLESS_INITOUT:
break;
case STUBLESS_UNMARSHAL:
if (pParam->param_attributes.ServerAllocSize)
*(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
@ -927,11 +989,6 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
else
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
}
/* make a note of the address of the return value parameter for later */
if (pParam->param_attributes.IsReturn)
retval_ptr = (LONG_PTR *)pArg;
break;
case STUBLESS_CALCSIZE:
if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
@ -988,7 +1045,21 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
if (pParam->param_attributes.ServerAllocSize)
HeapFree(GetProcessHeap(), 0, *(void **)pArg);
/* FIXME: call call_freer here for IN types with MustFree set */
break;
case STUBLESS_INITOUT:
if (!pParam->param_attributes.IsIn &&
pParam->param_attributes.IsOut &&
!pParam->param_attributes.ServerAllocSize &&
!pParam->param_attributes.IsByValue)
{
DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
if(size)
{
*(void **)pArg = NdrAllocate(pStubMsg, size);
memset(*(void **)pArg, 0, size);
}
}
break;
case STUBLESS_UNMARSHAL:
if (pParam->param_attributes.ServerAllocSize)
@ -1002,18 +1073,6 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
else
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
}
else if (pParam->param_attributes.IsOut &&
!pParam->param_attributes.ServerAllocSize &&
!pParam->param_attributes.IsByValue)
{
DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
if(size)
{
*(void **)pArg = NdrAllocate(pStubMsg, size);
memset(*(void **)pArg, 0, size);
}
}
break;
case STUBLESS_CALCSIZE:
if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
@ -1058,7 +1117,7 @@ static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
* if present, so adjust this */
unsigned short current_stack_offset_adjusted = current_stack_offset +
(object ? sizeof(void *) : 0);
unsigned char *pArg = (unsigned char *)(args+current_stack_offset_adjusted);
unsigned char *pArg = args + current_stack_offset_adjusted;
/* no more parameters; exit loop */
if (current_stack_offset_adjusted >= stack_size)
@ -1076,6 +1135,9 @@ static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
TRACE("\tbase type 0x%02x\n", *pTypeFormat);
if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
retval_ptr = (LONG_PTR *)pArg;
switch (phase)
{
case STUBLESS_MARSHAL:
@ -1089,9 +1151,7 @@ static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
case STUBLESS_UNMARSHAL:
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
else if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
retval_ptr = (LONG_PTR *)pArg;
break;
break;
case STUBLESS_CALCSIZE:
if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
@ -1113,6 +1173,9 @@ static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
if (pParam->param_direction == RPC_FC_RETURN_PARAM)
retval_ptr = (LONG_PTR *)pArg;
switch (phase)
{
case STUBLESS_MARSHAL:
@ -1127,14 +1190,9 @@ static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
call_freer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
else if (pParam->param_direction == RPC_FC_OUT_PARAM)
pStubMsg->pfnFree(*(void **)pArg);
break;
case STUBLESS_UNMARSHAL:
if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
pParam->param_direction == RPC_FC_IN_PARAM)
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
else if (pParam->param_direction == RPC_FC_RETURN_PARAM)
retval_ptr = (LONG_PTR *)pArg;
else if (pParam->param_direction == RPC_FC_OUT_PARAM)
break;
case STUBLESS_INITOUT:
if (pParam->param_direction == RPC_FC_OUT_PARAM)
{
DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
@ -1145,6 +1203,11 @@ static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
}
}
break;
case STUBLESS_UNMARSHAL:
if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
pParam->param_direction == RPC_FC_IN_PARAM)
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
break;
case STUBLESS_CALCSIZE:
if (pParam->param_direction == RPC_FC_OUT_PARAM ||
pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
@ -1406,9 +1469,10 @@ LONG WINAPI NdrStubCall2(
stubMsg.Buffer = stubMsg.BufferStart;
}
break;
case STUBLESS_MARSHAL:
case STUBLESS_UNMARSHAL:
case STUBLESS_INITOUT:
case STUBLESS_CALCSIZE:
case STUBLESS_MARSHAL:
case STUBLESS_FREE:
if (bV2Format)
retval_ptr = stub_do_args(&stubMsg, &pFormat[parameter_start_offset],

View file

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "ndrtypes.h"
/* there can't be any alignment with the structures in this file */
#include "pshpack1.h"

View file

@ -332,7 +332,7 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection *
break;
}
I_RpcFreeBuffer(&msg);
I_RpcFree(msg.Buffer);
RPCRT4_FreeHeader(response_hdr);
return status;
}

View file

@ -0,0 +1,148 @@
/*
* Asynchronous Call Support Functions
*
* Copyright 2007 Robert Shearman (for CodeWeavers)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include <stdarg.h>
#include "rpc.h"
#include "rpcndr.h"
#include "rpcasync.h"
#include "wine/debug.h"
#include "rpc_binding.h"
#include "rpc_message.h"
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
#define RPC_ASYNC_SIGNATURE 0x43595341
/***********************************************************************
* RpcAsyncInitializeHandle [RPCRT4.@]
*
* Initialises an asynchronous state so it can be used in other asynchronous
* functions and for use in asynchronous calls.
*
* PARAMS
* pAsync [I] Asynchronous state to initialise.
* Size [I] Size of the memory pointed to by pAsync.
*
* RETURNS
* Success: RPC_S_OK.
* Failure: Any error code.
*/
RPC_STATUS WINAPI RpcAsyncInitializeHandle(PRPC_ASYNC_STATE pAsync, unsigned int Size)
{
TRACE("(%p, %d)\n", pAsync, Size);
if (Size != sizeof(*pAsync))
{
ERR("invalid Size %d\n", Size);
return ERROR_INVALID_PARAMETER;
}
pAsync->Size = sizeof(*pAsync);
pAsync->Signature = RPC_ASYNC_SIGNATURE;
pAsync->Lock = 0;
pAsync->Flags = 0;
pAsync->StubInfo = NULL;
pAsync->RuntimeInfo = NULL;
memset(&pAsync->Reserved, 0, sizeof(*pAsync) - FIELD_OFFSET(RPC_ASYNC_STATE, Reserved));
return RPC_S_OK;
}
/***********************************************************************
* RpcAsyncGetCallStatus [RPCRT4.@]
*
* Retrieves the current status of the asynchronous call taking place.
*
* PARAMS
* pAsync [I] Asynchronous state to initialise.
*
* RETURNS
* RPC_S_OK - The call was successfully completed.
* RPC_S_INVALID_ASYNC_HANDLE - The asynchronous structure is not valid.
* RPC_S_ASYNC_CALL_PENDING - The call is still in progress and has not been completed.
* Any other error code - The call failed.
*/
RPC_STATUS WINAPI RpcAsyncGetCallStatus(PRPC_ASYNC_STATE pAsync)
{
FIXME("(%p): stub\n", pAsync);
return RPC_S_INVALID_ASYNC_HANDLE;
}
/***********************************************************************
* RpcAsyncCompleteCall [RPCRT4.@]
*
* Completes a client or server asynchronous call.
*
* PARAMS
* pAsync [I] Asynchronous state to initialise.
* Reply [I] The return value of the asynchronous function.
*
* RETURNS
* Success: RPC_S_OK.
* Failure: Any error code.
*/
RPC_STATUS WINAPI RpcAsyncCompleteCall(PRPC_ASYNC_STATE pAsync, void *Reply)
{
FIXME("(%p, %p): stub\n", pAsync, Reply);
return RPC_S_INVALID_ASYNC_HANDLE;
}
/***********************************************************************
* RpcAsyncAbortCall [RPCRT4.@]
*
* Aborts the asynchronous server call taking place.
*
* PARAMS
* pAsync [I] Asynchronous server state to abort.
* ExceptionCode [I] Exception code to return to the client in a fault packet.
*
* RETURNS
* Success: RPC_S_OK.
* Failure: Any error code.
*/
RPC_STATUS WINAPI RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync, ULONG ExceptionCode)
{
FIXME("(%p, %d/0x%x): stub\n", pAsync, ExceptionCode, ExceptionCode);
return RPC_S_INVALID_ASYNC_HANDLE;
}
/***********************************************************************
* RpcAsyncCancelCall [RPCRT4.@]
*
* Cancels the asynchronous client call taking place.
*
* PARAMS
* pAsync [I] Asynchronous client state to abort.
* fAbortCall [I] If TRUE, then send a cancel to the server, otherwise
* just wait for the call to complete.
*
* RETURNS
* Success: RPC_S_OK.
* Failure: Any error code.
*/
RPC_STATUS WINAPI RpcAsyncCancelCall(PRPC_ASYNC_STATE pAsync, BOOL fAbortCall)
{
FIXME("(%p, %s): stub\n", pAsync, fAbortCall ? "TRUE" : "FALSE");
return RPC_S_INVALID_ASYNC_HANDLE;
}

View file

@ -754,8 +754,12 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header,
TRACE("buffer length = %u\n", pMsg->BufferLength);
status = I_RpcGetBuffer(pMsg);
if (status != RPC_S_OK) goto fail;
pMsg->Buffer = I_RpcAllocate(pMsg->BufferLength);
if (!pMsg->Buffer)
{
status = ERROR_OUTOFMEMORY;
goto fail;
}
first_flag = RPC_FLG_FIRST;
auth_length = common_hdr.auth_len;
@ -842,7 +846,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header,
*Header, hdr_length,
(unsigned char *)pMsg->Buffer + buffer_length, data_length,
(RpcAuthVerifier *)auth_data,
(unsigned char *)auth_data + sizeof(RpcAuthVerifier),
auth_data + sizeof(RpcAuthVerifier),
header_auth_len - sizeof(RpcAuthVerifier));
if (status != RPC_S_OK) goto fail;
}
@ -890,6 +894,54 @@ fail:
return status;
}
/***********************************************************************
* I_RpcNegotiateTransferSyntax [RPCRT4.@]
*
* Negotiates the transfer syntax used by a client connection by connecting
* to the server.
*
* PARAMS
* pMsg [I] RPC Message structure.
* pAsync [I] Asynchronous state to set.
*
* RETURNS
* Success: RPC_S_OK.
* Failure: Any error code.
*/
RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax(PRPC_MESSAGE pMsg)
{
RpcBinding* bind = (RpcBinding*)pMsg->Handle;
RpcConnection* conn;
RPC_STATUS status = RPC_S_OK;
TRACE("(%p)\n", pMsg);
if (!bind || bind->server)
return RPC_S_INVALID_BINDING;
/* if we already have a connection, we don't need to negotiate again */
if (!pMsg->ReservedForRuntime)
{
RPC_CLIENT_INTERFACE *cif = pMsg->RpcInterfaceInformation;
if (!cif) return RPC_S_INTERFACE_NOT_FOUND;
if (!bind->Endpoint || !bind->Endpoint[0])
{
TRACE("automatically resolving partially bound binding\n");
status = RpcEpResolveBinding(bind, cif);
if (status != RPC_S_OK) return status;
}
status = RPCRT4_OpenBinding(bind, &conn, &cif->TransferSyntax,
&cif->InterfaceId);
if (status == RPC_S_OK)
pMsg->ReservedForRuntime = conn;
}
return status;
}
/***********************************************************************
* I_RpcGetBuffer [RPCRT4.@]
*
@ -916,11 +968,30 @@ fail:
*/
RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg)
{
TRACE("(%p): BufferLength=%d\n", pMsg, pMsg->BufferLength);
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);
RPC_STATUS status;
RpcBinding* bind = (RpcBinding*)pMsg->Handle;
TRACE("(%p): BufferLength=%d\n", pMsg, pMsg->BufferLength);
if (!bind)
return RPC_S_INVALID_BINDING;
pMsg->Buffer = I_RpcAllocate(pMsg->BufferLength);
TRACE("Buffer=%p\n", pMsg->Buffer);
return pMsg->Buffer ? RPC_S_OK : ERROR_OUTOFMEMORY;
if (!pMsg->Buffer)
return ERROR_OUTOFMEMORY;
if (!bind->server)
{
status = I_RpcNegotiateTransferSyntax(pMsg);
if (status != RPC_S_OK)
I_RpcFree(pMsg->Buffer);
}
else
status = RPC_S_OK;
return status;
}
/***********************************************************************
@ -952,8 +1023,19 @@ static RPC_STATUS I_RpcReAllocateBuffer(PRPC_MESSAGE pMsg)
*/
RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg)
{
RpcBinding* bind = (RpcBinding*)pMsg->Handle;
TRACE("(%p) Buffer=%p\n", pMsg, pMsg->Buffer);
HeapFree(GetProcessHeap(), 0, pMsg->Buffer);
if (!bind) return RPC_S_INVALID_BINDING;
if (pMsg->ReservedForRuntime)
{
RpcConnection *conn = pMsg->ReservedForRuntime;
RPCRT4_CloseBinding(bind, conn);
pMsg->ReservedForRuntime = NULL;
}
I_RpcFree(pMsg->Buffer);
return RPC_S_OK;
}
@ -978,43 +1060,26 @@ RPC_STATUS WINAPI I_RpcSend(PRPC_MESSAGE pMsg)
{
RpcBinding* bind = (RpcBinding*)pMsg->Handle;
RpcConnection* conn;
RPC_CLIENT_INTERFACE* cif = NULL;
RPC_STATUS status;
RpcPktHdr *hdr;
TRACE("(%p)\n", pMsg);
if (!bind || bind->server) return RPC_S_INVALID_BINDING;
if (!bind || bind->server || !pMsg->ReservedForRuntime) return RPC_S_INVALID_BINDING;
cif = pMsg->RpcInterfaceInformation;
if (!cif) return RPC_S_INTERFACE_NOT_FOUND; /* ? */
if (!bind->Endpoint || !bind->Endpoint[0])
{
TRACE("automatically resolving partially bound binding\n");
status = RpcEpResolveBinding(bind, cif);
if (status != RPC_S_OK) return status;
}
status = RPCRT4_OpenBinding(bind, &conn, &cif->TransferSyntax,
&cif->InterfaceId);
if (status != RPC_S_OK) return status;
conn = pMsg->ReservedForRuntime;
hdr = RPCRT4_BuildRequestHeader(pMsg->DataRepresentation,
pMsg->BufferLength, pMsg->ProcNum,
pMsg->BufferLength,
pMsg->ProcNum & ~RPC_FLAGS_VALID_BIT,
&bind->ObjectUuid);
if (!hdr)
{
RPCRT4_CloseBinding(bind, conn);
return ERROR_OUTOFMEMORY;
}
hdr->common.call_id = conn->NextCallId++;
status = RPCRT4_Send(conn, hdr, pMsg->Buffer, pMsg->BufferLength);
RPCRT4_FreeHeader(hdr);
/* save the connection, so the response can be read from it */
pMsg->ReservedForRuntime = conn;
return status;
}
@ -1042,41 +1107,14 @@ static inline BOOL is_hard_error(RPC_STATUS status)
RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
{
RpcBinding* bind = (RpcBinding*)pMsg->Handle;
RpcConnection* conn;
RPC_CLIENT_INTERFACE* cif = NULL;
RPC_SERVER_INTERFACE* sif = NULL;
RPC_STATUS status;
RpcPktHdr *hdr = NULL;
RpcConnection *conn;
TRACE("(%p)\n", pMsg);
if (!bind) return RPC_S_INVALID_BINDING;
if (pMsg->ReservedForRuntime) {
conn = pMsg->ReservedForRuntime;
pMsg->ReservedForRuntime = NULL;
} else {
if (bind->server) {
sif = pMsg->RpcInterfaceInformation;
if (!sif) return RPC_S_INTERFACE_NOT_FOUND; /* ? */
status = RPCRT4_OpenBinding(bind, &conn, &sif->TransferSyntax,
&sif->InterfaceId);
} else {
cif = pMsg->RpcInterfaceInformation;
if (!cif) return RPC_S_INTERFACE_NOT_FOUND; /* ? */
if (!bind->Endpoint || !bind->Endpoint[0])
{
TRACE("automatically resolving partially bound binding\n");
status = RpcEpResolveBinding(bind, cif);
if (status != RPC_S_OK) return status;
}
status = RPCRT4_OpenBinding(bind, &conn, &cif->TransferSyntax,
&cif->InterfaceId);
}
if (status != RPC_S_OK) return status;
}
if (!bind || bind->server || !pMsg->ReservedForRuntime) return RPC_S_INVALID_BINDING;
conn = pMsg->ReservedForRuntime;
status = RPCRT4_Receive(conn, &hdr, pMsg);
if (status != RPC_S_OK) {
WARN("receive failed with error %lx\n", status);
@ -1085,16 +1123,6 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
switch (hdr->common.ptype) {
case PKT_RESPONSE:
if (bind->server) {
status = RPC_S_PROTOCOL_ERROR;
goto fail;
}
break;
case PKT_REQUEST:
if (!bind->server) {
status = RPC_S_PROTOCOL_ERROR;
goto fail;
}
break;
case PKT_FAULT:
ERR ("we got fault packet with status 0x%lx\n", hdr->fault.status);
@ -1109,13 +1137,13 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
}
/* success */
RPCRT4_CloseBinding(bind, conn);
RPCRT4_FreeHeader(hdr);
return status;
fail:
RPCRT4_FreeHeader(hdr);
RPCRT4_DestroyConnection(conn);
pMsg->ReservedForRuntime = NULL;
return status;
}
@ -1140,16 +1168,55 @@ fail:
RPC_STATUS WINAPI I_RpcSendReceive(PRPC_MESSAGE pMsg)
{
RPC_STATUS status;
RPC_MESSAGE original_message;
void *original_buffer;
TRACE("(%p)\n", pMsg);
original_message = *pMsg;
original_buffer = pMsg->Buffer;
status = I_RpcSend(pMsg);
if (status == RPC_S_OK)
status = I_RpcReceive(pMsg);
/* free the buffer replaced by a new buffer in I_RpcReceive */
if (status == RPC_S_OK)
I_RpcFreeBuffer(&original_message);
I_RpcFree(original_buffer);
return status;
}
/***********************************************************************
* I_RpcAsyncSetHandle [RPCRT4.@]
*
* Sets the asynchronous state of the handle contained in the RPC message
* structure.
*
* PARAMS
* pMsg [I] RPC Message structure.
* pAsync [I] Asynchronous state to set.
*
* RETURNS
* Success: RPC_S_OK.
* Failure: Any error code.
*/
RPC_STATUS WINAPI I_RpcAsyncSetHandle(PRPC_MESSAGE pMsg, PRPC_ASYNC_STATE pAsync)
{
FIXME("(%p, %p): stub\n", pMsg, pAsync);
return RPC_S_INVALID_BINDING;
}
/***********************************************************************
* I_RpcAsyncAbortCall [RPCRT4.@]
*
* Aborts an asynchronous call.
*
* PARAMS
* pAsync [I] Asynchronous state.
* ExceptionCode [I] Exception code.
*
* RETURNS
* Success: RPC_S_OK.
* Failure: Any error code.
*/
RPC_STATUS WINAPI I_RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync, ULONG ExceptionCode)
{
FIXME("(%p, %d): stub\n", pAsync, ExceptionCode);
return RPC_S_INVALID_ASYNC_HANDLE;
}

View file

@ -3,6 +3,7 @@
*
* Copyright 2001 Ove Kåven, TransGaming Technologies
* Copyright 2004 Filip Navara
* Copyright 2006-2008 Robert Shearman (for CodeWeavers)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -17,9 +18,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* TODO:
* - a whole lot
*/
#include "config.h"
@ -163,16 +161,179 @@ static WINE_EXCEPTION_FILTER(rpc_filter)
return EXCEPTION_EXECUTE_HANDLER;
}
static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSAGE* msg)
static RPC_STATUS process_bind_packet(RpcConnection *conn, RpcPktBindHdr *hdr, RPC_MESSAGE *msg)
{
RPC_STATUS status;
RpcServerInterface* sif;
RpcPktHdr *response = NULL;
/* FIXME: do more checks! */
if (hdr->max_tsize < RPC_MIN_PACKET_SIZE ||
!UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status) ||
conn->server_binding) {
TRACE("packet size less than min size, or active interface syntax guid non-null\n");
sif = NULL;
} else {
/* create temporary binding */
if (RPCRT4_MakeBinding(&conn->server_binding, conn) == RPC_S_OK &&
RpcServerAssoc_GetAssociation(rpcrt4_conn_get_name(conn),
conn->NetworkAddr, conn->Endpoint,
conn->NetworkOptions,
hdr->assoc_gid,
&conn->server_binding->Assoc) == RPC_S_OK)
sif = RPCRT4_find_interface(NULL, &hdr->abstract, FALSE);
else
sif = NULL;
}
if (sif == NULL) {
TRACE("rejecting bind request on connection %p\n", conn);
/* Report failure to client. */
response = RPCRT4_BuildBindNackHeader(NDR_LOCAL_DATA_REPRESENTATION,
RPC_VER_MAJOR, RPC_VER_MINOR);
} else {
TRACE("accepting bind request on connection %p for %s\n", conn,
debugstr_guid(&hdr->abstract.SyntaxGUID));
/* accept. */
response = RPCRT4_BuildBindAckHeader(NDR_LOCAL_DATA_REPRESENTATION,
RPC_MAX_PACKET_SIZE,
RPC_MAX_PACKET_SIZE,
conn->server_binding->Assoc->assoc_group_id,
conn->Endpoint,
RESULT_ACCEPT, REASON_NONE,
&sif->If->TransferSyntax);
/* save the interface for later use */
conn->ActiveInterface = hdr->abstract;
conn->MaxTransmissionSize = hdr->max_tsize;
RPCRT4_release_server_interface(sif);
}
if (response)
status = RPCRT4_Send(conn, response, NULL, 0);
else
status = ERROR_OUTOFMEMORY;
RPCRT4_FreeHeader(response);
return status;
}
static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr *hdr, RPC_MESSAGE *msg)
{
RPC_STATUS status;
RpcPktHdr *response = NULL;
RpcServerInterface* sif;
RPC_DISPATCH_FUNCTION func;
UUID *object_uuid;
RpcPktHdr *response = NULL;
void *buf = msg->Buffer;
RPC_STATUS status;
BOOL exception;
UUID *object_uuid;
NDR_SCONTEXT context_handle;
void *buf = msg->Buffer;
/* fail if the connection isn't bound with an interface */
if (UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status)) {
/* FIXME: should send BindNack instead */
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
status);
RPCRT4_Send(conn, response, NULL, 0);
RPCRT4_FreeHeader(response);
return RPC_S_OK;
}
if (hdr->common.flags & RPC_FLG_OBJECT_UUID) {
object_uuid = (UUID*)(hdr + 1);
} else {
object_uuid = NULL;
}
sif = RPCRT4_find_interface(object_uuid, &conn->ActiveInterface, TRUE);
if (!sif) {
WARN("interface %s no longer registered, returning fault packet\n", debugstr_guid(&conn->ActiveInterface.SyntaxGUID));
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
NCA_S_UNK_IF);
RPCRT4_Send(conn, response, NULL, 0);
RPCRT4_FreeHeader(response);
return RPC_S_OK;
}
msg->RpcInterfaceInformation = sif->If;
/* copy the endpoint vector from sif to msg so that midl-generated code will use it */
msg->ManagerEpv = sif->MgrEpv;
if (object_uuid != NULL) {
RPCRT4_SetBindingObject(msg->Handle, object_uuid);
}
/* find dispatch function */
msg->ProcNum = hdr->opnum;
if (sif->Flags & RPC_IF_OLE) {
/* native ole32 always gives us a dispatch table with a single entry
* (I assume that's a wrapper for IRpcStubBuffer::Invoke) */
func = *sif->If->DispatchTable->DispatchTable;
} else {
if (msg->ProcNum >= sif->If->DispatchTable->DispatchTableCount) {
WARN("invalid procnum (%d/%d)\n", msg->ProcNum, sif->If->DispatchTable->DispatchTableCount);
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
NCA_S_OP_RNG_ERROR);
RPCRT4_Send(conn, response, NULL, 0);
RPCRT4_FreeHeader(response);
}
func = sif->If->DispatchTable->DispatchTable[msg->ProcNum];
}
/* put in the drep. FIXME: is this more universally applicable?
perhaps we should move this outward... */
msg->DataRepresentation =
MAKELONG( MAKEWORD(hdr->common.drep[0], hdr->common.drep[1]),
MAKEWORD(hdr->common.drep[2], hdr->common.drep[3]));
exception = FALSE;
/* dispatch */
RPCRT4_SetThreadCurrentCallHandle(msg->Handle);
__TRY {
if (func) func(msg);
} __EXCEPT(rpc_filter) {
exception = TRUE;
if (GetExceptionCode() == STATUS_ACCESS_VIOLATION)
status = ERROR_NOACCESS;
else
status = GetExceptionCode();
response = RPCRT4_BuildFaultHeader(msg->DataRepresentation,
RPC2NCA_STATUS(status));
} __ENDTRY
RPCRT4_SetThreadCurrentCallHandle(NULL);
/* release any unmarshalled context handles */
while ((context_handle = RPCRT4_PopThreadContextHandle()) != NULL)
RpcServerAssoc_ReleaseContextHandle(conn->server_binding->Assoc, context_handle, TRUE);
if (!exception)
response = RPCRT4_BuildResponseHeader(msg->DataRepresentation,
msg->BufferLength);
/* send response packet */
if (response) {
status = RPCRT4_Send(conn, response, exception ? NULL : msg->Buffer,
exception ? 0 : msg->BufferLength);
RPCRT4_FreeHeader(response);
} else
ERR("out of memory\n");
msg->RpcInterfaceInformation = NULL;
RPCRT4_release_server_interface(sif);
if (msg->Buffer == buf) buf = NULL;
TRACE("freeing Buffer=%p\n", buf);
I_RpcFree(buf);
return status;
}
static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSAGE* msg)
{
RPC_STATUS status;
msg->Handle = (RPC_BINDING_HANDLE)conn->server_binding;
@ -180,153 +341,13 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
case PKT_BIND:
TRACE("got bind packet\n");
/* FIXME: do more checks! */
if (hdr->bind.max_tsize < RPC_MIN_PACKET_SIZE ||
!UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status) ||
conn->server_binding) {
TRACE("packet size less than min size, or active interface syntax guid non-null\n");
sif = NULL;
} else {
/* create temporary binding */
if (RPCRT4_MakeBinding(&conn->server_binding, conn) == RPC_S_OK &&
RpcServerAssoc_GetAssociation(rpcrt4_conn_get_name(conn),
conn->NetworkAddr, conn->Endpoint,
conn->NetworkOptions,
hdr->bind.assoc_gid,
&conn->server_binding->Assoc) == RPC_S_OK)
sif = RPCRT4_find_interface(NULL, &hdr->bind.abstract, FALSE);
else
sif = NULL;
}
if (sif == NULL) {
TRACE("rejecting bind request on connection %p\n", conn);
/* Report failure to client. */
response = RPCRT4_BuildBindNackHeader(NDR_LOCAL_DATA_REPRESENTATION,
RPC_VER_MAJOR, RPC_VER_MINOR);
} else {
TRACE("accepting bind request on connection %p for %s\n", conn,
debugstr_guid(&hdr->bind.abstract.SyntaxGUID));
/* accept. */
response = RPCRT4_BuildBindAckHeader(NDR_LOCAL_DATA_REPRESENTATION,
RPC_MAX_PACKET_SIZE,
RPC_MAX_PACKET_SIZE,
conn->server_binding->Assoc->assoc_group_id,
conn->Endpoint,
RESULT_ACCEPT, REASON_NONE,
&sif->If->TransferSyntax);
/* save the interface for later use */
conn->ActiveInterface = hdr->bind.abstract;
conn->MaxTransmissionSize = hdr->bind.max_tsize;
RPCRT4_release_server_interface(sif);
}
status = RPCRT4_Send(conn, response, NULL, 0);
RPCRT4_FreeHeader(response);
if (status != RPC_S_OK)
goto fail;
status = process_bind_packet(conn, &hdr->bind, msg);
break;
case PKT_REQUEST:
TRACE("got request packet\n");
/* fail if the connection isn't bound with an interface */
if (UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status)) {
/* FIXME: should send BindNack instead */
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
status);
RPCRT4_Send(conn, response, NULL, 0);
RPCRT4_FreeHeader(response);
break;
}
if (hdr->common.flags & RPC_FLG_OBJECT_UUID) {
object_uuid = (UUID*)(&hdr->request + 1);
} else {
object_uuid = NULL;
}
sif = RPCRT4_find_interface(object_uuid, &conn->ActiveInterface, TRUE);
if (!sif) {
WARN("interface %s no longer registered, returning fault packet\n", debugstr_guid(&conn->ActiveInterface.SyntaxGUID));
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
NCA_S_UNK_IF);
RPCRT4_Send(conn, response, NULL, 0);
RPCRT4_FreeHeader(response);
break;
}
msg->RpcInterfaceInformation = sif->If;
/* copy the endpoint vector from sif to msg so that midl-generated code will use it */
msg->ManagerEpv = sif->MgrEpv;
if (object_uuid != NULL) {
RPCRT4_SetBindingObject(msg->Handle, object_uuid);
}
/* find dispatch function */
msg->ProcNum = hdr->request.opnum;
if (sif->Flags & RPC_IF_OLE) {
/* native ole32 always gives us a dispatch table with a single entry
* (I assume that's a wrapper for IRpcStubBuffer::Invoke) */
func = *sif->If->DispatchTable->DispatchTable;
} else {
if (msg->ProcNum >= sif->If->DispatchTable->DispatchTableCount) {
WARN("invalid procnum (%d/%d)\n", msg->ProcNum, sif->If->DispatchTable->DispatchTableCount);
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
NCA_S_OP_RNG_ERROR);
RPCRT4_Send(conn, response, NULL, 0);
RPCRT4_FreeHeader(response);
}
func = sif->If->DispatchTable->DispatchTable[msg->ProcNum];
}
/* put in the drep. FIXME: is this more universally applicable?
perhaps we should move this outward... */
msg->DataRepresentation =
MAKELONG( MAKEWORD(hdr->common.drep[0], hdr->common.drep[1]),
MAKEWORD(hdr->common.drep[2], hdr->common.drep[3]));
exception = FALSE;
/* dispatch */
RPCRT4_SetThreadCurrentCallHandle(msg->Handle);
__TRY {
if (func) func(msg);
} __EXCEPT(rpc_filter) {
exception = TRUE;
if (GetExceptionCode() == STATUS_ACCESS_VIOLATION)
status = ERROR_NOACCESS;
else
status = GetExceptionCode();
response = RPCRT4_BuildFaultHeader(msg->DataRepresentation,
RPC2NCA_STATUS(status));
} __ENDTRY
RPCRT4_SetThreadCurrentCallHandle(NULL);
/* release any unmarshalled context handles */
while ((context_handle = RPCRT4_PopThreadContextHandle()) != NULL)
RpcServerAssoc_ReleaseContextHandle(conn->server_binding->Assoc, context_handle, TRUE);
if (!exception)
response = RPCRT4_BuildResponseHeader(msg->DataRepresentation,
msg->BufferLength);
/* send response packet */
if (response) {
status = RPCRT4_Send(conn, response, exception ? NULL : msg->Buffer,
exception ? 0 : msg->BufferLength);
RPCRT4_FreeHeader(response);
} else
ERR("out of memory\n");
msg->RpcInterfaceInformation = NULL;
RPCRT4_release_server_interface(sif);
status = process_request_packet(conn, &hdr->request, msg);
break;
default:
@ -334,14 +355,8 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
break;
}
fail:
/* clean up */
if (msg->Buffer == buf) msg->Buffer = NULL;
TRACE("freeing Buffer=%p\n", buf);
HeapFree(GetProcessHeap(), 0, buf);
msg->Handle = 0;
I_RpcFreeBuffer(msg);
msg->Buffer = NULL;
RPCRT4_FreeHeader(hdr);
HeapFree(GetProcessHeap(), 0, msg);
}
@ -388,6 +403,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
HeapFree(GetProcessHeap(), 0, packet);
break;
}
msg = NULL;
}
RPCRT4_DestroyConnection(conn);
@ -1032,10 +1048,10 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
LeaveCriticalSection(&listen_cs);
return RPC_S_NOT_LISTENING;
}
do
{
LeaveCriticalSection(&listen_cs);
LeaveCriticalSection(&listen_cs);
LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
WaitForSingleObject(cps->server_ready_event, INFINITE);

View file

@ -446,8 +446,8 @@ static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
networkaddr_size = strlen(networkaddr) + 1;
endpoint_size = strlen(endpoint) + 1;
networkaddr_size = networkaddr ? strlen(networkaddr) + 1 : 1;
endpoint_size = endpoint ? strlen(endpoint) + 1 : 1;
size = sizeof(*smb_floor) + endpoint_size + sizeof(*nb_floor) + networkaddr_size;
if (!tower_data)
@ -461,7 +461,10 @@ static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
smb_floor->protid = EPM_PROTOCOL_SMB;
smb_floor->count_rhs = endpoint_size;
memcpy(tower_data, endpoint, endpoint_size);
if (endpoint)
memcpy(tower_data, endpoint, endpoint_size);
else
tower_data[0] = 0;
tower_data += endpoint_size;
nb_floor = (twr_empty_floor_t *)tower_data;
@ -472,7 +475,10 @@ static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
nb_floor->protid = EPM_PROTOCOL_NETBIOS;
nb_floor->count_rhs = networkaddr_size;
memcpy(tower_data, networkaddr, networkaddr_size);
if (networkaddr)
memcpy(tower_data, networkaddr, networkaddr_size);
else
tower_data[0] = 0;
tower_data += networkaddr_size;
return size;
@ -1025,7 +1031,7 @@ static int rpcrt4_conn_tcp_write(RpcConnection *Connection,
int bytes_written = 0;
do
{
int r = write(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written);
int r = send(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written, 0);
if (r >= 0)
bytes_written += r;
else if (errno != EAGAIN)

View file

@ -30,6 +30,7 @@
<file>ndr_ole.c</file>
<file>ndr_stubless.c</file>
<file>rpc_assoc.c</file>
<file>rpc_async.c</file>
<file>rpc_binding.c</file>
<file>rpc_epmap.c</file>
<file>rpc_message.c</file>

View file

@ -18,11 +18,11 @@
@ stdcall IUnknown_AddRef_Proxy(ptr)
@ stdcall IUnknown_QueryInterface_Proxy(ptr ptr ptr)
@ stdcall IUnknown_Release_Proxy(ptr)
@ stub I_RpcAbortAsyncCall
@ stdcall I_RpcAbortAsyncCall(ptr long) I_RpcAsyncAbortCall
@ stdcall I_RpcAllocate(long)
@ stub I_RpcAsyncAbortCall
@ stdcall I_RpcAsyncAbortCall(ptr long)
@ stub I_RpcAsyncSendReceive # NT4
@ stub I_RpcAsyncSetHandle
@ stdcall I_RpcAsyncSetHandle(ptr ptr)
@ stub I_RpcBCacheAllocate
@ stub I_RpcBCacheFree
@ stub I_RpcBindingCopy
@ -201,9 +201,9 @@
@ stdcall NdrContextHandleSize(ptr ptr ptr)
@ stdcall NdrConvert2(ptr ptr long)
@ stdcall NdrConvert(ptr ptr)
@ stub NdrCorrelationFree
@ stub NdrCorrelationInitialize
@ stub NdrCorrelationPass
@ stdcall NdrCorrelationFree(ptr)
@ stdcall NdrCorrelationInitialize(ptr ptr long long)
@ stdcall NdrCorrelationPass(ptr)
@ stub NdrDcomAsyncClientCall
@ stub NdrDcomAsyncStubCall
@ stdcall NdrDllCanUnloadNow(ptr)
@ -362,12 +362,12 @@
@ stub NdrpSetRpcSsDefaults
@ stub NdrpVarVtOfTypeDesc # wxp
@ stub PerformRpcInitialization
@ stub RpcAbortAsyncCall
@ stub RpcAsyncAbortCall
@ stub RpcAsyncCancelCall
@ stub RpcAsyncCompleteCall
@ stub RpcAsyncGetCallStatus
@ stub RpcAsyncInitializeHandle
@ stdcall RpcAbortAsyncCall(ptr long) RpcAsyncAbortCall
@ stdcall RpcAsyncAbortCall(ptr long)
@ stdcall RpcAsyncCancelCall(ptr long)
@ stdcall RpcAsyncCompleteCall(ptr ptr)
@ stdcall RpcAsyncGetCallStatus(ptr)
@ stdcall RpcAsyncInitializeHandle(ptr long)
@ stub RpcAsyncRegisterInfo
@ stdcall RpcBindingCopy(ptr ptr)
@ stdcall RpcBindingFree(ptr)
@ -394,12 +394,12 @@
@ stdcall RpcBindingToStringBindingA(ptr ptr)
@ stdcall RpcBindingToStringBindingW(ptr ptr)
@ stdcall RpcBindingVectorFree(ptr)
@ stub RpcCancelAsyncCall
@ stdcall RpcCancelAsyncCall(ptr long) RpcAsyncCancelCall
@ stdcall RpcCancelThread(ptr)
@ stub RpcCancelThreadEx
@ stub RpcCertGeneratePrincipalNameA
@ stub RpcCertGeneratePrincipalNameW
@ stub RpcCompleteAsyncCall
@ stdcall RpcCompleteAsyncCall(ptr ptr) RpcAsyncCompleteCall
@ stdcall RpcEpRegisterA(ptr ptr ptr str)
@ stub RpcEpRegisterNoReplaceA
@ stub RpcEpRegisterNoReplaceW
@ -416,11 +416,11 @@
@ stub RpcErrorSaveErrorInfo # wxp
@ stdcall RpcErrorStartEnumeration(ptr)
@ stub RpcFreeAuthorizationContext # wxp
@ stub RpcGetAsyncCallStatus
@ stdcall RpcGetAsyncCallStatus(ptr) RpcAsyncGetCallStatus
@ stub RpcIfIdVectorFree
@ stub RpcIfInqId
@ stdcall RpcImpersonateClient(ptr)
@ stub RpcInitializeAsyncHandle
@ stdcall RpcInitializeAsyncHandle(ptr long) RpcAsyncInitializeHandle
@ stub RpcMgmtBindingInqParameter # win9x
@ stub RpcMgmtBindingSetParameter # win9x
@ stdcall RpcMgmtEnableIdleCleanup()

View file

@ -19,74 +19,13 @@
*
* WINE RPC TODO's (and a few TODONT's)
*
* - Ove's decreasingly incomplete widl is an IDL compiler for wine. For widl
* to be wine's only IDL compiler, a fair bit of work remains to be done.
* until then we have used some midl-generated stuff. (What?)
* widl currently doesn't generate stub/proxy files required by wine's (O)RPC
* capabilities -- nor does it make those lovely format strings :(
* The MS MIDL compiler does some really esoteric stuff. Of course Ove has
* started with the less esoteric stuff. There are also lots of nice
* comments in there if you want to flex your bison and help build this monster.
*
* - RPC has a quite featureful error handling mechanism; basically none of this is
* implemented right now. We also have deficiencies on the compiler side, where
* wine's __TRY / __EXCEPT / __FINALLY macros are not even used for RpcTryExcept & co,
* due to syntactic differences! (we can fix it with widl by using __TRY)
*
* - There are several different memory allocation schemes for MSRPC.
* I don't even understand what they all are yet, much less have them
* properly implemented. Surely we are supposed to be doing something with
* the user-provided allocation/deallocation functions, but so far,
* I don't think we are doing this...
*
* - MSRPC provides impersonation capabilities which currently are not possible
* to implement in wine. At the very least we should implement the authorization
* API's & gracefully ignore the irrelevant stuff (to an extent we already do).
*
* - Some transports are not yet implemented. The existing transport implementations
* are incomplete and may be bug-infested.
*
* - The various transports that we do support ought to be supported in a more
* object-oriented manner, as in DCE's RPC implementation, instead of cluttering
* up the code with conditionals like we do now.
*
* - Data marshalling: So far, only the beginnings of a full implementation
* exist in wine. NDR protocol itself is documented, but the MS API's to
* convert data-types in memory into NDR are not. This is challenging work,
* and has supposedly been "at the top of Greg's queue" for several months now.
*
* - ORPC is RPC for OLE; once we have a working RPC framework, we can
* use it to implement out-of-process OLE client/server communications.
* ATM there is maybe a disconnect between the marshalling in the OLE DLLs
* and the marshalling going on here [TODO: well, is there or not?]
*
* - In-source API Documentation, at least for those functions which we have
* implemented, but preferably for everything we can document, would be nice,
* since some of this stuff is quite obscure.
*
* - Name services... [TODO: what about them]
*
* - Protocol Towers: Totally unimplemented.... I think.
*
* - Context Handle Rundown: whatever that is.
*
* - Nested RPC's: Totally unimplemented.
*
* - Statistics: we are supposed to be keeping various counters. we aren't.
*
* - Async RPC: Unimplemented.
*
* - XML/http RPC: Somewhere there's an XML fiend that wants to do this! Betcha
* we could use these as a transport for RPC's across computers without a
* permissions and/or licensing crisis.
*
* - The NT "ports" API, aka LPC. Greg claims this is on his radar. Might (or
* might not) enable users to get some kind of meaningful result out of
* NT-based native rpcrt4's. Commonly-used transport for self-to-self RPC's.
*
* - ...? More stuff I haven't thought of. If you think of more RPC todo's
* drop me an e-mail <gmturner007@ameritech.net> or send a patch to the
* wine-patches mailing list.
*/
#include "config.h"
@ -96,6 +35,8 @@
#include <stdlib.h>
#include <string.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winerror.h"
#include "winbase.h"
@ -871,11 +812,128 @@ void WINAPI I_RpcFree(void *Object)
/******************************************************************************
* I_RpcMapWin32Status (rpcrt4.@)
*
* Maps Win32 RPC error codes to NT statuses.
*
* PARAMS
* status [I] Win32 RPC error code.
*
* RETURNS
* Appropriate translation into an NT status code.
*/
LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status)
{
FIXME("(%ld): stub\n", status);
return 0;
TRACE("(%ld)\n", status);
switch (status)
{
case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED;
case ERROR_INVALID_HANDLE: return RPC_NT_SS_CONTEXT_MISMATCH;
case ERROR_OUTOFMEMORY: return STATUS_NO_MEMORY;
case ERROR_INVALID_PARAMETER: return STATUS_INVALID_PARAMETER;
case ERROR_INSUFFICIENT_BUFFER: return STATUS_BUFFER_TOO_SMALL;
case ERROR_MAX_THRDS_REACHED: return STATUS_NO_MEMORY;
case ERROR_NOACCESS: return STATUS_ACCESS_VIOLATION;
case ERROR_NOT_ENOUGH_SERVER_MEMORY: return STATUS_INSUFF_SERVER_RESOURCES;
case ERROR_WRONG_PASSWORD: return STATUS_WRONG_PASSWORD;
case ERROR_INVALID_LOGON_HOURS: return STATUS_INVALID_LOGON_HOURS;
case ERROR_PASSWORD_EXPIRED: return STATUS_PASSWORD_EXPIRED;
case ERROR_ACCOUNT_DISABLED: return STATUS_ACCOUNT_DISABLED;
case ERROR_INVALID_SECURITY_DESCR: return STATUS_INVALID_SECURITY_DESCR;
case RPC_S_INVALID_STRING_BINDING: return RPC_NT_INVALID_STRING_BINDING;
case RPC_S_WRONG_KIND_OF_BINDING: return RPC_NT_WRONG_KIND_OF_BINDING;
case RPC_S_INVALID_BINDING: return RPC_NT_INVALID_BINDING;
case RPC_S_PROTSEQ_NOT_SUPPORTED: return RPC_NT_PROTSEQ_NOT_SUPPORTED;
case RPC_S_INVALID_RPC_PROTSEQ: return RPC_NT_INVALID_RPC_PROTSEQ;
case RPC_S_INVALID_STRING_UUID: return RPC_NT_INVALID_STRING_UUID;
case RPC_S_INVALID_ENDPOINT_FORMAT: return RPC_NT_INVALID_ENDPOINT_FORMAT;
case RPC_S_INVALID_NET_ADDR: return RPC_NT_INVALID_NET_ADDR;
case RPC_S_NO_ENDPOINT_FOUND: return RPC_NT_NO_ENDPOINT_FOUND;
case RPC_S_INVALID_TIMEOUT: return RPC_NT_INVALID_TIMEOUT;
case RPC_S_OBJECT_NOT_FOUND: return RPC_NT_OBJECT_NOT_FOUND;
case RPC_S_ALREADY_REGISTERED: return RPC_NT_ALREADY_REGISTERED;
case RPC_S_TYPE_ALREADY_REGISTERED: return RPC_NT_TYPE_ALREADY_REGISTERED;
case RPC_S_ALREADY_LISTENING: return RPC_NT_ALREADY_LISTENING;
case RPC_S_NO_PROTSEQS_REGISTERED: return RPC_NT_NO_PROTSEQS_REGISTERED;
case RPC_S_NOT_LISTENING: return RPC_NT_NOT_LISTENING;
case RPC_S_UNKNOWN_MGR_TYPE: return RPC_NT_UNKNOWN_MGR_TYPE;
case RPC_S_UNKNOWN_IF: return RPC_NT_UNKNOWN_IF;
case RPC_S_NO_BINDINGS: return RPC_NT_NO_BINDINGS;
case RPC_S_NO_PROTSEQS: return RPC_NT_NO_PROTSEQS;
case RPC_S_CANT_CREATE_ENDPOINT: return RPC_NT_CANT_CREATE_ENDPOINT;
case RPC_S_OUT_OF_RESOURCES: return RPC_NT_OUT_OF_RESOURCES;
case RPC_S_SERVER_UNAVAILABLE: return RPC_NT_SERVER_UNAVAILABLE;
case RPC_S_SERVER_TOO_BUSY: return RPC_NT_SERVER_TOO_BUSY;
case RPC_S_INVALID_NETWORK_OPTIONS: return RPC_NT_INVALID_NETWORK_OPTIONS;
case RPC_S_NO_CALL_ACTIVE: return RPC_NT_NO_CALL_ACTIVE;
case RPC_S_CALL_FAILED: return RPC_NT_CALL_FAILED;
case RPC_S_CALL_FAILED_DNE: return RPC_NT_CALL_FAILED_DNE;
case RPC_S_PROTOCOL_ERROR: return RPC_NT_PROTOCOL_ERROR;
case RPC_S_UNSUPPORTED_TRANS_SYN: return RPC_NT_UNSUPPORTED_TRANS_SYN;
case RPC_S_UNSUPPORTED_TYPE: return RPC_NT_UNSUPPORTED_TYPE;
case RPC_S_INVALID_TAG: return RPC_NT_INVALID_TAG;
case RPC_S_INVALID_BOUND: return RPC_NT_INVALID_BOUND;
case RPC_S_NO_ENTRY_NAME: return RPC_NT_NO_ENTRY_NAME;
case RPC_S_INVALID_NAME_SYNTAX: return RPC_NT_INVALID_NAME_SYNTAX;
case RPC_S_UNSUPPORTED_NAME_SYNTAX: return RPC_NT_UNSUPPORTED_NAME_SYNTAX;
case RPC_S_UUID_NO_ADDRESS: return RPC_NT_UUID_NO_ADDRESS;
case RPC_S_DUPLICATE_ENDPOINT: return RPC_NT_DUPLICATE_ENDPOINT;
case RPC_S_UNKNOWN_AUTHN_TYPE: return RPC_NT_UNKNOWN_AUTHN_TYPE;
case RPC_S_MAX_CALLS_TOO_SMALL: return RPC_NT_MAX_CALLS_TOO_SMALL;
case RPC_S_STRING_TOO_LONG: return RPC_NT_STRING_TOO_LONG;
case RPC_S_PROTSEQ_NOT_FOUND: return RPC_NT_PROTSEQ_NOT_FOUND;
case RPC_S_PROCNUM_OUT_OF_RANGE: return RPC_NT_PROCNUM_OUT_OF_RANGE;
case RPC_S_BINDING_HAS_NO_AUTH: return RPC_NT_BINDING_HAS_NO_AUTH;
case RPC_S_UNKNOWN_AUTHN_SERVICE: return RPC_NT_UNKNOWN_AUTHN_SERVICE;
case RPC_S_UNKNOWN_AUTHN_LEVEL: return RPC_NT_UNKNOWN_AUTHN_LEVEL;
case RPC_S_INVALID_AUTH_IDENTITY: return RPC_NT_INVALID_AUTH_IDENTITY;
case RPC_S_UNKNOWN_AUTHZ_SERVICE: return RPC_NT_UNKNOWN_AUTHZ_SERVICE;
case EPT_S_INVALID_ENTRY: return EPT_NT_INVALID_ENTRY;
case EPT_S_CANT_PERFORM_OP: return EPT_NT_CANT_PERFORM_OP;
case EPT_S_NOT_REGISTERED: return EPT_NT_NOT_REGISTERED;
case EPT_S_CANT_CREATE: return EPT_NT_CANT_CREATE;
case RPC_S_NOTHING_TO_EXPORT: return RPC_NT_NOTHING_TO_EXPORT;
case RPC_S_INCOMPLETE_NAME: return RPC_NT_INCOMPLETE_NAME;
case RPC_S_INVALID_VERS_OPTION: return RPC_NT_INVALID_VERS_OPTION;
case RPC_S_NO_MORE_MEMBERS: return RPC_NT_NO_MORE_MEMBERS;
case RPC_S_NOT_ALL_OBJS_UNEXPORTED: return RPC_NT_NOT_ALL_OBJS_UNEXPORTED;
case RPC_S_INTERFACE_NOT_FOUND: return RPC_NT_INTERFACE_NOT_FOUND;
case RPC_S_ENTRY_ALREADY_EXISTS: return RPC_NT_ENTRY_ALREADY_EXISTS;
case RPC_S_ENTRY_NOT_FOUND: return RPC_NT_ENTRY_NOT_FOUND;
case RPC_S_NAME_SERVICE_UNAVAILABLE: return RPC_NT_NAME_SERVICE_UNAVAILABLE;
case RPC_S_INVALID_NAF_ID: return RPC_NT_INVALID_NAF_ID;
case RPC_S_CANNOT_SUPPORT: return RPC_NT_CANNOT_SUPPORT;
case RPC_S_NO_CONTEXT_AVAILABLE: return RPC_NT_NO_CONTEXT_AVAILABLE;
case RPC_S_INTERNAL_ERROR: return RPC_NT_INTERNAL_ERROR;
case RPC_S_ZERO_DIVIDE: return RPC_NT_ZERO_DIVIDE;
case RPC_S_ADDRESS_ERROR: return RPC_NT_ADDRESS_ERROR;
case RPC_S_FP_DIV_ZERO: return RPC_NT_FP_DIV_ZERO;
case RPC_S_FP_UNDERFLOW: return RPC_NT_FP_UNDERFLOW;
case RPC_S_FP_OVERFLOW: return RPC_NT_FP_OVERFLOW;
case RPC_S_CALL_IN_PROGRESS: return RPC_NT_CALL_IN_PROGRESS;
case RPC_S_NO_MORE_BINDINGS: return RPC_NT_NO_MORE_BINDINGS;
case RPC_S_CALL_CANCELLED: return RPC_NT_CALL_CANCELLED;
case RPC_S_INVALID_OBJECT: return RPC_NT_INVALID_OBJECT;
case RPC_S_INVALID_ASYNC_HANDLE: return RPC_NT_INVALID_ASYNC_HANDLE;
case RPC_S_INVALID_ASYNC_CALL: return RPC_NT_INVALID_ASYNC_CALL;
case RPC_S_GROUP_MEMBER_NOT_FOUND: return RPC_NT_GROUP_MEMBER_NOT_FOUND;
case RPC_X_NO_MORE_ENTRIES: return RPC_NT_NO_MORE_ENTRIES;
case RPC_X_SS_CHAR_TRANS_OPEN_FAIL: return RPC_NT_SS_CHAR_TRANS_OPEN_FAIL;
case RPC_X_SS_CHAR_TRANS_SHORT_FILE: return RPC_NT_SS_CHAR_TRANS_SHORT_FILE;
case RPC_X_SS_IN_NULL_CONTEXT: return RPC_NT_SS_IN_NULL_CONTEXT;
case RPC_X_SS_CONTEXT_DAMAGED: return RPC_NT_SS_CONTEXT_DAMAGED;
case RPC_X_SS_HANDLES_MISMATCH: return RPC_NT_SS_HANDLES_MISMATCH;
case RPC_X_SS_CANNOT_GET_CALL_HANDLE: return RPC_NT_SS_CANNOT_GET_CALL_HANDLE;
case RPC_X_NULL_REF_POINTER: return RPC_NT_NULL_REF_POINTER;
case RPC_X_ENUM_VALUE_OUT_OF_RANGE: return RPC_NT_ENUM_VALUE_OUT_OF_RANGE;
case RPC_X_BYTE_COUNT_TOO_SMALL: return RPC_NT_BYTE_COUNT_TOO_SMALL;
case RPC_X_BAD_STUB_DATA: return RPC_NT_BAD_STUB_DATA;
case RPC_X_PIPE_CLOSED: return RPC_NT_PIPE_CLOSED;
case RPC_X_PIPE_DISCIPLINE_ERROR: return RPC_NT_PIPE_DISCIPLINE_ERROR;
case RPC_X_PIPE_EMPTY: return RPC_NT_PIPE_EMPTY;
case ERROR_PASSWORD_MUST_CHANGE: return STATUS_PASSWORD_MUST_CHANGE;
case ERROR_ACCOUNT_LOCKED_OUT: return STATUS_ACCOUNT_LOCKED_OUT;
default: return status;
}
}
/******************************************************************************

View file

@ -1,5 +1,7 @@
--- rpc_server.c Tue Jan 01 13:09:34 2008
+++ rpc_server.c Fri Jan 11 15:58:57 2008
Index: rpc_server.c
===================================================================
--- rpc_server.c (working copy)
+++ rpc_server.c (working copy)
@@ -1017,22 +1017,30 @@
/***********************************************************************
* RpcMgmtServerWaitListen (RPCRT4.@)
@ -33,8 +35,10 @@
}
/***********************************************************************
--- rpc_transport.c Sun Jan 06 19:27:38 2008
+++ rpc_transport.c Fri Jan 11 15:59:32 2008
Index: rpc_transport.c
===================================================================
--- rpc_transport.c (working copy)
+++ rpc_transport.c (working copy)
@@ -54,10 +54,13 @@
#endif
#ifdef HAVE_SYS_POLL_H