Exemple #1
0
static void AccTrap( bool want_return )
{
    if( want_return ) {
        PutBuffPacket( RWBuff, TrapAccess( 1, &In[0], 1, &Out[0] ) );
    } else {
        TrapAccess( 1, &In[0], 0, NULL );
    }
}
Exemple #2
0
unsigned OnAnotherThreadAccess( unsigned in_num, in_mx_entry_p in_mx, unsigned out_num, mx_entry_p out_mx )
{
    unsigned    result;

    if( !ToldWinHandle || IsTrapFilePumpingMessageQueue() ) {
        return( TrapAccess( in_num, in_mx, out_num, out_mx ) );
    } else {
        DosSemClear( &PumpMessageSem );
        result = TrapAccess( in_num, in_mx, out_num, out_mx );
        WinPostMsg( GUIGetSysHandle( WndGui( WndMain ) ), WM_QUIT, 0, 0 );
        DosSemWait( &PumpMessageDoneSem, SEM_INDEFINITE_WAIT );
        DosSemSet( &PumpMessageDoneSem );
        return( result );
    }
}
Exemple #3
0
static unsigned DoRead( sys_handle hdl, void *ptr, unsigned len )
{
    mx_entry            in[1];
    mx_entry            out[2];
    file_read_req       acc;
    file_read_ret       ret;
    unsigned            got;

    SUPP_FILE_SERVICE( acc, REQ_FILE_READ );
    acc.handle = hdl;
    acc.len = len;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    out[1].ptr = ptr;
    out[1].len = len;
    CONV_LE_32( acc.handle );
    CONV_LE_16( acc.len );
    got = TrapAccess( 1, &in, 2, &out );
    CONV_LE_32( ret.err );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( ERR_RETURN );
    } else {
        return( got - sizeof( ret ) );
    }
}
Exemple #4
0
static unsigned DoAWrite( unsigned req, sys_handle hdl, void *ptr, unsigned len )
{
    mx_entry            in[2];
    mx_entry            out[1];
    union {
        file_write_req              file;
        file_write_console_req      con;
    } acc;
    file_write_ret      ret;

    SUPP_FILE_SERVICE( acc.file, req );
    if( req == REQ_FILE_WRITE_CONSOLE ) {
        in[0].len = sizeof( acc.con );
    } else {
        acc.file.handle = hdl;
    CONV_LE_32( acc.file.handle );
        in[0].len = sizeof( acc.file );
    }
    in[0].ptr = &acc;
    in[1].ptr = ptr;
    in[1].len = len;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, &in, 1, &out );
    CONV_LE_32( ret.err );
    CONV_LE_16( ret.len );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( ERR_RETURN );
    } else {
        return( ret.len );
    }
}
void RemoteUpdateRunThread( thread_state *thd )
{
    in_mx_entry                     in[1];
    mx_entry                        out[2];
    run_thread_get_runtime_req      acc;
    run_thread_get_runtime_ret      ret;

    if( SuppRunThreadId == 0 ) return;

    acc.supp.core_req = REQ_PERFORM_SUPPLEMENTARY_SERVICE;
    acc.supp.id = SuppRunThreadId;
    acc.req = REQ_RUN_THREAD_GET_RUNTIME;
    acc.thread = thd->tid;

    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    out[1].ptr = thd->extra;
    out[1].len = MAX_THD_EXTRA_SIZE;
    TrapAccess( 1, in, 2, out );

    thd->state = ret.state;
    thd->cs = ret.cs;
    thd->eip = ret.eip;    
}
Exemple #6
0
bool RemoteGetEnvironmentVariable( char *name, char *res, int res_len )
{
    in_mx_entry         in[2];
    mx_entry            out[2];
    env_get_var_req     acc;
    env_get_var_ret     ret;

    if( SuppEnvId == 0 ) return( false );
    SUPP_ENV_SERVICE( acc, REQ_ENV_GET_VAR );
    acc.res_len = res_len;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    out[1].ptr = res;
    out[1].len = res_len;
    TrapAccess( 2, in, 2, out );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( false );
    } else {
        return( true );
    }
}
Exemple #7
0
bool RemoteSetEnvironmentVariable( char *name, char *value )
{
    in_mx_entry         in[3];
    mx_entry            out[1];
    env_set_var_req     acc;
    env_set_var_ret     ret;

    if( SuppEnvId == 0 ) return( false );
    SUPP_ENV_SERVICE( acc, REQ_ENV_SET_VAR );
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    in[2].ptr = value;
    in[2].len = strlen( value ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 3, in, 1, out );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( false );
    } else {
        return( true );
    }
}
Exemple #8
0
bool RemoteSetFileDate( const char *name, long date )
{
    in_mx_entry                 in[2];
    mx_entry                    out[1];
    file_info_set_date_req      acc;
    file_info_set_date_ret      ret;

    if( SuppFileInfoId == 0 )
        return( false );
    SUPP_FILE_INFO_SERVICE( acc, REQ_FILE_INFO_SET_DATE );
    acc.date = date;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = (trap_elen)( strlen( name ) + 1 );
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, in, 1, out );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( false );
    } else {
        return( true );
    }
}
Exemple #9
0
static bool AccConnect( void )
{
    connect_req         *acc;
    char                *data;
    connect_ret         *ret;
    trap_elen           max;
    trap_elen           len;

    acc = GetInPtr( 0 );
    ret = GetOutPtr( 0 );
    data = GetOutPtr( sizeof( *ret ) );
    if( acc->ver.major != TrapVersion.major || acc->ver.minor > TrapVersion.minor ) {
        strcpy( data, TRP_ERR_WRONG_SERVER_VERSION );
        PutBuffPacket( RWBuff, sizeof( *acc ) + sizeof( TRP_ERR_WRONG_SERVER_VERSION ) );
    } else {
        len = TrapAccess( 1, &In[0], 1, &Out[0] );
        max = MaxPacketSize();
        if( max > sizeof( RWBuff ) )
            max = sizeof( RWBuff );
        if( ret->max_msg_size > max )
            ret->max_msg_size = max;
        CONV_LE_16( ret->max_msg_size );
        PutBuffPacket( RWBuff, len );
    }
    if( data[0] != '\0' ) {
        ServError( data );
        return( FALSE );
    }
    return( TRUE );
}
bool RemoteGetRunThreadInfo( int row, unsigned char *infotype, int *width, char *header, int maxsize )
{
    in_mx_entry         in[1];
    mx_entry            out[2];
    run_thread_info_req acc;
    run_thread_info_ret ret;

    if( SuppRunThreadId == 0 ) return( FALSE );

    acc.supp.core_req = REQ_PERFORM_SUPPLEMENTARY_SERVICE;
    acc.supp.id = SuppRunThreadId;
    acc.req = REQ_RUN_THREAD_INFO;
    acc.col = row;
    ret.info = 0;

    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    out[1].ptr = header;
    out[1].len = maxsize;
    TrapAccess( 1, in, 2, out );

    if( ret.info ) {
        *infotype = ret.info;
        *width = ret.width;
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Exemple #11
0
unsigned TrapSimpAccess( trap_elen in_len, in_data_p in_data, trap_elen out_len, out_data_p out_data )
{
    in_mx_entry     in[1];
    mx_entry        out[1];
    unsigned        result;

    in[0].ptr = in_data;
    in[0].len = in_len;
    if( out_len != 0 ) {
        out[0].ptr = out_data;
        out[0].len = out_len;
        result = TrapAccess( 1, in, 1, out );
    } else {
        result = TrapAccess( 1, in, 0, NULL );
    }
    return( result );
}
Exemple #12
0
unsigned TrapSimpAccess( unsigned in_len, void *in_data, unsigned out_len, void *out_data )
{
    mx_entry        in[1];
    mx_entry        out[1];
    unsigned        result;

    in[0].ptr = in_data;
    in[0].len = in_len;
    if( out_len != 0 ) {
        out[0].ptr = out_data;
        out[0].len = out_len;
        result = TrapAccess( 1, in, 1, out );
    } else {
        result = TrapAccess( 1, in, 0, NULL );
    }
    return( result );
}
Exemple #13
0
//NYI: The 'bool executable' should be changed to allow different file types
unsigned RemoteStringToFullName( bool executable, char *name, char *res,
                                 unsigned res_len )
{
    mx_entry            in[2];
    mx_entry            out[2];
    file_string_to_fullpath_req acc;
    file_string_to_fullpath_ret ret;
    handle              h;

    if( SuppFileId == 0 ) {
        h = LclStringToFullName( name, strlen( name ), res );
        if( h == NIL_HANDLE ) return( 0 );
        FileClose( h );
        return( strlen( res ) );
    }
#ifdef __NT__
    // check whether short filename is necessary
    switch( SysConfig.os ) {
    case OS_AUTOCAD:
    case OS_DOS:
    case OS_RATIONAL:
    case OS_PHARLAP:
    case OS_WINDOWS:
        // convert long file name to short "DOS" compatible form
        {
            char short_filename[MAX_PATH + 1] = "";

            GetShortPathNameA( name, short_filename, MAX_PATH );
            if( strlen( short_filename ) != 0 ) {
                strcpy( name, short_filename );
            }
        }
        break;
    }
#endif
    SUPP_FILE_SERVICE( acc, REQ_FILE_STRING_TO_FULLPATH );
    acc.file_type = ( executable ? TF_TYPE_EXE : TF_TYPE_PRS );
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    out[1].ptr = res;
    out[1].len = res_len;
    TrapAccess( 2, &in, 2, &out );
    CONV_LE_32( ret.err );
    if( ret.err != 0 ) {
        *res = NULLCHAR;
        return( 0 );
    } else {
        return( strlen( res ) );
    }
}
Exemple #14
0
sys_handle RemoteOpen( char *name, open_access mode )
{
    mx_entry            in[2];
    mx_entry            out[1];
    file_open_req       acc;
    file_open_ret       ret;
    int                 locfile;

    if( SuppFileId == 0 ) return( NIL_SYS_HANDLE );

    SUPP_FILE_SERVICE( acc, REQ_FILE_OPEN );
    acc.mode = 0;
    if( mode & OP_READ )
        acc.mode |= TF_READ;
    if( mode & OP_WRITE )
        acc.mode |= TF_WRITE;
    if( mode & OP_CREATE ) {
        acc.mode |= TF_CREATE;
        if( mode & OP_EXEC )
            acc.mode |= TF_EXEC;
    }
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, &in, 1, &out );
    CONV_LE_32( ret.err );
    CONV_LE_32( ret.handle );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
            return( NIL_SYS_HANDLE );
    } else {
        /* See if the file is available locally. If so, open it here as
         * well as on the remote machine.
         */
        // TODO: check if remote file is the same!

#ifdef LOGGING
        fprintf( logf, "Trying to open local copy of remote file (remote handle %d)\n", ret.handle );
        fprintf( logf, "%s\n", name );
#endif

        if( (locfile = open(name, O_RDONLY | O_BINARY, 0 )) != -1 ) {
            if(AddCachedHandle( locfile, ret.handle ) != 0 )
                close( locfile );
#ifdef LOGGING
            fprintf(logf, "Success\n", name);
#endif
        }
        return( ret.handle );
    }
}
Exemple #15
0
trap_shandle GetSuppId( char *name )
{
    mx_entry                            in[2];
    mx_entry                            out[1];
    get_supplementary_service_req       acc;
    get_supplementary_service_ret       ret;

    acc.req = REQ_GET_SUPPLEMENTARY_SERVICE;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, in, 1, out );
    if( ret.err != 0 ) return( 0 );
    return( ret.id );
}
Exemple #16
0
unsigned RemoteErase( char *name )
{
    mx_entry            in[2];
    mx_entry            out[1];
    file_erase_req      acc;
    file_erase_ret      ret;

    if( SuppFileId == 0 ) return( 0 );
    SUPP_FILE_SERVICE( acc, REQ_FILE_ERASE );
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, &in, 1, &out );
    CONV_LE_32( ret.err );
    return( StashErrCode( ret.err, OP_REMOTE ) );
}
Exemple #17
0
long RemoteFork( char *cmd, unsigned len )
{
    mx_entry            in[2];
    mx_entry            out[1];
    file_run_cmd_req    acc;
    file_run_cmd_ret    ret;

    if( SuppFileId == 0 ) return( 0 );
    SUPP_FILE_SERVICE( acc, REQ_FILE_RUN_CMD );
    acc.chk_size = CheckSize;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = cmd;
    in[1].len = len;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, &in, 1, &out );
    CONV_LE_32( ret.err );
    return( StashErrCode( ret.err, OP_REMOTE ) );
}
Exemple #18
0
long RemoteGetFileDate( char *name )
{
    mx_entry            in[2];
    mx_entry            out[1];
    file_info_get_date_req      acc;
    file_info_get_date_ret      ret;

    if( SuppFileInfoId == 0 ) return( -1 );
    SUPP_FILE_INFO_SERVICE( acc, REQ_FILE_INFO_GET_DATE );
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, in, 1, out );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( -1 );
    } else {
        return( ret.date );
    }
}
Exemple #19
0
unsigned OnAnotherThreadAccess( unsigned in_num, in_mx_entry_p in_mx, unsigned out_num, mx_entry_p out_mx )
{
    return( TrapAccess( in_num, in_mx, out_num, out_mx ) );
}
Exemple #20
0
void InitTrap( char *trap_file )
{
    mx_entry            in[1];
    mx_entry            out[2];
    connect_req         in_mx;
    connect_ret         out_mx;
    char                *error;
    trap_version        ver;
    char                buff[ TXT_LEN ];

#ifdef ENABLE_TRAP_LOGGING
    if( TrpDebugFile )
        OpenTrapTraceFile( TrpDebugFile, TrpDebugFileFlush );
#endif

/* Don't use TxtBuff except for error -- it may have a Finger message in it */

#if !defined( BUILD_RFX )
    TrapSetFailCallBack( TrapFailed );
#endif
    InitTrapError = FALSE;
    RestoreHandlers();
    ver.remote = FALSE;
#if !defined( BUILD_RFX )
    if( stricmp( trap_file, "dumb" ) == 0 ) {
        error = LoadDumbTrap( &ver );
    } else {
#endif
        error = LoadTrap( trap_file, buff, &ver );
#if !defined( BUILD_RFX )
    }
#endif
    GrabHandlers();
    if( error != NULL ) {
        strcpy( buff, error );
        InitTrapError = TRUE;
        StartupErr( buff );
    }
    in_mx.req = REQ_CONNECT;
    in_mx.ver.major = TRAP_MAJOR_VERSION;
    in_mx.ver.minor = TRAP_MINOR_VERSION;
    in_mx.ver.remote = FALSE;
    in[0].ptr = &in_mx;
    in[0].len = sizeof( in_mx );
    out[0].ptr = &out_mx;
    out[0].len = sizeof( out_mx );
    buff[0] = '\0';
    out[1].ptr = buff;
    out[1].len = MAX_ERR_MSG_SIZE;
    TrapAccess( 1, in, 2, out );
    MaxPacketLen = out_mx.max_msg_size;
    if( buff[0] != '\0' ) {
        KillTrap();
        InitTrapError = TRUE;
        StartupErr( buff );
    }
#if !defined( BUILD_RFX )
    if( !InitTrapError ) {
        InitSuppServices();
    }
#endif
    if( ver.remote ) {
        _SwitchOn( SW_REMOTE_LINK );
    } else {
        _SwitchOff( SW_REMOTE_LINK );
    }
}
Exemple #21
0
unsigned OnAnotherThreadAccess( trap_elen in_num, in_mx_entry_p in_mx, trap_elen out_num, mx_entry_p out_mx )
{
    return( TrapAccess( in_num, in_mx, out_num, out_mx ) );
}