コード例 #1
0
static char *ReadInTrap( tiny_handle_t fh )
{
    dos_exe_header      hdr;
    memptr              relocbuff[NUM_BUFF_RELOCS];
    unsigned            relocnb;
    unsigned            imagesize;
    unsigned            hdrsize;
    rm_call_struct      read;
    unsigned            offset;

    if( TINY_ERROR( TinyRead( fh, &hdr, sizeof( hdr ) ) ) ) {
        return( TC_ERR_CANT_LOAD_TRAP );
    }
    if( hdr.signature != DOS_SIGNATURE ) {
        return( TC_ERR_BAD_TRAP_FILE );
    }

    hdrsize = hdr.hdr_size * 16;
    imagesize = ( hdr.file_size * 0x200 ) - (-hdr.mod_size & 0x1ff) - hdrsize;
    TrapMem.dpmi_adr = DPMIAllocateDOSMemoryBlock( _NBPARAS( imagesize ) + hdr.min_16 );
    if( TrapMem.segm.pm == 0 ) {
        return( TC_ERR_OUT_OF_DOS_MEMORY );
    }
    TinySeek( fh, hdrsize, TIO_SEEK_SET );

    memset( &read, 0, sizeof( read ) );
    for( offset = 0; offset < imagesize; offset += (unsigned_16)read.eax ) {
        read.ss = RMData.segm.rm;
        read.sp = offsetof( rm_data, stack ) + STACK_SIZE;
        read.edx = offset;
        read.ebx = fh;
        read.ds = TrapMem.segm.rm;
        read.ecx = imagesize - offset;
        read.eax = 0x3f00;
#if 1
        relocnb = DPMISimulateRealModeInterrupt( 0x21, 0, 0, &read );
        if( (read.flags & 1) || (unsigned_16)read.eax == 0 ) {
            return( TC_ERR_CANT_LOAD_TRAP );
        }
#else
        read.eax = TinyRead( fh, (void *)((TrapMem.segm.rm << 4) + offset), imagesize - offset );
        if( (signed_32)read.eax < 0 ) {
            return( TC_ERR_CANT_LOAD_TRAP );
        }
#endif
    }
    TinySeek( fh, hdr.reloc_offset, TIO_SEEK_SET );
    for( relocnb = NUM_BUFF_RELOCS; hdr.num_relocs > 0; --hdr.num_relocs, ++relocnb ) {
        if( relocnb >= NUM_BUFF_RELOCS ) {
            if( TINY_ERROR( TinyRead( fh, relocbuff, sizeof( memptr ) * NUM_BUFF_RELOCS ) ) ) {
                return( TC_ERR_CANT_LOAD_TRAP );
            }
            relocnb = 0;
        }
        *(addr_seg __far *)MK_PM( TrapMem.segm.rm + relocbuff[relocnb].s.segment, relocbuff[relocnb].s.offset )
        += TrapMem.segm.rm;
    }
    return( NULL );
}
コード例 #2
0
static void MouseRestoreState( addr_seg buff_rmseg, addr32_off buff_offset )
{
    memset( &CallStruct, 0, sizeof( CallStruct ) );
    CallStruct.eax = 0x17;
    CallStruct.es = buff_rmseg;
    CallStruct.edx = buff_offset;
    DPMISimulateRealModeInterrupt( 0x33, 0, 0, &CallStruct );
}
コード例 #3
0
static void _VidStateRestore( uint_16 requested_state, addr_seg buff_rmseg,
                              addr32_off buff_offset )
{
    memset( &CallStruct, 0, sizeof( CallStruct ) );
    CallStruct.eax = 0x1c02;
    CallStruct.es = buff_rmseg;
    CallStruct.ebx = buff_offset;
    CallStruct.ecx = requested_state;
    DPMISimulateRealModeInterrupt( 0x10, 0, 0, &CallStruct );
}
コード例 #4
0
ファイル: trpld.c プロジェクト: Azarien/open-watcom-v2
static char *ReadInTrap( dig_ldhandle ldfh )
{
    dos_exe_header      hdr;
    memptr              relocbuff[NUM_BUFF_RELOCS];
    unsigned            relocnb;
    unsigned            imagesize;
    unsigned            hdrsize;
    rm_call_struct      rm_dos_read;
    unsigned            offset;

    if( DIGLoader( Read )( ldfh, &hdr, sizeof( hdr ) ) ) {
        return( TC_ERR_CANT_LOAD_TRAP );
    }
    if( hdr.signature != DOS_SIGNATURE ) {
        return( TC_ERR_BAD_TRAP_FILE );
    }

    hdrsize = hdr.hdr_size * 16;
    imagesize = ( hdr.file_size * 0x200 ) - (-hdr.mod_size & 0x1ff) - hdrsize;
    TrapMem.dpmi_adr = DPMIAllocateDOSMemoryBlock( _NBPARAS( imagesize ) + hdr.min_16 );
    if( TrapMem.segm.pm == 0 ) {
        return( TC_ERR_OUT_OF_DOS_MEMORY );
    }
    DIGLoader( Seek )( ldfh, hdrsize, DIG_ORG );

    // DPMI file read to real mode memory
    memset( &rm_dos_read, 0, sizeof( rm_dos_read ) );
    for( offset = 0; offset < imagesize; offset += (unsigned_16)rm_dos_read.eax ) {
        rm_dos_read.ss = RMData.segm.rm;
        rm_dos_read.sp = offsetof( rm_data, stack ) + STACK_SIZE;
        rm_dos_read.edx = offset;
        rm_dos_read.ebx = ldfh;
        rm_dos_read.ds = TrapMem.segm.rm;
        rm_dos_read.ecx = imagesize - offset;
        rm_dos_read.eax = 0x3f00;
        relocnb = DPMISimulateRealModeInterrupt( 0x21, 0, 0, &rm_dos_read );
        if( (rm_dos_read.flags & 1) || (unsigned_16)rm_dos_read.eax == 0 ) {
            return( TC_ERR_CANT_LOAD_TRAP );
        }
    }
    DIGLoader( Seek )( ldfh, hdr.reloc_offset, DIG_ORG );
    for( relocnb = NUM_BUFF_RELOCS; hdr.num_relocs > 0; --hdr.num_relocs, ++relocnb ) {
        if( relocnb >= NUM_BUFF_RELOCS ) {
            if( DIGLoader( Read )( ldfh, relocbuff, sizeof( memptr ) * NUM_BUFF_RELOCS ) ) {
                return( TC_ERR_CANT_LOAD_TRAP );
            }
            relocnb = 0;
        }
        *(addr_seg __far *)MK_PM( TrapMem.segm.rm + relocbuff[relocnb].s.segment, relocbuff[relocnb].s.offset ) += TrapMem.segm.rm;
    }
    return( NULL );
}
コード例 #5
0
static void BIOSCharSet( uint_8 vidroutine, uint_8 bytesperchar,
                         uint_16 patterncount, uint_16 charoffset,
                         addr_seg table_rmseg, addr32_off table_offset )
{
    memset( &CallStruct, 0, sizeof( CallStruct ) );
    CallStruct.eax = 0x1100 | vidroutine;
    CallStruct.ebx = (uint_32)bytesperchar << 8;
    CallStruct.ecx = patterncount;
    CallStruct.edx = charoffset;
    CallStruct.es = table_rmseg;
    CallStruct.ebp = table_offset;
    DPMISimulateRealModeInterrupt( 0x10, 0, 0, &CallStruct );
}
コード例 #6
0
ファイル: wrlang.c プロジェクト: ABratovic/open-watcom-v2
static unsigned short dos_get_code_page( void )
/*********************************************/
{
    if( _IsPharLap() ) {
        union REGPACK   regs;

        memset( &regs, 0, sizeof( regs ) );
        regs.w.ax = 0x6601;                 /* get extended country info */
        intr( 0x21, &regs );
        if( (regs.w.flags & 1) == 0 ) {
            return( regs.w.bx );            /* return active code page */
        }
    } else if( _IsRational() ) {
        rm_call_struct  dblock;

        memset( &dblock, 0, sizeof( dblock ) );
        dblock.eax = 0x6601;                /* get extended country info */
        DPMISimulateRealModeInterrupt( 0x21, 0, 0, &dblock );
        if( (dblock.flags & 1) == 0 ) {
            return( (unsigned short)dblock.ebx );
        }
    }
    return( 437 );                          /* return default */
}