Exemple #1
0
static void fillThreadInfo( HWND hwnd, ProcStats *info ) {

    HWND        lb;
    int         index;
    char        buf[100];
    DWORD       threadid;
    ThreadStats thdinfo;
#ifndef CHICAGO
    char        *str1;
#endif

    lb = GetDlgItem( hwnd, THREAD_LIST );
    index = (int)SendMessage( lb, LB_GETCURSEL, 0, 0L );
    if( index == LB_ERR ) {
        SetDlgItemText( hwnd, THREAD_TID, "" );
        SetDlgItemText( hwnd, THREAD_SUSPEND_CNT, "" );
        SetDlgItemText( hwnd, THREAD_PRIORITY, "" );
    } else {
        enableChoices( hwnd, TRUE );
        SendMessage( lb, LB_GETTEXT, index, (LPARAM)(LPSTR)buf );
        threadid = getThreadId( buf );
        sprintf( buf, "tid = %08lX", threadid );
        SetDlgItemText( hwnd, THREAD_TID, buf );

        if( GetThreadInfo( info->pid, threadid, &thdinfo ) ) {
#ifndef CHICAGO
            if( thdinfo.state == 5 ) {  /* the thread is in a wait state */
                str1 = SrchMsg( thdinfo.wait_reason, ThreadWaitMsgs, NULL );
                if( str1 == NULL ) {
                    str1 = AllocRCString( STR_WAIT_4_UNKNOWN );
                    RCsprintf( buf, STR_STATE, str1 );
                    FreeRCString( str1 );
                } else {
                    RCsprintf( buf, STR_STATE, str1 );
                }
            } else {
                str1 = SrchMsg( thdinfo.state, ThreadStateMsgs, NULL );
                if( str1 == NULL ) {
                    str1 = AllocRCString( STR_BRACED_UNKNOWN );
                    RCsprintf( buf, STR_STATE, str1 );
                    FreeRCString( str1 );
                } else {
                    RCsprintf( buf, STR_STATE, str1 );
                }
            }
            SetDlgItemText( hwnd, THREAD_SUSPEND_CNT, buf );
#endif

            /* get priority */
            RCsprintf( buf, STR_PRIORITY_X, thdinfo.cur_pri,
                        thdinfo.base_pri );
            SetDlgItemText( hwnd, THREAD_PRIORITY, buf );
        }
    }
}
Exemple #2
0
/*
 * AppDebuggerErrMsg
 */
void AppDebuggerErrMsg( void *_info ) {

    ProcAttatchInfo *info = _info;
    char        buf[100];
    ProcStats   stats;

    if( GetProcessInfo( info->info.pid, &stats ) ) {
        RCsprintf( buf, STR_CANT_DEBUG_PROC_X_NAME, info->info.pid,
                   stats.name );
    } else {
        RCsprintf( buf, STR_CANT_DEBUG_PROC_X, info->info.pid );
    }
    MessageBox( MainHwnd, buf, AppName,
                MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND );
}
Exemple #3
0
/*
 * ProcessIncomingMessage - get a string associated with a message id
 */
void ProcessIncomingMessage( int msgid, char *class_name, char *res )
{
    message     *msg;
    char        *fmtstr;
    char        buf[256];

    res[0] = 0;
    msg = GetMessageDataFromID( msgid, class_name );
    if( msg != NULL ) {
        if( msg->bits[M_WATCH] ) {
            strcpy( res, msg->str );
        }
        if( msg->bits[M_STOPON] ) {
            SetSpyState( OFF );
            RCsprintf( buf, STR_SPYING_STOPPED, msg->str );
            MessageBox( SpyMainWindow, buf, SpyName,
                        MB_OK | MB_ICONINFORMATION );
        }
        msg->count++;
    } else if( msgid > WM_USER ) {
        userMsg->count++;
        if( userMsg->bits[M_WATCH] ) {
            fmtstr = GetRCString( STR_WM_USER_PLUS );
            sprintf( res, fmtstr, msgid - WM_USER );
        }
        if( userMsg->bits[M_STOPON] ) {
            SetSpyState( OFF );
            fmtstr = GetRCString( STR_WM_USER_PLUS );
            sprintf( res, fmtstr, msgid - WM_USER );
            RCsprintf( buf, STR_SPYING_STOPPED, res );
            MessageBox( SpyMainWindow, buf, SpyName,
                        MB_OK | MB_ICONINFORMATION );
        }
    } else {
        if( Filters[MC_UNKNOWN].flag[M_WATCH] ) {
            fmtstr = GetRCString( STR_UNKNOWN_MSG );
            sprintf( res, fmtstr, msgid );
        }
        if( Filters[MC_UNKNOWN].flag[M_STOPON] ) {
            SetSpyState( OFF );
            fmtstr = GetRCString( STR_UNKNOWN_MSG );
            RCsprintf( buf, STR_SPYING_STOPPED, res );
            MessageBox( SpyMainWindow, buf, SpyName,
                        MB_OK | MB_ICONINFORMATION );
        }
    }

} /* ProcessIncomingMessage */
Exemple #4
0
/*
 * MakeLog - make the log file
 */
