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.

76 lines
2.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994.
  5. //
  6. // File: transmit.h
  7. //
  8. // Contents: Function prototypes for STGMEDIUM marshalling.
  9. //
  10. // Functions: STGMEDIUM_to_xmit
  11. // STGMEDIUM_from_xmit
  12. // STGMEDIUM_free_inst
  13. //
  14. // History: May-10-94 ShannonC Created
  15. // May-10-95 Ryszardk wire_marshal changes
  16. // Dec-14-00 JohnDoty Created as a place to put all the
  17. // C++ specific stuff for marshalling.
  18. //
  19. //--------------------------------------------------------------------------
  20. #pragma once
  21. #include "transmit.h"
  22. //+-------------------------------------------------------------------------
  23. //
  24. // class: CUserMarshalInfo
  25. //
  26. // purpose: Simple wrapper for NdrGetUserMarshalInfo.
  27. //
  28. // history: 11-Aug-99 JohnStra Created
  29. //
  30. //+-------------------------------------------------------------------------
  31. class CUserMarshalInfo
  32. {
  33. public:
  34. CUserMarshalInfo( ULONG* pFlags, UCHAR* pBuffer, ULONG Level = 1 )
  35. {
  36. // NdrGetUserMarshalInfo may fail. It shouldn't, but if it does we
  37. // must gracefully handle it.
  38. _RpcStatus = NdrGetUserMarshalInfo( pFlags, Level, &_MarshalInfo );
  39. _pSuppliedBuffer = pBuffer;
  40. if (RPC_S_OK == _RpcStatus)
  41. {
  42. if ( _pSuppliedBuffer < (UCHAR*)_MarshalInfo.Level1.Buffer ||
  43. _pSuppliedBuffer > ((UCHAR*)_MarshalInfo.Level1.Buffer + _MarshalInfo.Level1.BufferSize) )
  44. RpcRaiseException( ERROR_INVALID_USER_BUFFER );
  45. }
  46. }
  47. inline UCHAR* GetBuffer()
  48. {
  49. return( _pSuppliedBuffer );
  50. }
  51. inline ULONG_PTR GetBufferSize()
  52. {
  53. return( (RPC_S_OK == _RpcStatus) ?
  54. (ULONG_PTR) (_MarshalInfo.Level1.BufferSize - (_pSuppliedBuffer - (UCHAR*)_MarshalInfo.Level1.Buffer)) :
  55. (ULONG_PTR) 0x7FFFFFFF );
  56. }
  57. inline IRpcChannelBuffer* GetRpcChannelBuffer()
  58. {
  59. return( (RPC_S_OK == _RpcStatus) ?
  60. _MarshalInfo.Level1.pRpcChannelBuffer : NULL );
  61. }
  62. private:
  63. RPC_STATUS _RpcStatus;
  64. UCHAR* _pSuppliedBuffer;
  65. NDR_USER_MARSHAL_INFO _MarshalInfo;
  66. };