Source code of Windows XP (NT5)
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.

99 lines
3.1 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1998-2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: PackBuff.h
  6. * Content: Packed Buffers
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 01/11/00 mjn Created
  12. * 06/15/2000 rmt Added func to add string to packbuffer
  13. * 02/06/2001 rodtoll WINBUG #293871: DPLOBBY8: [IA64] Lobby launching a 64-bit
  14. * app from 64-bit lobby launcher crashes with unaligned memory error.
  15. *
  16. ***************************************************************************/
  17. #ifndef __PACK_BUFF_H__
  18. #define __PACK_BUFF_H__
  19. //**********************************************************************
  20. // Constant definitions
  21. //**********************************************************************
  22. //**********************************************************************
  23. // Macro definitions
  24. //**********************************************************************
  25. //**********************************************************************
  26. // Structure definitions
  27. //**********************************************************************
  28. //**********************************************************************
  29. // Variable definitions
  30. //**********************************************************************
  31. //**********************************************************************
  32. // Function prototypes
  33. //**********************************************************************
  34. //**********************************************************************
  35. // Class prototypes
  36. //**********************************************************************
  37. // class for packed buffer
  38. class CPackedBuffer
  39. {
  40. public:
  41. CPackedBuffer() { }; // Constructor
  42. ~CPackedBuffer() { }; // Destructor
  43. void Initialize( void *const pvBuffer,
  44. const DWORD dwBufferSize,
  45. const BOOL fAlignedRequired = FALSE );
  46. HRESULT AddToFront( const void *const pvBuffer,
  47. const DWORD dwBufferSize, const BOOL fAlignedRequired = FALSE );
  48. HRESULT AddToBack( const void *const pvBuffer,
  49. const DWORD dwBufferSize,
  50. const BOOL fAlignedRequired = FALSE );
  51. PVOID GetStartAddress( void ) { return m_pStart; };
  52. HRESULT AddWCHARStringToBack( const wchar_t * const pwszString, const BOOL fAlignedRequired = FALSE );
  53. HRESULT AddStringToBack( const char *const pszString );
  54. PVOID GetHeadAddress( void ) const { return( m_pHead ); }
  55. PVOID GetTailAddress( void ) const { return( m_pTail ); }
  56. DWORD GetHeadOffset( void ) const
  57. {
  58. return( (DWORD)(m_pHead - m_pStart) );
  59. }
  60. DWORD GetTailOffset( void ) const
  61. {
  62. return( (DWORD)(m_pTail - m_pStart) );
  63. }
  64. DWORD GetSpaceRemaining( void ) const { return( m_dwRemaining ); }
  65. DWORD GetSizeRequired( void ) const { return( m_dwRequired ); }
  66. private:
  67. BYTE *m_pStart; // Start of the buffer
  68. BYTE *m_pHead; // Pointer to head of free buffer
  69. BYTE *m_pTail; // Pointer to tail of free buffer
  70. DWORD m_dwRemaining; // bytes remaining in buffer
  71. DWORD m_dwRequired; // bytes required so far
  72. BOOL m_bBufferTooSmall; // buffer has run out of space
  73. };
  74. #endif // __PACK_BUFF_H__