void MakeLog( ExceptDlgInfo *faultinfo )
{
    bool    wasfault;

    wasfault = ( faultinfo != NULL );
    RefreshCostlyInfo();
    if( startLogFile() ) {
        char    err_buf[ _MAX_PATH + 100 ];

        RCsprintf( err_buf, STR_CANT_OPEN_LOG, LogData.logname );
        MessageBox( NULL, err_buf, AppName, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND );
        return;
    }
    logSysInfo( wasfault );
    notesAdded = FALSE;
    if( LogData.query_notes ) {
        AnotateLog( MainHwnd, Instance, NotePrint );
    }
    if( wasfault ) {
        logFaultInfo( faultinfo );
    }
    if( LogData.log_process ) {
        logProcessList();
    }
    logStrPrintf( logLine );
    finishLogFile();
}
Exemple #5
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 );
}
Exemple #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 );
}
Exemple #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 );
    }
}
Exemple #8
0
/*
 * EraseLog
 */
void EraseLog( void ) {

    char        buf[500];
    int         ret;

    RCsprintf( buf, STR_ERASE_LOG_FILE, LogData.logname );
    ret = MessageBox( NULL, buf, AppName, MB_YESNO | MB_ICONQUESTION );
    if( ret == IDYES ) {
        remove( LogData.logname );
        ignoreLogChecks = FALSE;
    }
}
Exemple #9
0
/*
 * FormatException
 */
void FormatException( char *buf, DWORD code ) {

    char        *str;

    str = SrchMsg( code, ExceptionMsgs, NULL );
    if( str == NULL ) {
        str = buf;
        RCsprintf( buf, STR_UNKNOWN_EXCEPTION_X, code );
    } else {
        strcpy( buf, str );
    }
}
Exemple #10
0
static BOOL readLogOptions( HWND hwnd, char *buf ) {

    DWORD       asm_lines;
    DWORD       asm_bkup;
    DWORD       max_fsize;
    char        numhelp[NUM_HELP_SIZE];

    CopyRCString( STR_FIELD_MUST_BE_NUMERIC, numhelp, NUM_HELP_SIZE );
    GetDlgItemText( hwnd, LOG_MAXFL, buf, BUF_SIZE );
    if( !ParseNumeric( buf, FALSE, &max_fsize ) ) {
        RCsprintf( buf, STR_MAX_LOG_FILE_SIZE_INV, numhelp );
        MessageBox( hwnd, buf, AppName, MB_OK | MB_ICONEXCLAMATION );
        return( FALSE );
    }
    GetDlgItemText( hwnd, LOG_DISASM_LINES, buf, BUF_SIZE );
    if( !ParseNumeric( buf, FALSE, &asm_lines ) ) {
        RCsprintf( buf, STR_DISASM_LINES_INVALID, numhelp );
        MessageBox( hwnd, buf, AppName, MB_OK | MB_ICONEXCLAMATION );
        return( FALSE );
    }
    GetDlgItemText( hwnd, LOG_DISASM_BACKUP, buf, BUF_SIZE );
    if( !ParseNumeric( buf, FALSE, &asm_bkup ) ) {
        RCsprintf( buf, STR_DISASM_BKUP_INVALID, numhelp );
        MessageBox( hwnd, buf, AppName, MB_OK | MB_ICONEXCLAMATION );
        return( FALSE );
    }
    GetDlgItemText( hwnd, LOG_FILE_NAME, LogData.logname, BUF_SIZE );
    GetDlgItemText( hwnd, LOG_VIEWER, LogData.editor, BUF_SIZE );
    LogData.asm_cnt = asm_lines;
    LogData.asm_bkup = asm_bkup;
    LogData.max_flen = max_fsize;
    LogData.log_process = IsDlgButtonChecked( hwnd, LOG_TASKS );
    LogData.log_stacktrace = IsDlgButtonChecked( hwnd, LOG_STACK_TRACE );
    LogData.log_mem_manager = IsDlgButtonChecked( hwnd, LOG_MEM );
    LogData.log_mem_dmp = IsDlgButtonChecked( hwnd, LOG_MEM_DMP );
    LogData.query_notes = IsDlgButtonChecked( hwnd, LOG_QUERY_NOTES );
    LogData.autolog = IsDlgButtonChecked( hwnd, LOG_AUTOLOG );
    LogData.log_modules = IsDlgButtonChecked( hwnd, LOG_LOADED_MODULES );
    return( TRUE );
}
Exemple #11
0
BOOL CALLBACK QueryEndDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD        cmd;
    char        buf[100];
    HWND        lb;
    ProcNode    *procinfo;
    ProcStats   procstat;

    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        lb = GetDlgItem( hwnd, END_LIST );
        procinfo = GetNextOwnedProc( NULL );
        while( procinfo != NULL ) {
            if( GetProcessInfo( procinfo->procid, &procstat ) ) {
                RCsprintf( buf, STR_PROCESS_X_NAME, procinfo->procid,
                         procstat.name );
            } else {
                RCsprintf( buf, STR_PROCESS_X, procinfo->procid );
            }
            SendMessage( lb, LB_ADDSTRING, 0, (LPARAM)buf );
            procinfo = GetNextOwnedProc( procinfo );
        }
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case END_YES:
        case END_NO:
            EndDialog( hwnd, cmd );
            break;
        }
        break;
    default:
        return( FALSE );
    }
    return( TRUE );
}
Exemple #12
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 */
Exemple #13
0
/*
 * CheckLogSize
 */
