Exemplo n.º 1
0
/*
 * CheckForLocalSelect - return the index of the current item if it
 *                       has a local heap otherwise print an appropriate
 *                       message and return LB_ERR
 */
static DWORD CheckForLocalSelect( GblWndInfo *info ) {

    int    index;

    index = (int)SendMessage( info->list.box, LB_GETCURSEL, 0, 0 );
    if( index == LB_ERR ) {
        RCMessageBox( NULL, STR_NO_ITEM_SELECTED, HeapWalkName,
                    MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL );
    } else if( !HeapList[index]->info.ge.wHeapPresent ) {
        RCMessageBox( NULL, STR_HAS_NO_LCL_HEAP, HeapWalkName,
                    MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL );
        index = LB_ERR;
    }
    return( index );
}
Exemplo n.º 2
0
/*
 * SpyLogOpen - open the log file
 */
BOOL SpyLogOpen( void )
{
    int         f;
    WORD        flags;
    FARPROC     fp;
    INT_PTR     ret;
    char        *msgtitle;

    flags = 0;
    if( !LogCurInfo.init ) {
        SetLogDef();
    }
    if( LogCurInfo.config.query_for_name ) {
        if( !getLogName( LogCurInfo.config.name, LogCurInfo.hwnd ) ) {
            return( FALSE );
        }
    }
    strcpy( LogCurInfo.config.curname, LogCurInfo.config.name );
    switch( LogCurInfo.config.def_action ) {
    case LOG_ACTION_TRUNC:
        flags = O_TRUNC;
        break;
    case LOG_ACTION_APPEND:
        flags = O_APPEND;
        break;
    case LOG_ACTION_QUERY:
        if( !access( LogCurInfo.config.curname, F_OK ) ) {
            fp = MakeDlgProcInstance( LogExistsDlgProc, LogCurInfo.instance );
            ret = DialogBox( LogCurInfo.instance, "LOG_EXISTS_DLG", LogCurInfo.hwnd, (DLGPROC)fp );
            FreeProcInstance( fp );
            switch( ret ) {
            case LOG_APPEND:
                flags = O_APPEND;
                break;
            case LOG_REPLACE:
                flags = O_TRUNC;
                break;
            case LOG_CANCEL:
                return( FALSE );
            }
        }
        break;
    }
    f = open( LogCurInfo.config.curname, O_TEXT | O_WRONLY | O_CREAT | flags, S_IREAD | S_IWRITE );
    if( f < 0 ) {
        msgtitle = AllocRCString( LOG_LOG_ERROR );
        RCMessageBox( LogCurInfo.hwnd, LOG_CANT_OPEN_LOG, msgtitle,
                      MB_OK | MB_ICONEXCLAMATION );
        FreeRCString( msgtitle );
        return( FALSE );
    }
    if( LogCurInfo.writefn != NULL ) {
        LogCurInfo.writefn( f );
    }
    close( f );
    LogCurInfo.config.logging = TRUE;
    LogCurInfo.config.paused = FALSE;
    return( TRUE );

} /* SpyLogOpen */
Exemplo n.º 3
0
void BeginMonitor( heap_list *item ) {

    HWND                hwnd;
    char                title[50];
    int                 width;
    int                 hight;
    LocalMonInfo        *info;
    WORD                i;
    char                *msgtitle;

    if( !LabelsInitialized ) {
        MonitorLabels[ STATIC_SIZE ] = HWGetRCString( STR_STATIC_DATA );
        MonitorLabels[ STACK_SIZE ] = HWGetRCString( STR_STACK_ALLOCATED );
        MonitorLabels[ FIXED_SIZE ] = HWGetRCString( STR_FIXED_HEAP );
        MonitorLabels[ MOVE_SIZE ] = HWGetRCString( STR_MOVEABLE_HEAP );
        MonitorLabels[ FREE_SIZE ] = HWGetRCString( STR_FREE_HEAP );
        MonitorLabels[ OTHER_SIZE ] = HWGetRCString( STR_MONITOR_UNKNOWN );
        LabelsInitialized = TRUE;
    }
    if( Brushes.use_cnt == 0 ) {
        for( i=0; i < SIZE_CNT; i++ ) {
            Brushes.brush[i] = CreateSolidBrush( BarColors[i] );
        }
    }
    Brushes.use_cnt++;
    width = GetSystemMetrics( SM_CXSCREEN );
    hight = GetSystemMetrics( SM_CYSCREEN );
    RCsprintf( title, STR_LCL_MONITOR_TITLE, item->szModule );

    info = MemAlloc( sizeof( LocalMonInfo ) );
    memset( info, 0, sizeof( LocalMonInfo ) );
    info->instance = item->info.ge.hBlock;
    info->task_hdl = GetTaskHdl( info->instance );
    info->total_size = item->info.ge.dwBlockSize;
    info->handle = item->info.ge.hBlock;

    hwnd = CreateWindow(
        LOCAL_MONITOR_CLASS,            /* Window class name */
        title,                          /* Window caption */
        WS_OVERLAPPED|WS_CAPTION
        |WS_SYSMENU|WS_THICKFRAME
        |WS_MAXIMIZEBOX,                /* Window style */
        width/12,                       /* Initial X position */
        hight/4,                        /* Initial Y position */
        5*width/6,                      /* Initial X size */
        hight/2,                        /* Initial Y size */
        HeapWalkMainWindow,             /* Parent window handle */
        NULL,                           /* Window menu handle */
        Instance,                       /* Program instance handle */
        info );                         /* Create parameters */
    if( hwnd == NULL ) {
        msgtitle = HWAllocRCString( STR_MONITOR_LCL_HEAP );
        RCMessageBox( NULL, STR_CANT_OPEN_LCL_MONITOR, HeapWalkName,
                    MB_OK | MB_TASKMODAL | MB_ICONINFORMATION );
        HWFreeRCString( msgtitle );
    }
    ShowWindow( hwnd, SW_SHOWNORMAL );
    UpdateWindow( hwnd );
}
Exemplo n.º 4
0
BOOL LoadTheDips( void ) {

    int         rc;
    unsigned    i;
    char        *ptr;
    char        buf[256];
    char        status[80];
    BOOL        diploaded;

    diploaded = FALSE;
    i = 0;
    initDipMsgs();
    ptr = DIPDefaults;
    while( *ptr != '\0' ) {
        rc = DIPLoad( ptr );
        if( rc & DS_ERR ) {
            rc &= ~DS_ERR;
            switch( rc ) {
            case DS_FOPEN_FAILED:
                CopyRCString( STR_DIP_NOT_FOUND, status, sizeof( status ) );
                break;
            case DS_INVALID_DIP_VERSION:
                CopyRCString( STR_WRONG_DIP_VERSION, status, sizeof( status ) );
                break;
            case DS_INVALID_DIP:
                CopyRCString( STR_BAD_DIP, status, sizeof( status) );
                break;
            case DS_TOO_MANY_DIPS:
                CopyRCString( STR_TOO_MANY_DIPS, status, sizeof( status) );
                break;
            default:
                CopyRCString( STR_DIP_ERR_OTHER, status, sizeof( status) );
                break;
            }
        } else {
            CopyRCString( STR_DIP_LOADED, status, sizeof( status) );
            diploaded = TRUE;
        }
        sprintf( buf, "%-18s %s", ptr, status );
        theLoadInfo[i].loadmsg = MemAlloc( strlen( buf ) + 1 );
        theLoadInfo[i].loaded = !( rc & DS_ERR );
#ifdef __WINDOWS__
        if( theLoadInfo[i].loaded ) {
            theLoadInfo[i].hinst = DIPLastHandle;
        }
#endif
        strcpy( theLoadInfo[i].loadmsg, buf );
        ptr += strlen( ptr ) + 1;
        i++;
    }
    if( !diploaded ) {
        RCMessageBox( NULL, STR_NO_DIPS_LOADED, AppName,
                      MB_OK | MB_ICONEXCLAMATION );
        ShowDIPStatus( NULL );
        DIPFini();
        return( FALSE );
    }
    return( TRUE );
}
Exemplo n.º 5
0
/*
 * InitDip
 */
