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.

79 lines
1.6 KiB

  1. //=============================================================================
  2. //
  3. // MODULE: ASN1Boolean.cxx
  4. //
  5. // Description:
  6. //
  7. // Implementation of ASN.1 boolean parsing logic
  8. //
  9. // Modification History
  10. //
  11. // Mark Pustilnik Date: 06/08/02 - created
  12. //
  13. //=============================================================================
  14. #include "ASN1Parser.hxx"
  15. //
  16. // Retrieve the value of an ASN.1-encoded Boolean
  17. //
  18. DWORD
  19. ASN1ParserBoolean::GetValue(
  20. IN OUT ASN1FRAME * Frame,
  21. OUT ASN1VALUE * Value
  22. )
  23. {
  24. DWORD dw;
  25. ASN1FRAME FrameIn = *Frame;
  26. DWORD DLength = DataLength( Frame );
  27. ULPBYTE Address = Frame->Address;
  28. if ( *Frame->Address != BuildDescriptor(
  29. ctUniversal,
  30. pcPrimitive,
  31. (BYTE)utBoolean ))
  32. {
  33. dw = ERROR_INVALID_USER_BUFFER;
  34. goto Cleanup;
  35. }
  36. //
  37. // Skip over the the descriptor
  38. //
  39. Address++;
  40. //
  41. // Skip over the length header
  42. //
  43. Address += HeaderLength( Address );
  44. Value->Address = Address;
  45. Value->Length = DLength;
  46. Value->ut = utBoolean;
  47. Value->dw = 0;
  48. for ( ULONG i = 0; i < DLength; i++ )
  49. {
  50. Value->dw <<= 8;
  51. Value->dw += *Address;
  52. Address++;
  53. }
  54. Value->b = ( Value->dw != 0 );
  55. Frame->Address = Address;
  56. dw = ERROR_SUCCESS;
  57. Cleanup:
  58. if ( dw != ERROR_SUCCESS )
  59. {
  60. *Frame = FrameIn;
  61. }
  62. return dw;
  63. }