void CheckLogSize( void ) {

    struct stat         st;
    char                buf[100];
    int                 ret;

    /* if the user has already said they don't want to delete a large log
     * file don't keep asking */
    if( ignoreLogChecks ) return;
    if( stat( LogData.logname, &st ) == -1 ) return;
    if( st.st_size > LogData.max_flen ) {
        RCsprintf( buf, STR_DEL_BIG_LOG_FILE, st.st_size );
        ret = MessageBox( NULL, buf, AppName,
                          MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION );
        if( ret == IDYES ) {
            remove( LogData.logname );
        } else {
            ignoreLogChecks = TRUE;
        }
    }
}
Exemple #14
0
/*
 * LogHeader
 */
void LogHeader( int f )
{
    char        buf[100];
    unsigned    i;
    time_t      tm;

    tm = time( NULL );
    for( i = 0; i < 80; i++ ) {
        buf[i] = '-';
    }
    buf[i] = '\0';
    write( f, buf, strlen( buf ) );
    write( f, "\r\n", 2 );
    RCsprintf( buf, STR_LOG_HEADER, asctime( localtime( &tm ) ) );
    write( f, buf, strlen( buf ) );
    write( f, "\r\n", 2 );
    for( i = 0; i < 80; i++ ) {
        buf[i] = '-';
    }
    buf[i] = '\0';
    write( f, buf, strlen( buf ) );
    write( f, "\r\n", 2 );

} /* LogHeader */
Exemple #15
0
static void fillExceptionDlg( HWND hwnd, ExceptDlgInfo *info ) {

    char                buf[BUF_SIZE];
    char                fname[ FNAME_BUFLEN ];
    DWORD               line;
    ProcStats           stats;
    HWND                ctl;
    address             addr;

    GetCurrAddr(&addr,info->regs);
    SetDlgCourierFont( hwnd, INT_TASK_NAME );
    SetDlgCourierFont( hwnd, INT_TASK_PATH );
    SetDlgCourierFont( hwnd, INT_FAULT_TYPE );
    SetDlgCourierFont( hwnd, INT_CS_IP );
    SetDlgCourierFont( hwnd, INT_SOURCE_INFO );
    SetDlgCourierFont( hwnd, INT_SOURCE_INFO2 );

    RCsprintf( buf, STR_EXCEPTION_ENCOUNTERED, AppName );
    SetWindowText( hwnd, buf );

    CopyRCString( STR_PROCESS_NAME, buf, BUF_SIZE );
    SetDlgItemText( hwnd, INT_TASK_NAME_TEXT, buf );

    if( !info->dbinfo->u.Exception.dwFirstChance ) {
        if( ConfigData.exception_action == INT_CHAIN_TO_NEXT ) {
            ConfigData.exception_action = INT_TERMINATE;
        }
        ctl = GetDlgItem( hwnd, INT_CHAIN_TO_NEXT );
        EnableWindow( ctl, FALSE );
    }
    CheckDlgButton( hwnd, ConfigData.exception_action, BST_CHECKED );
    CopyRCString( STR_PROCESS_ID, buf, BUF_SIZE );
    SetDlgItemText( hwnd, INT_TASK_PATH_TEXT, buf );

    while( !GetProcessInfo( info->procinfo->procid, &stats ) ) {
        Sleep( 100 );
        RefreshInfo();
    }
    SetDlgItemText( hwnd, INT_TASK_NAME, stats.name );

    sprintf( buf, "%08lX", info->procinfo->procid );
    SetDlgItemText( hwnd, INT_TASK_PATH, buf );

    FormatException( buf, info->dbinfo->u.Exception.ExceptionRecord.ExceptionCode );
    SetDlgItemText( hwnd, INT_FAULT_TYPE, buf );

    if( info->threadinfo != NULL ) {
        strcpy( buf, "Fault " );
        MADRegSpecialName( MSR_IP, info->regs, MAF_FULL, BUF_SIZE - 7, buf+6 );
        SetDlgItemText( hwnd, INT_IP_NAME, buf );
        SetIp( hwnd, &addr );
    }
    if( info->got_dbginfo && GetLineNum( &addr,fname, FNAME_BUFLEN, &line ) ) {
        RCsprintf( buf, STR_LINE_X_OF, line );
        SetDlgItemText( hwnd, INT_SOURCE_INFO, buf );
        SetDlgItemText( hwnd, INT_SOURCE_INFO2, fname );
    } else {
        CopyRCString( STR_N_A, buf, BUF_SIZE );
        SetDlgItemText( hwnd, INT_SOURCE_INFO, buf );
        SetDlgItemText( hwnd, INT_SOURCE_INFO2, "" );
    }
}
Exemple #16
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 );
}
Exemple #17
0
/*
 * GetProfileInfo - read log info from profile
 */