bool InitDip( void )
{
    if( DIPInit() & DS_ERR ) {
        RCMessageBox( NULL, STR_CANT_LOAD_DIP, AppName, MB_OK | MB_ICONEXCLAMATION );
        return( false );
    }
    return( LoadTheDips() );
}
Exemplo n.º 6
0
/*
 * ThreadCtlProc
 */
INT_PTR CALLBACK RetCodeDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    RetCodeInfo         *info;
    WORD                cmd;
    char                buf[BUF_SIZE];
    char                *title;
    msg_id              info_str_id;
    bool                ret;

    ret = false;

    info = (RetCodeInfo *)GET_DLGDATA( hwnd );
    switch( msg ) {
    case WM_INITDIALOG:
        info = (RetCodeInfo *)lparam;
        info->really_kill = FALSE;
        SET_DLGDATA( hwnd, lparam );
        if( info->type == RETCD_THREAD ) {
            title = AllocRCString( STR_THREAD_RETURN_CODE );
            info_str_id = STR_THREAD_X;
        } else {
            title = AllocRCString( STR_PROCESS_RETURN_CODE );
            info_str_id = STR_PROCESS_X;
        }
        SetWindowText( hwnd, title );
        FreeRCString( title );
        RCsprintf( buf, info_str_id, info->type, info->id );
        SetDlgItemText( hwnd, RET_PROC_INFO, buf );
        SetDlgItemText( hwnd, RET_VALUE, "-1" );
        ret = true;
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case IDOK:
            GetDlgItemText( hwnd, RET_VALUE, buf, BUF_SIZE );
            if( !ParseNumeric( buf, TRUE, &info->rc ) ) {
                RCMessageBox( hwnd, STR_INVALID_RETURN_CODE,
                            AppName, MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            info->really_kill = TRUE;
            SendMessage( hwnd, WM_CLOSE, 0, 0L );
            break;
        case IDCANCEL:
            SendMessage( hwnd, WM_CLOSE, 0, 0L );
            break;
        }
        ret = true;
        break;
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        ret = true;
        break;
    }
    return( ret );
}
Exemplo n.º 7
0
/*
 * ViewLog
 */
