Пример #1
0
static RcStatus copyOtherTables( int *err_code )
{
    uint_32         tablelen;
    os2_exe_header  *oldhead;
    uint_32         oldoffset;
    WResFileID      oldhandle;
    RcStatus        ret;

    oldhead = &(Pass2Info.OldFile.u.NEInfo.WinHead);
    oldoffset = Pass2Info.OldFile.WinHeadOffset;
    oldhandle = Pass2Info.OldFile.Handle;

    /* the other tables start at the resident names table and end at the end */
    /* of the non-resident names table */
    tablelen = (oldhead->nonres_off + oldhead->nonres_size) - ( oldhead->resident_off + oldoffset );

    if( RCSEEK( oldhandle, oldhead->resident_off + oldoffset, SEEK_SET ) == -1 ) {
        *err_code = errno;
        return( RS_READ_ERROR );
    }

    ret = CopyExeData( Pass2Info.OldFile.Handle, Pass2Info.TmpFile.Handle, tablelen );
    *err_code = errno;
    return( ret );
} /* copyOtherTables */
Пример #2
0
/*
 * copyStubFile - copy from the begining of the file to the start of
 *                the win exe header
 */
static RcStatus copyStubFile( int *err_code )
{
    RcStatus    ret;

    ret = CopyExeData( Pass2Info.OldFile.Handle, Pass2Info.TmpFile.Handle, Pass2Info.OldFile.WinHeadOffset );
    *err_code = errno;
    return( ret );
} /* copyStubFile */
Пример #3
0
static RcStatus copyOneResource( ResTable *restab, FullTypeRecord *type,
            WResLangInfo *lang, WResResInfo *res, WResFileID reshandle,
            WResFileID outhandle, int shift_count, int *err_code )
/**********************************************************************/
{
    RcStatus            ret;
    long                out_offset;
    long                align_amount;

    /* align the output file to a boundary for shift_count */
    ret = RS_OK;
    align_amount = 0;   // shut up gcc
    out_offset = RCTELL( outhandle );
    if( out_offset == -1 ) {
        ret = RS_WRITE_ERROR;
        *err_code = errno;
    }
    if( ret == RS_OK ) {
        align_amount = AlignAmount( out_offset, shift_count );
        if( RCSEEK( outhandle, align_amount, SEEK_CUR ) == -1 ) {
            ret = RS_WRITE_ERROR;
            *err_code = errno;
        }
        out_offset += align_amount;
    }

    if( ret == RS_OK ) {
        if( RCSEEK( reshandle, lang->Offset, SEEK_SET ) == -1 ) {
            ret = RS_READ_ERROR;
            *err_code = errno;
        }
    }
    if( ret == RS_OK ) {
        ret = CopyExeData( reshandle, outhandle, lang->Length );
        *err_code = errno;
    }
    if( ret == RS_OK ) {
        align_amount = AlignAmount( RCTELL( outhandle ), shift_count );
        ret = PadExeData( outhandle, align_amount );
        *err_code = errno;
    }

    if( ret == RS_OK ) {
        addExeResRecord( restab, type, &(res->ResName), lang->MemoryFlags,
                out_offset >> shift_count,
                (lang->Length + align_amount) >> shift_count );
    }
Пример #4
0
/* NB: We copy resources in one go even if they span multiple segments.
 * This is fine because all segments but the last one are 64K big, and
 * hence will be nicely aligned.
 */
static RcStatus copyOneResource( WResLangInfo *lang, WResFileID reshandle,
            WResFileID outhandle, int shift_count, int *err_code )
/************************************************************************/
{
    RcStatus            ret;
    long                out_offset;
    long                align_amount;

    /* align the output file to a boundary for shift_count */
    ret = RS_OK;
    out_offset = RCTELL( outhandle );
    if( out_offset == -1 ) {
        ret = RS_WRITE_ERROR;
        *err_code = errno;
    }
    if( ret == RS_OK ) {
        align_amount = AlignAmount( out_offset, shift_count );
        if( RCSEEK( outhandle, align_amount, SEEK_CUR ) == -1 ) {
            ret = RS_WRITE_ERROR;
            *err_code = errno;
        }
        out_offset += align_amount;
    }

    if( ret == RS_OK ) {
        if( RCSEEK( reshandle, lang->Offset, SEEK_SET ) == -1 ) {
            ret = RS_READ_ERROR;
            *err_code = errno;
        }
    }
    if( ret == RS_OK ) {
        ret = CopyExeData( reshandle, outhandle, lang->Length );
        *err_code = errno;
    }
    if( ret == RS_OK ) {
        align_amount = AlignAmount( RCTELL( outhandle ), shift_count );
        ret = PadExeData( outhandle, align_amount );
        *err_code = errno;
    }

    return( ret );
} /* copyOneResource */
Пример #5
0
static bool myCopyExeData( ExeFileInfo *inexe, ExeFileInfo *outexe, uint_32 length )
{
    switch( CopyExeData( inexe->Handle, outexe->Handle, length ) ) {
    case RS_OK:
    case RS_PARAM_ERROR:
        return( false );
    case RS_READ_ERROR:
        RcError( ERR_READING_EXE, inexe->name, strerror( errno ) );
        break;
    case RS_READ_INCMPLT:
        RcError( ERR_UNEXPECTED_EOF, inexe->name );
        break;
    case RS_WRITE_ERROR:
        RcError( ERR_WRITTING_FILE, outexe->name, strerror( errno ) );
        break;
    default:
        RcError( ERR_INTERNAL, INTERR_UNKNOWN_RCSTATUS );
        break;
    }
    return( true );
}