|
|
1.1 root 1: // ************************************************************************
2: // MODULE : DEBMain.c
3: // PURPOSE : A Win32 Application demonstrating the Debug APIs
4: // FUNCTIONS :
5: // WinMain() - application entry point
6: // MainWndProc() - processes messages
7: // ProcessCommandsWndProc() - processes WM_COMMAND messages
8: // PreferencesDlgProc() - processes messages for "Preferences" dialog box
9: // AttachDlgProc() - processes messages for "Attach" dialog box
10: // AboutDlgProc() - processes messages for "About" dialog box
11: // NewListBoxWndProc() - subclass procedure to prevent listbox moving
12: // COMMENTS :
13: // ************************************************************************
14: #include <Windows.H> // required for all Windows applications
15: #include <StdIO.H> // sprintf()
16: #include <String.H> // lstrcat()
17: #include <Memory.H> // memcmp()
18:
19: #include "LinkList.H" // double linked list package (OBJ)
20: #include "ToolBar.H" // various ToolBar controls (DLL)
21: #include "DEBDebug.H" // debugging support functions
22: #include "DEBMisc.H" // misc support functions
23: #include "DEBMain.H" // specific to this module
24:
25: // ***********
26: // global data
27: // ***********
28: HWND hWndMain; // main window handle
29: HWND hWndDebugList; // debug event listbox handle
30: HWND hWndTextButtonBar; // windows handle to the text toolbar
31: HINSTANCE hInstance; // instance handle of this EXE
32: LIST ProcessList; // linked list of debugee process information
33: INT ActiveProcesses = 0; // count of active debugee processes
34: TCHAR szAppTitle[32]; // name of the application
35: HANDLE hProcess; // handle to current running debugee process
36: LONG MaxStrLen = 0; // maximum string length in Debug Event listbox
37:
38: //-- debugee specific data
39: PROCESS_INFORMATION pi; // process information
40: STARTUPINFO si; // debugee startup information
41:
42: //-- private profile settings
43: int xPos; // application window's horizontal position
44: int yPos; // application window's vertical position
45: int nWidth; // application window's width
46: int nHeight; // application window's height
47: BOOL fMaximized; // flag: maximized state?
48: BOOL fToolBar; // flag: display the ToolBar?
49: BOOL fSaveOnExit; // flag: save settings upon exit?
50: BOOL fSavedDirectory; // flag: use saved directory for opening files?
51: BOOL fClearOnNew; // flag: clears the event listbox on a new debugee
52: BOOL fVerbose; // flag: verbose event listings
53: BOOL fShowSymbols; // flag: show symbols (limited)
54: BOOL fSavePreferences; // flag: save the preferences settings
55: HFONT hFont; // current handle to the Debug Event listbox font
56: LOGFONT LogFont; // current logical font
57: COLORREF rgbColor; // current listbox text foreground color
58: COLORREF rgbBkColor; // current listbox text foreground color
59: LONG DebugMode; // debug mode flag CreateProcess
60: LONG DebugeePriority; // debugee priority CreateProcess
61:
62: // *************
63: // internal data
64: // *************
65: #define TOP_BORDER 4
66: #define BOTTOM_BORDER 4
67: #define SIDE_BORDER 4
68: #define MIN_HEIGHT 128
69:
70: WNDPROC OldListBoxWndProc; // original listbox procedure
71: TCHAR szShortAppTitle[16]; // short name of the application
72: BOOL fHelpUsed = FALSE; // boolean denoting online help invoked
73: SIZE ClientSize; // client windows size
74: SIZE DebugListBoxSize; // debug event listbox size
75: int TextButtonBarHeight; // text button bar height
76: int xPosOld; // application window's old horizontal position
77: int yPosOld; // application window's old vertical position
78:
79: //-- location of various files
80: TCHAR szPath[MAX_PATH]; // path where the running application resides
81: TCHAR szExePathName[MAX_PATH]; // full pathname of the application
82: TCHAR szHelpPathName[MAX_PATH]; // full pathname of the application's help file
83: TCHAR szIniPathName[MAX_PATH]; // full pathname of the application's ini file
84:
85:
86: // ************************************************************************
87: // FUNCTION : WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
88: // PURPOSE : initialize the window, process the message dispatch loop
89: // COMMENTS :
90: // ************************************************************************
91: int PASCAL
92: WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )
93: {
94: MSG msg;
95: WNDCLASS wndclass;
96:
97: LPCTSTR lpszMenuName = (LPCTSTR) "DebugMenu";
98: LPCTSTR lpszClassName = (LPCTSTR) "DebugClass";
99: LPCTSTR lpszIconName = (LPCTSTR) "DebugIcon";
100: LPCTSTR lpszAccelName = (LPCTSTR) "DebugAccel";
101: LPCTSTR lpszIniFileExt = (LPCTSTR) "INI";
102: LPCTSTR lpszHelpFileExt = (LPCTSTR) "HLP";
103:
104: HANDLE hAccel; // handle to the accelerator table
105:
106: UNREFERENCED_PARAMETER( lpCmdLine ); // avoid warnings
107: UNREFERENCED_PARAMETER( hPrevInst );
108:
109: hInstance = hInst;
110:
111: //-- register the debug event window class
112: wndclass.style = (UINT) NULL;
113: wndclass.lpfnWndProc = (WNDPROC) MainWndProc;
114: wndclass.cbClsExtra = (int) NULL;
115: wndclass.cbWndExtra = (int) NULL;
116: wndclass.hInstance = hInstance;
117: wndclass.hIcon = LoadIcon( hInstance, lpszIconName );
118: wndclass.hCursor = LoadCursor( hInstance, (LPTSTR) IDC_ARROW );
119: wndclass.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
120: wndclass.lpszMenuName = lpszMenuName;
121: wndclass.lpszClassName = lpszClassName;
122:
123: if( !RegisterClass(&wndclass) )
124: return( FALSE );
125:
126: //-- Load resource strings
127: LoadString( hInstance, IDS_APPTITLE, szAppTitle, sizeof(szAppTitle) );
128: LoadString( hInstance, IDS_SHORT_APPTITLE, szShortAppTitle,
129: sizeof(szShortAppTitle) );
130:
131: //-- get application pathname and store the ini and help file pathname
132: // (which is located in the same directory as the application)
133: GetModuleFileName( (HANDLE) NULL, szExePathName, sizeof(szExePathName)/sizeof(TCHAR) );
134: GetPathFromFullPathName( szExePathName, szPath, sizeof(szPath) );
135: wsprintf( szIniPathName, (LPCSTR) "%s\\%s.%s", szPath, szShortAppTitle, lpszIniFileExt );
136: wsprintf( szHelpPathName, (LPCSTR) "%s\\%s.%s", szPath, szShortAppTitle, lpszHelpFileExt );
137:
138: //-- retrieve stored default location from private profile data
139: GetPrivateProfileSettings( szAppTitle, szIniPathName );
140:
141: //-- Create a main window for this application instance
142: hWndMain = CreateWindow(
143: lpszClassName, // See RegisterClass() call
144: szAppTitle, // Text for window title bar
145: WS_OVERLAPPEDWINDOW, // Window style
146: xPos, // horizontal position
147: yPos, // vertical position
148: nWidth, // width
149: nHeight, // height
150: NULL, // Overlapped windows have no parent
151: NULL, // Use the window class menu
152: hInstance, // This instance owns this window
153: NULL ); // Extra pointer not needed
154:
155: //-- If window could not be created, return "failure"
156: if( !hWndMain )
157: return( FALSE );
158:
159: //-- Load main menu accelerators
160: if( !(hAccel = LoadAccelerators( hInstance, lpszAccelName) ) )
161: return( FALSE );
162:
163: //-- modify the menu to reflect saved settings
164: UpdateMenuSettings();
165:
166: //-- Make the window visible; update its client area; and return "success"
167: ShowWindow( hWndMain, (fMaximized) ? SW_SHOWMAXIMIZED : nCmdShow );
168: UpdateWindow( hWndMain ); // Sends WM_PAINT message
169:
170: //-- initialize the double linked list package that stores the thread handles
171: InitList( &ProcessList, OrderFunc );
172:
173: //-- Acquire and dispatch messages until a WM_QUIT message is received.
174: while( GetMessage( &msg, NULL, 0, 0 ) ) {
175: if( !TranslateAccelerator( hWndMain, hAccel, &msg ) ) {
176: TranslateMessage( &msg ); // Translates virtual key codes
177: DispatchMessage( &msg ); // Dispatches message to window
178: }
179: }
180:
181: return( msg.wParam ); // Returns the value from PostQuitMessage
182: }
183:
184:
185: // ************************************************************************
186: // FUNCTION : MainWndProc( HWND, UINT, WPARAM, LPARAM )
187: // PURPOSE : Processes uMsgs
188: // MESSAGES :
189: // WM_COMMAND - passed to ProcessCommandsWndProc()
190: // WM_DESTROY - destroy window
191: // ...
192: // COMMENTS : !! I will document this better at a later date !!
193: // ************************************************************************
194: LRESULT CALLBACK
195: MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
196: {
197: static HDC hDC;
198:
199: switch( uMsg ) {
200:
201: case WM_COMMAND:
202: return( ProcessCommandsWndProc( hWnd, uMsg, wParam, lParam) );
203:
204: //-- create debug event listbox
205: case UM_CREATE_LISTBOX: {
206: TCHAR szWindowName[64];
207:
208: LoadString( hInstance, IDS_DEBUG_EVENTS, szWindowName,
209: sizeof(szWindowName) );
210:
211: hWndDebugList = CreateWindow(
212: (LPCTSTR) "ListBox",
213: szWindowName,
214: WS_CHILD | WS_VISIBLE |
215: WS_CAPTION | WS_VSCROLL |
216: WS_HSCROLL | LBS_NOTIFY |
217: LBS_DISABLENOSCROLL | LBS_USETABSTOPS |
218: LBS_NOINTEGRALHEIGHT,
219: SIDE_BORDER,
220: fToolBar ? TextButtonBarHeight + TOP_BORDER : TOP_BORDER,
221: DebugListBoxSize.cx, DebugListBoxSize.cy,
222: hWnd, (HMENU) NULL, hInstance, NULL );
223:
224: //-- Subclass the listbox so the user cannot move it
225: OldListBoxWndProc = SubclassWindow( hWndDebugList, (WNDPROC) NewListBoxWndProc );
226:
227: //-- set listbox font & background color
228: hDC = GetDC( hWndDebugList );
229: hFont = CreateFontIndirect( &LogFont );
230: SelectObject( hDC, hFont );
231: SendMessage( hWndDebugList, WM_CTLCOLORLISTBOX, (DWORD) hDC,
232: (LONG) hWndDebugList );
233: SendMessage( hWndDebugList, WM_SETFONT, (DWORD) hFont, TRUE );
234: ReleaseDC( hWndDebugList, hDC );
235:
236: return( NULL );
237: }
238:
239: //-- Create ToolBar & Debug Events listbox
240: case WM_CREATE:
241: hWndTextButtonBar = CreateTextButtonBar( hWnd, &TextButtonBarHeight );
242: if( fToolBar )
243: ShowWindow( hWndTextButtonBar, SW_SHOW );
244: PostMessage( hWnd, UM_CREATE_LISTBOX, 0, 0 );
245: return( NULL );
246:
247: //-- resize the debug event listbox when the window size changes
248: case WM_SIZE:
249: ClientSize.cx = LOWORD( lParam );
250: ClientSize.cy = HIWORD( lParam );
251: DebugListBoxSize.cx = ClientSize.cx - ( 2*SIDE_BORDER );
252: DebugListBoxSize.cy = max( ClientSize.cy, MIN_HEIGHT + TOP_BORDER )
253: - (TOP_BORDER + BOTTOM_BORDER);
254:
255: if( fToolBar )
256: DebugListBoxSize.cy -= TextButtonBarHeight;
257:
258: if( hWndDebugList != NULL)
259: MoveWindow( hWndDebugList,
260: SIDE_BORDER,
261: fToolBar ? TextButtonBarHeight + TOP_BORDER : TOP_BORDER,
262: DebugListBoxSize.cx, DebugListBoxSize.cy, TRUE );
263:
264: if( wParam == SIZEFULLSCREEN ) {
265: fMaximized = 1;
266: xPos = xPosOld;
267: yPos = yPosOld;
268: }
269: else if( wParam == SIZENORMAL ) {
270: RECT rect;
271:
272: fMaximized = 0;
273: GetWindowRect( hWndMain, &rect );
274: nWidth = (int) (rect.right - rect.left);
275: nHeight = (int) (rect.bottom - rect.top);
276: }
277:
278: return( NULL );
279:
280: case WM_MOVE: {
281: RECT rect;
282:
283: GetWindowRect( hWndMain, &rect );
284: xPosOld = xPos;
285: yPosOld = yPos;
286: xPos = (int) rect.left;
287: yPos = (int) rect.top;
288: return( NULL );
289: }
290:
291: case WM_CTLCOLORLISTBOX: {
292: LOGBRUSH LogBrush;
293:
294: LogBrush.lbStyle = BS_SOLID;
295: LogBrush.lbColor = rgbBkColor;
296: LogBrush.lbHatch = NULL;
297:
298: SetTextColor( (HDC) wParam, rgbColor );
299: SetBkColor( (HDC) wParam, rgbBkColor );
300:
301: return( (LPARAM) CreateBrushIndirect( &LogBrush ) );
302: }
303:
304: case WM_CLOSE:
305: if( ActiveProcesses ) {
306: TCHAR szExitBoxTitle[64];
307: TCHAR szExitBoxText[256];
308:
309: LoadString( hInstance, IDS_EXIT_BOX_TITLE, szExitBoxTitle,
310: sizeof(szExitBoxTitle) );
311: LoadString( hInstance, IDS_EXIT_BOX_TEXT, szExitBoxText,
312: sizeof(szExitBoxText) );
313: if ( MessageBox( hWnd, szExitBoxText, szExitBoxTitle,
314: MB_YESNO | MB_ICONEXCLAMATION ) == IDNO )
315: return( NULL );
316: }
317:
318: //-- store location information to private profile data
319: WritePrivateProfileSettings( szAppTitle, szIniPathName );
320:
321: DestroyWindow( hWndTextButtonBar );
322: DestroyWindow( hWndDebugList );
323: DestroyWindow( hWndMain );
324:
325: return( NULL );
326:
327: case WM_DESTROY:
328: if( fHelpUsed )
329: WinHelp( hWnd, szHelpPathName, (UINT) HELP_QUIT, (DWORD) NULL );
330: PostQuitMessage( 0 );
331: return( NULL );
332:
333: default: // Passes it on if unproccessed
334: return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
335: }
336:
337: return( NULL );
338: }
339:
340:
341: // ************************************************************************
342: // FUNCTION : ProcessCommandsWndProc( HWND, UINT, WPARAM, LPARAM )
343: // PURPOSE : Processes WM_COMMAND messages for MainWndProc()
344: // MESSAGES :
345: // WM_COMMAND - application menu
346: // IDM_FILE_EXIT - exit the application
347: // IDM_FILE_ABOUT - About Dialog Box
348: // ...
349: // COMMENTS : !! I will document this better at a later date !!
350: // ************************************************************************
351: LRESULT CALLBACK
352: ProcessCommandsWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
353: {
354: static LPCTSTR lpszAboutDlgBox = (LPCTSTR) "AboutDlgBox";
355: static LPCTSTR lpszAttachDlgBox = (LPCTSTR) "AttachDlgBox";
356: static LPCTSTR lpszPreferencesDlgBox = (LPCTSTR) "PreferencesDlgBox";
357:
358: switch( LOWORD(wParam) ) {
359:
360: case IDM_FILE_OPEN:
361: if( ActiveProcesses ) {
362: MessageBox( hWndMain,
363: (LPTSTR) "This build of DEB is limited to\n"
364: "debugging only one process at a time.",
365: (LPTSTR) "Cannot Open Debugee",
366: MB_OK | MB_ICONEXCLAMATION );
367: return( FALSE );
368: }
369: if( !OpenDebugee( &pi, &si ) ) {
370: // handle cancel condition
371: }
372: else {
373: if( fClearOnNew ) {
374: SendMessage( hWndDebugList, LB_RESETCONTENT, 0, 0 );
375: MaxStrLen = 0;
376: }
377: }
378: return(NULL);
379:
380: case IDM_FILE_ATTACH:
381: if( ActiveProcesses ) {
382: MessageBox( hWndMain,
383: (LPTSTR) "This build of DEB is limited to\n"
384: "debugging only one process at a time.",
385: (LPTSTR) "Cannot Attach to Debugee",
386: MB_OK | MB_ICONEXCLAMATION );
387: return( FALSE );
388: }
389: if( !DialogBox( hInstance, lpszAttachDlgBox, hWnd,
390: (DLGPROC) AttachDlgProc ) ) {
391: // handle cancel condition
392: }
393: else {
394: if( fClearOnNew ) {
395: SendMessage( hWndDebugList, LB_RESETCONTENT, 0, 0 );
396: MaxStrLen = 0;
397: }
398: }
399: return(NULL);
400:
401: case IDM_EDIT_CUT:
402: CopyListBoxToClipboard( hWndDebugList, MaxStrLen );
403: SendMessage( hWnd, WM_COMMAND, IDM_EDIT_DELETE, 0 );
404: return( NULL );
405:
406: case IDM_EDIT_COPY: {
407: CopyListBoxToClipboard( hWndDebugList, MaxStrLen );
408: return( NULL );
409: }
410:
411: case IDM_EDIT_DELETE:
412: SendMessage( hWndDebugList, LB_RESETCONTENT, 0, 0 );
413: MaxStrLen = 0;
414: return( NULL );
415:
416: case IDM_OPTIONS_FONT:
417: if( !ChooseNewFont( hWndDebugList ) ) {
418: // handle cancel condition
419: }
420: return( NULL );
421:
422: case IDM_OPTIONS_COLOR:
423: ChooseNewBkColor( hWndDebugList );
424: return( NULL );
425:
426: case IDM_OPTIONS_PREFERENCES:
427: DialogBox( hInstance, lpszPreferencesDlgBox, hWnd,
428: (DLGPROC) PreferencesDlgProc );
429: return( NULL );
430:
431: case IDM_OPTIONS_TOOLBAR:
432: if( fToolBar ) {
433: fToolBar = 0;
434: CheckMenuItem( GetMenu(hWndMain), IDM_OPTIONS_TOOLBAR, MF_UNCHECKED );
435: ShowWindow( hWndTextButtonBar, SW_HIDE );
436: SendWmSizeMessage( hWndMain );
437: }
438: else {
439: fToolBar = 1;
440: CheckMenuItem( GetMenu(hWndMain), IDM_OPTIONS_TOOLBAR, MF_CHECKED );
441: ShowWindow( hWndTextButtonBar, SW_SHOW );
442: SendWmSizeMessage( hWndMain );
443: }
444: return( NULL );
445:
446: case IDM_OPTIONS_SAVEDDIR:
447: if( fSavedDirectory ) {
448: fSavedDirectory = 0;
449: CheckMenuItem( GetMenu(hWndMain), IDM_OPTIONS_SAVEDDIR,
450: MF_UNCHECKED );
451: }
452: else {
453: fSavedDirectory = 1;
454: CheckMenuItem( GetMenu(hWndMain), IDM_OPTIONS_SAVEDDIR,
455: MF_CHECKED );
456: }
457: return( NULL );
458:
459: case IDM_OPTIONS_SAVEONEXIT:
460: if( fSaveOnExit ) {
461: fSaveOnExit = 0;
462: CheckMenuItem( GetMenu(hWndMain), IDM_OPTIONS_SAVEONEXIT,
463: MF_UNCHECKED );
464: }
465: else {
466: fSaveOnExit = 1;
467: CheckMenuItem( GetMenu(hWndMain), IDM_OPTIONS_SAVEONEXIT,
468: MF_CHECKED );
469: }
470: return( NULL );
471:
472: case IDM_HELP_CONTENTS:
473: fHelpUsed = TRUE;
474: WinHelp( hWnd, (LPCTSTR) szHelpPathName, HELP_INDEX, (DWORD) NULL );
475: return( NULL );
476:
477: case IDM_HELP_SEARCH:
478: fHelpUsed = TRUE;
479: WinHelp( hWnd, (LPCTSTR) szHelpPathName, HELP_PARTIALKEY, (DWORD) "" );
480: return( NULL );
481:
482: case IDM_HELP_HOWTOUSE:
483: fHelpUsed = TRUE;
484: WinHelp( hWnd, (LPTSTR) NULL, HELP_HELPONHELP, (DWORD) NULL );
485: return( NULL );
486:
487: case IDM_HELP_ABOUT:
488: DialogBox( hInstance, lpszAboutDlgBox, hWnd, (DLGPROC) AboutDlgProc );
489: return( NULL );
490:
491: case IDM_FILE_EXIT:
492: SendMessage( hWndMain, WM_CLOSE, 0, 0 );
493: return( NULL );
494:
495: default:
496: return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
497: }
498:
499: }
500:
501:
502: // ************************************************************************
503: // FUNCTION : PreferencesDlgProc( HWND, UINT, WPARAM, LPARAM )
504: // PURPOSE : Processes message for "Preferences" dialog box
505: // MESSAGES :
506: // WM_INITDIALOG - initialize dialog box
507: // WM_COMMAND - Input received
508: // COMMENTS :
509: //
510: // Wait for user to click on "Ok" button, then close the dialog box.
511: // ************************************************************************
512: BOOL CALLBACK
513: PreferencesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
514: {
515: UNREFERENCED_PARAMETER( lParam );
516:
517: switch( uMsg ) {
518:
519: case WM_COMMAND:
520: switch( LOWORD(wParam) ) {
521:
522: case IDOK:
523: if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_PROCESS), BM_GETCHECK, 0, 0 ) )
524: DebugMode = DEBUG_PROCESS;
525: if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_ONLY_THIS_PROCESS), BM_GETCHECK, 0, 0 ) )
526: DebugMode = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS;
527: if( SendMessage( GetDlgItem( hDlg, IDC_IDLE_PRIORITY_CLASS), BM_GETCHECK, 0, 0 ) )
528: DebugeePriority = IDLE_PRIORITY_CLASS;
529: if( SendMessage( GetDlgItem( hDlg, IDC_NORMAL_PRIORITY_CLASS), BM_GETCHECK, 0, 0 ) )
530: DebugeePriority = NORMAL_PRIORITY_CLASS;
531: if( SendMessage( GetDlgItem( hDlg, IDC_HIGH_PRIORITY_CLASS), BM_GETCHECK, 0, 0 ) )
532: DebugeePriority = HIGH_PRIORITY_CLASS;
533: fClearOnNew = (BOOL) SendMessage( GetDlgItem( hDlg, IDC_CLEAR_ON_NEW),
534: BM_GETCHECK, 0 , 0 );
535: fVerbose = (BOOL) SendMessage( GetDlgItem( hDlg, IDC_VERBOSE),
536: BM_GETCHECK, 0 , 0 );
537: fShowSymbols = (BOOL) SendMessage( GetDlgItem( hDlg, IDC_SHOW_SYMBOLS),
538: BM_GETCHECK, 0 , 0 );
539: fSavePreferences = (BOOL) SendMessage( GetDlgItem( hDlg, IDC_SAVE_PREFERENCES),
540: BM_GETCHECK, 0 , 0 );
541: EndDialog( hDlg, TRUE );
542: return( TRUE );
543:
544: case IDCANCEL:
545: EndDialog( hDlg, FALSE );
546: return( TRUE );
547:
548: case IDHELP:
549: return( TRUE );
550:
551: }
552: break;
553:
554: case WM_INITDIALOG:
555:
556: switch( DebugMode ) {
557:
558: case DEBUG_PROCESS:
559: SendMessage( GetDlgItem( hDlg, IDC_DEBUG_PROCESS),
560: BM_SETCHECK, 1, 0);
561: break;
562:
563: case ( DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS ):
564: SendMessage( GetDlgItem( hDlg, IDC_DEBUG_ONLY_THIS_PROCESS),
565: BM_SETCHECK, 1, 0);
566: break;
567: }
568:
569: switch( DebugeePriority ) {
570:
571: case IDLE_PRIORITY_CLASS:
572: SendMessage( GetDlgItem( hDlg, IDC_IDLE_PRIORITY_CLASS),
573: BM_SETCHECK, 1, 0);
574: break;
575:
576: case NORMAL_PRIORITY_CLASS:
577: SendMessage( GetDlgItem( hDlg, IDC_NORMAL_PRIORITY_CLASS),
578: BM_SETCHECK, 1, 0);
579: break;
580:
581: case HIGH_PRIORITY_CLASS:
582: SendMessage( GetDlgItem( hDlg, IDC_HIGH_PRIORITY_CLASS),
583: BM_SETCHECK, 1, 0);
584: break;
585: }
586:
587: SendMessage( GetDlgItem( hDlg, IDC_CLEAR_ON_NEW), BM_SETCHECK,
588: fClearOnNew, 0 );
589: SendMessage( GetDlgItem( hDlg, IDC_VERBOSE), BM_SETCHECK,
590: fVerbose, 0 );
591: SendMessage( GetDlgItem( hDlg, IDC_SHOW_SYMBOLS), BM_SETCHECK,
592: fShowSymbols, 0 );
593: SendMessage( GetDlgItem( hDlg, IDC_SAVE_PREFERENCES), BM_SETCHECK,
594: fSavePreferences, 0 );
595:
596: return( TRUE );
597: }
598:
599: return( FALSE );
600: }
601:
602:
603: // ************************************************************************
604: // FUNCTION : AttachDlgProc( HWND, UINT, WPARAM, LPARAM )
605: // PURPOSE : Processes messages for "Attach" dialog box
606: // MESSAGES :
607: // WM_INITDIALOG - initialize dialog box
608: // WM_COMMAND - Input received
609: // COMMENTS :
610: //
611: // Wait for user to click on "Ok" button, then close the dialog box.
612: // ************************************************************************
613: BOOL CALLBACK
614: AttachDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
615: {
616: static HWND hWndProcessList;
617: static DWORD idDebugEventThread;
618: static DWORD dwProcessId;
619: static LONG idx;
620:
621: UNREFERENCED_PARAMETER( lParam );
622:
623: switch( uMsg ) {
624:
625: case WM_COMMAND:
626: switch( LOWORD(wParam) ) {
627:
628: case IDOK:
629: idx = (UINT) SendMessage( hWndProcessList, LB_GETCURSEL,
630: NULL, NULL );
631: dwProcessId = (DWORD) SendMessage( hWndProcessList,
632: LB_GETITEMDATA,
633: idx, NULL );
634:
635: //-- create debug event processing thread and attach to the process
636: CreateThread(
637: (LPSECURITY_ATTRIBUTES) NULL,
638: (DWORD) 0,
639: (LPTHREAD_START_ROUTINE) DebugEventThread,
640: (LPVOID) dwProcessId,
641: (DWORD) NULL,
642: (LPDWORD) &idDebugEventThread);
643: EndDialog( hDlg, TRUE );
644: return( TRUE );
645:
646: case IDCANCEL:
647: EndDialog( hDlg, FALSE );
648: return( TRUE );
649:
650: case IDHELP:
651: return( TRUE );
652:
653: }
654:
655: switch( HIWORD( wParam ) ) {
656:
657: case LBN_DBLCLK:
658: SendMessage( hDlg, WM_COMMAND, (WPARAM) IDOK, (LPARAM) 0L );
659: return( TRUE );
660: }
661: break;
662:
663: case WM_INITDIALOG:
664: hWndProcessList = GetDlgItem( hDlg, IDC_PROCESSLIST );
665: SendMessage( hWndProcessList, LB_RESETCONTENT, 0 , 0 );
666: for(; !EnumWindows( (WNDENUMPROC) EnumProcessListFunc,
667: (LPARAM) hWndProcessList ); )
668: ; // continue looping until done
669: return( TRUE );
670: }
671:
672: return( FALSE );
673: }
674:
675:
676: // ************************************************************************
677: // FUNCTION : AboutDlgProc( HWND, UINT, WPARAM, LPARAM )
678: // PURPOSE : Processes messages for "About" dialog box
679: // MESSAGES :
680: // WM_INITDIALOG - initialize dialog box
681: // WM_COMMAND - Input received
682: // COMMENTS :
683: // No initialization is needed for this particular dialog box, but TRUE
684: // must be returned to Windows.
685: //
686: // Wait for user to click on "Ok" button, then close the dialog box.
687: // ************************************************************************
688: BOOL CALLBACK
689: AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
690: {
691: UNREFERENCED_PARAMETER( lParam );
692:
693: switch( uMsg ) {
694:
695: case WM_COMMAND:
696: switch( LOWORD(wParam) ) {
697:
698: case IDOK:
699: EndDialog( hDlg, TRUE );
700: return( TRUE );
701: }
702: break;
703:
704: case WM_INITDIALOG:
705: return( TRUE );
706:
707: case WM_CLOSE:
708: EndDialog( hDlg, TRUE );
709: return( TRUE );
710:
711: }
712:
713: return( FALSE );
714: }
715:
716:
717: // ************************************************************************
718: // FUNCTION : NewListBoxWndProc( HWND, UINT, WPARAM, LPARAM )
719: // PURPOSE : Processes messages for "LISTBOX" class.
720: // COMMENTS : Prevents the user from moving the window
721: // by dragging the titlebar.
722: // ************************************************************************
723: LRESULT CALLBACK
724: NewListBoxWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
725: {
726: switch( uMsg ) {
727:
728: case WM_NCLBUTTONDOWN:
729: if( wParam == HTCAPTION ) {
730: SetFocus( hWnd );
731: return( NULL );
732: }
733: else
734: break;
735: }
736:
737: return( CallWindowProc( OldListBoxWndProc, hWnd, uMsg, wParam, lParam) );
738: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.