void ViewLog( void ) {

    char                        buf[ MAX_CMDLINE + _MAX_PATH ];
    BOOL                        ret;
    STARTUPINFO                 startinfo;
    PROCESS_INFORMATION         procinfo;

    if( access( LogData.logname, R_OK ) ) {
        RCsprintf( buf, STR_CANT_OPEN_LOG_FILE, LogData.logname );
        MessageBox( MainHwnd, buf, AppName,
                    MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND );
        return;
    }
    memset( &startinfo, 0, sizeof( STARTUPINFO ) );
    startinfo.cb = sizeof( STARTUPINFO );
    strcpy( buf, LogData.editor );
    strcat( buf, " " );
    strcat( buf, LogData.editor_cmdline );
    strcat( buf, " " );
    strcat( buf, LogData.logname );

    ret = CreateProcess( NULL,                  /* application path */
                   buf,                         /* command line */
                   NULL,                        /* process security
                                                   attributes */
                   NULL,                        /* main thread security
                                                   attributes */
                   FALSE,                       /* inherits parent handles */
                   NORMAL_PRIORITY_CLASS,       /* create parameters */
                   NULL,                        /* environment block */
                   NULL,                        /* current directory */
                   &startinfo,                  /* other startup info */
                   &procinfo );                 /* structure to get process
                                                   info */
    if( ret )  return;
    strcpy( buf, "notepad.exe" );
    strcat( buf, " " );
    strcat( buf, LogData.logname );
    ret = CreateProcess( NULL,                  /* application path */
                   buf,                         /* command line */
                   NULL,                        /* process security
                                                   attributes */
                   NULL,                        /* main thread security
                                                   attributes */
                   FALSE,                       /* inherits parent handles */
                   NORMAL_PRIORITY_CLASS,       /* create parameters */
                   NULL,                        /* environment block */
                   NULL,                        /* current directory */
                   &startinfo,                  /* other startup info */
                   &procinfo );                 /* structure to get process
                                                   info */
    if( !ret ) {
        RCMessageBox( MainHwnd, STR_CANT_START_EDITOR,
                      AppName, MB_OK | MB_ICONEXCLAMATION );
    }
}
Exemplo n.º 8
0
BOOL __export FAR PASCAL LocalMonitorProc( HWND hwnd, WORD msg, WORD wparam,
                                    DWORD lparam )
{
    LocalMonInfo        *info;
    HDC                 dc;
    WORD                i;
    PAINTSTRUCT         paint;
    char                *msgtitle;

    info = (LocalMonInfo *)GetWindowLong( hwnd, 0 );
    switch( msg ) {
    case WM_CREATE:
        info = (LocalMonInfo *)( ( (CREATESTRUCT *)lparam )->lpCreateParams );
        SetWindowLong( hwnd, 0, (DWORD)info );
        if( !SetTimer( hwnd, MONITOR_TIMER, REFRESH_TIME, NULL ) ) {
            msgtitle = HWAllocRCString( STR_MONITOR_LCL_HEAP );
            RCMessageBox( NULL, STR_CANT_OPEN_LCL_MONITOR, msgtitle,
                        MB_OK | MB_TASKMODAL | MB_ICONINFORMATION );
            HWFreeRCString( msgtitle );
            DestroyWindow( hwnd );
        }
        GetMonitorInfo( info );
        break;
    case WM_PAINT:
        dc = BeginPaint( hwnd, &paint );
        PaintMonitor( hwnd, dc, info );
        EndPaint( hwnd, &paint );
        break;
    case WM_TIMER:
        if( GetMonitorInfo( info ) ) {
            dc = GetDC( hwnd );
            PaintMonitor( hwnd, dc, info );
            ReleaseDC( hwnd, dc );
        }
        break;
    case WM_SIZE:
        dc = GetDC( hwnd );
        PaintMonitor( hwnd, dc, info );
        ReleaseDC( hwnd, dc );
        break;
    case WM_DESTROY:
        KillTimer( hwnd, MONITOR_TIMER );
        Brushes.use_cnt --;
        if( Brushes.use_cnt == 0 ) {
            for( i=0; i < SIZE_CNT; i++ ) {
                DeleteObject( Brushes.brush[i] );
            }
        }
        MemFree( info );
        break;
    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return( NULL );
}
Exemplo n.º 9
0
void WRDisplayErrorMsg( msg_id msg )
{
    char        *title;

    title = WRAllocRCString( WR_ERRMSG );

    if( !RCMessageBox( (HWND)NULL, msg, title, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL ) ) {
        MessageBeep( (UINT)-1 );
    }

    if( title != NULL ) {
        WRFreeRCString( title );
    }
}
Exemplo n.º 10
0
/*
 * ReportSave
 */
void ReportSave( HWND parent, char *fname, char *appname, BOOL save_ok )
{
    char        ful_fname[_MAX_PATH];
    char        buf[_MAX_PATH + 20];

    if( save_ok ) {
        relToAbs( fname, ful_fname );
        RCsprintf( buf, SLB_DATA_SAVED_TO, ful_fname );
        MessageBox( parent, buf, appname, MB_OK | MB_TASKMODAL );
    } else {
        RCMessageBox( parent, SLB_CANT_SAVE_DATA, appname,
                      MB_OK | MB_TASKMODAL | MB_ICONEXCLAMATION );
    }

} /* ReportSave */
Exemplo n.º 11
0
/*
 * InitSymbols
 */
BOOL InitSymbols( void ) {

    int         rc;
    BOOL        diploaded;

    diploaded = FALSE;
    rc = DIPInit();
    if( rc & DS_ERR ) {
        RCMessageBox( NULL, STR_CANT_INIT_DIP, AppName,
                      MB_OK | MB_ICONEXCLAMATION );
        return( FALSE );
    }
    if( LoadTheDips() ) {
        dipIsLoaded = TRUE;
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Exemplo n.º 12
0
/*
 * ThreadCtlProc
 */
BOOL CALLBACK ThreadCtlProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD                cmd;
    ThreadCtlInfo       *info;
    LRESULT             index;
    char                buf[200];
    DWORD               threadid;
    ThreadNode          *thread;
    ProcNode            *process;
    DWORD               susp_cnt;
    DWORD               rc;
    char                *action;

    info = (ThreadCtlInfo *)GET_DLGDATA( hwnd );
    switch( msg ) {
    case WM_INITDIALOG:
        info = MemAlloc( sizeof( ThreadCtlInfo ) );
        if( !GetProcessInfo( lparam, &info->procinfo ) ) {
             RCsprintf( buf, STR_CANT_GET_PROC_INFO, info->procid );
             MessageBox( hwnd, buf, AppName, MB_OK | MB_ICONEXCLAMATION );
             SendMessage( hwnd, WM_CLOSE, 0, 0 );
        }
        info->procid = lparam;
        ThreadDlg = hwnd;
        SET_DLGDATA( hwnd, info );
        fillThreadCtl( hwnd, &info->procinfo, buf );
        RCsprintf( buf, STR_THREAD_4_PROC_X, lparam );
        SetDlgItemText( hwnd, THREAD_PROC_NAME, buf );
        sprintf( buf, "(%s)", info->procinfo.name );
        SetDlgItemText( hwnd, THREAD_PROC_PATH, buf );
        SendDlgItemMessage( hwnd, THREAD_LIST, LB_SETCURSEL, 0, 0L );
        index = SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETCURSEL, 0, 0L );
        if( index != LB_ERR ) {
            enableChoices( hwnd, TRUE );
        }
        fillThreadInfo( hwnd, &info->procinfo );
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        if( cmd == THREAD_SUSPEND || cmd == THREAD_RESUME ||
            cmd == THREAD_KILL || cmd == THREAD_SET_PRIORITY ) {
            index = SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETCURSEL, 0, 0L );
            if( index == LB_ERR ) {
                RCMessageBox( hwnd, STR_NO_SELECTED_THREAD, AppName, MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETTEXT, (WPARAM)index, (LPARAM)(LPSTR)buf );
            threadid = getThreadId( buf );
            process = FindProcess( info->procinfo.pid );
            thread = FindThread( process, threadid );
        }
        switch( cmd ) {
        case IDOK:
            SendMessage( hwnd, WM_CLOSE, 0, 0L );
            break;
        case THREAD_REFRESH:
            RefreshInfo();
            if( GetProcessInfo( info->procid, &info->procinfo ) ) {
                fillThreadCtl( hwnd, &info->procinfo, buf );
                fillThreadInfo( hwnd, &info->procinfo );
            } else {
                action = AllocRCString( STR_REFRESH );
                RCMessageBox( hwnd, STR_CANT_REFRESH_THRD, action,
                              MB_OK | MB_ICONEXCLAMATION );
                FreeRCString( action );
            }
            break;
        case THREAD_SUSPEND:
            action = AllocRCString( STR_THREAD_SUSPEND );
            if( thread == NULL ) {
                RCsprintf( buf, STR_CANT_GET_HDL_4_THD_X, threadid );
                MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION );
            } else {
                susp_cnt = SuspendThread( thread->threadhdl );
                if( susp_cnt == -1 ) {
                    RCsprintf( buf, STR_CANT_SUSPEND_THRD_X, threadid );
                    MessageBox( hwnd, buf, action, MB_ICONQUESTION | MB_OK );
                } else if( susp_cnt > 0 ) {
                    RCsprintf( buf, STR_THREAD_ALREADY_SUSP, threadid, susp_cnt );
                    index = MessageBox( hwnd, buf, action, MB_ICONQUESTION | MB_YESNO );
                    if( index == IDNO ) {
                        ResumeThread( thread->threadhdl );
                    }
                }
                SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L );
            }
            FreeRCString( action );
            break;
        case THREAD_RESUME:
            action = AllocRCString( STR_RESUME );
            if( thread == NULL ) {
                RCsprintf( buf, STR_THREAD_NOT_RESUMED , threadid );
                MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION );
            } else {
                susp_cnt = ResumeThread( thread->threadhdl );
                if( susp_cnt == -1 ) {
                    RCsprintf( buf, STR_CANT_RESUME_THRD_X, threadid );
                    MessageBox( hwnd, buf, action,
                                MB_ICONEXCLAMATION | MB_OK );
                } else if( susp_cnt == 0 ) {
                    RCsprintf( buf, STR_THRD_IS_NOT_SUSP, threadid );
                    MessageBox( hwnd, buf, action,
                                MB_ICONEXCLAMATION | MB_OK );
                } else if( susp_cnt > 1 ) {
                    RCsprintf( buf, STR_SUSP_COUNT_DECREMENTED,
                                threadid, susp_cnt );
                    MessageBox( hwnd, buf, action,
                                MB_ICONEXCLAMATION | MB_OK );
                }
                SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L );
            }
            FreeRCString( action );
            break;
        case THREAD_KILL:
            action = AllocRCString( STR_KILL );
            if( thread == NULL ) {
                RCsprintf( buf, STR_THRD_NOT_TERMINATED, threadid );
                MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION );
            } else if( GetRetCode( hwnd, RETCD_THREAD, thread->threadid, &rc ) ) {
                if( !TerminateThread( thread->threadhdl, rc ) ) {
                    RCsprintf( buf, STR_CANT_KILL_THRD_X, threadid );
                    MessageBox( hwnd, buf, action,
                                MB_OK | MB_ICONEXCLAMATION );
                }
                SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L );
            }
            FreeRCString( action );
            break;
        case THREAD_SET_PRIORITY:
