コード例 #1
0
ファイル: msysdep.c プロジェクト: Azarien/open-watcom-v2
RET_T TouchFile( const char *name )
/****************************************/
{
    tiny_date_t     dt;
    tiny_time_t     tm;
    tiny_ftime_t    p_hms;
    tiny_fdate_t    p_ymd;
    tiny_ret_t      ret;

    ret = TinyOpen( name, TIO_WRITE );
    if( TINY_OK( ret ) ) {
        dt = TinyGetDate();
        p_ymd.year  = dt.year + (1900 - 1980);
        p_ymd.month = dt.month;
        p_ymd.day   = dt.day_of_month;

        tm = TinyGetTime();
        p_hms.hours   = tm.hour;
        p_hms.minutes = tm.minutes;
        p_hms.twosecs = tm.seconds / 2;

        TinySetFileStamp( TINY_INFO( ret ), p_hms, p_ymd );
        TinyClose( TINY_INFO( ret ) );
    } else {
        ret = TinyCreate( name, TIO_NORMAL );
        if( TINY_OK( ret ) ) {
            TinyClose( TINY_INFO( ret ) );
        } else {
            return( RET_ERROR );
        }
    }
    return( RET_SUCCESS );
}
コード例 #2
0
static const char *GetHelpName( const char *exe_name )
{
    /*
      if executable is:
          PE format, subsystem PE_SS_PL_DOSSTYLE (0x42) then PEDHELP.EXP
      or:
          PE format, other subsystems then PENHELP.EXP
      otherwise:
          PLSHELP.EXP
    */
    tiny_ret_t          rc;
    tiny_handle_t       handle;
    unsigned_32         off;
    union {
        dos_exe_header  dos;
        pe_header       pe;
    }   head;

    handle = -1;
    rc = TinyOpen( exe_name, 0 );
    if( TINY_ERROR( rc ) )
        goto exp;
    handle = TINY_INFO( rc );
    TinyRead( handle, &head.dos, sizeof( head.dos ) );
    if( head.dos.signature != DOS_SIGNATURE )
        goto exp;
    TinySeek( handle, OS2_NE_OFFSET, SEEK_SET );
    TinyRead( handle, &off, sizeof( off ) );
    TinySeek( handle, off, SEEK_SET );
    TinyRead( handle, &head.pe, sizeof( head.pe ) );
    TinyClose( handle );
    handle = -1;
    switch( head.pe.signature ) {
    case PE_SIGNATURE:
    case PL_SIGNATURE:
        if( head.pe.subsystem == PE_SS_PL_DOSSTYLE ) {
            _DBG_Writeln( "Want PEDHELP" );
            return( HELPNAME_DS );
        }
        _DBG_Writeln( "Want PENHELP" );
        return( HELPNAME_NS );
    }
exp:
    if( handle != -1 )
        TinyClose( handle );
    _DBG_Writeln( "Want PLSHELP" );
    return( HELPNAME );
}
コード例 #3
0
void XcleanUp( where_parm where )
{
    TinyClose( fileHandle );
    fileHandle = TINY_HANDLE_NULL;
    TinyDelete( fullName );
    fullName = NULL;
}
コード例 #4
0
ファイル: _clse.c プロジェクト: ABratovic/open-watcom-v2
int __close( int handle )
{
    tiny_ret_t rc;
#ifdef DEFAULT_WINDOWING
    LPWDATA res;
#endif
    int     rv;

    __handle_check( handle, -1 );
    rv = 0;
    rc = TinyClose( handle );
    if( TINY_OK(rc) ) {
#ifdef DEFAULT_WINDOWING
        if( _WindowsCloseWindow != 0 ) {
            res = _WindowsIsWindowedHandle( handle );
            if( res != NULL ) {
                _WindowsRemoveWindowedHandle( handle );
                _WindowsCloseWindow( res );
            }
        }
#endif
    } else {
        __set_errno( EBADF );
        rv = -1;
    }
    __SetIOMode_nogrow( handle, 0 );
    return( rv );
}
コード例 #5
0
ファイル: spawn.c プロジェクト: ABratovic/open-watcom-v2
/*
 * chkClose
 */
