00001
00007 #pragma once
00008
00009 #include "patchlist.h"
00010 #include <bzscmn/serializer.h>
00011 #include <bzscmn/file.h>
00012
00013 DECLARE_SERIALIZEABLE_STRUC10_I(MonitorParams,
00014 bool, ToolsNotInstalled, false,
00015 BazisLib::String, ToolsPath, _T(""),
00016 bool, AutoInvokeDebugger, true,
00017 bool, AutoCloseDebugger, false,
00018 unsigned, DebuggerType, 1,
00019 bool, WaitForOS, true,
00020 bool, InitialBreakIn, true,
00021 unsigned, DebugLevel, 1,
00022 unsigned, PatchDelay, 3,
00023 BazisLib::String, CustomDebuggerTemplate, _T("cmd.exe /c \"$(toolspath)\\test.cmd\" $(pipename)"));
00024
00026 class CMainDlg : public CDialogImpl<CMainDlg>, public CDialogResize<CMainDlg>
00027 {
00028 private:
00029 PatchedProcessList m_Processes;
00030 PatchedProcessSet m_PatchedSet;
00031
00032 private:
00033 CListViewCtrl m_ListView, m_StatsView;
00034 CImageList m_ImageList;
00035
00036 unsigned m_ProcessorCount;
00037
00038 MonitorParams m_Params;
00039 BazisLib::FilePath m_DbgToolsPath;
00040
00041 CComboBox m_DebugLevel;
00042
00043 public:
00044 enum { IDD = IDD_MAINDLG };
00045
00046 CMainDlg();
00047
00048 #pragma region Message maps
00049
00050 BEGIN_MSG_MAP(CMainDlg)
00051 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
00052 COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
00053 COMMAND_ID_HANDLER(IDOK, OnOK)
00054 COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
00055 MESSAGE_HANDLER(WM_TIMER, OnTimer)
00056 COMMAND_HANDLER(IDC_CLEARLOG, BN_CLICKED, OnBnClickedClearlog)
00057 COMMAND_HANDLER(IDC_UNPATCH, BN_CLICKED, OnBnClickedUnpatch)
00058 COMMAND_HANDLER(IDC_DBGPATH, BN_CLICKED, OnBnClickedDbgpath)
00059 COMMAND_HANDLER(IDC_TRACEASSIST, BN_CLICKED, OnBnClickedTraceassist)
00060 CHAIN_MSG_MAP(CDialogResize)
00061 COMMAND_ID_HANDLER(IDC_RUNDBG, OnRunDebugger);
00062
00063 COMMAND_ID_HANDLER(IDC_STARTDBG, OnParamsChanged);
00064 COMMAND_ID_HANDLER(IDC_STOPDBG, OnParamsChanged);
00065 COMMAND_ID_HANDLER(IDC_USEKD, OnParamsChanged);
00066 COMMAND_ID_HANDLER(IDC_USEWINDBG, OnParamsChanged);
00067 COMMAND_ID_HANDLER(IDC_USECUSTOM, OnParamsChanged);
00068 COMMAND_ID_HANDLER(IDC_BREAKIN, OnParamsChanged);
00069 COMMAND_ID_HANDLER(IDC_LOGPACKETS, OnLogPacketsChanged);
00070 COMMAND_HANDLER(IDC_DBGTEMPLATE, EN_KILLFOCUS, OnParamsChanged);
00071
00072 NOTIFY_HANDLER(IDC_LIST1, LVN_ITEMCHANGED, OnSelChanged)
00073 COMMAND_HANDLER(IDC_DBGLEVEL, CBN_SELCHANGE, OnDebugLevelChanged)
00074 END_MSG_MAP()
00075
00076 BEGIN_DLGRESIZE_MAP(CMainDlg)
00077 DLGRESIZE_CONTROL(IDC_LIST1, DLSZ_SIZE_X | DLSZ_SIZE_Y)
00078 DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X | DLSZ_MOVE_Y)
00079
00080 DLGRESIZE_CONTROL(IDC_STARTDBG, DLSZ_MOVE_Y)
00081 DLGRESIZE_CONTROL(IDC_STOPDBG, DLSZ_MOVE_Y)
00082 DLGRESIZE_CONTROL(IDC_USEKD, DLSZ_MOVE_Y)
00083 DLGRESIZE_CONTROL(IDC_USEWINDBG, DLSZ_MOVE_Y)
00084 DLGRESIZE_CONTROL(IDC_RUNDBG, DLSZ_MOVE_Y | DLSZ_MOVE_X)
00085 DLGRESIZE_CONTROL(IDC_EDIT1, DLSZ_MOVE_Y | DLSZ_SIZE_X)
00086 DLGRESIZE_CONTROL(IDC_DBGMSGTEXT, DLSZ_MOVE_Y)
00087 DLGRESIZE_CONTROL(IDC_DBGLEVEL, DLSZ_MOVE_Y | DLSZ_SIZE_X)
00088 DLGRESIZE_CONTROL(IDC_UNPATCH, DLSZ_MOVE_Y | DLSZ_MOVE_X)
00089 DLGRESIZE_CONTROL(IDC_USECUSTOM, DLSZ_MOVE_Y)
00090 DLGRESIZE_CONTROL(IDC_DBGTEMPLATE, DLSZ_MOVE_Y | DLSZ_SIZE_X)
00091 DLGRESIZE_CONTROL(IDC_CLEARLOG, DLSZ_MOVE_X | DLSZ_MOVE_Y)
00092 DLGRESIZE_CONTROL(IDC_DBGPATH, DLSZ_MOVE_Y | DLSZ_SIZE_X)
00093 DLGRESIZE_CONTROL(IDC_STATS, DLSZ_SIZE_Y | DLSZ_MOVE_X)
00094
00095 DLGRESIZE_CONTROL(IDC_TRACEASSIST, DLSZ_SIZE_X | DLSZ_MOVE_Y)
00096 DLGRESIZE_CONTROL(IDC_BREAKIN, DLSZ_MOVE_Y)
00097 DLGRESIZE_CONTROL(IDC_LOGPACKETS, DLSZ_MOVE_Y)
00098 END_DLGRESIZE_MAP()
00099
00100 #pragma endregion
00101 #pragma region Message handlers
00102
00103
00104
00105
00106
00107
00108 LRESULT OnTimer(UINT , WPARAM , LPARAM , BOOL& );
00109 LRESULT OnInitDialog(UINT , WPARAM , LPARAM , BOOL& );
00110 LRESULT OnAppAbout(WORD , WORD , HWND , BOOL& );
00111 LRESULT OnOK(WORD , WORD wID, HWND , BOOL& );
00112 LRESULT OnCancel(WORD , WORD wID, HWND , BOOL& );
00113 LRESULT OnParamsChanged(WORD , WORD wID, HWND , BOOL& );
00114 LRESULT OnLogPacketsChanged(WORD , WORD wID, HWND , BOOL& );
00115 LRESULT OnRunDebugger(WORD , WORD wID, HWND , BOOL& );
00116 LRESULT OnSelChanged(int , LPNMHDR , BOOL& );
00117 LRESULT OnDebugLevelChanged(WORD , WORD wID, HWND , BOOL& );
00118
00119 #pragma endregion
00120
00121 protected:
00122 void SearchForNewProcesses();
00123 void UpdateProcessInfo();
00124 void RunDebugger(unsigned entryIndex);
00125 void PerformProcessActions(PatchedProcess &proc, BazisLib::TimeSpan &runTime, bool *pPatchingStarted);
00126 void CleanupProcessEntry(PatchedProcess &proc);
00127 void SaveParamsToRegistry();
00128
00129 void CreateStatusMapping(PatchedProcess &proc, bool Reset);
00130 bool InitiatePatching(PatchedProcess &proc);
00131 void UpdateLog(PatchedProcess &proc);
00132 void UpdateUnpatchButton(int SelectionIndex);
00133
00134 void UpdateParamControls();
00135 void OnDebuggerPathChanged();
00136 void DisplayStats(PatchedProcess &proc);
00137 public:
00138 LRESULT OnBnClickedClearlog(WORD , WORD , HWND , BOOL& );
00139 LRESULT OnBnClickedUnpatch(WORD , WORD , HWND , BOOL& );
00140 LRESULT OnBnClickedDbgpath(WORD , WORD , HWND , BOOL& );
00141 LRESULT OnBnClickedTraceassist(WORD , WORD , HWND , BOOL& );
00142 };