//          {
//              ThreadPriorityInfo      prinfo;
//
//              if( thread == NULL ) {
//                  sprintf( buf, "Unable to get a handle for thread %08X.\n",
//                           threadid );
//                  MessageBox( hwnd, buf, "Set Priority",
//                              MB_OK | MB_ICONEXCLAMATION );
//              } else {
//                  prinfo.procid = info->procid;
//                  prinfo.thread = thread;
//                  prinfo.priority = GetThreadPriority( thread->threadhdl );
//                  prinfo.procinfo = &info->procinfo;
//                  DialogBoxParam( Instance, "THREAD_PRIORITY_DLG", hwnd,
//                                  ThreadPriorityDlgProc, (DWORD)&prinfo );
//                  fillThreadInfo( hwnd, &info->procinfo );
//              }
//          }
//          break;
        case THREAD_LIST:
            if( HIWORD( wparam ) == LBN_SELCHANGE ) {
                fillThreadInfo( hwnd, &info->procinfo );
            }
            break;
        }
        break;
    case DR_TASK_LIST_CHANGE:
        /* make sure this process still exists */
//here  if( FindProcess( info->procid ) == NULL ) {
//here      SendDlgItemMessage( hwnd, THREAD_LIST, LB_RESETCONTENT, 0, 0L );
//here      enableChoices( hwnd, FALSE );
//here      info->proc = NULL;
//here  } else {
//here      fillThreadCtl( hwnd, info->proc, buf );
//here  }
        break;
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        break;
    case WM_DESTROY:
        MemFree( info );
        ThreadDlg = NULL;
        break;
    default:
        return( FALSE );
    }
    return( TRUE );
}
Exemplo n.º 13
0
/*
 * ThreadCtlProc
 */
