static ExtendedSort() { FARPROC dialproc; dialproc = MakeProcInstance( ExtendedSortProc, Instance ); JDialogBox( Instance, "EXTEND_SORT", HeapWalkMainWindow, dialproc ); FreeProcInstance( dialproc ); } /* ExtendedSort */
void ShowDIPStatus( HWND hwnd ) { FARPROC fp; fp = MakeProcInstance( (FARPROC)ShowDipStatDlgProc, Instance ); JDialogBox( Instance, "DIP_STATUS_DLG", hwnd, (DLGPROC)fp ); FreeProcInstance( fp ); }
/* * HWConfigure - get configuration information from the user */ void HWConfigure( void ) { FARPROC fp; fp = MakeProcInstance( (FARPROC)ConfigDlgProc, Instance ); JDialogBox( Instance, "HEAP_CONFIG", HeapWalkMainWindow, (DLGPROC)fp ); FreeProcInstance( fp ); } /* HWConfigure */
/* * DoStatDialog - run the stat dialog */ void DoStatDialog( HWND hwnd ) { FARPROC fp; fp = MakeProcInstance( StatDialog, Instance ); JDialogBox( Instance, "TASKSTATUS", hwnd, fp ); FreeProcInstance( fp ); } /* DoStatDialog */
/* * DoStatDialog - run the stat dialog */ int DoStatDialog( HWND hwnd ) { DLGPROC fp; INT_PTR ret; fp = (DLGPROC)MakeProcInstance( StatDialog, Instance ); ret = JDialogBox( Instance, "TASKSTATUS", hwnd, fp ); FreeProcInstance( fp ); return( ret ); } /* DoStatDialog */
/* * QueryEnd - warn the user about the consequences of exitting */ BOOL QueryEnd( HWND owner ) { INT_PTR rc; if( GetNextOwnedProc( NULL ) == NULL ) { return( TRUE ); } rc = JDialogBox( Instance, "END_DLG", owner, QueryEndDlgProc ); return( rc == END_YES ); }
/* * SetLogOptions */ void SetLogOptions( HWND hwnd ) { JDialogBox( Instance, "LOG", hwnd, LogOptsDlgProc ); }
/* * StatDialog - show task status */ BOOL CALLBACK StatDialog( HWND hwnd, UINT msg,WPARAM wparam, LPARAM lparam ) { WORD cmd; FARPROC fp; StatData *statdata; statdata = (StatData *)GetWindowLong( hwnd, DWL_USER ); fp = fp; switch( msg ) { case STAT_FOREGROUND: #ifdef __NT__ SetForegroundWindow( hwnd ); #else SetActiveWindow( hwnd ); #endif break; case WM_INITDIALOG: InitStatDialog( hwnd ); return( FALSE ); case STAT_MAD_NOTIFY: switch( wparam ) { case MNT_REDRAW_REG: case MNT_MODIFY_REG: DoUpdateWalk( hwnd, (mad_reg_set_data *)lparam ); break; case MNT_MODIFY_IP: case MNT_REDRAW_DISASM: DisplayAsmLines( hwnd, &( statdata->curr_addr ) ); break; } break; case WM_VSCROLL: ScrollAsmDisplay( hwnd, wparam, &( statdata->curr_addr ) ); break; case WM_CLOSE: PostMessage( hwnd, WM_COMMAND, IDCANCEL, 0L ); return( TRUE ); case WM_DESTROY: StatHdl = NULL; MemFree( statdata ); break; case WM_COMMAND: if( HIWORD( wparam ) == CBN_SELCHANGE ) { SwitchRegSets( hwnd, statdata ); break; } cmd = LOWORD( wparam ); switch( cmd ) { #ifndef __NT__ case STAT_SEG_MAP: fp = MakeProcInstance( SegMapDlgProc, Instance ); JDialogBox( Instance, "SEG_MAP_DLG", hwnd, fp ); FreeProcInstance( fp ); break; case STAT_STACK_TRACE: StartStackTraceDialog( hwnd ); break; #else case STAT_SEG_MAP: { HANDLE hdl; ExceptDlgInfo * info; info = StatGetExceptDlgInfo( hwnd ); DuplicateHandle( GetCurrentProcess(), info->procinfo->prochdl, GetCurrentProcess(), &hdl, 0, FALSE, DUPLICATE_SAME_ACCESS ); WalkMemory( hwnd, hdl, info->procinfo->procid ); } break; #endif case STAT_SYMBOLS: if( StatShowSymbols == TRUE ) { StatShowSymbols = FALSE; } else { StatShowSymbols = TRUE; } DisplayAsmLines( hwnd, &( statdata->curr_addr ) ); break; case IDCANCEL: EndDialog( hwnd, 0 ); return( TRUE ); case IDOK: EndDialog( hwnd, 1 ); return( TRUE ); } } return( FALSE ); } /* StatDialog */
/* * StatDialog - show task status */ BOOL FAR PASCAL StatDialog( HWND hwnd, UINT msg, UINT wparam, DWORD lparam ) { WORD cmd; FARPROC fp; fp = fp; lparam = lparam; switch( msg ) { case WM_INITDIALOG: InitStatDialog( hwnd ); oldIntData = IntData; return( TRUE ); break; case WM_VSCROLL: ScrollAsmDisplay( hwnd, wparam, &currAddr, &firstAddr, STAT_DISASM_1, STAT_DISASM_8, STAT_SCROLL ); break; case WM_USER: /* an owned window is being destroyed make sure * Windows doesn't take the focus away from us*/ SetFocus( hwnd ); break; case WM_CLOSE: PostMessage( hwnd, WM_COMMAND, STAT_CANCEL, 0L ); return( TRUE ); case WM_COMMAND: cmd = LOWORD( wparam ); switch( cmd ) { #ifndef __NT__ case STAT_SEG_MAP: fp = MakeProcInstance( SegMapDlgProc, Instance ); JDialogBox( Instance, "SEG_MAP_DLG", hwnd, fp ); FreeProcInstance( fp ); break; case STAT_STACK_TRACE: StartStackTraceDialog( hwnd ); break; #else case STAT_SEG_MAP: { HANDLE hdl; DuplicateHandle( GetCurrentProcess(), processHdl, GetCurrentProcess(), &hdl, 0, FALSE, DUPLICATE_SAME_ACCESS ); WalkMemory( hwnd, hdl, processID ); } break; #endif case STAT_SYMBOLS: StatShowSymbols = !StatShowSymbols; CheckDlgButton( hwnd, STAT_SYMBOLS, ( StatShowSymbols ) ? BST_CHECKED : BST_UNCHECKED ); DisplayAsmLines( hwnd, &currAddr, &firstAddr, STAT_DISASM_1, STAT_DISASM_8, STAT_SCROLL ); break; case STAT_APPLY: GetStatRegisters( hwnd ); InitStatDialog( hwnd ); return( TRUE ); case IDCANCEL: IntData = oldIntData; EndDialog( hwnd, 0 ); return( TRUE ); case IDOK: GetStatRegisters( hwnd ); EndDialog( hwnd, 0 ); return( TRUE ); } } return( FALSE ); } /* StatDialog */
/* * NewImage - create a new image and return the image type (bitmap, icon, or cursor) */ int NewImage( int img_type, const char *filename ) { WPI_DLGPROC dlgproc; INT_PTR button_type; short width; short height; short bcount; img_node node; char ext[_MAX_EXT]; // If filename is not NULL and we don't know the image type, // then guess based on the file extesion. if( filename != NULL && img_type == UNDEF_IMG ) { _splitpath( filename, NULL, NULL, NULL, ext ); if( stricmp( ext, ".bmp" ) == 0 ) { img_type = BITMAP_IMG; } else if( stricmp( ext, ".ico" ) == 0 ) { img_type = ICON_IMG; } else if( stricmp( ext, ".cur" ) == 0 ) { img_type = CURSOR_IMG; } } if( img_type == UNDEF_IMG ) { dlgproc = _wpi_makedlgprocinstance( SelImgDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, SELECTIMAGE, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { return( FALSE ); } } else { imgType = img_type; } imageCount++; switch( imgType ) { case BITMAP_IMG: dlgproc = _wpi_makedlgprocinstance( SelBitmapDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, BITMAPTYPE, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { imgType = UNDEF_IMG; imageCount--; return( imgType ); } else if( button_type == SEL_SELECT ) { #ifdef __OS2_PM__ IEDisplayErrorMsg( WIE_NOTE, WIE_NOTIMPLEMENTED, MB_OK | MB_ICONINFORMATION ); return( FALSE ); #else if( !SelectDynamicBitmap( &node, imageCount, filename ) ) { return( FALSE ); } #endif } else { initializeImage( &node, filename ); } break; case ICON_IMG: if( !CreateNewIcon( &width, &height, &bcount, TRUE ) ) { imgType = UNDEF_IMG; return( imgType ); } imgWidth = width; imgHeight = height; bitCount = bcount; initializeImage( &node, filename ); break; case CURSOR_IMG: #ifdef __OS2_PM__ if( !CreateNewIcon( &width, &height, &bcount, FALSE ) ) { imgType = UNDEF_IMG; return( imgType ); } imgWidth = width; imgHeight = height; bitCount = bcount; #else dlgproc = MakeProcInstance_DLG( SelCursorDlgProc, Instance ); button_type = JDialogBox( Instance, "CURSORTYPE", HMainWindow, dlgproc ); FreeProcInstance_DLG( dlgproc ); if( button_type == IDCANCEL ) { imgType = UNDEF_IMG; return( imgType ); } #endif initializeImage( &node, filename ); break; default: return( FALSE ); } node.wrinfo = NULL; node.lnode = NULL; CreateNewDrawPad( &node ); SetupMenuAfterOpen(); return( imgType ); } /* NewImage */
/* * HeapWalkProc - show task status */ BOOL FAR PASCAL HeapWalkProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { HMENU mh; HMENU mh2; HCURSOR hourglass; HCURSOR oldcursor; DLGPROC dlgproc; DWORD index; heap_list hl; GblWndInfo *info; RECT area; about_info ai; info = (GblWndInfo *)GetWindowLong( hwnd, 0 ); switch( msg ) { case WM_CREATE: InitPaintProc(); info = MemAlloc( sizeof( GblWndInfo ) ); if( info == NULL ) { ErrorBox( hwnd, STR_UNABLE_2_STARTUP, MB_OK | MB_ICONINFORMATION ); PostQuitMessage( 0 ); } memset( info, 0, sizeof( GblWndInfo ) ); SetWindowLong( hwnd, 0, (DWORD)info ); // hdc = GetDC( hwnd ); // ReleaseDC(hwnd, hdc); SetDisplayType( hwnd, &( info->list.title ), HEAPMENU_DISPLAY_INIT ); CreateListBox( hwnd, &info->list, GLOBAL_LB ); info->alloc_dlgproc = MakeProcInstance_DLG( AllocDlgProc, Instance ); info->alloc_dialog = JCreateDialog( Instance, "ALLOC_DLG", hwnd, info->alloc_dlgproc ); memset( &ResHwnd, 0, MAX_RES * sizeof( HWND ) ); break; case WM_MEASUREITEM: break; case WM_MOVE: GetWindowRect( hwnd, &area ); if( !info->minimized ) { Config.last_glob_xpos = Config.glob_xpos; Config.last_glob_ypos = Config.glob_ypos; Config.glob_xpos = area.left; Config.glob_ypos = area.top; } break; case WM_SIZE: ResizeListBox( LOWORD( lparam ), HIWORD( lparam ), &( info->list ) ); if( wparam == SIZE_MINIMIZED || wparam == SIZE_MAXIMIZED ) { Config.glob_xpos = Config.last_glob_xpos; Config.glob_ypos = Config.last_glob_ypos; } if( wparam == SIZE_MINIMIZED ) { info->minimized = TRUE; HideResources( TRUE ); } else if( info->minimized ) { HideResources( FALSE ); info->minimized = FALSE; } else if( wparam != SIZE_MAXIMIZED ) { GetWindowRect( hwnd, &area ); Config.glob_xsize = area.right - area.left; Config.glob_ysize = area.bottom - area.top; } return( DefWindowProc( hwnd, msg, wparam, lparam ) ); break; case WM_CLOSE: PostMessage( hwnd, WM_COMMAND, HEAPMENU_EXIT, 0L ); return( TRUE ); case WM_QUERYENDSESSION: SaveConfigFile( FALSE ); return( TRUE ); break; case WM_DESTROY: FiniPaintProc(); KillPushWin( info->list.title ); SaveConfigFile( FALSE ); if( info != NULL ) { FreeProcInstance_DLG( info->alloc_dlgproc ); MemFree( info ); } DestroyMonoFonts(); CvrCtl3dUnregister( Instance ); CvrCtl3DFini( Instance ); WWinHelp( hwnd, "heapwalk.hlp", HELP_QUIT, 0 ); PostQuitMessage( 0 ); break; case WM_ACTIVATEAPP: if( wparam && !NoRefresh ) { if( info->doing_add ) { info->need_refresh = TRUE; } else { InitHeapList( info->list.box, TRUE ); } } break; case WM_MENUSELECT: if( LOWORD( lparam & MF_POPUP ) ) { mh = GetMenu( hwnd ); mh2 = GetSubMenu( mh, 6 ); if( (HMENU)wparam == mh2 ) { ShowWindow( info->alloc_dialog, SW_SHOWNOACTIVATE ); } else if( (HMENU)wparam != GetSubMenu( mh2, 3 ) && (HMENU)wparam != GetSubMenu( mh2, 4 ) && (HMENU)wparam != GetSubMenu( mh2, 5 ) ) { ShowWindow( info->alloc_dialog, SW_HIDE ); } } return( DefWindowProc( hwnd, msg, wparam, lparam ) ); break; case WM_COMMAND: switch( wparam ) { case HEAPMENU_ABOUT: ai.owner = hwnd; ai.inst = Instance; ai.name = HWAllocRCString( STR_ABOUT_NAME ); ai.version = HWAllocRCString( STR_ABOUT_VERSION ); ai.title = HWAllocRCString( STR_ABOUT_TITLE ); DoAbout( &ai ); HWFreeRCString( ai.title ); HWFreeRCString( ai.version ); HWFreeRCString( ai.name ); break; case HEAPMENU_HELP_CONTENTS: WWinHelp( hwnd, "heapwalk.hlp", HELP_CONTENTS, 0 ); break; case HEAPMENU_HELP_SRCH: WWinHelp( hwnd, "heapwalk.hlp", HELP_PARTIALKEY, (HELP_DATA)(LPCSTR)"" ); break; case HEAPMENU_HELP_ON_HELP: WWinHelp( hwnd, "winhelp.hlp", HELP_HELPONHELP, 0 ); break; case HEAPEX_LIST: if( !info->doing_add ) { if( HIWORD( lparam ) == LBN_DBLCLK ) { ShowHeapObject( (HWND)LOWORD( lparam ) ); } } else { if( HIWORD( lparam ) == LBN_SELCHANGE || HIWORD( lparam ) == LBN_DBLCLK ) { RefreshAdd( info->add_dialog, info->list.box ); RedrawBox( info->list.box, index ); } } break; case HEAPMENU_GLOBAL_REFRESH: InitHeapList( info->list.box, TRUE ); break; case HEAPMENU_FONT: if( ChooseMonoFont( hwnd ) ) { ResetFont( info ); } break; case HEAPMENU_EXIT: DestroyWindow( hwnd ); FreeHeapList(); break; case HEAPMENU_DISPLAY_DPMI: case HEAPMENU_DISPLAY_ENTIRE: case HEAPMENU_DISPLAY_LRU: case HEAPMENU_DISPLAY_FREE: SetDisplayType( hwnd, &( info->list.title ), wparam ); InitHeapList( info->list.box, FALSE ); break; case HEAPMENU_SORT_ADDR: case HEAPMENU_SORT_HANDLE: case HEAPMENU_SORT_MODULE: case HEAPMENU_SORT_SIZE: case HEAPMENU_SORT_TYPE: case HEAPMENU_SORT_GRAN: case HEAPMENU_SORT_DPL: case HEAPMENU_SORT_FLAG: case HEAPMENU_SORT_LRU: mh = GetMenu( hwnd ); CheckMenuItem( mh, GSortType, MF_UNCHECKED | MF_BYCOMMAND ); CheckMenuItem( mh, wparam, MF_CHECKED | MF_BYCOMMAND ); if( GSortType != wparam ) { GSortType = wparam; SortHeapList(); ReDisplayHeapList( info->list.box, NULL ); } break; case HEAPMENU_OBJECT_SHOW: ShowHeapObject( info->list.box ); break; case HEAPMENU_OBJECT_DISCARD: if( GlobDiscardObj( info->list.box ) ) { InitHeapList( info->list.box, TRUE ); } break; case HEAPMENU_OBJECT_NEWEST: if( GlobSetObjPos( info->list.box, FALSE ) ) { if( GSortType == HEAPMENU_SORT_LRU ) { InitHeapList( info->list.box, TRUE ); } } break; case HEAPMENU_OBJECT_OLDEST: if( GlobSetObjPos( info->list.box, TRUE ) ) { if( GSortType == HEAPMENU_SORT_LRU ) { InitHeapList( info->list.box, TRUE ); } } break; case HEAPMENU_OBJECT_GET_SELECTOR: ShowSelector( info->list.box ); break; case HEAPMENU_GLOBAL_HEAPINFO: DisplayGlobHeapInfo( hwnd ); break; case HEAPMENU_GLOBAL_MEMORYINFO: DisplayMemManInfo( hwnd ); break; case HEAPMENU_GLOBAL_COMPACT: GlobalCompact( 0 ); InitHeapList( info->list.box, TRUE ); break; case HEAPMENU_GLOBAL_COMP_DISC: GlobalCompact( -1 ); InitHeapList( info->list.box, TRUE ); break; case HEAPMENU_GLOBAL_CODE_SIZE: dlgproc = MakeProcInstance_DLG( SetCodeDlgProc, Instance ); JDialogBox( Instance, "CODE_AREA_DLG", hwnd, dlgproc ); FreeProcInstance_DLG( dlgproc ); break; case HEAPMENU_FILE_SAVE: InitHeapList( info->list.box, TRUE ); SaveListBox( SLB_SAVE_TMP, PutOutGlobalHeader, DumpGlobalLine, Config.gfname, HeapWalkName, hwnd, info->list.box ); break; case HEAPMENU_FILE_SAVE_TO: InitHeapList( info->list.box, TRUE ); SaveListBox( SLB_SAVE_AS, PutOutGlobalHeader, DumpGlobalLine, Config.gfname, HeapWalkName, hwnd, info->list.box ); break; case HEAPMENU_SAVE_CONFIG: SaveConfigFile( TRUE ); break; case HEAPMENU_CONFIGURE: HWConfigure(); break; case HEAPMENU_LOCAL_MONITOR: index = CheckForLocalSelect( info ); if( index != LB_ERR ) { BeginMonitor( HeapList[index] ); } break; case HEAPMENU_COMPACT_AND_LOCALWALK: LocalCompact( -1 ); /* fall through */ case HEAPMENU_LOCAL_LOCALWALK: index = CheckForLocalSelect( info ); if( index != LB_ERR ) { LocalWalk( HeapList[index] ); } break; case HEAPMENU_GDI_LOCALWALK: if( GetDGroupItem( "GDI", &hl ) ) { LocalWalk( &hl ); } break; case HEAPMENU_USER_LOCALWALK: if( GetDGroupItem( "USER", &hl ) ) { LocalWalk( &hl ); } break; case HEAPMENU_FREE_ALL: MyFreeAllMem(); UpdateAllocInfo( info->alloc_dialog ); PaintAllWindows(); break; case HEAPMENU_FREE_1K: case HEAPMENU_FREE_2K: case HEAPMENU_FREE_5K: case HEAPMENU_FREE_10K: case HEAPMENU_FREE_25K: case HEAPMENU_FREE_50K: hourglass = LoadCursor( NULL, IDC_WAIT ); SetCapture( hwnd ); oldcursor= SetCursor( hourglass ); FreeSomeMem( wparam ); UpdateAllocInfo( info->alloc_dialog ); SetCursor( oldcursor ); ReleaseCapture(); PaintAllWindows(); break; case HEAPMENU_ALLOC_1K: case HEAPMENU_ALLOC_2K: case HEAPMENU_ALLOC_5K: case HEAPMENU_ALLOC_10K: case HEAPMENU_ALLOC_25K: case HEAPMENU_ALLOC_50K: hourglass = LoadCursor( NULL, IDC_WAIT ); SetCapture( hwnd ); oldcursor= SetCursor( hourglass ); AllocMore( wparam ); UpdateAllocInfo( info->alloc_dialog ); SetCursor( oldcursor ); ReleaseCapture(); PaintAllWindows(); break; case HEAPMENU_ALLOC_ALL: case HEAPMENU_ALLOC_BUT_1K: case HEAPMENU_ALLOC_BUT_2K: case HEAPMENU_ALLOC_BUT_5K: case HEAPMENU_ALLOC_BUT_10K: case HEAPMENU_ALLOC_BUT_25K: case HEAPMENU_ALLOC_BUT_50K: hourglass = LoadCursor( NULL, IDC_WAIT ); SetCapture( hwnd ); oldcursor= SetCursor( hourglass ); AllocAllBut( wparam ); UpdateAllocInfo( info->alloc_dialog ); SetCursor( oldcursor ); ReleaseCapture(); PaintAllWindows(); break; case HEAPMENU_ALLOC_NK: case HEAPMENU_ALLOC_BUT_NK: case HEAPMENU_FREE_NK: DoNBytes( hwnd, wparam ); UpdateAllocInfo( info->alloc_dialog ); PaintAllWindows(); break; case HEAPMENU_ADD: info->add_dialog = StartAdd( hwnd, &info->list ); if( info->add_dialog != NULL ) { info->doing_add = TRUE; info->need_refresh = FALSE; } else { ErrorBox( hwnd, STR_UNABLE_TO_ADD, MB_OK| MB_ICONINFORMATION ); } break; } break; case WM_USER: /* an owned window is being destroyed make sure * Windows doesn't take the focus away from us*/ NoRefresh = TRUE; SetFocus( hwnd ); NoRefresh = FALSE; break; default: return( DefWindowProc( hwnd, msg, wparam, lparam ) ); } return( FALSE ); } /* HeapWalkProc */