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.

107 lines
2.8 KiB

4 years ago
  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1993 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. pFormatString->PushFormatChar( fc );
  28. if (FC_BLKHOLE == fc)
  29. {
  30. pFormatString->PushByte( BLKHOLE_BASETYPE ); // flags
  31. pFormatString->PushShort( (short) -1 ); // Reserved
  32. }
  33. }
  34. void
  35. CG_BASETYPE::GenNdrParamDescription( CCB * pCCB )
  36. {
  37. FORMAT_STRING * pProcFormatString;
  38. CG_PARAM * pParam;
  39. PARAM_ATTRIBUTES Attributes;
  40. pProcFormatString = pCCB->GetProcFormatString();
  41. pParam = (CG_PARAM *) pCCB->GetLastPlaceholderClass();
  42. Attributes.MustSize = 0;
  43. Attributes.MustFree = 0;
  44. Attributes.IsPipe = 0;
  45. Attributes.IsIn = pParam->IsParamIn();
  46. Attributes.IsOut = pParam->IsParamOut();
  47. Attributes.IsReturn = (pParam->GetCGID() == ID_CG_RETURN);
  48. Attributes.IsBasetype = 1;
  49. Attributes.IsByValue = 0;
  50. Attributes.IsSimpleRef = 0;
  51. Attributes.IsDontCallFreeInst = 0;
  52. Attributes.ServerAllocSize = 0;
  53. Attributes.Unused = 0;
  54. // Attributes.
  55. pProcFormatString->PushShort( *((short *)&Attributes) );
  56. // Stack offset as number of ints.
  57. pProcFormatString->PushShortStackOffset(
  58. pParam->GetStackOffset( pCCB, I386_STACK_SIZING ),
  59. pParam->GetStackOffset( pCCB, ALPHA_STACK_SIZING ),
  60. pParam->GetStackOffset( pCCB, MIPS_STACK_SIZING ),
  61. pParam->GetStackOffset( pCCB, PPC_STACK_SIZING ),
  62. pParam->GetStackOffset( pCCB, MAC_STACK_SIZING ) );
  63. pProcFormatString->PushFormatChar( GetFormatChar() );
  64. pProcFormatString->PushByte( 0 );
  65. }
  66. long
  67. CG_BASETYPE::FixedBufferSize( CCB * pCCB )
  68. {
  69. long WireSize;
  70. WireSize = GetWireSize();
  71. //
  72. // Return twice the size of the basetype on the wire to cover alignment
  73. // padding, plus the difference of it's size with a long if it is smaller
  74. // than a long. The second value allows us to do a slightly optimized
  75. // marshall/unmarshall of basetypes in the interpreter.
  76. //
  77. return (WireSize * 2) +
  78. ((WireSize < sizeof(long)) ? (sizeof(long) - WireSize) : 0);
  79. }