INT_PTR CALLBACK ThreadPriorityDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD                cmd;
    ThreadPriorityInfo  *info;
    char                buf[100];
    bool                ret;

    info = (ThreadPriorityInfo *)GET_DLGDATA( hwnd );
    switch( msg ) {
    case WM_INITDIALOG:
        info = (ThreadPriorityInfo *)lparam;
        sprintf( buf, "pid = %08lX (%s)", info->procid,
                 info->procinfo->name );
        SetDlgItemText( hwnd, PRIORITY_INFO, buf );
        sprintf( buf, "tid = %08lX", info->thread->threadid );
        SetDlgItemText( hwnd, PRIORITY_PATH, buf );
        switch( info->priority ) {
        case THREAD_PRIORITY_IDLE:
            CheckDlgButton( hwnd, PRIORITY_IDLE, BST_CHECKED );
            break;
        case THREAD_PRIORITY_LOWEST:
            CheckDlgButton( hwnd, PRIORITY_LOWEST, BST_CHECKED );
            break;
        case THREAD_PRIORITY_BELOW_NORMAL:
            CheckDlgButton( hwnd, PRIORITY_BELOW_NORMAL, BST_CHECKED );
            break;
        case THREAD_PRIORITY_NORMAL:
            CheckDlgButton( hwnd, PRIORITY_NORMAL, BST_CHECKED );
            break;
        case THREAD_PRIORITY_ABOVE_NORMAL:
            CheckDlgButton( hwnd, PRIORITY_ABOVE_NORMAL, BST_CHECKED );
            break;
        case THREAD_PRIORITY_HIGHEST:
            CheckDlgButton( hwnd, PRIORITY_HIGHEST, BST_CHECKED );
            break;
        case THREAD_PRIORITY_TIME_CRITICAL:
            CheckDlgButton( hwnd, PRIORITY_TIME_CRITICAL, BST_CHECKED );
            break;
        }
        SET_DLGDATA( hwnd, lparam );
        ret = true;
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case IDOK:
            if( IsDlgButtonChecked( hwnd, PRIORITY_IDLE ) ) {
                ret = SetThreadPriority( info->thread->threadhdl,
                                         THREAD_PRIORITY_IDLE ) != 0;
            } else if( IsDlgButtonChecked( hwnd, PRIORITY_LOWEST ) ) {
                ret = SetThreadPriority( info->thread->threadhdl,
                                         THREAD_PRIORITY_LOWEST ) != 0;
            } else if( IsDlgButtonChecked( hwnd, PRIORITY_BELOW_NORMAL ) ) {
                ret = SetThreadPriority( info->thread->threadhdl,
                                         THREAD_PRIORITY_BELOW_NORMAL ) != 0;
            } else if( IsDlgButtonChecked( hwnd, PRIORITY_NORMAL ) ) {
                ret = SetThreadPriority( info->thread->threadhdl,
                                         THREAD_PRIORITY_NORMAL ) != 0;
            } else if( IsDlgButtonChecked( hwnd, PRIORITY_ABOVE_NORMAL ) ) {
                ret = SetThreadPriority( info->thread->threadhdl,
                                         THREAD_PRIORITY_ABOVE_NORMAL ) != 0;
            } else if( IsDlgButtonChecked( hwnd, PRIORITY_HIGHEST ) ) {
                ret = SetThreadPriority( info->thread->threadhdl,
                                         THREAD_PRIORITY_HIGHEST ) != 0;
            } else if( IsDlgButtonChecked( hwnd, PRIORITY_TIME_CRITICAL ) ) {
                ret = SetThreadPriority( info->thread->threadhdl,
                                         THREAD_PRIORITY_TIME_CRITICAL ) != 0;
            }
            if( !ret ) {
                RCMessageBox( hwnd, STR_CANT_SET_THREAD_PRI, AppName,
                             MB_OK | MB_ICONEXCLAMATION );
            }
            SendMessage( hwnd, WM_CLOSE, 0, 0L );
            break;
        case IDCANCEL:
            SendMessage( hwnd, WM_CLOSE, 0, 0L );
            break;
        }
        ret = true;
        break;
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        ret = true;
        break;
    }
    return( ret );
}
Exemplo n.º 14
0
/*
 * ExceptionProc
 */
