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.

136 lines
4.1 KiB

  1. #ifndef _PACKET_H_
  2. #define _PACKET_H_
  3. #ifdef __cplusplus
  4. // Packet Manager for Code Downloader
  5. // A Packet is a unit of work that takes time eg. trust verifcation of a piece
  6. // setup of a piece or INF processing of one piece. To be able to have the
  7. // client be responsive with UI and abort capabilty we need to split out work
  8. // into as small units as possible and queue up these CDLPackets
  9. // CDLPackets get run on a timer per thread.
  10. class CCodeDownload;
  11. class CDownload;
  12. #define CPP_SIGNATURE 0x050395
  13. #define PROCESS_PACKET_INTERVAL 200 // 1/5 of a second
  14. typedef enum {
  15. PACKET_PRIORITY_NORMAL = 0,
  16. PACKET_PRIORITY_HIGH = 1
  17. } PACKET_PRIORITY;
  18. // use 0xffff0000 for storing msg types for different objs
  19. // if you want to add a msg for a new obj, make a new msg type for that
  20. // obj and then add the obj into the PACKETOBJ union and
  21. // write a packet constrcutor for that obj
  22. #define MSG_CDOWNLOAD_OBJ 0x00000000
  23. #define MSG_CCODEDOWNLOAD_OBJ 0x00010000
  24. #define GETMSGTYPE(msg) (msg & 0xffff0000)
  25. #define MAKEMSG(mtype,n) (mtype|n)
  26. // msgs for CDOWNLOAD
  27. #define CODE_DOWNLOAD_TRUST_PIECE MAKEMSG(MSG_CDOWNLOAD_OBJ, 1)
  28. #define CODE_DOWNLOAD_PROCESS_PIECE MAKEMSG(MSG_CDOWNLOAD_OBJ, 2)
  29. // msgs for CCODEDOWNLOAD
  30. #define CODE_DOWNLOAD_PROCESS_INF MAKEMSG(MSG_CCODEDOWNLOAD_OBJ, 1)
  31. #define CODE_DOWNLOAD_SETUP MAKEMSG(MSG_CCODEDOWNLOAD_OBJ, 2)
  32. #define CODE_DOWNLOAD_WAIT_FOR_EXE MAKEMSG(MSG_CCODEDOWNLOAD_OBJ, 3)
  33. typedef union {
  34. CCodeDownload* pcdl;
  35. CDownload* pdl;
  36. } PACKETOBJ;
  37. class CCDLPacket;
  38. class CCDLPacketMgr {
  39. public:
  40. CCDLPacketMgr();
  41. ~CCDLPacketMgr();
  42. HRESULT TimeSlice();
  43. UINT_PTR GetTimer() const {return m_Timer;}
  44. HRESULT Post(CCDLPacket *pPkt, ULONG pri = PACKET_PRIORITY_NORMAL);
  45. HRESULT AbortPackets(CDownload *pdl);
  46. HRESULT Kill(CCDLPacket *pPkt);
  47. private:
  48. UINT_PTR m_Timer;
  49. //BUGBUG: if we want priority classes then we soudl really have
  50. // multiple lists!
  51. CList<CCDLPacket *,CCDLPacket *>
  52. m_PacketList; // linked list of pointers to
  53. // CCDLPacket objects ongoing on
  54. // this thread.A CDLPacket is a unit
  55. // of work that takes time eg.
  56. // trust verifcation of a piece
  57. // setup of a piece or INF
  58. // processing of one piece.
  59. // To be able to have the
  60. // client be responsive with UI
  61. // and abort capabilty we need
  62. // to split out work into as
  63. // small units as possible
  64. // and queue up these CDLPackets
  65. // CDLPackets get run on a timer per
  66. // thread.
  67. };
  68. class CCDLPacket {
  69. public:
  70. CCDLPacket(DWORD type, CCodeDownload *pcdl, DWORD_PTR param);
  71. CCDLPacket(DWORD type, CDownload *pcdl, DWORD_PTR param);
  72. ~CCDLPacket();
  73. HRESULT Post(ULONG pri = PACKET_PRIORITY_NORMAL);
  74. HRESULT Kill();
  75. HRESULT Process();
  76. CDownload* GetDownload()
  77. {
  78. if (GETMSGTYPE(m_type) == MSG_CDOWNLOAD_OBJ)
  79. return m_obj.pdl;
  80. else
  81. return NULL;
  82. }
  83. CCodeDownload* GetCodeDownload()
  84. {
  85. if (GETMSGTYPE(m_type) == MSG_CCODEDOWNLOAD_OBJ)
  86. return m_obj.pcdl;
  87. else
  88. return NULL;
  89. }
  90. private:
  91. DWORD m_signature;
  92. DWORD_PTR m_param;
  93. DWORD m_type;
  94. PACKETOBJ m_obj;
  95. };
  96. #endif
  97. #endif // _PACKET_H_