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.

209 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. vststmsgclient.hxx
  5. Abstract:
  6. Declaration of test message classes for the client along with
  7. shared structs, enums and defines which both the client and
  8. the server use.
  9. Brian Berkowitz [brianb] 05/22/2000
  10. TBD:
  11. Revision History:
  12. Name Date Comments
  13. brianb 05/22/2000 Created
  14. ssteiner 06/07/2000 Split client and server portions into
  15. two files. vststmsg.hxx contains
  16. the server portion.
  17. --*/
  18. #ifndef _VSTSTMSGCLIENT_H_
  19. #define _VSTSTMSGCLIENT_H_
  20. //
  21. // Types shared between client and server
  22. //
  23. const LPCWSTR s_wszPipeName = L"\\\\.\\pipe\\VSTSTPIPE";
  24. void InitMsgTypes();
  25. // types of pointers recognized by marshaling engine
  26. typedef enum VSTST_VARPTR_TYPE
  27. {
  28. VSTST_VPT_UNDEFINED = 0,
  29. VSTST_VPT_BYTE, // uninterpreted byte string
  30. VSTST_VPT_ANSI, // ansi string
  31. VSTST_VPT_UNICODE, // unicode string
  32. VSTST_VPT_MAXPOINTERTYPE
  33. };
  34. typedef enum VSTST_MSG_TYPE
  35. {
  36. VSTST_MT_UNDEFINED = 0,
  37. VSTST_MT_TEXT, // message containing text
  38. VSTST_MT_IMMEDIATETEXT, // message containing text
  39. VSTST_MT_FAILURE, // generic failure message
  40. VSTST_MT_UNEXPECTEDEXCEPTION, // unexpected exception message
  41. VSTST_MT_OPERATIONFAILURE, // failed hresult received
  42. VSTST_MT_SUCCESS, // sucessful result
  43. VSTST_MT_MAXMSGTYPE
  44. };
  45. // priority describing how messages are handled
  46. typedef enum VSTST_MSG_PRIORITY
  47. {
  48. VSTST_MP_QUEUED,
  49. VSTST_MP_IMMEDIATE,
  50. VSTST_MP_MAXPRIORITY
  51. };
  52. // header on all messages sent to the test controller
  53. typedef struct _VSTST_MSG_HDR
  54. {
  55. LONGLONG processId; // id of process sending the message
  56. LONGLONG sequence; // sequence number for message
  57. VSTST_MSG_TYPE type; // message type
  58. time_t time; // time message was sent
  59. size_t cbMsg; // total size of message in bytes
  60. struct _VSTST_MSG_HDR *pmsgNext; // next message on queue
  61. BYTE rgb[1]; // first byte of message
  62. } VSTST_MSG_HDR;
  63. // dispatch function per message
  64. typedef void (*VSTST_MSG_HANDLER)(VSTST_MSG_HDR *phdr, VOID *pPrivateData);
  65. // table describing how messages are handled
  66. typedef struct _VSTST_MSG_TYPE_TABLE
  67. {
  68. size_t cbFixed; // size of fixed length portion of message
  69. UINT cVarPtr; // # of variable length pointers
  70. VSTST_MSG_PRIORITY priority; // priority of message
  71. VSTST_MSG_HANDLER pfnHandler; // function to handle messpage
  72. BYTE pointerTypes[8]; // up to 16 pointer types
  73. } VSTST_MSG_TYPE_TABLE;
  74. extern VSTST_MSG_TYPE_TABLE g_msgTypes[VSTST_MT_MAXMSGTYPE];
  75. typedef struct _VSTST_TEXTMSG
  76. {
  77. LPCSTR pch;
  78. } VSTST_TEXTMSG;
  79. typedef struct _VSTST_UNEXPECTEDEXCEPTIONMSG
  80. {
  81. LPCSTR szFailedRoutine;
  82. } VSTST_UNEXPECTEDEXCEPTIONMSG;
  83. typedef struct _VSTST_OPERATIONFAILUREMSG
  84. {
  85. HRESULT hr;
  86. LPCSTR szFailedOperation;
  87. } VSTST_OPERATIONFAILUREMSG;
  88. typedef struct _VSTST_FAILUREMSG
  89. {
  90. LPCSTR szFailure;
  91. } VSTST_FAILUREMSG;
  92. typedef struct _VSTST_SUCCESSMSG
  93. {
  94. LPCSTR szMsg;
  95. } VSTST_SUCCESSMSG;
  96. //
  97. // Types specific to the client
  98. //
  99. // class for sending messages from the client to the server
  100. class CVsTstClientMsg
  101. {
  102. public:
  103. // constructor
  104. CVsTstClientMsg();
  105. // destructor
  106. ~CVsTstClientMsg();
  107. // initialize message processing
  108. HRESULT Init
  109. (
  110. LONGLONG processId,
  111. UINT cbMaxMsg,
  112. bool bIgnorePipeCreationFailure
  113. );
  114. // send a message
  115. HRESULT SendMessage(VSTST_MSG_TYPE type, void *pv);
  116. private:
  117. // critical section protecting sending messages
  118. CComCriticalSection m_cs;
  119. // whether crtical section is initailized
  120. bool m_bcsInitialized;
  121. // process id used in messages
  122. LONGLONG m_processId;
  123. // maximum message length
  124. UINT m_cbMaxMsgLength;
  125. // message
  126. BYTE *m_rgbMsg;
  127. // handle to pipe
  128. HANDLE m_hPipe;
  129. // don't try writing to pipe because it doesn't exist
  130. bool m_bSkipWrites;
  131. // sequence number for queued messages
  132. LONGLONG m_seqQueued;
  133. // sequence number for immediate messages
  134. LONGLONG m_seqImmediate;
  135. };
  136. // generic logging functions for client tests
  137. class CVsTstClientLogger
  138. {
  139. public:
  140. CVsTstClientLogger() :
  141. m_pClient(NULL)
  142. {
  143. }
  144. void SetClientMsg(CVsTstClientMsg *pClient)
  145. {
  146. m_pClient = pClient;
  147. }
  148. void LogFailure(LPCSTR szFailure);
  149. void LogUnexpectedException(LPCSTR szRoutine);
  150. void LogSuccess(LPCSTR szMsg);
  151. void LogMessage(LPCSTR szMsg);
  152. void ValidateResult(HRESULT hr, LPCSTR szOperation);
  153. private:
  154. CVsTstClientMsg *m_pClient;
  155. };
  156. #endif // _VSTSTMSGCLIENT_H_