BOOL CALLBACK ExceptionProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD                cmd;
    ExceptDlgInfo       *info;
    ProcNode            *procinfo;
    WORD                tmp;
    address             addr;

    info = FaultGetExceptDlgInfo( hwnd );
    switch( msg ) {
    case WM_INITDIALOG:
        /* make sure this dialog always comes up on top of everything else */
        SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                        SWP_NOSIZE | SWP_NOMOVE );
        SetWindowPos( hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
                        SWP_NOSIZE | SWP_NOMOVE );
        centerDialog( hwnd );
        info = MemAlloc( sizeof( ExceptDlgInfo ) );
        info->dbinfo = (DEBUG_EVENT *)lparam;
        info->rc = 0;
        info->action = 0;
        SetWindowLong( hwnd, DWL_USER, (DWORD)info );
        info->procinfo = FindProcess( info->dbinfo->dwProcessId );
        info->threadinfo = FindThread( info->procinfo,
                                       info->dbinfo->dwThreadId );
        info->module = ModuleFromAddr( info->procinfo,
               info->dbinfo->u.Exception.ExceptionRecord.ExceptionAddress );
        if( info->threadinfo != NULL ) {
            AllocMadRegisters( &(info->regs) );
            LoadMADRegisters( info->regs, info->threadinfo->threadhdl );
            GetCurrAddr( &( info->init_ip ), info->regs );
        }
        if( info->module == NULL ) {
            info->got_dbginfo = FALSE;
        } else {
            if( !LoadDbgInfo( info->module ) ) {
                info->got_dbginfo = FALSE;
            } else {
                info->got_dbginfo = TRUE;
            }
        }
        if( LogData.autolog ) {         //Just create the log and exit
            tmp = ConfigData.exception_action;
            CheckDlgButton( hwnd, INT_TERMINATE, BST_CHECKED );
            SendMessage( hwnd, WM_COMMAND,
                        MAKELONG( INT_ACT_AND_LOG, BN_CLICKED ),
                        (LPARAM)GetDlgItem( hwnd, INT_ACT_AND_LOG ) );
            ConfigData.exception_action = tmp;
        } else {
            fillExceptionDlg( hwnd, info );
        }
        setProcessHdl( info->procinfo->prochdl );
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case INT_ACT_AND_LOG:
            MakeLog( info );
            /* fall through */
        case INT_ACT:
            if( IsDlgButtonChecked( hwnd, INT_TERMINATE ) ) {
                ConfigData.exception_action = INT_TERMINATE;
//              hp = OpenProcess( PROCESS_TERMINATE, FALSE,
//                                info->dbinfo->dwProcessId );
                procinfo = FindProcess( info->dbinfo->dwProcessId );
                if( procinfo == NULL ) {
                    RCMessageBox( hwnd, STR_CANT_TERMINATE_APP,
                                  AppName, MB_OK | MB_ICONEXCLAMATION );
                } else {
                    TerminateProcess( procinfo->prochdl, -1 );
//                  CloseHandle( hp );
                    info->rc = DBG_CONTINUE;
                    info->action = INT_TERMINATE;
                    SendMessage( hwnd, WM_CLOSE, 0, 0L );
                }
            } else if( IsDlgButtonChecked( hwnd, INT_CHAIN_TO_NEXT ) ) {
                ConfigData.exception_action = INT_CHAIN_TO_NEXT;
                info->rc = DBG_EXCEPTION_NOT_HANDLED;
                info->action = INT_CHAIN_TO_NEXT;
                SendMessage( hwnd, WM_CLOSE, 0, 0L );
            } else if( IsDlgButtonChecked( hwnd, INT_RESTART ) ) {
                ConfigData.exception_action = INT_RESTART;
                info->rc = DBG_CONTINUE;
                info->action = INT_RESTART;
                SendMessage( hwnd, WM_CLOSE, 0, 0L );
            }
            break;
        case INT_REGISTERS:
            SetDisasmInfo( info->procinfo->prochdl, info->module );
            StatShowSymbols = TRUE;
            if ( DoStatDialog( hwnd ) == 1 ){
                StoreMADRegisters( info->regs, info->threadinfo->threadhdl );
                GetCurrAddr(&addr,info->regs);
                SetIp( hwnd, &addr );
            }
            LoadMADRegisters( info->regs, info->threadinfo->threadhdl );
            break;
        case INT_LOG_OPTIONS:
            SetLogOptions( hwnd );
            break;
        }
        break;
    case WM_CLOSE:
        if( info->rc == 0 ) {
            SendMessage( hwnd, WM_COMMAND, INT_ACT, 0L );
        } else {
            if( info->got_dbginfo ) {
                UnloadDbgInfo( info->module );
            }
            EndDialog( hwnd, info->rc );
        }
        break;
    case WM_DESTROY:
        DeAllocMadRegisters( info->regs );
        MemFree( info );
        break;
    default:
        return( FALSE );
        break;
    }
    return( TRUE );
}
Exemplo n.º 15
0
/*
 * AliasDlgProc - alias list dialog procedure
 */
