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.

150 lines
3.2 KiB

  1. //=============================================================================
  2. //
  3. // MODULE: ASN1Unit.cxx
  4. //
  5. // Description:
  6. //
  7. // Implementation of ASN.1 "unit" parsing logic
  8. //
  9. // Modification History
  10. //
  11. // Mark Pustilnik Date: 06/08/02 - created
  12. //
  13. //=============================================================================
  14. #include "ASN1Parser.hxx"
  15. //
  16. // Parses the unit through calling into the derived class' GetValue() method
  17. // then uses Display() to show it in Netmon
  18. //
  19. DWORD
  20. ASN1ParserUnit::Parse(
  21. IN OUT ASN1FRAME * Frame
  22. )
  23. {
  24. DWORD dw;
  25. ASN1VALUE Value;
  26. ASN1FRAME FrameIn = *Frame;
  27. dw = VerifyAndSkipHeader( Frame );
  28. if ( dw != ERROR_SUCCESS )
  29. {
  30. goto Cleanup;
  31. }
  32. dw = GetValue(
  33. Frame,
  34. &Value
  35. );
  36. if ( dw != ERROR_SUCCESS )
  37. {
  38. goto Cleanup;
  39. }
  40. //
  41. // If a summary property is present, display it now
  42. // and indent the display for value property
  43. //
  44. if ( m_hPropertySummary != NULL )
  45. {
  46. dw = Display(
  47. Frame,
  48. &Value,
  49. m_hPropertySummary,
  50. 0
  51. );
  52. if ( dw != ERROR_SUCCESS )
  53. {
  54. goto Cleanup;
  55. }
  56. Frame->Level += 1;
  57. }
  58. //
  59. // If an object has a valid property value handle, it is displayable
  60. // Otherwise, it should have a value collector class
  61. //
  62. if ( m_hPropertyValue != NULL )
  63. {
  64. dw = Display(
  65. Frame,
  66. &Value,
  67. m_hPropertyValue,
  68. m_IFlags
  69. );
  70. }
  71. //
  72. // Octet values might come out with a subparser attached, in which case
  73. // this subparser should be invoked right now
  74. //
  75. if ( dw == ERROR_SUCCESS &&
  76. Value.ut == utOctetString &&
  77. Value.SubParser != NULL )
  78. {
  79. ASN1FRAME FrameHere;
  80. FrameHere.Address = Value.Address;
  81. FrameHere.hFrame = Frame->hFrame;
  82. FrameHere.Level = Frame->Level + 1;
  83. dw = Value.SubParser->Parse( &FrameHere );
  84. }
  85. if ( m_hPropertySummary != NULL )
  86. {
  87. Frame->Level -= 1;
  88. }
  89. if ( dw != ERROR_SUCCESS )
  90. {
  91. goto Cleanup;
  92. }
  93. //
  94. // See if the value of this unit modifies the parsing done to some other
  95. // unit, and if so, inform the modifyee of the modifier value
  96. //
  97. if ( QueryModifyee() != NULL )
  98. {
  99. dw = QueryModifyee()->SetModifier( &Value );
  100. if ( dw != ERROR_SUCCESS )
  101. {
  102. goto Cleanup;
  103. }
  104. }
  105. Cleanup:
  106. if ( QueryValueCollector() != NULL &&
  107. ( dw == ERROR_SUCCESS ||
  108. ( dw == ERROR_INVALID_USER_BUFFER && IsOptional())))
  109. {
  110. DWORD dw2;
  111. dw2 = QueryValueCollector()->CollectValue(( dw == ERROR_SUCCESS ) ? &Value : NULL );
  112. if ( dw == ERROR_SUCCESS &&
  113. dw2 != ERROR_SUCCESS )
  114. {
  115. dw = dw2;
  116. }
  117. }
  118. if ( dw != ERROR_SUCCESS )
  119. {
  120. *Frame = FrameIn;
  121. }
  122. return dw;
  123. }