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.

263 lines
7.6 KiB

  1. #ifndef __EVNTPARM_H_INCLUDED
  2. #define __EVNTPARM_H_INCLUDED
  3. #include <windows.h>
  4. #include <uicommon.h>
  5. #include "shmemsec.h"
  6. struct CEventParameters
  7. {
  8. public:
  9. GUID EventGUID;
  10. CSimpleStringWide strFullItemName;
  11. CSimpleStringWide strEventDescription;
  12. CSimpleStringWide strDeviceID;
  13. CSimpleStringWide strDeviceDescription;
  14. DWORD dwDeviceType;
  15. ULONG ulEventType;
  16. ULONG ulReserved;
  17. HWND hwndParent;
  18. CSharedMemorySection<HWND> *pWizardSharedMemory;
  19. public:
  20. CEventParameters( const CEventParameters &other )
  21. : EventGUID(other.EventGUID),
  22. strFullItemName(other.strFullItemName),
  23. strDeviceID(other.strDeviceID),
  24. strDeviceDescription(other.strDeviceDescription),
  25. dwDeviceType(other.dwDeviceType),
  26. ulEventType(other.ulEventType),
  27. ulReserved(other.ulReserved),
  28. hwndParent(other.hwndParent),
  29. pWizardSharedMemory(other.pWizardSharedMemory),
  30. strEventDescription(other.strEventDescription)
  31. {
  32. }
  33. CEventParameters &operator=( const CEventParameters &other )
  34. {
  35. if (this != &other)
  36. {
  37. EventGUID = other.EventGUID;
  38. strFullItemName = other.strFullItemName;
  39. strDeviceID = other.strDeviceID;
  40. strDeviceDescription = other.strDeviceDescription;
  41. dwDeviceType = other.dwDeviceType;
  42. ulEventType = other.ulEventType;
  43. ulReserved = other.ulReserved;
  44. hwndParent = other.hwndParent;
  45. pWizardSharedMemory = other.pWizardSharedMemory;
  46. }
  47. return *this;
  48. }
  49. CEventParameters()
  50. : EventGUID(IID_NULL),
  51. dwDeviceType(0),
  52. ulEventType(0),
  53. ulReserved(0),
  54. pWizardSharedMemory(NULL)
  55. {
  56. }
  57. ~CEventParameters()
  58. {
  59. if (pWizardSharedMemory)
  60. {
  61. pWizardSharedMemory = NULL;
  62. }
  63. }
  64. };
  65. class CStiEventData
  66. {
  67. public:
  68. class CStiEventHandler
  69. {
  70. private:
  71. CSimpleStringWide m_strApplicationName;
  72. CSimpleStringWide m_strCommandLine;
  73. public:
  74. CStiEventHandler()
  75. {
  76. }
  77. CStiEventHandler( const CSimpleStringWide &strApplicationName, const CSimpleStringWide &strCommandLine )
  78. : m_strApplicationName(strApplicationName),
  79. m_strCommandLine(strCommandLine)
  80. {
  81. }
  82. CStiEventHandler( const CStiEventHandler &other )
  83. : m_strApplicationName(other.ApplicationName()),
  84. m_strCommandLine(other.CommandLine())
  85. {
  86. }
  87. ~CStiEventHandler()
  88. {
  89. }
  90. CStiEventHandler &operator=( const CStiEventHandler &other )
  91. {
  92. if (this != &other)
  93. {
  94. m_strApplicationName = other.ApplicationName();
  95. m_strCommandLine = other.CommandLine();
  96. }
  97. return *this;
  98. }
  99. bool IsValid() const
  100. {
  101. return (m_strApplicationName.Length() && m_strCommandLine.Length());
  102. }
  103. CSimpleStringWide ApplicationName() const
  104. {
  105. return m_strApplicationName;
  106. }
  107. CSimpleStringWide CommandLine() const
  108. {
  109. return m_strCommandLine;
  110. }
  111. };
  112. typedef CSimpleDynamicArray<CStiEventHandler> CStiEventHandlerArray;
  113. private:
  114. GUID m_guidEvent;
  115. CSimpleStringWide m_strEventDescription;
  116. CSimpleStringWide m_strDeviceId;
  117. CSimpleStringWide m_strDeviceDescription;
  118. DWORD m_dwDeviceType;
  119. ULONG m_ulEventType;
  120. ULONG m_ulReserved;
  121. CStiEventHandlerArray m_EventHandlers;
  122. public:
  123. CStiEventData()
  124. : m_guidEvent(IID_NULL),
  125. m_dwDeviceType(0),
  126. m_ulEventType(0),
  127. m_ulReserved(0)
  128. {
  129. }
  130. CStiEventData( const GUID *pguidEvent,
  131. LPCWSTR pwszEventDescription,
  132. LPCWSTR pwszDeviceId,
  133. LPCWSTR pwszDeviceDescription,
  134. DWORD dwDeviceType,
  135. LPCWSTR pwszFullItemName,
  136. ULONG *pulEventType,
  137. ULONG ulReserved
  138. )
  139. : m_guidEvent(pguidEvent ? *pguidEvent : IID_NULL),
  140. m_strEventDescription(pwszEventDescription),
  141. m_strDeviceId(pwszDeviceId),
  142. m_strDeviceDescription(pwszDeviceDescription),
  143. m_dwDeviceType(dwDeviceType),
  144. m_ulEventType(pulEventType ? *pulEventType : 0),
  145. m_ulReserved(ulReserved)
  146. {
  147. //
  148. // Crack event handlers.
  149. //
  150. // Walk the string until we come to the end, marked by double \0 characters
  151. //
  152. LPCWSTR pwszCurr = pwszFullItemName;
  153. while (pwszCurr && *pwszCurr)
  154. {
  155. //
  156. // Save the application name
  157. //
  158. CSimpleStringWide strApplication = pwszCurr;
  159. //
  160. // Advance to the command line
  161. //
  162. pwszCurr += lstrlen(pwszCurr) + 1;
  163. //
  164. // Save the command line
  165. //
  166. CSimpleStringWide strCommandLine = pwszCurr;
  167. //
  168. // Advance to the next token
  169. //
  170. pwszCurr += lstrlen(pwszCurr) + 1;
  171. //
  172. // If both application and command line are valid strings, add them to the list
  173. //
  174. if (strApplication.Length() && strCommandLine.Length())
  175. {
  176. m_EventHandlers.Append( CStiEventHandler( strApplication, strCommandLine ) );
  177. }
  178. }
  179. }
  180. CStiEventData( const CStiEventData &other )
  181. : m_guidEvent(other.Event()),
  182. m_strEventDescription(other.EventDescription()),
  183. m_strDeviceId(other.DeviceId()),
  184. m_strDeviceDescription(other.DeviceDescription()),
  185. m_dwDeviceType(other.DeviceType()),
  186. m_ulEventType(other.EventType()),
  187. m_ulReserved(other.Reserved()),
  188. m_EventHandlers(other.EventHandlers())
  189. {
  190. }
  191. ~CStiEventData()
  192. {
  193. }
  194. CStiEventData &operator=( const CStiEventData &other )
  195. {
  196. if (this != &other)
  197. {
  198. m_guidEvent = other.Event();
  199. m_strEventDescription = other.EventDescription();
  200. m_strDeviceId = other.DeviceId();
  201. m_strDeviceDescription = other.DeviceDescription();
  202. m_dwDeviceType = other.DeviceType();
  203. m_ulEventType = other.EventType();
  204. m_ulReserved = other.Reserved();
  205. m_EventHandlers = other.EventHandlers();
  206. }
  207. return *this;
  208. }
  209. GUID Event() const
  210. {
  211. return m_guidEvent;
  212. }
  213. CSimpleStringWide EventDescription() const
  214. {
  215. return m_strEventDescription;
  216. }
  217. CSimpleStringWide DeviceId() const
  218. {
  219. return m_strDeviceId;
  220. }
  221. CSimpleStringWide DeviceDescription() const
  222. {
  223. return m_strDeviceDescription;
  224. }
  225. DWORD DeviceType() const
  226. {
  227. return m_dwDeviceType;
  228. }
  229. ULONG EventType() const
  230. {
  231. return m_ulEventType;
  232. }
  233. ULONG Reserved() const
  234. {
  235. return m_ulReserved;
  236. }
  237. const CStiEventHandlerArray &EventHandlers() const
  238. {
  239. return m_EventHandlers;
  240. }
  241. };
  242. #endif __EVNTPARM_H_INCLUDED