INT_PTR CALLBACK AliasDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    AnAlias     *cur;
    size_t      len;
    char        buf[CONST_LEN];
    char        msgbuf[256];
    int         sel;
    char        *endptr;
    char        *realend;
    char        *alias;
    long        id;
    WORD        cmd;

    switch( msg ) {
    case WM_INITDIALOG:
        if( (char *)lparam != NULL ) {
            SetWindowText( hwnd, (char *)lparam );
        }
        SendDlgItemMessage( hwnd, ALIAS_TEXT, EM_LIMITTEXT, 20, 0 );
        for( cur = CurHdl->data; cur != NULL; cur = cur->next ) {
            sprintf( buf, "0x%08lX", cur->id );
            SendDlgItemMessage( hwnd, ALIAS_ID_LIST, LB_ADDSTRING, 0, (LPARAM)buf );
        }
        break;
#ifndef NOUSE3D
    case WM_SYSCOLORCHANGE:
        CvrCtl3dColorChange();
        break;
#endif
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
            case IDOK:
            case ALIAS_DO_MORE:
                SendDlgItemMessage( hwnd, ALIAS_CUR_ID, WM_GETTEXT, CONST_LEN, (LPARAM)buf );
                realend = buf;
                while( *realend != '\0' ) {
                    realend++;
                }
                realend--;
                while( isspace( *realend ) ) {
                    realend--;
                }
                realend++;
                id = strtol( buf, &endptr, 0 );
                if( endptr != realend || *buf == '\0' ) {
                    RCMessageBox( hwnd, ALIAS_VALUE_MUST_BE_INT, "", MB_OK );
                    break;
                }
                len = SendDlgItemMessage( hwnd, ALIAS_TEXT, WM_GETTEXTLENGTH, 0, 0 );
                alias = MemAlloc( len + 1 );
                len = SendDlgItemMessage( hwnd, ALIAS_TEXT, WM_GETTEXT, len + 1, (LPARAM)alias );
                /* check for spaces */
                endptr = alias;
                while( !isspace( *endptr ) && *endptr != '\0' ) {
                    endptr++;
                }
                realend = endptr;
                while( isspace( *endptr ) ) {
                    endptr++;
                }
                if( *endptr != '\0' ) {
                    RCMessageBox( hwnd, ALIAS_NO_SPACES_ALLOWED, "", MB_OK );
                    MemFree( alias );
                    break;
                }
                realend = '\0'; /* truncate trailing spaces */
                cur = findAliasFromText( CurHdl, alias );
                if( cur == NULL ) {
                    AddAlias( CurHdl, alias, id );
                } else {
                    RCsprintf( msgbuf, ALIAS_NO_DUPLICATES_ALLOWED, alias, cur->id );
                    MessageBox( hwnd, msgbuf, "", MB_OK );
                    MemFree( alias );
                    break;
                }
                MemFree( alias );
                EndDialog( hwnd, cmd );
                break;
            case IDCANCEL:
                EndDialog( hwnd, cmd );
                break;
            case ALIAS_ID_LIST:
                if( GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_SELCHANGE ) {
                    sel = (int)SendDlgItemMessage( hwnd, ALIAS_ID_LIST, LB_GETCURSEL, 0, 0L );
                    SendDlgItemMessage( hwnd, ALIAS_ID_LIST, LB_GETTEXT, sel, (LPARAM)buf );
                    SendDlgItemMessage( hwnd, ALIAS_CUR_ID, WM_SETTEXT, 0, (LPARAM)buf );
                    cur = getIthAlias( CurHdl, sel );
                    SendDlgItemMessage( hwnd, ALIAS_TEXT, WM_SETTEXT, 0, (LPARAM)cur->name );
                }
                break;
            default:
                return( FALSE );
        }
    default:
        return( FALSE );
    }
    return( TRUE );
}
Exemplo n.º 16
0
/*
 * ConfigDlgProc - handle messages from the configure dialog
 */
