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.

193 lines
5.5 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1993-2000 Microsoft Corporation
  3. Module Name:
  4. btndr.hxx
  5. Abstract:
  6. Contains routines for the generation of the new NDR format strings for
  7. base types, and the new NDR marshalling and unmarshalling calls.
  8. Notes:
  9. History:
  10. DKays Oct-1993 Created.
  11. ----------------------------------------------------------------------------*/
  12. #include "becls.hxx"
  13. #pragma hdrstop
  14. extern CMD_ARG * pCommand;
  15. void
  16. CG_BASETYPE::GenNdrFormat( CCB * pCCB )
  17. /*++
  18. Routine Description :
  19. Generates the format string description for a simple type.
  20. Arguments :
  21. pCCB - pointer to the code control block.
  22. --*/
  23. {
  24. FORMAT_STRING * pFormatString = pCCB->GetFormatString();
  25. FORMAT_CHARACTER fc = GetFormatChar();
  26. // Generate the base type's description always.
  27. if ( GetRangeAttribute() )
  28. {
  29. if ( GetFormatStringOffset() == -1 )
  30. {
  31. SetFormatStringOffset( pFormatString->GetCurrentOffset() );
  32. GenRangeFormatString(
  33. pFormatString,
  34. GetRangeAttribute(),
  35. 0, // flags
  36. fc
  37. );
  38. }
  39. }
  40. else
  41. {
  42. pFormatString->PushFormatChar( fc );
  43. }
  44. }
  45. void CG_BASETYPE::GetNdrParamAttributes(
  46. CCB * pCCB,
  47. PARAM_ATTRIBUTES *attributes )
  48. {
  49. CG_PARAM *pParam = (CG_PARAM *) pCCB->GetLastPlaceholderClass();
  50. attributes->MustSize = 0;
  51. attributes->MustFree = 0;
  52. attributes->IsPipe = 0;
  53. attributes->IsIn = (unsigned short) pParam->IsParamIn();
  54. attributes->IsOut = (unsigned short) pParam->IsParamOut();
  55. attributes->IsReturn = (pParam->GetCGID() == ID_CG_RETURN);
  56. attributes->IsBasetype = ( GetRangeAttribute() == 0 );
  57. attributes->IsByValue = ( GetRangeAttribute() != 0 );
  58. attributes->IsSimpleRef = 0;
  59. attributes->IsDontCallFreeInst = 0;
  60. attributes->ServerAllocSize = 0;
  61. attributes->SaveForAsyncFinish = pParam->IsSaveForAsyncFinish();
  62. attributes->IsPartialIgnore = pParam->IsParamPartialIgnore();
  63. attributes->IsForceAllocate = 0;
  64. }
  65. void
  66. CG_BASETYPE::GenNdrParamDescription( CCB * pCCB )
  67. {
  68. FORMAT_STRING * pProcFormatString;
  69. PARAM_ATTRIBUTES Attributes;
  70. CG_PARAM *pParam;
  71. pProcFormatString = pCCB->GetProcFormatString();
  72. pParam = (CG_PARAM *) pCCB->GetLastPlaceholderClass();
  73. GetNdrParamAttributes( pCCB, &Attributes );
  74. // Attributes.
  75. pProcFormatString->PushParamFlagsShort( *((short *)&Attributes) );
  76. // Stack offset as number of ints.
  77. pProcFormatString->PushUShortStackOffsetOrSize(
  78. pParam->GetStackOffset( pCCB, I386_STACK_SIZING ) );
  79. if ( GetRangeAttribute() )
  80. {
  81. pProcFormatString->PushShort( GetFormatStringOffset() );
  82. }
  83. else
  84. {
  85. pProcFormatString->PushFormatChar( GetFormatChar() );
  86. pProcFormatString->PushByte( 0 );
  87. }
  88. }
  89. long
  90. CG_BASETYPE::FixedBufferSize( CCB * )
  91. {
  92. long WireSize;
  93. WireSize = GetWireSize();
  94. //
  95. // Return twice the size of the basetype on the wire to cover alignment
  96. // padding, plus the difference of it's size with a long if it is smaller
  97. // than a long. The second value allows us to do a slightly optimized
  98. // marshall/unmarshall of basetypes in the interpreter.
  99. //
  100. return (long)((WireSize * 2) +
  101. ((WireSize < sizeof(long)) ? (sizeof(long) - WireSize) : 0));
  102. }
  103. void
  104. GenRangeFormatString(
  105. FORMAT_STRING* pFormatString,
  106. node_range_attr* pRangeAttr,
  107. unsigned char uFlags,
  108. FORMAT_CHARACTER formatChar
  109. )
  110. {
  111. if ( pRangeAttr )
  112. {
  113. pFormatString->PushFormatChar( FC_RANGE );
  114. pFormatString->PushByte( ( uFlags & 0xF0 ) | unsigned char( formatChar & 0x0F ) ); // flags:type
  115. // RKK64: TBD: full range on hypers
  116. pFormatString->PushLong( (ulong) pRangeAttr->GetMinExpr()->GetValue() ); // min.
  117. pFormatString->PushLong( (ulong) pRangeAttr->GetMaxExpr()->GetValue() ); // max.
  118. }
  119. }
  120. void
  121. CG_CS_TAG::GenNdrFormat( CCB * pCCB )
  122. /*++
  123. Routine Description :
  124. Generates the format string description for a cs_tag type.
  125. Arguments :
  126. pCCB - pointer to the code control block.
  127. Notes :
  128. FC_CS_TAG
  129. ndr_cs_tag_flags<1> // Flags (this is cs_stag, etc)
  130. index_of_tag_routine<2> // The tag routine index
  131. --*/
  132. {
  133. FORMAT_STRING *pFormatString = pCCB->GetFormatString();
  134. CG_PROC *pProc = (CG_PROC *) pCCB->GetCGNodeContext();
  135. node_proc *pTagRoutine;
  136. short index;
  137. SetFormatStringOffset( pFormatString->GetCurrentOffset() );
  138. pTagRoutine = pProc->GetCSTagRoutine();
  139. if ( pTagRoutine )
  140. {
  141. index = pCCB->GetCsTagRoutineList().Insert( pTagRoutine->GetSymName() );
  142. MIDL_ASSERT( index != NDR_INVALID_TAG_ROUTINE_INDEX );
  143. }
  144. else
  145. {
  146. index = NDR_INVALID_TAG_ROUTINE_INDEX;
  147. }
  148. pFormatString->PushFormatChar( FC_CS_TAG );
  149. pFormatString->PushByte( * (unsigned char * ) & Flags );
  150. pFormatString->PushShort( index );
  151. }