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