Windows NT 4.0 source code leak
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.

138 lines
3.5 KiB

4 years ago
  1. /************************************************************************
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name :
  4. srvout.c
  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 "ndrp.h"
  15. #include "hndl.h"
  16. #include "interp.h"
  17. void
  18. NdrOutInit(
  19. PMIDL_STUB_MESSAGE pStubMsg,
  20. PFORMAT_STRING pFormat,
  21. uchar ** ppArg
  22. )
  23. /*++
  24. Routine Description :
  25. This routine is called to manage server side issues for [out] params
  26. such as allocation and context handle initialization. Due to the fact
  27. that for [out] conformant objects on stack, their size descriptors may
  28. not have been unmarshalled when we need to know their size, this routine
  29. must be called after all other unmarshalling has occurred. Really, we
  30. could defer only [out], conformant data, but the logic in walking the
  31. format string to determine if an object is conformant does not warrant
  32. that principle, so all [out] data is deferred.
  33. Arguments :
  34. pStubMsg - Pointer to stub message.
  35. pFormat - Format string description for the type.
  36. ppArg - Location of argument on stack.
  37. Return :
  38. None.
  39. --*/
  40. {
  41. // Don't screw with this, it must be a signed long!
  42. long Size;
  43. //
  44. // Check for a non-Interface pointer (they have a much different format
  45. // than regular pointers).
  46. //
  47. if ( IS_BASIC_POINTER(*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 ( SIMPLE_POINTER(pFormat[1]) )
  55. {
  56. Size = SIMPLE_TYPE_MEMSIZE(pFormat[2]);
  57. goto DoAlloc;
  58. }
  59. //
  60. // Check for a pointer to a pointer.
  61. //
  62. if ( POINTER_DEREF(pFormat[1]) )
  63. {
  64. Size = sizeof(void *);
  65. goto DoAlloc;
  66. }
  67. // We have a pointer to complex type.
  68. pFormat += 2;
  69. pFormat += *(signed short *)pFormat;
  70. }
  71. if ( *pFormat == FC_BIND_CONTEXT )
  72. {
  73. NdrSaveContextHandle(
  74. pStubMsg,
  75. NDRSContextUnmarshall( 0, pStubMsg->RpcMsg->DataRepresentation ),
  76. ppArg,
  77. pFormat );
  78. return;
  79. }
  80. //
  81. // If we get here we have to make a call to size a complex type.
  82. //
  83. Size = (long) NdrpMemoryIncrement( pStubMsg,
  84. 0,
  85. pFormat );
  86. DoAlloc:
  87. //
  88. // Check for a negative size. This an application error condition for
  89. // signed size specifiers.
  90. //
  91. if ( Size < 0 )
  92. RpcRaiseException( RPC_X_INVALID_BOUND );
  93. *ppArg = NdrAllocate( pStubMsg, (size_t) Size);
  94. MIDL_memset( *ppArg, 0, (size_t) Size );
  95. // We are almost done, except for an out ref to ref to ... etc.
  96. // If this is the case keep allocating pointees of ref pointers.
  97. if ( *pFormat == FC_RP && POINTER_DEREF(pFormat[1]) )
  98. {
  99. pFormat += 2;
  100. pFormat += *(signed short *)pFormat;
  101. if ( *pFormat == FC_RP )
  102. NdrOutInit( pStubMsg, pFormat, (uchar **) *ppArg );
  103. }
  104. }