BOOL FAR PASCAL ConfigDlgProc( HWND hwnd, WORD msg, WORD wparam, DWORD lparam )
{
    MemWndConfig        info;
    HeapConfigInfo      heapdef;
    char                buf[_MAX_PATH];

    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        GetMemWndConfig( &info );
        SetupConfigDlg( &Config, &info, hwnd );
        break;
    case WM_SYSCOLORCHANGE:
        CvrCtl3dColorChange();
        break;
    case WM_COMMAND:
        switch( wparam ) {
        case CONFIG_GLOB_BROWSE:
            doFileBrowse( hwnd, CONFIG_GNAME );
            break;
        case CONFIG_LOCAL_BROWSE:
            doFileBrowse( hwnd, CONFIG_LNAME );
            break;
        case CONFIG_MEM_BROWSE:
            doFileBrowse( hwnd, CONFIG_MNAME );
            break;
        case CONFIG_DEFAULT:
            GetMemWndDefault( &info );
            GetDefaults( &heapdef );
            SetupConfigDlg( &heapdef, &info, hwnd );
            break;
        case CONFIG_OK:
            GetDlgItemText( hwnd, CONFIG_GNAME, buf, _MAX_PATH );
            if( !ValidateFName( buf ) ) {
                GetWindowText( hwnd, buf, sizeof( buf ) );
                RCMessageBox( hwnd, STR_INVALID_GLOB_FNAME,
                              buf, MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            GetDlgItemText( hwnd, CONFIG_LNAME, buf, _MAX_PATH );
            if( !ValidateFName( buf ) ) {
                GetWindowText( hwnd, buf, sizeof( buf ) );
                RCMessageBox( hwnd, STR_INVALID_LCL_FNAME, buf,
                            MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            GetDlgItemText( hwnd, CONFIG_MNAME, buf, _MAX_PATH );
            if( !ValidateFName( buf ) ) {
                GetWindowText( hwnd, buf, sizeof( buf ) );
                RCMessageBox( hwnd, STR_INVALID_MEM_FNAME, buf,
                            MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            GetMemWndConfig( &info );
            info.autopos_info = IsDlgButtonChecked( hwnd, CONFIG_AUTOPOS );
            info.disp_info = IsDlgButtonChecked( hwnd, CONFIG_DISP_MEM_INFO );
            if( IsDlgButtonChecked( hwnd, CONFIG_MULT_MEM_WND ) ) {
                info.allowmult = WND_MULTI;
            } else {
                info.allowmult = WND_REPLACE;
            }
            Config.disp_res = IsDlgButtonChecked( hwnd, CONFIG_DISP_RES );
            Config.save_glob_pos = IsDlgButtonChecked( hwnd,
                                                       CONFIG_SAVE_MAIN_POS );
            Config.save_mem_pos = IsDlgButtonChecked( hwnd,
                                                       CONFIG_SAVE_MEM_POS );
            GetDlgItemText( hwnd, CONFIG_GNAME, Config.gfname, _MAX_PATH );
            GetDlgItemText( hwnd, CONFIG_LNAME, Config.lfname, _MAX_PATH );
            GetDlgItemText( hwnd, CONFIG_MNAME, info.fname, _MAX_PATH );
            SetMemWndConfig( &info );
            /* fall through */
        case CONFIG_CANCEL:
            EndDialog( hwnd, FALSE );
            break;
        default:
            return( FALSE );
        }
        break;
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        break;
    default:
        return( FALSE );
    }
    return( TRUE );
} /* ConfigDlgProc */
Exemplo n.º 17
0
/*
 * SetDisplayType - changes the heap display type to 'type' unless type is
 *                  'HEAPMENU_DISPLAY_INIT' in which case this is assumed to
 *                  be the first call to SetDisplayType and the heap display
 *                  type is set to 'HeapType'
 */
static void SetDisplayType( HWND hwnd, HWND **title, WORD type ) {

    HMENU       mh;
    char        buf[256];
    char        *typename;

    if( type == HeapType ) return;
    if( type == HEAPMENU_DISPLAY_DPMI && !WDebug386 ) {
        RCMessageBox( HeapWalkMainWindow, STR_INSTALL_WDEBUG,
                      HeapWalkName, MB_OK | MB_ICONEXCLAMATION );
        return;
    }
    mh = GetMenu( hwnd );
    if( type == HEAPMENU_DISPLAY_INIT ) {
        type = HeapType;
        HeapType = HEAPMENU_DISPLAY_INIT;
    } else {
        CheckMenuItem( mh, HeapType, MF_UNCHECKED | MF_BYCOMMAND );
    }

    /* undo anything done for the previous state */
    switch( HeapType ) {
    case HEAPMENU_DISPLAY_DPMI:
        EnableMenuItem( mh, HEAPMENU_ADD, MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_DISCARD,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_OLDEST,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_NEWEST,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_LOCALWALK,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_COMPACT_AND_LOCALWALK,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_GET_SELECTOR,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_MONITOR,
                        MF_BYCOMMAND | MF_ENABLED );
        ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP,
                    (UINT)LoadMenu( Instance, "SORTMENU" ),
                    HWGetRCString( STR_SORT ) );
        KillPushWin( *title );
        *title = SetUpPushWindows( hwnd, HEAPMENU_DISPLAY_ENTIRE );
        if( GSortType == HEAPMENU_SORT_GRAN ||
            GSortType == HEAPMENU_SORT_DPL ) GSortType = HEAPMENU_SORT_HANDLE;
        break;
    case HEAPMENU_DISPLAY_LRU:
        DeleteMenu( mh, HEAPMENU_SORT_LRU, MF_BYCOMMAND );
        if( GSortType == HEAPMENU_SORT_LRU ) GSortType = HEAPMENU_SORT_HANDLE;
        break;
    case HEAPMENU_DISPLAY_INIT:
        if( type != HEAPMENU_DISPLAY_DPMI ) {
            *title = SetUpPushWindows( hwnd, type );
            ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP,
                    (UINT)LoadMenu( Instance, "SORTMENU" ),
                    HWGetRCString( STR_SORT ) );
        } else {
            *title = NULL;
        }
        break;
    }
    /* do things for the new state */
    switch( type ) {
    case HEAPMENU_DISPLAY_DPMI:
        ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP,
                    (UINT)LoadMenu( Instance, "SORTDPMIMENU" ),
                    HWGetRCString( STR_SORT ) );
        EnableMenuItem( mh, HEAPMENU_ADD, MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_DISCARD,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_OLDEST,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_NEWEST,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_LOCALWALK,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_COMPACT_AND_LOCALWALK,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_GET_SELECTOR,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_MONITOR,
                        MF_BYCOMMAND | MF_GRAYED );
        if( GSortType == HEAPMENU_SORT_MODULE ||
                GSortType == HEAPMENU_SORT_TYPE ) {
            CheckMenuItem( mh, GSortType, MF_UNCHECKED | MF_BYCOMMAND );
            GSortType = HEAPMENU_SORT_ADDR;
        }
//      SetTitle( HeapDPMITitles, title );
        KillPushWin( *title );
        *title = SetUpPushWindows( hwnd, type );
        typename = HWAllocRCString( STR_SELECTOR_LIST_ITEMS );
        break;
    case HEAPMENU_DISPLAY_LRU:
        InsertMenu( mh, HEAPMENU_SORT_FLAG, MF_BYCOMMAND, HEAPMENU_SORT_LRU,
                   GetRCString( STR_BY_AGE ) );
        typename = HWAllocRCString( STR_LRU_ITEMS );
        break;
    case HEAPMENU_DISPLAY_ENTIRE:
        typename = HWAllocRCString( STR_ENTIRE_HEAP );
        break;
    case HEAPMENU_DISPLAY_FREE:
        typename = HWAllocRCString( STR_FREE_ITEMS );
        break;
    default:
        typename = "";
        break;
    }
    CheckMenuItem( mh, type, MF_CHECKED | MF_BYCOMMAND );
    CheckMenuItem( mh, GSortType, MF_CHECKED | MF_BYCOMMAND );
    DrawMenuBar( hwnd );
    sprintf( buf, "%s - %s", HeapWalkName, typename );
    HWFreeRCString( typename );
    SetWindowText( hwnd, buf );
    HeapType = type;
} /* SetDisplayType */