예제 #1
0
bool SetMsgText( char *message, unsigned *conditions )
/****************************************************/
{
    char        *equal,*comma1,*comma2;
    address     addr,buff_addr;
    long        buff_len;
    size_t      sym_len;
    long        num_returns;
    cmd_list    *cmds;

#define IS_DEBUGGER_COMMAND(m,x)   (memcmp( m, DEBUGGER_COMMAND( x ), sizeof( DEBUGGER_COMMAND( x ) ) - 1 ) == 0)
#define DEBUGGER_COMMAND_SKIP(m,x)   m += sizeof( DEBUGGER_COMMAND( x ) ) - 1

    if( IS_DEBUGGER_COMMAND( message, THREADID ) ) {
        DEBUGGER_COMMAND_SKIP( message, THREADID );
        equal = strchr( message, '=' );
        if( equal == NULL )
            return( true );
        *equal = NULLCHAR;
        CheckForNewThreads( false );
        NameThread( strtoul( message, NULL, 16 ), equal + 1 );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, SETTRUE ) ) {
        DEBUGGER_COMMAND_SKIP( message, SETTRUE );
        if( DlgScanDataAddr( message, &addr ) ) {
            ProgPoke( addr, "\x1", 1 );
        }
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, EXECUTE ) ) {
        DEBUGGER_COMMAND_SKIP( message, EXECUTE );
        if( InCall == 0 ) {
            cmds = AllocCmdList( "go/keep", sizeof( "go/keep" ) - 1 );
            PushCmdList( cmds );
            TypeInpStack( INP_HOOK );
            FreeCmdList( cmds );
        }
        cmds = AllocCmdList( message, strlen( message ) );
        PushCmdList( cmds );
        TypeInpStack( INP_HOOK );
        FreeCmdList( cmds );
        *conditions |= COND_STOP;
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, MESSAGE ) ) {
        DEBUGGER_COMMAND_SKIP( message, MESSAGE );
        AddMessageText( message );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, LOOKUP ) ) {
        DEBUGGER_COMMAND_SKIP( message, LOOKUP );
        comma1 = strchr( message, ',' );
        if( comma1 == NULL )
            return( true );
        *comma1++ = NULLCHAR;
        comma2 = strchr( comma1, ',' );
        if( comma2 == NULL )
            return( true );
        *comma2++ = NULLCHAR;
        if( !DlgScanDataAddr( message, &addr ) )
            return( true );
        if( !DlgScanDataAddr( comma1, &buff_addr ) )
            return( true );
        if( !DlgScanLong( comma2, &buff_len ) )
            return( true );
        CnvNearestAddr( addr, TxtBuff, TXT_LEN );
        sym_len = strlen( TxtBuff ) + 1;
        if( sym_len > buff_len ) {
            sym_len = (size_t)buff_len;
            TxtBuff[sym_len - 1] = NULLCHAR;
        }
        ProgPoke( buff_addr, TxtBuff, sym_len );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, LOADMODULE ) ) {
        DEBUGGER_COMMAND_SKIP( message, LOADMODULE );
        comma1 = strchr( message, ',' );
        if( comma1 == NULL )
            return( true );
        *comma1++ = NULLCHAR;
        if( !DlgScanDataAddr( message, &addr ) )
            return( true );
        SymUserModLoad( comma1, &addr );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, UNLOADMODULE ) ) {
        DEBUGGER_COMMAND_SKIP( message, UNLOADMODULE );
        SymUserModUnload( message );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, BREAKRETURN ) ) {
        DEBUGGER_COMMAND_SKIP( message, BREAKRETURN );
        if( !DlgScanLong( message, &num_returns ) )
            return( true );
        // TODO: do something with num_returns value
        return( false );
    } else {
        AddMessageText( message );
        return( true );
    }

