コード例 #1
0
ファイル: hllld.c プロジェクト: bhanug/open-watcom-v2
/*
 * Checks if there is a tailing HLL signature in the file.
 *
 * This may work not work on executable images because of file alignments
 * imposed by the linker (ilink at least). However, TryFindInImage will
 * deal with those formats, so it doesn't really matter here.
 */
static dip_status TryFindTrailer( imp_image_handle *ii )
{
    hll_trailer         sig;
    unsigned long       pos;

    pos = DCSeek( ii->sym_file, DIG_SEEK_POSBACK( sizeof( sig ) ), DIG_END );
    if( pos == DIG_SEEK_ERROR ) {
        return( DS_ERR | DS_FSEEK_FAILED );
    }
    if( DCRead( ii->sym_file, &sig, sizeof( sig ) ) != sizeof( sig ) ) {
        return( DS_ERR | DS_FREAD_FAILED );
    }
    if( !IsHllSignature( &sig ) ) {
        return( DS_FAIL );
    }

    pos -= sig.offset - sizeof( sig );
    return( FoundHLLSign( ii, pos, sig.offset - sizeof( sig ) ) );
}
コード例 #2
0
static dip_status TryFindTrailer( dig_fhandle fid, unsigned long *offp, unsigned long *sizep )
{
    cv_trailer          sig;
    unsigned long       pos;

    pos = DCSeek( fid, DIG_SEEK_POSBACK( sizeof( sig ) ), DIG_END );
    if( pos == DIG_SEEK_ERROR ) {
        return( DS_ERR|DS_FSEEK_FAILED );
    }
    if( DCRead( fid, &sig, sizeof( sig ) ) != sizeof( sig ) ) {
        return( DS_ERR|DS_FREAD_FAILED );
    }
    if( memcmp( sig.sig, CV4_NB09, sizeof( sig.sig ) ) != 0 ) {
        return( DS_FAIL );
    }
    *sizep = sig.offset - sizeof( sig );
    *offp = pos - *sizep;
    return( DS_OK );
}