Exemple #1
0
unsigned ReqProg_load( void )
{
    char                buffer[160];
    char                *src;
    char                *dst;
    char                *name;
    char                *endparm;
    char                *err;
    tiny_ret_t          rc;
    prog_load_ret       *ret;
    unsigned_16         len;

    SaveVectors( OrigVectors );
    _DBG_EnterFunc( "AccLoadProg()" );
    ret = GetOutPtr( 0 );
    src = name = GetInPtr( sizeof( prog_load_req ) );
    rc = FindFilePath( src, buffer, DosXExtList );
    endparm = LinkParm;
    while( *endparm++ != '\0' ) {}      // skip program name
    strcpy( endparm, buffer );
    err = RemoteLink( LinkParm, 0 );
    if( err != NULL ) {
        _DBG_Writeln( "Can't RemoteLink" );
        TinyWrite( TINY_ERR, err, strlen( err ) );
        LoadError = err;
        ret->err = 1;
        len = 0;
    } else {
        if( TINY_OK( rc ) ) {
            while( *src++ != '\0' ) {}
            len = GetTotalSize() - ( src - name ) - sizeof( prog_load_req );
            dst = (char *)buffer;
            while( *dst++ != '\0' ) {};
            memcpy( dst, src, len );
            dst += len;
            _DBG_Writeln( "StartPacket" );
            StartPacket();
            _DBG_Writeln( "AddPacket" );
            AddPacket( sizeof( prog_load_req ), In_Mx_Ptr[0].ptr );
            _DBG_Writeln( "AddPacket" );
            AddPacket( dst - buffer, buffer );
            _DBG_Writeln( "PutPacket" );
            PutPacket();
            _DBG_Writeln( "GetPacket" );
            len = GetPacket();
            _DBG_Writeln( "RemovePacket" );
            RemovePacket( sizeof( *ret ), ret );
        } else {
            len = DoAccess();
        }
        _DBG_Writeln( "Linked --" );
        if( ret->err != 0 ) {
            get_err_text_req    erracc;
            prog_kill_req       killacc;
            int                 msg_len;

            _DBG_Writeln( "loadret->errcode != 0" );
            if( LoadError == NULL ) {
                _DBG_Writeln( "making a REQ_GET_ERR_TEXT request" );
                erracc.req = REQ_GET_ERR_TEXT;
                erracc.err = ret->err;
                _DBG_Writeln( "StartPacket" );
                StartPacket();
                _DBG_Writeln( "AddPacket" );
                AddPacket( sizeof( erracc ), &erracc );
                _DBG_Writeln( "PutPacket" );
                PutPacket();
                _DBG_Writeln( "GetPacket" );
                msg_len = GetPacket();
                _DBG_Writeln( "RemovePacket" );
                RemovePacket( msg_len, FailMsg );
                _DBG_Write( "FailMsg :  " );
                _DBG_NoTabWriteln( FailMsg );
                LoadError = FailMsg;
            }

            _DBG_Writeln( "making a REQ_PROG_KILL request" );
            killacc.req = REQ_PROG_KILL;
            _DBG_Writeln( "StartPacket" );
            StartPacket();
            _DBG_Writeln( "AddPacket" );
            AddPacket( sizeof( killacc ), &killacc );
            _DBG_Writeln( "PutPacket" );
            PutPacket();
            _DBG_Writeln( "GetPacket" );
            GetPacket();
            //RemovePacket( msg_len, &erracc );
            RemoteUnLink();

            TaskLoaded = FALSE;
        }
    }
    if( ret->err == 0 ) {
        _DBG_Writeln( "loadret->error_code == 0" );
        TaskLoaded = TRUE;
    }
    SaveVectors( LoadVectors );
    SaveVectors( CurrVectors );
    _DBG_ExitFunc( "AccLoadProg()" );
    return( len );
}
Exemple #2
0
const char *RemoteLink( const char *parms, bool server )
{
#ifdef SERVER
    unsigned long       link;
  #if defined(ACAD)
    {
        XVersion = 2;
        if( GetCS() & 3 ) {
            Meg1 = 0x37;
        } else {
            Meg1 = 0x60;
        }
    }
  #elif defined(PHARLAP)
    {
        CONFIG_INF              config;
        static unsigned char    buff[256];

        _dx_config_inf(&config, buff );
        XVersion = config.c_major;
        if( XVersion >= 3 ) {
            Meg1 = config.c_dos_sel;
        } else {
            Meg1 = 0x60;
        }
    }
  #elif defined(CAUSEWAY)
    Meg1 = GetZeroSel();
  #endif
    parms = parms;
    link = GetDosLong( LINK_VECTOR * 4 );
    if( link >= (1024UL * 1024UL) || GetDosLong( link ) != LINK_SIGNATURE ) {
        return( TRP_ERR_not_from_command );
    }
    RMBuffPtr = RMLinToPM( GetDosLong( link + 4 ), 0 );
    RMProcAddr = GetDosLong( link + 8 );
    PutDosLong( LINK_VECTOR * 4, GetDosLong( link + 12 ) );
#else
    static char     fullpath[256];              /* static because ss != ds */
    static char     buff[256];
    static char     *endname;
    char            *name;
    char            *buffp;
    char            *endparm;
    void            __far *link[4];
    void            __far * __far * link_ptr;
    unsigned        len;
  #if defined(PHARLAP)
    const char      *exe_name;
  #endif

    _DBG_EnterFunc( "RemoteLink()" );
    BackFromFork = 0;
    link_ptr = (void __far *)(LINK_VECTOR * 4);
    link[ 3 ] = *link_ptr;
    link[ 2 ] = MK_FP( GetCS(), (unsigned )BackFromProtMode );
    link[ 1 ] = (void __far *)MK_LINEAR( &Buff );
    link[ 0 ] = (void __far *)LINK_SIGNATURE;
    *link_ptr = (void __far *)MK_LINEAR( &link );
    // parms has following format
    // "trap parameters string"+"\0"+"command line string"+"\0"
    _DBG_Write( "Parms: " );
    _DBG_NoTabWriteln( parms );
    while( *parms == ' ' )
        ++parms;
    if( *parms == '`' ) {
        ++parms;
        buffp = buff;
        while( *parms != '\0' ) {
            if( *parms == '`' ) {
                ++parms;
                break;
            }
            *buffp++ = *parms++;
        }
        *buffp = '\0';
    }
    while( *parms == ' ' )
        ++parms;
    if( setjmp( RealModeState ) == 0 ) {
        name = FindExtender( fullpath, &endname );
        if( name == NULL ) {
            _DBG_ExitFunc( "RemoteLink(), unable to find extender" );
            return( TRP_ERR_no_extender );
        }
        _DBG_Write( "Extender name: " );
        _DBG_NoTabWriteln( name );
        while( *endname++ != '\0' ) {}      // skip after extender name + '\0'
  #if defined(ACAD)
        buffp = buff;
        *buffp = '\0';
  #else
        {
            static char     *endhelp;
            const char      *help_name;

    #if defined(PHARLAP)
            exe_name = parms;
            while( *exe_name++ != '\0' ) {} // skip to command line
            help_name = GetHelpName( exe_name );
    #else
            help_name = HELPNAME;
    #endif
            buffp = SearchPath( DOSEnvFind( "PATH" ), help_name, buff, &endhelp );
            if( *buffp == '\0' ) {
                _DBG_ExitFunc( "RemoteLink(), unable to find extender help file" );
                return( TRP_ERR_no_extender );
            }
        }
  #endif
        _DBG_Write( "Extender help name: " );
        _DBG_NoTabWriteln( buffp );
        endparm = CopyStr( parms, endname + 1 );     // reserve length byte
        endparm = CopyStr( buffp, CopyStr( " ", endparm ) );
  #if defined(PHARLAP)
        endparm = CopyStr( " ", endparm );
        endparm = CopyStr( exe_name, endparm );     // add extra executable name
  #endif
        len = endparm - ( endname + 1 );
        if( len > 126 )
            len = 126;
        *endname = len;       // setup length byte
        endparm = endname + len + 1;
        endparm[0] = '\r';
        endparm[1] = '\0';
        _DBG_Write( "Extender Cmd line: " );
        _DBG_NoTabWriteln( endname + 1 );
        _DBG_Writeln( "calling _fork() to start extender/debugee" );
        if( _fork( name, endname ) != 0 ) {
            _DBG_ExitFunc( "RemoteLink(), unable to start extender" );
            return( TRP_ERR_cant_start_extender );
        }
    } else if( BackFromFork || !BeenToProtMode ) {
        _DBG_ExitFunc( "RemoteLink(), extender could not start extender help file" );
        return( TRP_ERR_cant_start_extender );
    }
#endif
    server = server;
    _DBG_ExitFunc( "RemoteLink()" );
    return( NULL );
}
Exemple #3
0
trap_retval ReqProg_load( void )
{
    char                buffer[160];
    char                *src;
    char                *dst;
    char                *name;
    char                *endparm;
    const char          *err;
    tiny_ret_t          rc;
    prog_load_ret       *ret;
    trap_elen           len;

    SaveVectors( OrigVectors );
    _DBG_EnterFunc( "AccLoadProg()" );
    ret = GetOutPtr( 0 );
    src = name = GetInPtr( sizeof( prog_load_req ) );
    rc = FindProgFile( src, buffer, DosExtList );
    endparm = LinkParms;
    while( *endparm++ != '\0' ) {}      // skip trap parameters
    strcpy( endparm, buffer );          // add command line
    // result is as follow
    // "trap parameters string"+"\0"+"command line string"+"\0"
    err = RemoteLink( LinkParms, false );
    if( err != NULL ) {
        _DBG_Writeln( "Can't RemoteLink" );
        TinyWrite( TINY_ERR, err, strlen( err ) );
        LoadError = err;
        ret->err = 1;
        len = 0;
    } else {
        if( TINY_OK( rc ) ) {
            while( *src++ != '\0' ) {}
            len = GetTotalSize() - ( src - name ) - sizeof( prog_load_req );
            dst = (char *)buffer;
            while( *dst++ != '\0' ) {};
            memcpy( dst, src, len );
            dst += len;
            _DBG_Writeln( "StartPacket" );
            StartPacket();
            _DBG_Writeln( "AddPacket" );
            AddPacket( In_Mx_Ptr[0].ptr, sizeof( prog_load_req ) );
            _DBG_Writeln( "AddPacket" );
            AddPacket( buffer, dst - buffer );
            _DBG_Writeln( "PutPacket" );
            PutPacket();
            _DBG_Writeln( "GetPacket" );
            len = GetPacket();
            _DBG_Writeln( "RemovePacket" );
            RemovePacket( ret, sizeof( *ret ) );
        } else {
            len = DoAccess();
        }
        _DBG_Writeln( "Linked --" );
        if( ret->err != 0 ) {
            get_err_text_req    erracc;
            prog_kill_req       killacc;
            trap_elen           msg_len;

            _DBG_Writeln( "loadret->errcode != 0" );
            if( LoadError == NULL ) {
                _DBG_Writeln( "making a REQ_GET_ERR_TEXT request" );
                erracc.req = REQ_GET_ERR_TEXT;
                erracc.err = ret->err;
                _DBG_Writeln( "StartPacket" );
                StartPacket();
                _DBG_Writeln( "AddPacket" );
                AddPacket( &erracc, sizeof( erracc ) );
                _DBG_Writeln( "PutPacket" );
                PutPacket();
                _DBG_Writeln( "GetPacket" );
                msg_len = GetPacket();
                _DBG_Writeln( "RemovePacket" );
                RemovePacket( FailMsg, msg_len );
                _DBG_Write( "FailMsg :  " );
                _DBG_NoTabWriteln( FailMsg );
                LoadError = FailMsg;
            }

            _DBG_Writeln( "making a REQ_PROG_KILL request" );
            killacc.req = REQ_PROG_KILL;
            _DBG_Writeln( "StartPacket" );
            StartPacket();
            _DBG_Writeln( "AddPacket" );
            AddPacket( &killacc, sizeof( killacc ) );
            _DBG_Writeln( "PutPacket" );
            PutPacket();
            _DBG_Writeln( "GetPacket" );
            GetPacket();
            //RemovePacket( &erracc, msg_len );
            RemoteUnLink();

            TaskLoaded = false;
        }
    }
    if( ret->err == 0 ) {
        _DBG_Writeln( "loadret->error_code == 0" );
        TaskLoaded = true;
    }
    SaveVectors( LoadVectors );
    SaveVectors( CurrVectors );
    _DBG_ExitFunc( "AccLoadProg()" );
    return( len );
}