static void chkClose( void )
{
    switch( isWhere ) {
    case ON_DISK:
        TinyClose( fileHandle );
        break;
    }

} /* chkClose */
コード例 #6
0
error_idx LocalClose( sys_handle filehndl )
{
    tiny_ret_t  ret;

    ret = TinyClose( filehndl );
    if( TINY_ERROR( ret ) ) {
        return( StashErrCode( TINY_INFO( ret ), OP_LOCAL ) );
    }
    return( 0 );
}
コード例 #7
0
ファイル: dosfile.c プロジェクト: Ukusbobra/open-watcom-v2
trap_retval ReqFile_close( void )
{
    tiny_ret_t      rc;
    file_close_req  *acc;
    file_close_ret  *ret;

    acc = GetInPtr( 0 );
    ret = GetOutPtr( 0 );
    rc = TinyClose( acc->handle );
    ret->err = TINY_ERROR( rc ) ? TINY_INFO( rc ) : 0;
    return( sizeof( *ret ) );
}
コード例 #8
0
ファイル: linkio.c プロジェクト: JWasm/JWlink
void QClose( f_handle file, char *name )
/*********************************************/
/* file close */
{
    tiny_ret_t h;

    CheckBreak();
    h = TinyClose( file );
    OpenFiles--;
    if( TINY_OK( h ) || name == NULL ) return;
    LnkMsg( ERR+MSG_IO_PROBLEM, "12", name, QErrMsg( TINY_INFO( h ) ) );
}
コード例 #9
0
ファイル: spawn.c プロジェクト: ABratovic/open-watcom-v2
static void cleanUp( void )
{
    switch( isWhere ) {
    case ON_DISK:
        TinyClose( fileHandle );
        TinyDelete( fullName );
        break;
#ifndef NOXMS
    case IN_XMS:
        memGiveBack( &GiveBackXMSBlock );
        break;
#endif
#ifndef NOEMS
    case IN_EMS:
        memGiveBack( &GiveBackEMSBlock );
        break;
#endif
    }

} /* cleanUp */
コード例 #10
0
ファイル: doschk.c プロジェクト: NoSuchProcess/open-watcom-v2
void CheckPointRestore( void )
{
    dos_mem_block   *chk;
    tiny_ret_t      rc;
    tiny_handle_t   hdl;

    rc = TinyOpen( ChkFile, TIO_READ );
    if( TINY_ERROR( rc ) )
        return;
    hdl = TINY_INFO( rc );

    TinyRead( hdl, &chk, sizeof( chk ) );
    TinyRead( hdl, chk, sizeof( *chk ) );
    TinyRead( hdl, &chk, sizeof( chk ) );
    while( TinyRead( hdl, chk, 0x8000 ) == 0x8000 ) {
        chk = MK_FP( FP_SEG( chk ) + 0x800, 0 );
    }
    TinyClose( hdl );
    Cleanup();
}
コード例 #11
0
ファイル: dosfile.c プロジェクト: Ukusbobra/open-watcom-v2
static tiny_ret_t TryPath( char *name, char *end, char *ext_list )
{
    tiny_ret_t  rc;
    char        *p;
    int         done;
    int         mode;

    done = 0;
    mode = 0 ; //IsDOS3 ? 0x40 : 0;
    do {
        if( *ext_list == '\0' ) done = 1;
        for( p = end; *p = *ext_list; ++p, ++ext_list )
            {}
        rc = TinyOpen( name, mode );
        if( TINY_OK( rc ) ) {
            TinyClose( TINY_INFO( rc ) );
            return( rc );
        }
        ++ext_list;
    } while( !done );
    return( rc );
}
コード例 #12
0
ファイル: dosxlink.c プロジェクト: Azarien/open-watcom-v2
static char *SearchPath( const char __far *env, const char *file, char *buff, char **pendname )
{
    char        *endname;
    char        *name;
    tiny_ret_t  rc;
    char        save[20];
    unsigned    len;
    char        *ptr;

    if( env == NULL ) {
        CopyStr( ";", buff );
    } else {
        CopyStr( ";", CopyStr( env, CopyStr( ".;", buff ) ) );
    }
    name = buff;
    len = strlen( file );
    while( *name ) {
        endname = name;
        while( *endname != ';' )
            ++endname;
        memcpy( save, endname, len + 2 );
        ptr = endname;
        if( name != ptr && ptr[-1]!=':' && ptr[-1]!='/' && ptr[-1]!='\\' ) {
            *ptr++ = '\\';
        }
        memcpy( ptr, file, len + 1 );
        rc = TinyOpen( name, 0 );
        if( TINY_OK( rc ) ) {
            TinyClose( TINY_INFO( rc ) );
            break;
        }
        memcpy( endname, save, len + 2 );
        name = endname + 1;
    }
    *pendname = endname;
    return( name );
}
コード例 #13
0
trap_retval ReqProg_load( void )
{
    addr_seg        psp;
    pblock          parmblock;
    tiny_ret_t      rc;
    char            *parm;
    char            *name;
    char            __far *dst;
    char            exe_name[128];
    char            ch;
    EXE_TYPE        exe;
    prog_load_ret   *ret;
    unsigned        len;

    ExceptNum = -1;
    ret = GetOutPtr( 0 );
    memset( &TaskRegs, 0, sizeof( TaskRegs ) );
    TaskRegs.EFL = MyFlags() & ~USR_FLAGS;
    /* build a DOS command line parameter in our PSP command area */
    Flags.BoundApp = FALSE;
    psp = DbgPSP();
    parm = name = GetInPtr( sizeof( prog_load_req ) );
    if( TINY_ERROR( FindFilePath( name, exe_name, DosExtList ) ) ) {
        exe_name[0] = '\0';
    }
    while( *parm++ != '\0' ) {}     // skip program name
    len = GetTotalSize() - ( parm - name ) - sizeof( prog_load_req );
    if( len > 126 )
        len = 126;
    dst = MK_FP( psp, CMD_OFFSET + 1 );
    for( ; len > 0; --len ) {
        ch = *parm++;
        if( ch == '\0' ) {
            if( len == 1 )
                break;
            ch = ' ';
        }
        *dst++ = ch;
    }
    *dst = '\r';
    *(byte __far *)MK_FP( psp, CMD_OFFSET ) = FP_OFF( dst ) - ( CMD_OFFSET + 1 );
    parmblock.envstring = 0;
    parmblock.commandln.segment = psp;
    parmblock.commandln.offset =  CMD_OFFSET;
    parmblock.fcb01.segment = psp;
    parmblock.fcb02.segment = psp;
    parmblock.fcb01.offset  = 0x5C;
    parmblock.fcb02.offset  = 0x6C;
    exe = CheckEXEType( exe_name );
    if( EXEhandle != 0 ) {
        TinyClose( EXEhandle );
        EXEhandle = 0;
    }
    switch( exe ) {
    case EXE_RATIONAL_386:
        ret->err = ERR_RATIONAL_EXE;
        return( sizeof( *ret ) );
    case EXE_PHARLAP_SIMPLE:
        ret->err = ERR_PHARLAP_EXE;
        return( sizeof( *ret ) );
    }
    SegmentChain = 0;
    BoundAppLoading = FALSE;
    rc = DOSLoadProg( exe_name, &parmblock );
    if( TINY_OK( rc ) ) {
        TaskRegs.SS = parmblock.startsssp.segment;
        /* for some insane reason DOS returns a starting SP two less then
           normal */
        TaskRegs.ESP = parmblock.startsssp.offset + 2;
        TaskRegs.CS = parmblock.startcsip.segment;
        TaskRegs.EIP = parmblock.startcsip.offset;
        psp = DOSTaskPSP();
    } else {
        psp = TinyAllocBlock( TinyAllocBlock( 0xffff ) );
        TinyFreeBlock( psp );
        TaskRegs.SS = psp + 0x10;
        TaskRegs.ESP = 0xfffe;
        TaskRegs.CS = psp + 0x10;
        TaskRegs.EIP = 0x100;
    }
    TaskRegs.DS = psp;
    TaskRegs.ES = psp;
    if( TINY_OK( rc ) ) {
        if( Flags.NoOvlMgr || !CheckOvl( parmblock.startcsip ) ) {
            if( exe == EXE_OS2 ) {
                opcode_type __far *loc_brk_opcode;

                BoundAppLoading = TRUE;
                RunProg( &TaskRegs, &TaskRegs );
                loc_brk_opcode = MK_FP(TaskRegs.CS, TaskRegs.EIP);
                if( *loc_brk_opcode == BRKPOINT ) {
                    *loc_brk_opcode = saved_opcode;
                }
                BoundAppLoading = FALSE;
                rc = TinyOpen( exe_name, TIO_READ_WRITE );
                if( TINY_OK( rc ) ) {
                    EXEhandle = TINY_INFO( rc );
                    SeekEXEset( StartByte );
                    WriteEXE( saved_opcode );
                    TinySetFileStamp( EXEhandle, EXETime, EXEDate );
                    TinyClose( EXEhandle );
                    EXEhandle = 0;
                    Flags.BoundApp = TRUE;
                }
            }
        }
    }
    ret->err = TINY_ERROR( rc ) ? TINY_INFO( rc ) : 0;
    ret->task_id = psp;
    ret->flags = 0;
    ret->mod_handle = 0;
    return( sizeof( *ret ) );
}
コード例 #14
0
ファイル: dostrio.c プロジェクト: pavanvunnava/open-watcom-v2
unsigned DIGPathClose( dig_fhandle h )
{
    TinyClose( h );
    return( 0 );
}
コード例 #15
0
ファイル: open.c プロジェクト: ABratovic/open-watcom-v2
static int __F_NAME(__sopen,__wsopen)( const CHAR_TYPE *name, int mode,
                                       int shflag, va_list args )
{
    int         rwmode;
    int         handle;
    int         attr;
    int         permission;
    unsigned    iomode_flags;
    tiny_ret_t  rc;
    char        dummy;
#ifdef __WIDECHAR__
    char        mbName[MB_CUR_MAX * _MAX_PATH];     /* single-byte char */
#endif

    handle = -1;
    rc = 0;
    while( *name == STRING( ' ' ) )
        ++name;
#ifdef __WIDECHAR__
    /*** If necessary, convert the wide filename to multibyte form ***/
    if( wcstombs( mbName, name, sizeof( mbName ) ) == -1 ) {
        mbName[0] = '\0';
    }
#endif
    rwmode = mode & ( O_RDONLY | O_WRONLY | O_RDWR | O_NOINHERIT );
    if( _dos_open( __F_NAME(name,mbName), rwmode | shflag, &handle ) == 0 ) {
        if( handle >= __NFiles ) {
            TinyClose( handle );
            __set_errno( EMFILE );
            return( -1 );
        }
    }
                                        /* 17-apr-90   05-sep-91 */
    if( (mode & (O_RDONLY | O_WRONLY | O_RDWR)) != O_RDONLY ) {
        if( handle != -1 ) {
            if( ! isatty( handle ) ) {      /* if not a device */
#if 0
                rc = TinyAccess( name, 0 ); /* check for existence */
                if( TINY_ERROR( rc ) ) {    /* file does not exist */
                    TinyClose( handle );    /* close whatever file we got */
                    handle = -1;
                } else if( mode & O_EXCL ) {    /* must not exist */
#else
    /*
    Don't need to do the access check, since the file was opened
    and therefore must exist (TinyOpen can't create a file).
    We don't want to do the check because there are classes of items
    in the file system namespace that are not devices, but the TinyAccess
    will fail on (e.g. named pipes).
    */
                /* must not exist if O_CREAT specified */
                if( (mode & O_EXCL) && (mode & O_CREAT) ) {
#endif
                    TinyClose( handle );
                    __set_errno( EEXIST );
                    return( -1 );
                } else if( mode & O_TRUNC ) {   /* truncate file */
                    rc = TinyWrite( handle, &dummy, 0 );
                    if( TINY_ERROR( rc ) ) {
                        TinyClose( handle );
                        return( __set_errno_dos( TINY_INFO( rc ) ) );
                    }
                }
            }
        }
    }
    if( handle == -1 ) {                    /* could not open */
        if( (mode & O_CREAT) == 0 || _RWD_doserrno != E_nofile ) {
            return( -1 );
        }
        /* creating the file */
        permission = va_arg( args, int );
        va_end( args );
        if( permission == 0 )
            permission = S_IWRITE | S_IREAD;
        permission &= ~_RWD_umaskval;               /* 05-jan-95 */
        attr = 0;
        if(( permission & S_IWRITE) == 0 )
            attr = _A_RDONLY;
        #if 0
            /* remove this support because it is not consistently available */
            if( _RWD_osmajor >= 5
                #ifdef __DOS_EXT__
                    && !_IsFlashTek()
                    && !_IsRational()
                #endif
                ) {
                /* this function is only available in version DOS 5 and up */
                /* this new way was added to handle the case of creating a */
                /* new file with read-only access, but with a writeable */
                /* file handle */
                #ifdef __WIDECHAR__
                    rc = TinyCreateEx( mbName, rwmode|shflag, attr, TIO_OPEN );
                #else
                    rc = TinyCreateEx( name, rwmode|shflag, attr, TIO_OPEN );
                #endif
                if( TINY_ERROR( rc ) ) {
                    return( __set_errno_dos( TINY_INFO( rc ) ) );
                }
                handle = TINY_INFO( rc );
            } else
        #endif
        {
            /* do it the old way */
            if( _dos_creat( __F_NAME(name,mbName), attr, &handle ) ) {
                return( -1 );
            }
            if( handle >= __NFiles ) {
                TinyClose( handle );
                __set_errno( EMFILE );
                return( -1 );
            }

            /* 21-nov-90 AFS: the file is created so now the file must be */
            /*                    opened with the correct share permissions */
            if( shflag != 0 ) {
                rc = TinyClose( handle );
                if( TINY_ERROR( rc ) ) {
                    return( __set_errno_dos( TINY_INFO( rc ) ) );
                }
                if( _dos_open( __F_NAME(name,mbName), rwmode | shflag, &handle ) ) {
                    return( -1 );
                }
                /* handle does not equal -1 now */
            }
        }
    }
    iomode_flags = __GetIOMode( handle );
    iomode_flags &= ~(_READ|_WRITE|_APPEND|_BINARY);     /* 11-aug-88 */
    if( isatty( handle ) )              iomode_flags |= _ISTTY;
    rwmode &= ~O_NOINHERIT;
    if( rwmode == O_RDWR )              iomode_flags |= _READ | _WRITE;
    if( rwmode == O_RDONLY)             iomode_flags |= _READ;
    if( rwmode == O_WRONLY)             iomode_flags |= _WRITE;
    if( mode & O_APPEND )               iomode_flags |= _APPEND;
    if( mode & (O_BINARY|O_TEXT) ) {
        if( mode & O_BINARY )           iomode_flags |= _BINARY;
    } else {
        if( _RWD_fmode == O_BINARY )    iomode_flags |= _BINARY;
    }
    __SetIOMode( handle, iomode_flags );
#ifdef DEFAULT_WINDOWING
    if( _WindowsNewWindow != 0 ) {
        if( !__F_NAME(stricmp,wcscmp)( name, STRING( "con" ) ) ) {
            _WindowsNewWindow( NULL, handle, -1 );
        }
    }
#endif
    return( handle );
}


#if 0 /* couldn't find any user; please re-enable if it's necessary */
#ifndef __WIDECHAR__                    /* compile one version only */
int __set_binary( int handle )
{
    unsigned        iomode_flags;

    __ChkTTYIOMode( handle );
    iomode_flags = __GetIOMode( handle );
    iomode_flags |= _BINARY;
    __SetIOMode( handle, iomode_flags );
    if( iomode_flags & _ISTTY ) {
        tiny_ret_t rc;

        rc = TinyGetDeviceInfo( handle );
        if( TINY_ERROR( rc ) ) {
            return( __set_errno_dos( TINY_INFO( rc ) ) );
        }
        rc = TinySetDeviceInfo( handle, TINY_INFO(rc) | TIO_CTL_RAW );
        if( TINY_ERROR( rc ) ) {
            return( __set_errno_dos( TINY_INFO( rc ) ) );
        }
    }
    return( 0 );
}
コード例 #16
0
ファイル: doschk.c プロジェクト: NoSuchProcess/open-watcom-v2
bool CheckPointMem( unsigned max, char *f_buff )
{
    dos_mem_block   *mem;
    dos_mem_block   *start;
    dos_mem_block   *end;
    dos_mem_block   *next;
    dos_mem_block   *chk;
    tiny_ret_t      rc;
    tiny_handle_t   hdl;
    unsigned        size;
    unsigned        bytes;
    unsigned        psp;
    char            *p;

    if( max == 0 ) return( FALSE );
    ChkFile = f_buff;
    psp = TinyGetPSP();
    start = MK_FP( psp - 1, 0 );
    while( start->owner == psp ) {
        if( start->chain == END_OF_CHAIN ) return( FALSE );
//        start = NEXT_BLOCK( start );
        start = MK_FP( (FP_SEG( start ) + (start)->size + 1), 0 );
    }
    mem = start;
    for( ;; ) {
        if( mem->owner == 0 && mem->size >= max ) return( FALSE );
        if(  mem->chain == END_OF_CHAIN ) break;
//        mem = NEXT_BLOCK( mem );
        mem = MK_FP( (FP_SEG( mem ) + (mem)->size + 1), 0 );
    }
//    end = NEXT_BLOCK( mem );
      end = MK_FP( (FP_SEG( mem ) + (mem)->size + 1), 0 );
    size = FP_SEG( end ) - FP_SEG( start );
    if( size < 0x1000 ) return( FALSE );
    *f_buff++ = TinyGetCurrDrive() + 'A';
    *f_buff++ = ':';
    *f_buff++ = '\\';
    rc = TinyFarGetCWDir( (char __far *)f_buff, 0 );
    if( TINY_ERROR( rc ) )
        return( FALSE );
    while( *f_buff != 0 ) ++f_buff;
    if( f_buff[-1] == '\\' ) {
        --f_buff;
    } else {
        *f_buff++ = '\\';
    }
    for( p = CHECK_FILE; *f_buff = *p; ++p, ++f_buff ) {}
    rc = TinyCreate( ChkFile, TIO_NORMAL );
    if( TINY_ERROR( rc ) )
        return( FALSE );
    hdl = TINY_INFO( rc );
    if( size > max ) size = max;
    chk = MK_FP( FP_SEG( end ) - size - 1, 0 );
    mem = start;
    for( ;; ) {
//        next = NEXT_BLOCK( mem );
        next = MK_FP( (FP_SEG( mem ) + (mem)->size + 1), 0 );
        if( FP_SEG( next ) > FP_SEG( chk ) ) break;
        mem = next;
    }
    if( !PUT_ITEM( mem ) || !PUT_ITEM( *mem ) || !PUT_ITEM( chk ) ) {
        TinyClose( hdl );
        Cleanup();
        return( FALSE );
    }
    next = chk;
    while( FP_SEG( next ) < FP_SEG( end ) ) {
        size = FP_SEG( end ) - FP_SEG( next );
        if( size >= 0x1000 ) size = 0x0800;
        bytes = size << 4;
        if( TinyWrite( hdl, next, bytes ) != bytes ) {
            TinyClose( hdl );
            Cleanup();
            return( FALSE );
        }
        next = MK_FP( FP_SEG( next ) + size, 0 );
    }
    TinyClose( hdl );
    mem->chain = MEMORY_BLOCK;
    mem->size = FP_SEG( chk ) - FP_SEG( mem ) - 1;
    chk->size = FP_SEG( end ) - FP_SEG( chk ) - 1;
    chk->chain = END_OF_CHAIN;
    chk->owner = 0;
    return( TRUE );
}
コード例 #17
0
ファイル: cwacc.c プロジェクト: ABratovic/open-watcom-v2
static void AddModHandle( char *name, epsp_t *epsp )
/**************************************************/
{
    mod_t           *mod;
    tiny_ret_t      rc;
    int             handle;
    object_record   obj;
    unsigned_32     off;
    os2_flat_header os2_hdr;
    addr_off        new_base;
    unsigned        i;

    if( ModHandles == NULL ) {
        ModHandles = malloc( sizeof( mod_t ) );
    } else {
        ModHandles = realloc( ModHandles, ( NumModHandles + 1 ) * sizeof( mod_t ) );
    }
    mod = &ModHandles[NumModHandles];
    ++NumModHandles;
    mod->epsp = epsp;
    mod->loaded = TRUE;
    mod->SegCount = 0;
    mod->ObjInfo = NULL;
    if( XVersion >= 0x404 ) {
        name = epsp->FileName;
    }
    rc = TinyOpen( name, TIO_READ );
    if( TINY_ERROR( rc ) ) {
        return;
    }
    handle = TINY_INFO( rc );
    TinySeek( handle, OS2_NE_OFFSET, SEEK_SET );
    TinyRead( handle, &off, sizeof( off ) );
    TinySeek( handle, off, SEEK_SET );
    TinyRead( handle, &os2_hdr, sizeof( os2_hdr ) );
    TinySeek( handle, os2_hdr.objtab_off + off, SEEK_SET );
    mod->SegCount = os2_hdr.num_objects;
    mod->ObjInfo = malloc( os2_hdr.num_objects * sizeof( seg_t ) );
    new_base = 0;
    for( i = 0; i < os2_hdr.num_objects; ++i ) {
        TinyRead( handle, &obj, sizeof( obj ) );
        mod->ObjInfo[i].flags = obj.flags;
        mod->ObjInfo[i].base = obj.addr;
        mod->ObjInfo[i].size = obj.size;
        mod->ObjInfo[i].new_base = new_base;
        new_base += ALIGN4K( obj.size );
        if( NumModHandles == 1 ) {      // main executable
            if( obj.flags & OBJ_BIG ) {
                if( obj.flags & OBJ_EXECUTABLE ) {
                    if( flatCode == FLAT_SEL ) {
                        flatCode = ( mod->epsp->SegBase + i * 8 ) | 3;
                    }
                } else {
                    if( flatData == FLAT_SEL ) {
                        flatData = ( mod->epsp->SegBase + i * 8 ) | 3;
                    }
                }
            }
        }
    }
    TinyClose( handle );
}
コード例 #18
0
void XchkClose( where_parm where )
{
    TinyClose( fileHandle );
    fileHandle = TINY_HANDLE_NULL;
}