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.

111 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name :
  4. exchnge.h
  5. Abstract:
  6. Defines the objects which track communication transactions with
  7. the client
  8. Revision History:
  9. --*/
  10. #pragma once
  11. #include <midatlax.h>
  12. typedef enum {
  13. demsStopped,
  14. demsStarted
  15. } DrExchangeManagerState;
  16. class DrSession;
  17. class DrExchangeManager : public TopObj, public ISessionPacketReceiver,
  18. ISessionPacketSender
  19. {
  20. private:
  21. PRX_MID_ATLAS _RxMidAtlas;
  22. DrExchangeManagerState _demsState;
  23. DrSession *_Session;
  24. static VOID DestroyAtlasCallback(DrExchange *Exchange);
  25. NTSTATUS OnDeviceIoCompletion(PRDPDR_HEADER RdpdrHeader, ULONG cbPacket,
  26. BOOL *DoDefaultRead);
  27. public:
  28. BOOL Start();
  29. VOID Stop();
  30. DrExchangeManager();
  31. BOOL Initialize(DrSession *Session);
  32. VOID Uninitialize();
  33. BOOL CreateExchange(IExchangeUser *ExchangeUser,
  34. PVOID Context, SmartPtr<DrExchange> &Exchange);
  35. NTSTATUS StartExchange(SmartPtr<DrExchange> &Exchange,
  36. class IExchangeUser *ExchangeUser, PVOID Buffer, ULONG Length,
  37. BOOL LowPrioSend = FALSE);
  38. BOOL Find(USHORT Mid, SmartPtr<DrExchange> &ExchangeFound);
  39. VOID Discard(SmartPtr<DrExchange> &Exchange);
  40. BOOL ReadMore(ULONG cbSaveData, ULONG cbWantData = 0);
  41. //
  42. // ISessionPacketHandler methods
  43. //
  44. virtual BOOL RecognizePacket(PRDPDR_HEADER RdpdrHeader);
  45. virtual NTSTATUS HandlePacket(PRDPDR_HEADER RdpdrHeader, ULONG Length,
  46. BOOL *DoDefaultRead);
  47. //
  48. // ISessionPacketSender methods
  49. //
  50. virtual NTSTATUS SendCompleted(PVOID Context,
  51. PIO_STATUS_BLOCK IoStatusBlock);
  52. };
  53. //
  54. // This DrExchange is more like a structure than a class, because the work
  55. // is really done in DrExchangeManager. It's set up this way because
  56. // the work often needs to happen in a SpinLock, and there should be no
  57. // messing around time wise while we've got the SpinLock, not even a
  58. // extraneous function call.
  59. //
  60. // I've left it a class so I can hide the constructor and destructor
  61. //
  62. class DrExchange : public RefCount
  63. {
  64. friend class DrExchangeManager;
  65. private:
  66. DrExchangeManager *_ExchangeManager;
  67. DrExchange(DrExchangeManager *ExchangeManager,
  68. IExchangeUser *ExchangeUser, PVOID Context);
  69. public:
  70. virtual ~DrExchange();
  71. //
  72. // These are used by ExchangeManager and the user of the exchange
  73. //
  74. PVOID _Context;
  75. IExchangeUser *_ExchangeUser;
  76. USHORT _Mid;
  77. #define DREXCHANGE_SUBTAG 'xErD'
  78. //
  79. // Memory Management Operators
  80. //
  81. inline void *__cdecl operator new(size_t sz)
  82. {
  83. return DRALLOCATEPOOL(NonPagedPool, sz, DREXCHANGE_SUBTAG);
  84. }
  85. inline void __cdecl operator delete(void *ptr)
  86. {
  87. DRFREEPOOL(ptr);
  88. }
  89. };