#undef IS_DEBUGGER_COMMAND
#undef DEBUGGER_COMMAND_SKIP

}
예제 #2
0
bool SetMsgText( char *message, unsigned *conditions )
/****************************************************/
{
    char        *equal,*comma1,*comma2;
    address     addr,buff_addr;
    long        buff_len,sym_len;
    long        num_returns;
    cmd_list    *cmds;

    if( memcmp( message, DEBUGGER_THREADID_COMMAND,
                sizeof( DEBUGGER_THREADID_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_THREADID_COMMAND ) - 1;
        equal = strchr( message, '=' );
        if( equal == NULL ) return( TRUE );
        *equal = '\0';
        CheckForNewThreads( FALSE );
        NoCRLF( equal + 1 );
        NameThread( strtoul( message, NULL, 16 ), equal + 1 );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_SETTRUE_COMMAND,
                sizeof( DEBUGGER_SETTRUE_COMMAND ) - 1 ) == 0 ) {
        unsigned old = NewCurrRadix( 16 );
        NoCRLF( message );
        if( DlgScanDataAddr( message + sizeof( DEBUGGER_SETTRUE_COMMAND ) - 1, &addr ) ) {
            ProgPoke( addr, "\x1", 1 );
        }
        NewCurrRadix( old );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_EXECUTE_COMMAND,
                sizeof( DEBUGGER_EXECUTE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_EXECUTE_COMMAND ) - 1;
        NoCRLF( message );
        if( InCall == 0 ) {
            cmds = AllocCmdList( "go/keep", strlen( "go/keep" ) );
            PushCmdList( cmds );
            TypeInpStack( INP_HOOK );
            FreeCmdList( cmds );
        }
        cmds = AllocCmdList( message, strlen( message ) );
        PushCmdList( cmds );
        TypeInpStack( INP_HOOK );
        FreeCmdList( cmds );
        *conditions |= COND_STOP;
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_MESSAGE_COMMAND,
                sizeof( DEBUGGER_MESSAGE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_MESSAGE_COMMAND ) - 1;
        NoCRLF( message );
        AddMessageText( message );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_LOOKUP_COMMAND,
                sizeof( DEBUGGER_LOOKUP_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_LOOKUP_COMMAND ) - 1;
        comma1 = strchr( message, ',' );
        if( comma1 == NULL ) return( TRUE );
        *comma1++ = '\0';
        comma2 = strchr( comma1, ',' );
        if( comma2 == NULL ) return( TRUE );
        *comma2++ = '\0';
        NoCRLF( comma2 );
        if( !DlgScanDataAddr( message, &addr ) )
            return( TRUE );
        if( !DlgScanDataAddr( comma1, &buff_addr ) )
            return( TRUE );
        if( !DlgScanLong( comma2, &buff_len ) )
            return( TRUE );
        CnvNearestAddr( addr, TxtBuff, TXT_LEN );
        sym_len = strlen( TxtBuff ) + 1;
        if( sym_len > buff_len ) {
            TxtBuff[buff_len - 1] = '\0';
            sym_len = buff_len;
        }
        ProgPoke( buff_addr, TxtBuff, sym_len );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_LOADMODULE_COMMAND,
                sizeof( DEBUGGER_LOADMODULE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_LOADMODULE_COMMAND ) - 1;
        comma1 = strchr( message, ',' );
        if( comma1 == NULL )
            return( TRUE );
        *comma1++ = '\0';
        NoCRLF( comma1 );
        if( !DlgScanDataAddr( message, &addr ) )
            return( TRUE );
        SymUserModLoad( comma1, &addr );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_UNLOADMODULE_COMMAND,
                sizeof( DEBUGGER_UNLOADMODULE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_UNLOADMODULE_COMMAND ) - 1;
        NoCRLF( message );
        SymUserModUnload( message );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_BREAKRETURN_COMMAND,
                sizeof( DEBUGGER_BREAKRETURN_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_BREAKRETURN_COMMAND ) - 1;
        NoCRLF( message );
        if( !DlgScanLong( message, &num_returns ) )
            return( TRUE );
        // TODO: do something with num_returns value
        return( FALSE );
    } else {
        AddMessageText( message );
        return( TRUE );
    }
}