Example #1
0
static bool WriteSegData( void *_sdata, void *_start )
/****************************************************/
{
    segdata         *sdata = _sdata;
    unsigned long   *start = _start;
    unsigned long   newpos;
    unsigned long   pad;

    if( !sdata->isuninit && !sdata->isdead ) {
        newpos = *start + sdata->a.delta;
        if( newpos + (unsigned long)sdata->length < newpos )
            return( FALSE );
        if( newpos > COMAmountWritten ) {
            pad = newpos - COMAmountWritten;
            PadLoad( pad );
            WriteInfoLoad( sdata->u1.vm_ptr, sdata->length );
            COMAmountWritten += sdata->length + pad;
        } else {
            pad = COMAmountWritten - newpos;
            WriteInfoLoad( sdata->u1.vm_ptr + pad, sdata->length - pad );
            COMAmountWritten += sdata->length - pad;
        }
    }
    return( FALSE );
}
Example #2
0
static bool WriteSegData( void *_sdata, void *_start )
/****************************************************/
{
    segdata         *sdata = _sdata;
    soffset         *start = _start;
    soffset         newpos;
    soffset         pad;

    if( !sdata->isuninit && !sdata->isdead ) {
        newpos = *start + sdata->a.delta;
        if( newpos + (soffset)sdata->length > 0 ) {
            if( newpos > COMAmountWritten ) {
                pad = newpos - COMAmountWritten;
                PadLoad( pad );
                WriteInfoLoad( sdata->u1.vm_ptr, sdata->length );
                COMAmountWritten += sdata->length + pad;
            } else {
                pad = COMAmountWritten - newpos;
                WriteInfoLoad( sdata->u1.vm_ptr + pad, sdata->length - pad );
                COMAmountWritten += sdata->length - pad;
            }
        }
    }
    return( false );
}
Example #3
0
static unsigned_32 WriteNovImports( fixed_header *header )
/********************************************************/
{
    nov_import *    import;
    unsigned_32     count;
    char *          name;
    unsigned_8      namelen;
    unsigned_32     wrote;
    unsigned_32     refs;
    virt_mem *      vmem_array;
    symbol *        sym;

    wrote = count = 0;
    for( sym = HeadSym; sym != NULL; sym = sym->link ) {
        if( !( IS_SYM_IMPORTED( sym ) ) )
            continue;
        /* so SymFini doesn't try to free it */
        if( sym->p.import == DUMMY_IMPORT_PTR )
            sym->p.import = NULL;
        import = sym->p.import;

        if( import != NULL ) {
            count++;
            name = sym->name;
            namelen = strlen( name );

            /*
            // netware prefix support
            */
            if( sym->prefix ) {
                namelen += ( strlen( sym->prefix ) + 1);
                WriteLoad( &namelen, sizeof( unsigned_8 ) );
                WriteLoad( sym->prefix, strlen( sym->prefix ) );
                WriteLoad( "@", 1 );
                WriteLoad( name, strlen( sym->name ) );
            } else {
                WriteLoad( &namelen, sizeof( unsigned_8 ) );
                WriteLoad( name, namelen );
            }

            wrote += namelen + sizeof( unsigned_8 ) + sizeof( unsigned_32 );
            if( import->contents <= MAX_IMP_INTERNAL ) {
                refs = import->contents;
                WriteLoad( &refs, sizeof( unsigned_32 ) );
                refs *= sizeof( unsigned_32 );
                WriteLoad( &import->num_relocs, refs );
            } else {        // imports are in virtual memory.
                refs = import->num_relocs;
                WriteLoad( &refs, sizeof( unsigned_32 ) );
                vmem_array = import->vm_ptr;
                for( ; refs > IMP_NUM_VIRT; refs -= IMP_NUM_VIRT ) {
                    WriteInfoLoad( *vmem_array, IMP_VIRT_ALLOC_SIZE );
                    vmem_array++;
                }
                WriteInfoLoad( *vmem_array, refs * sizeof( unsigned_32 ) );
                refs = import->num_relocs * sizeof( unsigned_32 );
            }
            wrote += refs;
        }
    }
    header->numberOfExternalReferences = count;
    return( wrote );
}
Example #4
0
static void CopyLoad( virt_mem data, unsigned long length )
/*********************************************************/
{
    WriteInfoLoad( data, length );
}