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.

335 lines
11 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2002 Microsoft Corporation. All rights reserved.
  3. // Copyright (c) 2002 OSR Open Systems Resources, Inc.
  4. //
  5. // ProviderControlGUIDDlg.cpp : implementation file
  6. //////////////////////////////////////////////////////////////////////////////
  7. #include "stdafx.h"
  8. #include <tchar.h>
  9. #include <wmistr.h>
  10. #include <initguid.h>
  11. extern "C" {
  12. #include <evntrace.h>
  13. }
  14. #include <traceprt.h>
  15. #include "TraceView.h"
  16. #include "LogSession.h"
  17. #include "DisplayDlg.h"
  18. #include "utils.h"
  19. #include "ProviderControlGUIDDlg.h"
  20. // CProviderControlGuidDlg dialog
  21. IMPLEMENT_DYNAMIC(CProviderControlGuidDlg, CDialog)
  22. CProviderControlGuidDlg::CProviderControlGuidDlg(CWnd* pParent, CTraceSession *pTraceSession)
  23. : CDialog(CProviderControlGuidDlg::IDD, pParent)
  24. {
  25. m_pTraceSession = pTraceSession;
  26. }
  27. CProviderControlGuidDlg::~CProviderControlGuidDlg()
  28. {
  29. }
  30. int CProviderControlGuidDlg::OnInitDialog()
  31. {
  32. int ret;
  33. ret = CDialog::OnInitDialog();
  34. //
  35. // Default to the PDB radio button being selected
  36. //
  37. CheckRadioButton(IDC_PDB_SELECT_RADIO,
  38. IDC_MANUAL_SELECT_RADIO,
  39. IDC_PDB_SELECT_RADIO);
  40. //
  41. // Enable PDB edit box and browse button
  42. //
  43. m_pdbFileName.EnableWindow(TRUE);
  44. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(TRUE);
  45. //
  46. // Disable all controls associated with other radio buttons
  47. //
  48. m_ctlFileName.EnableWindow(FALSE);
  49. GetDlgItem(IDC_CTL_BROWSE_BUTTON)->EnableWindow(FALSE);
  50. m_controlGuidName.EnableWindow(FALSE);
  51. GetDlgItem(IDC_PROCESS_CHECK)->EnableWindow(FALSE);
  52. GetDlgItem(IDC_THREAD_CHECK)->EnableWindow(FALSE);
  53. GetDlgItem(IDC_NET_CHECK)->EnableWindow(FALSE);
  54. GetDlgItem(IDC_DISK_CHECK)->EnableWindow(FALSE);
  55. GetDlgItem(IDC_PAGEFAULT_CHECK)->EnableWindow(FALSE);
  56. GetDlgItem(IDC_HARDFAULT_CHECK)->EnableWindow(FALSE);
  57. GetDlgItem(IDC_IMAGELOAD_CHECK)->EnableWindow(FALSE);
  58. GetDlgItem(IDC_REGISTRY_CHECK)->EnableWindow(FALSE);
  59. GetDlgItem(IDC_FILEIO_CHECK)->EnableWindow(FALSE);
  60. return ret;
  61. }
  62. void CProviderControlGuidDlg::DoDataExchange(CDataExchange* pDX)
  63. {
  64. CDialog::DoDataExchange(pDX);
  65. DDX_Control(pDX, IDC_PDB_FILE_EDIT, m_pdbFileName);
  66. DDX_Control(pDX, IDC_CTL_FILE_EDIT, m_ctlFileName);
  67. DDX_Control(pDX, IDC_MANUAL_GUID_EDIT, m_controlGuidName);
  68. }
  69. BEGIN_MESSAGE_MAP(CProviderControlGuidDlg, CDialog)
  70. ON_BN_CLICKED(IDC_PDB_BROWSE_BUTTON, OnBnClickedPdbBrowseButton)
  71. ON_BN_CLICKED(IDC_CTL_BROWSE_BUTTON, OnBnClickedCtlBrowseButton)
  72. ON_BN_CLICKED(IDC_PDB_SELECT_RADIO, OnBnClickedPdbSelectRadio)
  73. ON_BN_CLICKED(IDC_CTL_SELECT_RADIO, OnBnClickedCtlSelectRadio)
  74. ON_BN_CLICKED(IDC_MANUAL_SELECT_RADIO, OnBnClickedManualSelectRadio)
  75. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  76. ON_BN_CLICKED(IDC_KERNEL_LOGGER_SELECT_RADIO, OnBnClickedKernelLoggerSelectRadio)
  77. END_MESSAGE_MAP()
  78. // CProviderControlGuidDlg message handlers
  79. void CProviderControlGuidDlg::OnBnClickedPdbBrowseButton()
  80. {
  81. //
  82. // Use the common controls file open dialog
  83. //
  84. CFileDialog fileDlg(TRUE,
  85. _T("pdb"),_T("*.pdb"),
  86. OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_READONLY |
  87. OFN_HIDEREADONLY | OFN_EXPLORER | OFN_NOCHANGEDIR,
  88. _T("Program Database Files (*.pdb)|*.pdb||"),
  89. this);
  90. //
  91. // Pop the dialog... Any error, just return
  92. //
  93. if( fileDlg.DoModal()!=IDOK ) {
  94. return;
  95. }
  96. //
  97. // Get the file name and display it
  98. //
  99. if(!fileDlg.GetPathName().IsEmpty()) {
  100. m_pdbFileName.SetWindowText(fileDlg.GetPathName());
  101. m_pdbFileName.SetFocus();
  102. }
  103. }
  104. void CProviderControlGuidDlg::OnBnClickedCtlBrowseButton()
  105. {
  106. //
  107. // Use the common controls file open dialog
  108. //
  109. CFileDialog fileDlg(TRUE,
  110. _T("ctl"),_T("*.ctl"),
  111. OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_READONLY |
  112. OFN_HIDEREADONLY | OFN_EXPLORER | OFN_NOCHANGEDIR,
  113. _T("Control GUID Files (*.ctl)|*.ctl|All Files (*.*)|*.*||"),
  114. this);
  115. //
  116. // Pop the dialog... Any error, just return
  117. //
  118. if( fileDlg.DoModal()!=IDOK ) {
  119. return;
  120. }
  121. //
  122. // Get the file name and display it
  123. //
  124. if(!fileDlg.GetPathName().IsEmpty()) {
  125. m_ctlFileName.SetWindowText(fileDlg.GetPathName());
  126. m_ctlFileName.SetFocus();
  127. }
  128. }
  129. void CProviderControlGuidDlg::OnBnClickedPdbSelectRadio()
  130. {
  131. //
  132. // Set the PDB radio button and unset the rest
  133. //
  134. CheckRadioButton(IDC_PDB_SELECT_RADIO,
  135. IDC_KERNEL_LOGGER_SELECT_RADIO,
  136. IDC_PDB_SELECT_RADIO);
  137. //
  138. // Enable the PDB filename edit box and browse button
  139. //
  140. m_pdbFileName.EnableWindow(TRUE);
  141. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(TRUE);
  142. //
  143. // Disable all controls associated with other radio buttons
  144. //
  145. m_ctlFileName.EnableWindow(FALSE);
  146. GetDlgItem(IDC_CTL_BROWSE_BUTTON)->EnableWindow(FALSE);
  147. m_controlGuidName.EnableWindow(FALSE);
  148. GetDlgItem(IDC_PROCESS_CHECK)->EnableWindow(FALSE);
  149. GetDlgItem(IDC_THREAD_CHECK)->EnableWindow(FALSE);
  150. GetDlgItem(IDC_NET_CHECK)->EnableWindow(FALSE);
  151. GetDlgItem(IDC_DISK_CHECK)->EnableWindow(FALSE);
  152. GetDlgItem(IDC_PAGEFAULT_CHECK)->EnableWindow(FALSE);
  153. GetDlgItem(IDC_HARDFAULT_CHECK)->EnableWindow(FALSE);
  154. GetDlgItem(IDC_IMAGELOAD_CHECK)->EnableWindow(FALSE);
  155. GetDlgItem(IDC_REGISTRY_CHECK)->EnableWindow(FALSE);
  156. GetDlgItem(IDC_FILEIO_CHECK)->EnableWindow(FALSE);
  157. }
  158. void CProviderControlGuidDlg::OnBnClickedCtlSelectRadio()
  159. {
  160. //
  161. // Set the CTL radio button and unset the rest
  162. //
  163. CheckRadioButton(IDC_PDB_SELECT_RADIO,
  164. IDC_KERNEL_LOGGER_SELECT_RADIO,
  165. IDC_CTL_SELECT_RADIO);
  166. //
  167. // Enable the CTL name edit box and browse button
  168. //
  169. m_ctlFileName.EnableWindow(TRUE);
  170. GetDlgItem(IDC_CTL_BROWSE_BUTTON)->EnableWindow(TRUE);
  171. //
  172. // Disable all controls associated with other radio buttons
  173. //
  174. m_pdbFileName.EnableWindow(FALSE);
  175. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(FALSE);
  176. m_controlGuidName.EnableWindow(FALSE);
  177. GetDlgItem(IDC_PROCESS_CHECK)->EnableWindow(FALSE);
  178. GetDlgItem(IDC_THREAD_CHECK)->EnableWindow(FALSE);
  179. GetDlgItem(IDC_NET_CHECK)->EnableWindow(FALSE);
  180. GetDlgItem(IDC_DISK_CHECK)->EnableWindow(FALSE);
  181. GetDlgItem(IDC_PAGEFAULT_CHECK)->EnableWindow(FALSE);
  182. GetDlgItem(IDC_HARDFAULT_CHECK)->EnableWindow(FALSE);
  183. GetDlgItem(IDC_IMAGELOAD_CHECK)->EnableWindow(FALSE);
  184. GetDlgItem(IDC_REGISTRY_CHECK)->EnableWindow(FALSE);
  185. GetDlgItem(IDC_FILEIO_CHECK)->EnableWindow(FALSE);
  186. }
  187. void CProviderControlGuidDlg::OnBnClickedManualSelectRadio()
  188. {
  189. //
  190. // Set the Manual radio button and unset the rest
  191. //
  192. CheckRadioButton(IDC_PDB_SELECT_RADIO,
  193. IDC_KERNEL_LOGGER_SELECT_RADIO,
  194. IDC_MANUAL_SELECT_RADIO);
  195. //
  196. // Enable the GUID name edit box
  197. //
  198. m_controlGuidName.EnableWindow(TRUE);
  199. //
  200. // Disable all controls associated with other radio buttons
  201. //
  202. m_pdbFileName.EnableWindow(FALSE);
  203. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(FALSE);
  204. m_ctlFileName.EnableWindow(FALSE);
  205. GetDlgItem(IDC_CTL_BROWSE_BUTTON)->EnableWindow(FALSE);
  206. GetDlgItem(IDC_PROCESS_CHECK)->EnableWindow(FALSE);
  207. GetDlgItem(IDC_THREAD_CHECK)->EnableWindow(FALSE);
  208. GetDlgItem(IDC_NET_CHECK)->EnableWindow(FALSE);
  209. GetDlgItem(IDC_DISK_CHECK)->EnableWindow(FALSE);
  210. GetDlgItem(IDC_PAGEFAULT_CHECK)->EnableWindow(FALSE);
  211. GetDlgItem(IDC_HARDFAULT_CHECK)->EnableWindow(FALSE);
  212. GetDlgItem(IDC_IMAGELOAD_CHECK)->EnableWindow(FALSE);
  213. GetDlgItem(IDC_REGISTRY_CHECK)->EnableWindow(FALSE);
  214. GetDlgItem(IDC_FILEIO_CHECK)->EnableWindow(FALSE);
  215. }
  216. void CProviderControlGuidDlg::OnBnClickedKernelLoggerSelectRadio()
  217. {
  218. //
  219. // Set the Kernel Logger radio button and unset the rest
  220. //
  221. CheckRadioButton(IDC_PDB_SELECT_RADIO,
  222. IDC_KERNEL_LOGGER_SELECT_RADIO,
  223. IDC_KERNEL_LOGGER_SELECT_RADIO);
  224. //
  225. // Enable the kernel logger check boxes
  226. //
  227. GetDlgItem(IDC_PROCESS_CHECK)->EnableWindow(TRUE);
  228. GetDlgItem(IDC_THREAD_CHECK)->EnableWindow(TRUE);
  229. GetDlgItem(IDC_NET_CHECK)->EnableWindow(TRUE);
  230. GetDlgItem(IDC_DISK_CHECK)->EnableWindow(TRUE);
  231. GetDlgItem(IDC_PAGEFAULT_CHECK)->EnableWindow(TRUE);
  232. GetDlgItem(IDC_HARDFAULT_CHECK)->EnableWindow(TRUE);
  233. GetDlgItem(IDC_IMAGELOAD_CHECK)->EnableWindow(TRUE);
  234. GetDlgItem(IDC_REGISTRY_CHECK)->EnableWindow(TRUE);
  235. GetDlgItem(IDC_FILEIO_CHECK)->EnableWindow(TRUE);
  236. //
  237. // Disable all controls associated with other radio buttons
  238. //
  239. m_pdbFileName.EnableWindow(FALSE);
  240. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(FALSE);
  241. m_ctlFileName.EnableWindow(FALSE);
  242. GetDlgItem(IDC_CTL_BROWSE_BUTTON)->EnableWindow(FALSE);
  243. m_controlGuidName.EnableWindow(FALSE);
  244. }
  245. void CProviderControlGuidDlg::OnBnClickedOk()
  246. {
  247. CString str;
  248. if(BST_CHECKED == IsDlgButtonChecked(IDC_PDB_SELECT_RADIO)) {
  249. m_pdbFileName.GetWindowText(m_pTraceSession->m_pdbFile);
  250. EndDialog(1);
  251. return;
  252. }
  253. if(BST_CHECKED == IsDlgButtonChecked(IDC_CTL_SELECT_RADIO)) {
  254. m_ctlFileName.GetWindowText(m_pTraceSession->m_ctlFile);
  255. EndDialog(1);
  256. return;
  257. }
  258. if(BST_CHECKED == IsDlgButtonChecked(IDC_MANUAL_SELECT_RADIO)) {
  259. m_controlGuidName.GetWindowText(str);
  260. m_pTraceSession->m_controlGuid.Add(str);
  261. EndDialog(1);
  262. return;
  263. }
  264. if(BST_CHECKED == IsDlgButtonChecked(IDC_KERNEL_LOGGER_SELECT_RADIO)) {
  265. //
  266. // Convert the system kernel logger control GUID to a string
  267. //
  268. GuidToString(SystemTraceControlGuid, str);
  269. m_pTraceSession->m_controlGuid.Add(str);
  270. m_pTraceSession->m_bKernelLogger = TRUE;
  271. //
  272. // Get the kernel logger options
  273. //
  274. m_bProcess = ((CButton *)GetDlgItem(IDC_PROCESS_CHECK))->GetCheck();
  275. m_bThread = ((CButton *)GetDlgItem(IDC_THREAD_CHECK))->GetCheck();
  276. m_bDisk = ((CButton *)GetDlgItem(IDC_DISK_CHECK))->GetCheck();
  277. m_bNet = ((CButton *)GetDlgItem(IDC_NET_CHECK))->GetCheck();
  278. m_bFileIO = ((CButton *)GetDlgItem(IDC_FILEIO_CHECK))->GetCheck();
  279. m_bPageFault = ((CButton *)GetDlgItem(IDC_PAGEFAULT_CHECK))->GetCheck();
  280. m_bHardFault = ((CButton *)GetDlgItem(IDC_HARDFAULT_CHECK))->GetCheck();
  281. m_bImageLoad = ((CButton *)GetDlgItem(IDC_IMAGELOAD_CHECK))->GetCheck();
  282. m_bRegistry = ((CButton *)GetDlgItem(IDC_REGISTRY_CHECK))->GetCheck();
  283. EndDialog(1);
  284. return;
  285. }
  286. EndDialog(2);
  287. }