Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.8 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1998 - 2000 Microsoft Corporation
  3. Module Name :
  4. relmrl.c
  5. Abstract :
  6. This file contains release of Marshaled Data (called before unmarshal).
  7. Author :
  8. Yong Qu (yongqu@microsoft.com) Nov 1998
  9. Revision History :
  10. ---------------------------------------------------------------------*/
  11. #include "precomp.hxx"
  12. #define USE_STUBLESS_PROXY
  13. #define CINTERFACE
  14. #include "ndrole.h"
  15. #include "rpcproxy.h"
  16. #include "hndl.h"
  17. #include "interp2.h"
  18. #include "pipendr.h"
  19. #include "expr.h"
  20. #include <stddef.h>
  21. #include <stdarg.h>
  22. /* client side: we only care about the [in] part.
  23. it's basically like unmarshal on the server side, just that
  24. we immediately free the buffer (virtual stack) after unmarshalling.
  25. The call it not necessary always OLE call: one side raw RPC and
  26. the other side OLE call is possible: do we support this?
  27. mostly code from NdrStubCall2, remove irrelavant code.
  28. */
  29. #define IN_BUFFER 0
  30. #define OUT_BUFFER 1
  31. #define IsSameDir(dwFlags,paramflag) ((dwFlags == IN_BUFFER)? paramflag->IsIn :paramflag->IsOut)
  32. HRESULT Ndr64pReleaseMarshalBuffer(
  33. RPC_MESSAGE * pRpcMsg,
  34. PMIDL_SYNTAX_INFO pSyntaxInfo,
  35. unsigned long ProcNum,
  36. PMIDL_STUB_DESC pStubDesc,
  37. DWORD dwFlags,
  38. BOOLEAN fServer )
  39. {
  40. ushort StackSize;
  41. MIDL_STUB_MESSAGE StubMsg;
  42. NDR64_PARAM_FORMAT * Params;
  43. long NumberParams;
  44. long n;
  45. HRESULT hr = S_OK;
  46. uchar * pBuffer;
  47. PFORMAT_STRING pFormatTypes;
  48. long FormatOffset;
  49. PFORMAT_STRING pFormat;
  50. NDR_PROC_CONTEXT ProcContext;
  51. NDR64_PROC_FLAGS * pNdr64Flags;
  52. NDR64_PROC_FORMAT * pHeader = NULL;
  53. NDR64_PARAM_FLAGS * pParamFlags;
  54. NDR_ASSERT( ! ((ULONG_PTR)pRpcMsg->Buffer & 0x7),
  55. "marshaling buffer misaligned at server" );
  56. pFormat = NdrpGetProcString( pSyntaxInfo,
  57. XFER_SYNTAX_NDR64,
  58. ProcNum );
  59. Ndr64ServerInitialize(pRpcMsg,&StubMsg,pStubDesc);
  60. StubMsg.fHasExtensions = 1;
  61. StubMsg.fHasNewCorrDesc = 1;
  62. pFormatTypes = pSyntaxInfo->TypeString;
  63. pHeader = (NDR64_PROC_FORMAT *) pFormat;
  64. pNdr64Flags = (NDR64_PROC_FLAGS *) & (pHeader->Flags );
  65. NumberParams = pHeader->NumberOfParams;
  66. if ( pNdr64Flags->UsesFullPtrPackage )
  67. StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit( 0, XLAT_SERVER );
  68. Params = (NDR64_PARAM_FORMAT *)( (char *) pFormat + sizeof( NDR64_PROC_FORMAT ) + pHeader->ExtensionSize );
  69. // Save the original buffer pointer to restore later.
  70. pBuffer = StubMsg.Buffer;
  71. // Get the type format string.
  72. RpcTryFinally
  73. {
  74. RpcTryExcept
  75. {
  76. //
  77. // Check if we need to do any walking .
  78. //
  79. NDR64_SET_WALKIP(StubMsg.uFlags);
  80. for ( n = 0; n < NumberParams; n++ )
  81. {
  82. pParamFlags = ( NDR64_PARAM_FLAGS * ) & ( Params[n].Attributes );
  83. if ( ( dwFlags == IN_BUFFER ) &&
  84. ( pParamFlags->IsPartialIgnore ) )
  85. {
  86. PMIDL_STUB_MESSAGE pStubMsg = &StubMsg;
  87. // Skip the boolean pointer in the buffer
  88. ALIGN( StubMsg.Buffer, NDR64_PTR_WIRE_ALIGN );
  89. StubMsg.Buffer += sizeof(NDR64_PTR_WIRE_TYPE);
  90. CHECK_EOB_RAISE_BSD( StubMsg.Buffer );
  91. continue;
  92. }
  93. if ( ! IsSameDir(dwFlags,pParamFlags) )
  94. continue;
  95. if ( pParamFlags->IsBasetype )
  96. {
  97. NDR64_FORMAT_CHAR type = *(PFORMAT_STRING)Params[n].Type;
  98. ALIGN( StubMsg.Buffer, NDR64_SIMPLE_TYPE_BUFALIGN( type ) );
  99. StubMsg.Buffer += NDR64_SIMPLE_TYPE_BUFSIZE( type );
  100. }
  101. else
  102. {
  103. //
  104. // Complex type or pointer to complex type.
  105. //
  106. Ndr64TopLevelTypeMemorySize( &StubMsg,
  107. Params[n].Type );
  108. }
  109. }
  110. }
  111. RpcExcept( EXCEPTION_EXECUTE_HANDLER )
  112. {
  113. hr = HRESULT_FROM_WIN32(RpcExceptionCode());
  114. }
  115. RpcEndExcept
  116. }
  117. RpcFinally
  118. {
  119. NdrFullPointerXlatFree( StubMsg.FullPtrXlatTables );
  120. StubMsg.Buffer = pBuffer;
  121. }
  122. RpcEndFinally
  123. return hr;
  124. }