Source code of Windows XP (NT5)
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.

146 lines
3.9 KiB

  1. /************************************************************************
  2. Copyright (c) 1993 - 1999 Microsoft Corporation
  3. Module Name :
  4. srvout.cxx
  5. Abstract :
  6. Contains routines for support of [out] parameters on server side during
  7. unmarshalling phase. This includes deferral, allocation and handle
  8. initialization.
  9. Author :
  10. Bruce McQuistan (brucemc) 12/93.
  11. Revision History :
  12. DKays 10/94 Major comment and code clean up.
  13. ***********************************************************************/
  14. #include "precomp.hxx"
  15. void
  16. Ndr64OutInit(
  17. PMIDL_STUB_MESSAGE pStubMsg,
  18. PNDR64_FORMAT pFormat,
  19. uchar ** ppArg
  20. )
  21. /*++
  22. Routine Description :
  23. This routine is called to manage server side issues for [out] params
  24. such as allocation and context handle initialization. Due to the fact
  25. that for [out] conformant objects on stack, their size descriptors may
  26. not have been unmarshalled when we need to know their size, this routine
  27. must be called after all other unmarshalling has occurred. Really, we
  28. could defer only [out], conformant data, but the logic in walking the
  29. format string to determine if an object is conformant does not warrant
  30. that principle, so all [out] data is deferred.
  31. Arguments :
  32. pStubMsg - Pointer to stub message.
  33. pFormat - Format string description for the type.
  34. ppArg - Location of argument on stack.
  35. Return :
  36. None.
  37. --*/
  38. {
  39. const NDR64_POINTER_FORMAT *pPointerFormat =
  40. (const NDR64_POINTER_FORMAT*)pFormat;
  41. // This must be a signed long!
  42. LONG_PTR Size;
  43. //
  44. // Check for a non-Interface pointer (they have a much different format
  45. // than regular pointers).
  46. //
  47. if ( NDR64_IS_BASIC_POINTER(*(PFORMAT_STRING)pFormat) )
  48. {
  49. //
  50. // Check for a pointer to a basetype (we don't have to worry about
  51. // a non-sized string pointer because these are not allowed as [out]
  52. // only.
  53. //
  54. if ( NDR64_SIMPLE_POINTER( pPointerFormat->Flags ) )
  55. {
  56. Size = NDR64_SIMPLE_TYPE_MEMSIZE( *(PFORMAT_STRING)pPointerFormat->Pointee );
  57. goto DoAlloc;
  58. }
  59. //
  60. // Check for a pointer to a pointer.
  61. //
  62. if ( NDR64_POINTER_DEREF( pPointerFormat->Flags ) )
  63. {
  64. Size = PTR_MEM_SIZE;
  65. goto DoAlloc;
  66. }
  67. // We have a pointer to complex type.
  68. pFormat = pPointerFormat->Pointee;
  69. }
  70. if ( *(PFORMAT_STRING)pFormat == FC64_BIND_CONTEXT )
  71. {
  72. NDR_SCONTEXT Context =
  73. Ndr64ContextHandleInitialize( pStubMsg,
  74. (PFORMAT_STRING)pFormat );
  75. if ( ! Context )
  76. RpcRaiseException( RPC_X_SS_CONTEXT_MISMATCH );
  77. Ndr64SaveContextHandle(
  78. pStubMsg,
  79. Context,
  80. ppArg,
  81. (PFORMAT_STRING)pFormat );
  82. return;
  83. }
  84. //
  85. // If we get here we have to make a call to size a complex type.
  86. //
  87. Size = Ndr64pMemorySize( pStubMsg,
  88. pFormat,
  89. FALSE );
  90. DoAlloc:
  91. //
  92. // Check for a negative size. This an application error condition for
  93. // signed size specifiers.
  94. //
  95. if ( Size < 0 )
  96. RpcRaiseException( RPC_X_INVALID_BOUND );
  97. *ppArg = (uchar *)NdrAllocate( pStubMsg, (size_t) Size);
  98. MIDL_memset( *ppArg, 0, (size_t) Size );
  99. // We are almost done, except for an out ref to ref to ... etc.
  100. // If this is the case keep allocating pointees of ref pointers.
  101. if ( *(PFORMAT_STRING)pFormat == FC64_RP && NDR64_POINTER_DEREF( pPointerFormat->Flags ) )
  102. {
  103. pFormat = pPointerFormat->Pointee;
  104. if ( *(PFORMAT_STRING)pFormat == FC64_RP )
  105. Ndr64OutInit( pStubMsg, pFormat, (uchar **) *ppArg );
  106. }
  107. }