void GetProfileInfo( void )
{
    char        tmp[256];
    char        buf[10];
    struct stat st;
    int         rc;

    GetWindowsDirectory( tmp, sizeof( tmp ) );
    strcat( tmp,"\\drwatcom.log" );
    strlwr( tmp );
    GetPrivateProfileString( profID, FILENAME, tmp, LogInfo.filename,
                                        MAX_FNAME, iniFile );

    GetPrivateProfileString( profID, PLOG_STACK_TRACE,"1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_STACK_TRACE ] = buf[0];

    GetPrivateProfileString( profID, PLOG_TASKS, "1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_TASKS ] = buf[0];

    GetPrivateProfileString( profID, PLOG_MODULES, "1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_MODULES ] = buf[0];

    GetPrivateProfileString( profID, PLOG_GDI, "1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_GDI ] = buf[0];

    GetPrivateProfileString( profID, PLOG_USER, "1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_USER ] = buf[0];

    GetPrivateProfileString( profID, PLOG_MEM, "1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_MEM ] = buf[0];

    GetPrivateProfileString( profID, PLOG_MOD_SEGMENTS, "1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_MOD_SEGMENTS ] = buf[0];

    GetPrivateProfileString( profID, PLOG_AUTOLOG, "0", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_AUTOLOG ] = buf[0];

    GetPrivateProfileString( profID, PLOG_NOTE, "1", buf,
                             sizeof( buf ), iniFile );
    LogInfo.flags[ LOGFL_NOTE ] = buf[0];

    LogInfo.disasmbackup = getProfileLong( DISASM_BACKUP, 2 );
    LogInfo.disasmlines = getProfileLong( DISASM_LINES, 8 );
    LogInfo.maxlogsize = getProfileLong( MAX_LOG_SIZE, 100000L );
    if( stat( LogInfo.filename, &st ) != -1 ) {
        if( st.st_size > LogInfo.maxlogsize ) {
            RCsprintf( tmp, STR_LOG_BIG_ERASE, st.st_size );
            rc = MessageBox( MainWindow, tmp, AppName, MB_YESNO );
            if( rc == IDYES ) {
                remove( LogInfo.filename );
            }
        }
    }
    DumpHow = getProfileLong( DUMP_HOW, DUMP_ALL );
    AlertOnWarnings = ( getProfileLong( ALERT_ON_WARNINGS, 1 ) != 0 );
    ExceptionAction = getProfileLong( EXCPT_ACTION, INT_TERMINATE );
    GetPrivateProfileString( profID, DEBUG_OPTS, "/swap", DebuggerOpts,
                sizeof( DebuggerOpts ), iniFile );
    InitMonoFont( profID, iniFile, SYSTEM_FIXED_FONT, Instance );

} /* GetProfileInfo */
Exemple #18
0
/*
 * InitStatDialog
 */
static void InitStatDialog( HWND hwnd )
{
    int         i;
    char        buff[256];
    syminfo     si;
    ADDRESS     addr;

    SetDWORDEditField( hwnd, STAT_AX, IntData.EAX );
    SetDWORDEditField( hwnd, STAT_BX, IntData.EBX );
    SetDWORDEditField( hwnd, STAT_CX, IntData.ECX );
    SetDWORDEditField( hwnd, STAT_DX, IntData.EDX );
    SetDWORDEditField( hwnd, STAT_SI, IntData.ESI );
    SetDWORDEditField( hwnd, STAT_DI, IntData.EDI );
    SetDWORDEditField( hwnd, STAT_BP, IntData.EBP );

    SetWORDEditField( hwnd, STAT_DS, IntData.DS );
    SetWORDEditField( hwnd, STAT_ES, IntData.ES );
    SetWORDEditField( hwnd, STAT_FS, IntData.FS );
    SetWORDEditField( hwnd, STAT_GS, IntData.GS );

    SetWORDEditField( hwnd, STAT_CS, IntData.CS );
    SetDWORDEditField( hwnd, STAT_IP, IntData.EIP );
    SetWORDEditField( hwnd, STAT_SS, IntData.SS );
    SetDWORDEditField( hwnd, STAT_SP, IntData.ESP );

    CheckDlgButton( hwnd, STAT_FLAG_A, ( IntData.EFlags & FLAG_A_MASK ) ? BST_CHECKED : BST_UNCHECKED );
    CheckDlgButton( hwnd, STAT_FLAG_C, ( IntData.EFlags & FLAG_C_MASK ) ? BST_CHECKED : BST_UNCHECKED );
    CheckDlgButton( hwnd, STAT_FLAG_D, ( IntData.EFlags & FLAG_D_MASK ) ? BST_CHECKED : BST_UNCHECKED );
    CheckDlgButton( hwnd, STAT_FLAG_I, ( IntData.EFlags & FLAG_I_MASK ) ? BST_CHECKED : BST_UNCHECKED );
    CheckDlgButton( hwnd, STAT_FLAG_Z, ( IntData.EFlags & FLAG_Z_MASK ) ? BST_CHECKED : BST_UNCHECKED );
    CheckDlgButton( hwnd, STAT_FLAG_S, ( IntData.EFlags & FLAG_S_MASK ) ? BST_CHECKED : BST_UNCHECKED );
    CheckDlgButton( hwnd, STAT_FLAG_P, ( IntData.EFlags & FLAG_P_MASK ) ? BST_CHECKED : BST_UNCHECKED );
    CheckDlgButton( hwnd, STAT_FLAG_O, ( IntData.EFlags & FLAG_O_MASK ) ? BST_CHECKED : BST_UNCHECKED );

    CheckDlgButton( hwnd, STAT_SYMBOLS, ( StatShowSymbols ) ? BST_CHECKED : BST_UNCHECKED );

    /*
     * fill in source information
     */
    addr.seg = IntData.CS;
    addr.offset = IntData.EIP;
    if( FindWatSymbol( &addr, &si, TRUE ) == FOUND ) {
        RCsprintf( buff, STR_SRC_INFO_FMT, si.linenum, si.filename );
    } else {
        RCsprintf( buff, STR_N_A );
    }
    SetDlgMonoFont( hwnd, STAT_SRC_INFO );
    SetDlgItemText( hwnd, STAT_SRC_INFO, buff );

#ifdef __NT__
    {
        ProcStats       procinfo;
        HWND            button;

        if( GetProcessInfo( processID, &procinfo ) ) {
            RCsprintf( buff, STR_STATUS_4_PROC_X, processID, procinfo.name );
            SetWindowText( hwnd, buff );
        }
        CopyRCString( STR_VIEW_MEM_HT_KEY, buff, sizeof( buff ) );
        SetDlgItemText( hwnd, STAT_SEG_MAP, buff );
        button = GetDlgItem( hwnd, STAT_STACK_TRACE );
        ShowWindow( button, SW_HIDE );
    }
#endif

    /*
     * display code, starting 2 instructions before hand
     */
    currAddr.seg = IntData.CS;
    currAddr.offset = IntData.EIP;
    firstAddr = currAddr;
    InstructionBackup( 2, &currAddr );
    for( i=STAT_DISASM_1;i<=STAT_DISASM_8;i++ ) {
        SetDlgCourierFont( hwnd, i );
    }
    DisplayAsmLines( hwnd, &currAddr, &firstAddr, STAT_DISASM_1,
                        STAT_DISASM_8, STAT_SCROLL );

} /* InitStatDialog */
Exemple #19
0
/*
 * AboutProc - callback routine for settings dialog
 */
WINEXPORT INT_PTR CALLBACK AboutProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    char        buff[256];
    LPABOUTINFO pai;

    lparam = lparam;

    switch( msg ) {
    case WM_INITDIALOG:
        pai = (LPABOUTINFO)lparam;
        if( pai->title != NULL ) {
            SetWindowText( hwnd, pai->title );
        }
        if( pai->name != NULL ) {
            sprintf( buff, banner1p1( "%s" ), pai->name );
            SetDlgItemText( hwnd, ABOUT_NAME, buff );
        }
        if( pai->version != NULL ) {
            SetDlgItemText( hwnd, ABOUT_VERSION, pai->version );
        }
        if( pai->first_cr_year != NULL ) {
#if defined( __WATCOMC__) && !defined( __ALPHA__ )
            if( _fstrcmp( pai->first_cr_year, CURR_YEAR ) ) {
#else
            if( strcmp( pai->first_cr_year, CURR_YEAR ) ) {
#endif
                sprintf( buff, banner2a( "%s" ), pai->first_cr_year );
            } else {
                strcpy( buff, banner2a( "1984" ) );
            }
            SetDlgItemText( hwnd, ABOUT_COPYRIGHT, buff );
        }
#if defined( __WINDOWS__ ) || defined( __WINDOWS_386__ )
        {
            DWORD       flags;
            DWORD       kfree;
            WORD        pcfree;
            SYSHEAPINFO shi;
            char        work[16];
            char        info[50];

            flags = GetWinFlags();
            if( flags & WF_ENHANCED ) {
                CopyRCString( ABT_386_ENH, info, sizeof( info ) );
            } else {
                CopyRCString( ABT_STD_MODE, info, sizeof( info ) );
            }
            SetDlgItemText( hwnd, ABOUT_INFO1, info );
            kfree = GetFreeSpace( 0 ) / 1024L;
            ltoa( kfree, work, 10 );
            RCsprintf( buff, ABT_MEM_X_KB_FREE, (LPSTR)work );
            SetDlgItemText( hwnd, ABOUT_INFO2, buff );

            shi.dwSize = sizeof( shi );
            if( SystemHeapInfo( &shi ) ) {
                pcfree = shi.wGDIFreePercent;
                if( pcfree > shi.wUserFreePercent )
                    pcfree = shi.wUserFreePercent;
                RCsprintf( buff, ABT_SYS_RESOURCES_FREE, pcfree );
            } else {
                CopyRCString( ABT_SYS_RESOURCES_N_A, buff, sizeof( buff ) );
            }
            SetDlgItemText( hwnd, ABOUT_INFO3, buff );
        }
#else
        {
            SYSTEM_INFO         si;
            MEMORYSTATUS        ms;

            GetSystemInfo( &si );
            switch( si.dwProcessorType ) {
            case PROCESSOR_INTEL_386:
                CopyRCString( ABT_RUNNING_ON_386, buff, sizeof( buff ) );
                break;
            case PROCESSOR_INTEL_486:
                CopyRCString( ABT_RUNNING_ON_486, buff, sizeof( buff ) );
                break;
            case PROCESSOR_INTEL_PENTIUM:
                CopyRCString( ABT_RUNNING_ON_586, buff, sizeof( buff ) );
                break;
            case PROCESSOR_MIPS_R4000:
            case PROCESSOR_ALPHA_21064:
            default:
                buff[0] = '\0';
                break;
            }
            SetDlgItemText( hwnd, ABOUT_INFO1, buff );

            ms.dwLength = sizeof( ms );
            GlobalMemoryStatus( &ms );
            RCsprintf( buff, ABT_VIRT_MEM,
                       (ms.dwAvailPhys + ms.dwAvailPageFile) / 1024L );
            SetDlgItemText( hwnd, ABOUT_INFO2, buff );
            RCsprintf( buff, ABT_MEM_LOAD, ms.dwMemoryLoad );
            SetDlgItemText( hwnd, ABOUT_INFO3, buff );

        }
#endif
        return( TRUE );
#ifndef NOUSE3D
    case WM_SYSCOLORCHANGE:
        CvrCtl3dColorChange();
        break;
#endif
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        break;
    case WM_COMMAND:
        switch( LOWORD( wparam ) ) {
        case IDOK:
        case IDCANCEL:
            EndDialog( hwnd, 0 );
            break;
        }
    }
    return( FALSE );

} /* AboutProc */

/*
 * DoAbout - show the startup dialog
 */
void DoAbout( LPABOUTINFO ai )
{
    FARPROC     proc;

    proc = MakeDlgProcInstance( AboutProc, ai->inst );
    DialogBoxParam( ai->inst, "About", ai->owner, (DLGPROC)proc, (LPARAM)ai );
    FreeProcInstance( proc );

} /* DoAbout */
Exemple #20
0
/*
 * memDumpHeader - put summary information at the top of a memory dump
 */
static void memDumpHeader( int hdl, MemWndInfo *info )
{
    time_t              tm;
    char                buf[80];
    unsigned            len;
    unsigned            type_index;
    char                *rcstr;
#ifndef __NT__
    GLOBALENTRY         ge;
    descriptor          desc;
    char                access[20];
#endif

    tm = time( NULL );
    RCsprintf( buf, MWND_MEM_DMP_CREATED, asctime( localtime( &tm ) ), &len );
    write( hdl, buf, len );

#ifndef __NT__
    if( info->isdpmi ) {
        rcstr = AllocRCString( MWND_DPMI_ITEM );
        len = strlen( rcstr );
        write( hdl, rcstr, len );
        FreeRCString( rcstr );
        GetADescriptor( info->sel, &desc );
        RCsprintf( buf, MWND_SELECTOR, info->sel, &len );
        write( hdl, buf, len );
        RCsprintf( buf, MWND_BASE, GET_DESC_BASE( desc ), &len );
        write( hdl, buf, len );
        RCsprintf( buf, MWND_LIMIT, GET_DESC_LIMIT( desc), &len );
        write( hdl, buf, len );
        if( desc.type == 2 ) {
            RCsprintf( buf, MWND_TYPE_DATA, &len );
        } else {
            RCsprintf( buf, MWND_TYPE_CODE, &len );
        }
        write( hdl, buf, len );
        sprintf( buf, "DPL:         \t%1d\n%n", desc.dpl, &len );
        write( hdl, buf, len );
        if( desc.granularity ) {
            RCsprintf( buf, MWND_GRANULARITY_PAGE, &len );
        } else {
            RCsprintf( buf, MWND_GRANULARITY_BYTE, &len );
        }
        write( hdl, buf, len );
        createAccessString( access, &desc );
        RCsprintf( buf, MWND_ACCESS, access, &len );
        write( hdl, buf, len );
    } else {
        ge.dwSize = sizeof( GLOBALENTRY );
        GlobalEntryHandle( &ge, (HGLOBAL)info->sel );
        RCsprintf( buf, MWND_BLOCK_ADDR, ge.dwAddress, &len );
        write( hdl, buf, len );
        RCsprintf( buf, MWND_BLOCK_HDL, ge.hBlock, &len );
        write( hdl, buf, len );
        RCsprintf( buf, MWND_BLOCK_SIZE, ge.dwBlockSize, &len );
        write( hdl, buf, len );
        RCsprintf( buf, MWND_LOCK_CNT, ge.wcLock, &len );
        write( hdl, buf, len );
        RCsprintf( buf, MWND_PAGE_LOCK_CNT, ge.wcPageLock, &len );
        write( hdl, buf, len );
    }
#endif

    type_index = info->disp_type - MEMINFO_BYTE;
    rcstr = AllocRCString( Disp_Types[type_index] );
    sprintf( buf, "%s\n\n%n", rcstr, &len );
    FreeRCString( rcstr );
    write( hdl, buf, len );

} /* MemDumpHeader */
Exemple #21
0
/*
 * ProcessIncomingMessage - get a string associated with a message id
 */
void ProcessIncomingMessage( UINT msgid, char *class_name, char *res )
{
    message     *msg;
    const char  *fmtstr;
    char        buf[256];
    char        hexstr[20];

    res[0] = '\0';
    msg = GetMessageDataFromID( msgid, class_name );
    if( msg != NULL ) {
        if( msg->watch ) {
            strcpy( res, msg->str );
        }
        if( msg->stopon ) {
            SetSpyState( OFF );
            RCsprintf( buf, STR_SPYING_STOPPED, msg->str );
            MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION );
        }
        msg->count++;
    } else if( msgid >= WM_USER && msgid < WM_APP ) {
        userMsg->count++;
        if( userMsg->watch ) {
            fmtstr = GetRCString( STR_WM_USER_PLUS );
            sprintf( res, fmtstr, msgid - WM_USER );
        }
        if( userMsg->stopon ) {
            SetSpyState( OFF );
            fmtstr = GetRCString( STR_WM_USER_PLUS );
            sprintf( res, fmtstr, msgid - WM_USER );
            RCsprintf( buf, STR_SPYING_STOPPED, res );
            MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION );
        }
    } else if( msgid >= WM_APP && msgid < 0xC000 ) {
        appMsg->count++;
        if( appMsg->watch ) {
            fmtstr = GetRCString( STR_WM_APP_PLUS );
            sprintf( res, fmtstr, msgid - WM_APP );
        }
        if( appMsg->stopon ) {
            SetSpyState( OFF );
            fmtstr = GetRCString( STR_WM_APP_PLUS );
            sprintf( res, fmtstr, msgid - WM_APP );
            RCsprintf( buf, STR_SPYING_STOPPED, res );
            MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION );
        }
    } else {
        if( Filters[MC_UNKNOWN].watch ) {
            GetHexStr( hexstr, msgid, 0 );
            fmtstr = GetRCString( STR_UNKNOWN_MSG );
            sprintf( res, fmtstr, hexstr );
        }
        if( Filters[MC_UNKNOWN].stopon ) {
            SetSpyState( OFF );
            GetHexStr( hexstr, msgid, 0 );
            fmtstr = GetRCString( STR_UNKNOWN_MSG );
            sprintf( res, fmtstr, hexstr );
            RCsprintf( buf, STR_SPYING_STOPPED, res );
            MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION );
        }
    }

} /* ProcessIncomingMessage */
Exemple #22
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 );
}
Exemple #23
0
/*
 * InitStatDialog
 */
static void InitStatDialog( HWND hwnd )
{
    int                 i;
    char                buff[256];
    ExceptDlgInfo       *info;
    syminfo             si;
    CreateRegListData   data;
    StatData            *statdata;
    RECT                c_rect;
    HWND                combo;

    info = StatGetExceptDlgInfo( hwnd );
    StatHdl = hwnd;
    statdata = MemAlloc( sizeof( StatData ) );

    /*
     * fill in source information
     */
    GetCurrAddr( &( statdata->curr_addr ), info->regs );
    if( FindWatSymbol( &( statdata->curr_addr ), &si, TRUE ) == FOUND ) {
        RCsprintf( buff, STR_SRC_INFO_FMT, si.linenum, si.filename );
        StatShowSymbols = TRUE;
        CheckDlgButton( hwnd, STAT_SYMBOLS, ( StatShowSymbols ) ? BST_CHECKED : BST_UNCHECKED );
    } else {
        RCsprintf( buff, STR_N_A );
        StatShowSymbols = FALSE;
        EnableWindow( GetDlgItem( hwnd, STAT_SYMBOLS ), FALSE );
    }
    SetDlgMonoFont( hwnd, STAT_SRC_INFO );
    SetDlgItemText( hwnd, STAT_SRC_INFO, buff );

#ifdef __NT__
    {
        ProcStats       procinfo;
        HWND            button;
        if( GetProcessInfo( info->procinfo->procid, &procinfo ) ) {
            RCsprintf( buff, STR_STATUS_4_PROC_X, info->procinfo->procid, procinfo.name );
            SetWindowText( hwnd, buff );
        }
        CopyRCString( STR_VIEW_MEM_HT_KEY, buff, sizeof( buff ) );
        SetDlgItemText( hwnd, STAT_SEG_MAP, buff );
        button = GetDlgItem( hwnd, STAT_STACK_TRACE );
        ShowWindow( button, SW_HIDE );
    }
#endif
    InstructionBackward( 2, &( statdata->curr_addr ) );
    for( i = STAT_DISASM_1;i <= STAT_DISASM_8; i++ ) {
        SetDlgCourierFont( hwnd, i );
    }
    DisplayAsmLines( hwnd, &( statdata->curr_addr ) );
    data.index = 0;
    data.parent = hwnd;
    data.max_len = 0;
    combo = GetDlgItem( hwnd, STAT_REGISTER_COMBO );
    MADRegSetWalk( MTK_ALL, CreateAllRegLists, &data );
    if( data.index == 1 ) {
        SendMessage( combo, CB_GETLBTEXT, (WPARAM)0, (LPARAM)buff );
        SetDlgItemText( hwnd, STAT_REGISTER_SET, buff );
        DestroyWindow( combo );
    } else {
        GetChildPos( hwnd, combo, &c_rect );
        SendMessage( combo, CB_SETCURSEL, (WPARAM)0, (LPARAM)0 );
        c_rect.right += data.max_len;
        c_rect.bottom += SendMessage( combo, CB_GETITEMHEIGHT, 0, 0 ) * ( data.index + 1);
        MoveWindow( combo, c_rect.left, c_rect.top, c_rect.right, c_rect.bottom, FALSE );
    }
    SetFocus( GetDlgItem( hwnd, IDOK ) );
    statdata->reg_set_index = 0;
    SetWindowLong(hwnd,DWL_USER,(LONG)statdata);
} /* InitStatDialog */