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.

141 lines
3.7 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1995-1999 Microsoft Corporation
  3. Module Name:
  4. pipendr.cxx
  5. Abstract:
  6. Contains routines for the generation of the new NDR format strings for
  7. pipe types.
  8. Notes:
  9. History:
  10. SteveBl Dec-1995 Created.
  11. ----------------------------------------------------------------------------*/
  12. #include "becls.hxx"
  13. extern CMD_ARG * pCommand;
  14. #pragma hdrstop
  15. void
  16. CG_PIPE::GenNdrFormat( CCB * pCCB )
  17. /*++
  18. The format string is:
  19. FC_PIPE
  20. flags & alignment<1> // pointer flags on the higher nibble
  21. index to type desc<2> // the usual
  22. memory size<2>
  23. buffer size<2> // wire size, essential
  24. If either memory size or buffer size > 64k then
  25. the FC_BIG_PIPE flag is set and the following format string is used:
  26. FC_PIPE
  27. flags & alignment<1>
  28. index to type desc<2>
  29. memory size<4>
  30. buffer size<4>
  31. --*/
  32. {
  33. if ( GetFormatStringOffset() != -1 )
  34. return;
  35. pCommand->GetNdrVersionControl().SetHasRawPipes();
  36. FORMAT_STRING * pFormatString;
  37. CG_NDR * pChild;
  38. long ChildOffset;
  39. // Format offset
  40. pFormatString = pCCB->GetFormatString();
  41. pChild = (CG_NDR *) GetChild();
  42. MIDL_ASSERT( pChild );
  43. // Do this in case the child is a simple type.
  44. ChildOffset = pFormatString->GetCurrentOffset();
  45. pChild->GenNdrFormat( pCCB );
  46. // Again, do this in case the child is a simple type.
  47. pFormatString->Align();
  48. SetFormatStringOffset( pFormatString->GetCurrentOffset() );
  49. // Real stuff now
  50. pFormatString->PushFormatChar( FC_PIPE );
  51. // Compute the memory size and buffer size.
  52. // Account for alignment
  53. unsigned long uMemorySize = pChild->GetMemorySize();
  54. unsigned long uBufferSize = pChild->HasAFixedBufferSize()
  55. ? pChild->GetWireSize()
  56. : 0;
  57. // Now the flag byte.
  58. unsigned char FlagByte = unsigned char(pChild->GetWireAlignment() - 1);
  59. if (uMemorySize > 0xffff || uBufferSize > 0xffff)
  60. FlagByte |= FC_BIG_PIPE;
  61. if ( IsObjectPipe() )
  62. FlagByte |= FC_OBJECT_PIPE;
  63. if ( GetRangeAttribute() )
  64. {
  65. FlagByte |= FC_PIPE_HAS_RANGE;
  66. }
  67. pFormatString->PushByte( FlagByte );
  68. // Now the index to the type desc
  69. if ( pChild->IsSimpleType() )
  70. {
  71. pFormatString->PushShortOffset(
  72. ChildOffset - pFormatString->GetCurrentOffset() );
  73. }
  74. else
  75. {
  76. pFormatString->PushShortOffset(
  77. pChild->GetFormatStringOffset() -
  78. pFormatString->GetCurrentOffset() );
  79. }
  80. // Now push the memory size and buffer size.
  81. if (FlagByte & FC_BIG_PIPE)
  82. {
  83. pFormatString->PushLong( uMemorySize);
  84. pFormatString->PushLong( uBufferSize);
  85. }
  86. else
  87. {
  88. pFormatString->PushShort( (short) uMemorySize);
  89. pFormatString->PushShort( (short) uBufferSize);
  90. }
  91. if ( GetRangeAttribute() )
  92. {
  93. // RKK64: TBD support for a range check on hyper.
  94. pFormatString->PushLong( (ulong) GetRangeAttribute()->GetMinExpr()->GetValue() ); // min.
  95. pFormatString->PushLong( (ulong) GetRangeAttribute()->GetMaxExpr()->GetValue() ); // max.
  96. }
  97. SetFormatStringEndOffset( pFormatString->GetCurrentOffset() );
  98. pFormatString->OptimizeFragment( this );
  99. }