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.

234 lines
6.9 KiB

  1. #pragma warning(disable:4135)
  2. #include <afxwin.h>
  3. #pragma warning(default:4135)
  4. #include <afxdlgs.h>
  5. #include "resource.h"
  6. #define _DBWIN32_
  7. #include "dbwin32.h"
  8. BEGIN_MESSAGE_MAP(DbWin32RunDlg, CDialog)
  9. // Windows messages
  10. ON_CBN_EDITCHANGE(IDC_COMMANDLINE, OnEditChange)
  11. ON_CBN_SELCHANGE(IDC_COMMANDLINE, OnSelChange)
  12. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  13. // Command handlers
  14. // Idle update handlers
  15. END_MESSAGE_MAP()
  16. DbWin32RunDlg::DbWin32RunDlg(CString *pstIn) : CDialog(IDR_RUNDLG)
  17. {
  18. pst = pstIn;
  19. }
  20. DbWin32RunDlg::~DbWin32RunDlg()
  21. {
  22. }
  23. BOOL DbWin32RunDlg::OnInitDialog()
  24. {
  25. int iSt;
  26. CComboBox *pcb = (CComboBox *)GetDlgItem(IDC_COMMANDLINE);
  27. for (iSt = 0; iSt < MAX_HISTORY; iSt++)
  28. if (!pst[iSt].IsEmpty())
  29. pcb->AddString(pst[iSt]);
  30. if (pcb->GetCount())
  31. {
  32. pcb->SetCurSel(0);
  33. OnSelChange();
  34. }
  35. return(CDialog::OnInitDialog());
  36. }
  37. void DbWin32RunDlg::OnEditChange()
  38. {
  39. CComboBox *pcb = (CComboBox *)GetDlgItem(IDC_COMMANDLINE);
  40. CButton *pbutton = (CButton *)GetDlgItem(IDOK);
  41. pcb->GetWindowText(stCommandLine);
  42. pbutton->EnableWindow(!stCommandLine.IsEmpty());
  43. }
  44. void DbWin32RunDlg::OnSelChange()
  45. {
  46. CComboBox *pcb = (CComboBox *)GetDlgItem(IDC_COMMANDLINE);
  47. CButton *pbutton = (CButton *)GetDlgItem(IDOK);
  48. pcb->GetLBText(pcb->GetCurSel(), stCommandLine);
  49. pbutton->EnableWindow(!stCommandLine.IsEmpty());
  50. }
  51. void DbWin32RunDlg::OnBrowse()
  52. {
  53. CComboBox *pcb = (CComboBox *)GetDlgItem(IDC_COMMANDLINE);
  54. CFileDialog fdlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY |
  55. OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST, "Executable Files|*.exe||",
  56. this);
  57. if (fdlg.DoModal() == IDOK)
  58. {
  59. pcb->SetWindowText(fdlg.GetPathName());
  60. OnEditChange();
  61. }
  62. }
  63. struct EnumInfo
  64. {
  65. CListBox *plb;
  66. WindowList *pwl;
  67. DWORD dwProcessCur;
  68. };
  69. BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam)
  70. {
  71. int iItem;
  72. DWORD dwProcess;
  73. char szTitle[256];
  74. WindowInfo wi;
  75. EnumInfo *pei = (EnumInfo *)lParam;
  76. if (hWnd)
  77. {
  78. GetWindowText(hWnd, szTitle, sizeof(szTitle));
  79. if (*szTitle)
  80. {
  81. GetWindowThreadProcessId(hWnd, &dwProcess);
  82. if (dwProcess != pei->dwProcessCur)
  83. {
  84. wi.dwProcess = 0;
  85. for (iItem = 0; (iItem < pei->pwl->Count()) &&
  86. (wi.dwProcess != dwProcess); iItem++)
  87. pei->pwl->GetItem(iItem, &wi);
  88. if (iItem == pei->pwl->Count())
  89. {
  90. iItem = pei->plb->AddString(szTitle);
  91. pei->plb->SetItemData(iItem, dwProcess);
  92. }
  93. }
  94. }
  95. }
  96. return(TRUE);
  97. }
  98. BEGIN_MESSAGE_MAP(DbWin32AttachDlg, CDialog)
  99. // Windows messages
  100. ON_LBN_DBLCLK(IDC_PROCESS, OnDoubleClick)
  101. // Command handlers
  102. // Idle update handlers
  103. END_MESSAGE_MAP()
  104. DbWin32AttachDlg::DbWin32AttachDlg(WindowList *pwlIn) : CDialog(IDR_ATTACHDLG)
  105. {
  106. pwl = pwlIn;
  107. }
  108. DbWin32AttachDlg::~DbWin32AttachDlg()
  109. {
  110. }
  111. BOOL DbWin32AttachDlg::OnInitDialog()
  112. {
  113. EnumInfo ei;
  114. CListBox *plb = (CListBox *)GetDlgItem(IDC_PROCESS);
  115. CDialog::OnInitDialog();
  116. plb->ResetContent();
  117. ei.plb = plb;
  118. ei.pwl = pwl;
  119. ei.dwProcessCur = GetCurrentProcessId();
  120. EnumWindows(EnumProc, (LPARAM)&ei);
  121. plb->SetCurSel(0);
  122. return(TRUE);
  123. }
  124. void DbWin32AttachDlg::OnOK()
  125. {
  126. CListBox *plb = (CListBox *)GetDlgItem(IDC_PROCESS);
  127. dwProcess = (DWORD)plb->GetItemData(plb->GetCurSel());
  128. CDialog::OnOK();
  129. }
  130. void DbWin32AttachDlg::OnDoubleClick()
  131. {
  132. OnOK();
  133. }
  134. BEGIN_MESSAGE_MAP(DbWin32OptionsDlg, CDialog)
  135. // Windows messages
  136. // Command handlers
  137. ON_CONTROL(BN_CLICKED, IDC_NEWPROCESS, OnClicked)
  138. // Idle update handlers
  139. END_MESSAGE_MAP()
  140. DbWin32OptionsDlg::DbWin32OptionsDlg(DbWin32Options *pdboIn) : CDialog(IDR_OPTIONSDLG)
  141. {
  142. pdbo = pdboIn;
  143. }
  144. DbWin32OptionsDlg::~DbWin32OptionsDlg()
  145. {
  146. }
  147. BOOL DbWin32OptionsDlg::OnInitDialog()
  148. {
  149. CDialog::OnInitDialog();
  150. ((CButton *)GetDlgItem(IDC_NEWPROCESS))->SetCheck(pdbo->fNewOnProcess ? 1 : 0);
  151. ((CButton *)GetDlgItem(IDC_NEWTHREAD))->SetCheck(pdbo->fNewOnThread ? 1 : 0);
  152. GetDlgItem(IDC_NEWTHREAD)->EnableWindow(pdbo->fNewOnProcess);
  153. ((CButton *)GetDlgItem(IDC_ONTOP))->SetCheck(pdbo->fOnTop ? 1 : 0);
  154. ((CButton *)GetDlgItem(IDC_MINIMIZE))->SetCheck((pdbo->nInactive == INACTIVE_MINIMIZE) ? 1 : 0);
  155. ((CButton *)GetDlgItem(IDC_NONE))->SetCheck((pdbo->nInactive == INACTIVE_NONE) ? 1 : 0);
  156. ((CButton *)GetDlgItem(IDC_CLOSE))->SetCheck((pdbo->nInactive == INACTIVE_CLOSE) ? 1 : 0);
  157. ((CButton *)GetDlgItem(IDC_FILTER_OUTPUT))->SetCheck((pdbo->wFilter & DBO_OUTPUTDEBUGSTRING) ? 1 : 0);
  158. ((CButton *)GetDlgItem(IDC_FILTER_EXCEPTIONS))->SetCheck((pdbo->wFilter & DBO_EXCEPTIONS) ? 1 : 0);
  159. ((CButton *)GetDlgItem(IDC_FILTER_PROCESSCREATE))->SetCheck((pdbo->wFilter & DBO_PROCESSCREATE) ? 1 : 0);
  160. ((CButton *)GetDlgItem(IDC_FILTER_PROCESSEXIT))->SetCheck((pdbo->wFilter & DBO_PROCESSEXIT) ? 1 : 0);
  161. ((CButton *)GetDlgItem(IDC_FILTER_THREADCREATE))->SetCheck((pdbo->wFilter & DBO_THREADCREATE) ? 1 : 0);
  162. ((CButton *)GetDlgItem(IDC_FILTER_THREADEXIT))->SetCheck((pdbo->wFilter & DBO_THREADEXIT) ? 1 : 0);
  163. ((CButton *)GetDlgItem(IDC_FILTER_DLLLOAD))->SetCheck((pdbo->wFilter & DBO_DLLLOAD) ? 1 : 0);
  164. ((CButton *)GetDlgItem(IDC_FILTER_DLLUNLOAD))->SetCheck((pdbo->wFilter & DBO_DLLUNLOAD) ? 1 : 0);
  165. ((CButton *)GetDlgItem(IDC_FILTER_RIP))->SetCheck((pdbo->wFilter & DBO_RIP) ? 1 : 0);
  166. return(TRUE);
  167. }
  168. void DbWin32OptionsDlg::OnOK()
  169. {
  170. pdbo->fNewOnProcess = ((CButton *)GetDlgItem(IDC_NEWPROCESS))->GetCheck();
  171. pdbo->fNewOnThread = ((CButton *)GetDlgItem(IDC_NEWTHREAD))->GetCheck();
  172. pdbo->fOnTop = ((CButton *)GetDlgItem(IDC_ONTOP))->GetCheck();
  173. if (((CButton *)GetDlgItem(IDC_NONE))->GetCheck())
  174. pdbo->nInactive = INACTIVE_NONE;
  175. else if (((CButton *)GetDlgItem(IDC_CLOSE))->GetCheck())
  176. pdbo->nInactive = INACTIVE_CLOSE;
  177. else
  178. pdbo->nInactive = INACTIVE_MINIMIZE;
  179. pdbo->wFilter = 0;
  180. if (((CButton *)GetDlgItem(IDC_FILTER_OUTPUT))->GetCheck())
  181. pdbo->wFilter = DBO_OUTPUTDEBUGSTRING;
  182. if (((CButton *)GetDlgItem(IDC_FILTER_EXCEPTIONS))->GetCheck())
  183. pdbo->wFilter |= DBO_EXCEPTIONS;
  184. if (((CButton *)GetDlgItem(IDC_FILTER_PROCESSCREATE))->GetCheck())
  185. pdbo->wFilter |= DBO_PROCESSCREATE;
  186. if (((CButton *)GetDlgItem(IDC_FILTER_PROCESSEXIT))->GetCheck())
  187. pdbo->wFilter |= DBO_PROCESSEXIT;
  188. if (((CButton *)GetDlgItem(IDC_FILTER_THREADCREATE))->GetCheck())
  189. pdbo->wFilter |= DBO_THREADCREATE;
  190. if (((CButton *)GetDlgItem(IDC_FILTER_THREADEXIT))->GetCheck())
  191. pdbo->wFilter |= DBO_THREADEXIT;
  192. if (((CButton *)GetDlgItem(IDC_FILTER_DLLLOAD))->GetCheck())
  193. pdbo->wFilter |= DBO_DLLLOAD;
  194. if (((CButton *)GetDlgItem(IDC_FILTER_DLLUNLOAD))->GetCheck())
  195. pdbo->wFilter |= DBO_DLLUNLOAD;
  196. if (((CButton *)GetDlgItem(IDC_FILTER_RIP))->GetCheck())
  197. pdbo->wFilter |= DBO_RIP;
  198. CDialog::OnOK();
  199. }
  200. void DbWin32OptionsDlg::OnClicked()
  201. {
  202. BOOL fNewOnProcess = ((CButton *)GetDlgItem(IDC_NEWPROCESS))->GetCheck();
  203. ((CButton *)GetDlgItem(IDC_NEWTHREAD))->SetCheck(0);
  204. GetDlgItem(IDC_NEWTHREAD)->EnableWindow(fNewOnProcess);
  205. }