Source code of Windows XP (NT5)
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.

346 lines
6.0 KiB

  1. #define INITIAL_LIST_SIZE 32
  2. #define LIST_CHUNK_SIZE 10
  3. #define WM_SENDTEXT WM_USER
  4. #define WM_ENDTHREAD (WM_USER+1)
  5. #define DBO_OUTPUTDEBUGSTRING 0x0001
  6. #define DBO_EXCEPTIONS 0x0002
  7. #define DBO_PROCESSCREATE 0x0004
  8. #define DBO_PROCESSEXIT 0x0008
  9. #define DBO_THREADCREATE 0x0010
  10. #define DBO_THREADEXIT 0x0020
  11. #define DBO_DLLLOAD 0x0040
  12. #define DBO_DLLUNLOAD 0x0080
  13. #define DBO_RIP 0x0100
  14. #define DBO_ALL 0xFFFF
  15. struct AttachInfo
  16. {
  17. DWORD dwProcess;
  18. HWND hwndFrame;
  19. };
  20. struct ExecInfo
  21. {
  22. LPSTR lpszCommandLine;
  23. HWND hwndFrame;
  24. };
  25. struct SystemWindowInfo
  26. {
  27. HWND hwndFrame;
  28. };
  29. struct StringInfo
  30. {
  31. DWORD dwProcess;
  32. DWORD dwThread;
  33. DWORD dwParentProcess;
  34. LPCSTR lpszText;
  35. int cLines;
  36. };
  37. class GrowableList
  38. {
  39. public:
  40. GrowableList(int cbSizeIn);
  41. virtual ~GrowableList();
  42. int Count();
  43. BOOL FindItem(void *pvFind, int *piFound = NULL);
  44. void GetItem(int iItem, void *pvItem);
  45. void InsertItem(void *pvItem);
  46. void RemoveItem(void *pvItem);
  47. void RemoveItem(int iItem);
  48. protected:
  49. virtual BOOL IsEqual(void *pv1, void *pv2) = 0;
  50. int cbSize;
  51. int cItemsCur;
  52. int cItemsMax;
  53. void *pvData;
  54. };
  55. void __cdecl AttachThread(void *pv);
  56. void __cdecl ExecThread(void *pv);
  57. void __cdecl SystemThread(void *pv);
  58. #ifdef _DBDBG32_
  59. #define EXCEPTION_VDM_EVENT 0x40000005L
  60. #define BUF_SIZE 1024
  61. #define MODULE_SIZE 32
  62. struct ProcessInfo
  63. {
  64. DWORD dwProcess;
  65. HANDLE hProcess;
  66. char rgchModule[MODULE_SIZE];
  67. };
  68. class ProcessList : public GrowableList
  69. {
  70. public:
  71. ProcessList();
  72. ~ProcessList();
  73. protected:
  74. virtual BOOL IsEqual(void *pv1, void *pv2);
  75. };
  76. struct ThreadInfo
  77. {
  78. DWORD dwProcess;
  79. DWORD dwThread;
  80. };
  81. class ThreadList : public GrowableList
  82. {
  83. public:
  84. ThreadList();
  85. ~ThreadList();
  86. protected:
  87. virtual BOOL IsEqual(void *pv1, void *pv2);
  88. };
  89. struct DllInfo
  90. {
  91. DWORD dwProcess;
  92. LPVOID lpBaseOfDll;
  93. char rgchModule[MODULE_SIZE];
  94. };
  95. class DllList : public GrowableList
  96. {
  97. public:
  98. DllList();
  99. ~DllList();
  100. protected:
  101. virtual BOOL IsEqual(void *pv1, void *pv2);
  102. };
  103. void __cdecl DebugThread(HWND hwndFrame, DWORD dwProcess);
  104. void SendText(HWND hwndFrame, DEBUG_EVENT *pDebugEvent, DWORD dwParentProcess,
  105. LPCSTR lpszText, WORD wEvent);
  106. void ProcessExceptionEvent(EXCEPTION_DEBUG_INFO *pException, LPSTR lpszBuf);
  107. void GetModuleName(HANDLE hFile, HANDLE hProcess, DWORD_PTR BaseOfImage, LPSTR lpszBuf);
  108. #endif // _DBDBG32_
  109. #ifdef _DBWIN32_
  110. #define MAX_LINES 500
  111. #define MAX_HISTORY 5
  112. #define INACTIVE_MINIMIZE 0
  113. #define INACTIVE_NONE 1
  114. #define INACTIVE_CLOSE 2
  115. struct DbWin32Options
  116. {
  117. RECT rcWindow;
  118. int nShowCmd;
  119. BOOL fOnTop;
  120. BOOL fChildMax;
  121. int nInactive;
  122. BOOL fNewOnProcess;
  123. BOOL fNewOnThread;
  124. WORD wFilter;
  125. CString rgstCommandLine[MAX_HISTORY];
  126. };
  127. class DbWin32Child;
  128. struct WindowInfo
  129. {
  130. DWORD dwProcess;
  131. DWORD dwThread;
  132. DbWin32Child *pwndChild;
  133. };
  134. class WindowList : public GrowableList
  135. {
  136. public:
  137. WindowList();
  138. ~WindowList();
  139. protected:
  140. virtual BOOL IsEqual(void *pv1, void *pv2);
  141. };
  142. class DbWin32App : public CWinApp
  143. {
  144. public:
  145. DbWin32App();
  146. ~DbWin32App();
  147. void ReadOptions();
  148. void WriteOptions(WINDOWPLACEMENT *pwpl);
  149. protected:
  150. virtual BOOL InitInstance();
  151. DbWin32Options dbo;
  152. };
  153. class DbWin32Edit : public CEdit
  154. {
  155. public:
  156. DbWin32Edit();
  157. ~DbWin32Edit();
  158. BOOL Create(CWnd *pwndParent);
  159. };
  160. class DbWin32Child : public CMDIChildWnd
  161. {
  162. public:
  163. DbWin32Child(WORD wFilterIn);
  164. ~DbWin32Child();
  165. void AddText(WORD wEvent, LPCSTR lpszText, int cLines, BOOL fSetTitle);
  166. protected:
  167. DbWin32Edit wndEdit;
  168. CFont fontCur;
  169. WORD wFilter;
  170. private:
  171. // Windows messages
  172. afx_msg int OnCreate(LPCREATESTRUCT lpcs);
  173. afx_msg void OnDestroy();
  174. afx_msg void OnSize(UINT nType, int cx, int cy);
  175. afx_msg void OnMDIActivate(BOOL bActivate, CWnd *pwndActivate, CWnd *pwndDeactivate);
  176. afx_msg BOOL OnNcActivate(BOOL bActivate);
  177. // Command handlers
  178. afx_msg void OnFileSaveBuffer();
  179. afx_msg void OnEditCopy();
  180. afx_msg void OnEditClearBuffer();
  181. afx_msg void OnEditSelectAll();
  182. // Idle update handlers
  183. // Notification messages
  184. afx_msg void OnMaxText();
  185. DECLARE_MESSAGE_MAP()
  186. };
  187. class DbWin32Frame : public CMDIFrameWnd
  188. {
  189. public:
  190. DbWin32Frame(DbWin32Options *pdbo);
  191. ~DbWin32Frame();
  192. void ExecProcess(LPCSTR lpszCommandLine);
  193. void ChildMaximized(BOOL fMax);
  194. void FileSystem();
  195. protected:
  196. virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
  197. WindowList wl;
  198. DbWin32Child *pwndSystem;
  199. DbWin32Options *pdbo;
  200. BOOL fInCreate;
  201. BOOL fNT351;
  202. private:
  203. // Windows messages
  204. afx_msg void OnDestroy();
  205. afx_msg LRESULT OnSendText(WPARAM wParam, LPARAM lParam);
  206. afx_msg LRESULT OnEndThread(WPARAM wParam, LPARAM lParam);
  207. // Command handlers
  208. afx_msg void OnFileRun();
  209. afx_msg void OnFileAttach();
  210. afx_msg void OnFileSystem();
  211. afx_msg void OnFileExit();
  212. afx_msg void OnOptions();
  213. afx_msg void OnAbout();
  214. // Idle update handlers
  215. afx_msg void OnUpdateFileSystem(CCmdUI *pCmdUI);
  216. DECLARE_MESSAGE_MAP()
  217. };
  218. class DbWin32RunDlg : public CDialog
  219. {
  220. public:
  221. DbWin32RunDlg(CString *pstIn);
  222. ~DbWin32RunDlg();
  223. CString &GetCommandLine();
  224. protected:
  225. virtual BOOL OnInitDialog();
  226. CString *pst;
  227. CString stCommandLine;
  228. private:
  229. // Windows messages
  230. afx_msg void OnEditChange();
  231. afx_msg void OnSelChange();
  232. afx_msg void OnBrowse();
  233. // Command handlers
  234. // Idle update handlers
  235. DECLARE_MESSAGE_MAP()
  236. };
  237. class DbWin32AttachDlg : public CDialog
  238. {
  239. public:
  240. DbWin32AttachDlg(WindowList *pwlIn);
  241. ~DbWin32AttachDlg();
  242. DWORD GetSelectedProcess();
  243. protected:
  244. virtual BOOL OnInitDialog();
  245. virtual void OnOK();
  246. WindowList *pwl;
  247. DWORD dwProcess;
  248. private:
  249. // Windows messages
  250. afx_msg void OnDoubleClick();
  251. // Command handlers
  252. // Idle update handlers
  253. DECLARE_MESSAGE_MAP()
  254. };
  255. class DbWin32OptionsDlg : public CDialog
  256. {
  257. public:
  258. DbWin32OptionsDlg(DbWin32Options *pdboIn);
  259. ~DbWin32OptionsDlg();
  260. protected:
  261. virtual BOOL OnInitDialog();
  262. virtual void OnOK();
  263. DbWin32Options *pdbo;
  264. private:
  265. afx_msg void OnClicked();
  266. DECLARE_MESSAGE_MAP()
  267. };
  268. inline CString &DbWin32RunDlg::GetCommandLine()
  269. {
  270. return(stCommandLine);
  271. }
  272. inline DWORD DbWin32AttachDlg::GetSelectedProcess()
  273. {
  274. return(dwProcess);
  275. }
  276. #endif // _DBWIN32_