Esempio n. 1
0
File: hdisk.c Progetto: FDOS/format
/* forces re-creation of DPB when drive is next accessed */
void Force_Drive_Recheck()
{
    regs.h.ah = 0x0d; /* reset disk system of DOS, flush buffers */
    intdos(&regs, &regs);

    regs.h.ah = 0x32; /* force re-reading of boot sector (not useful for FAT1x?) */
    regs.h.dl = param.drive_number + 1;
    intdosx(&regs, &regs, &sregs);	/* DS:BX is DPB pointer on return - ignored! */
    segread(&sregs);			/* restore defaults */

    if (param.fat_type == FAT32)
    {
        /* structure is DW size 0x18, DW 0, DD function (2 "force media change"),
         * plus 0x10 unused bytes */
        union REGS r;
        struct SREGS s;
        char some_struc[0x20];
        memset(some_struc,0, 0x20);
        some_struc[0] = 0x18;
        some_struc[4] = 2;
        r.x.ax = 0x7304;		/* get/set FAT32 flag stuff */
        s.es   = FP_SEG(&some_struc[0]);
        r.x.di = FP_OFF(&some_struc[0]);
        r.h.dl = param.drive_number+1; /* A: is 1 etc. */
        r.x.cx = 0x18; /* structure size */
        intdosx(&r, &r, &s);
        segread(&sregs);		/* restore defaults */
    } /* FAT32 */
}
Esempio n. 2
0
File: MOVE.C Progetto: FDOS/move
static char *Truename(char *dst, char *src)
{
      union REGS rg;
      struct SREGS rs;
      size_t len;

      if (!src || !*src || !dst)
         return NULL;

      rg.h.ah = 0x60;
      rg.x.si = FP_OFF(src);
      rg.x.di = FP_OFF(dst);
      rs.ds   = FP_SEG(src);
      rs.es   = FP_SEG(dst);

      intdosx(&rg, &rg, &rs);

      if (rg.x.cflag)
         return NULL;
      else
         len = strlen(dst);

      /* DRR: remove trailing '\', but not if it's a drive
       * specification
       */
      if (len > 3 && dst[len-1] == '\\')
         dst[len-1] = '\0';

      return dst;
}
Esempio n. 3
0
unsigned GetFAT32SectorSize(int drivenum)
{
    union REGS inregs, outregs;
    struct SREGS sregs;

    char drive[4], far* fpDrive = (char far*) &drive;
    struct xdfree free, far* fpFree = (struct xdfree far*) &free;

    inregs.x.ax = 0x7303;

    memcpy(drive, "?:\\", 4);
    drive[0] = (char) (drivenum+'A');

    sregs.ds    = FP_SEG(fpDrive);
    inregs.x.dx = FP_OFF(fpDrive);

    free.version = 0;
    sregs.es     = FP_SEG(fpFree);
    inregs.x.di  = FP_OFF(fpFree);
    inregs.x.cx  = sizeof(struct xdfree);

    intdosx(&inregs, &outregs, &sregs);

    if (outregs.x.cflag)
        return 0;
    else if (outregs.h.al == 0)     /* Old DOS */
        return 0;
    else
        return (unsigned) free.BytesPerSector;
}
Esempio n. 4
0
int srch1st(char *pszFile, uint16_t wAttr, fileinfo *pInfo) { /* Search first matching file */
  union REGS inreg;
  union REGS outreg;
  struct SREGS sregs;

  DEBUG_ENTER(("srch1st(\"%s\", 0x%04X, 0x%p);\n", pszFile, wAttr, pInfo));

  /* Make sure the DTA is assigned before calling DOS functions 4E and 4F */
  put_dta((char *)pInfo);

  inreg.h.ah = 0x4e;
  inreg.x.cx = wAttr;
  inreg.x.dx = OFFSET_OF(pszFile);
  sregs.ds = SEGMENT_OF(pszFile);

  intdosx(&inreg, &outreg, &sregs);

  if (CF & outreg.x.cflag) {
    DEBUG_LEAVE(("return %d; // DOS error code\n", outreg.x.ax));
    return (int)(outreg.x.ax);
  }

  previousFI = *pInfo; /* Save it for the workaround for the VMWare player bug */

  DEBUG_LEAVE(("return 0;  // Success\n"));
  return 0;
}
Esempio n. 5
0
 emmtest()
 {
      /*
      Tests for the presence of expnaded memory by attempting to
      open the file EMMXXXX0.
      */
 
      union REGS regs;
      struct SREGS sregs;
      int error;
      long handle;
 
      /* Attempt to open the file device EMMXXXX0 */
      regs.x.ax = 0x3d00;
      regs.x.dx = (int)"EMMXXXX0";
      sregs.ds = 0; //????
      intdosx(&regs,&regs,&sregs);
      handle = regs.x.ax;
      error = regs.x.cflag;
 
      if (!error)
      {
           regs.h.ah = 0x3e;
           regs.x.bx = handle;
           intdos(&regs,&regs);
      }
      return error;
 }
Esempio n. 6
0
WORD ProgramLoad(char *ProgName, char *Parameters) {
  char *LoadFile = ProgName;
  char *CmdLine = Parameters;
  union REGS r;
  struct SREGS s;

  WORD FreeMemorySize;
  WORD Stack_Seg = 0, Stack_Ptr = 0;

  struct Parameter_AL00 par_blk;
  par_blk.EnvSeg = 0;
  par_blk.CmdLineOffset = FP_OFF(CmdLine);
  par_blk.CmdLineSeg = FP_SEG(CmdLine);
  par_blk.FCB1 = par_blk.FCB2 = (DWORD)-1;

  r.h.ah = 0x48; r.x.bx = 0xFFFF; intdos(&r, &r);
  if (r.x.bx < MINPARA) { return 8; }

  Stack_Seg = _SS; Stack_Ptr = _SP;

  r.x.ax = 0x4B00; 	/* Load & Execute */
  r.x.dx = FP_OFF(LoadFile);
  r.x.bx = FP_OFF(&par_blk);
  s.es = s.ds = FP_SEG(LoadFile);
  intdosx(&r, &r, &s);
  if (r.x.flags & 1) { return r.x.ax; }
  disable();
  _SS = Stack_Seg; _SP = Stack_Ptr;
  enable();
  return 0;
}
Esempio n. 7
0
File: ndir.c Progetto: swhobbit/UUPC
extern DIR *opendirx( const char *dirname, char *pattern)
{
   union REGS inregs, outregs;
   struct SREGS segregs;
   char pathname[FILENAME_MAX];
   DTA far *dtasave;
   DTA far *dtaptr;
   char far *pathptr;

/*--------------------------------------------------------------------*/
/*                    Build pathname to be scanned                    */
/*--------------------------------------------------------------------*/

   strcpy(pathname, dirname);
   if ((*pattern != '/') || (dirname[ strlen(dirname) - 1] != '/'))
      strcat(pathname,"/");
   strcat(pathname, pattern);

   /* allocate control block */
   thisDirP = malloc(sizeof(DIR));
   checkref( thisDirP );

/*--------------------------------------------------------------------*/
/*                     Set disk transfer address                      */
/*--------------------------------------------------------------------*/

   dtasave = (DTA far *)getdta();
   dtaptr = (DTA far *)&(thisDirP->dirdta);
   setdta((char far *)dtaptr);

/*--------------------------------------------------------------------*/
/*                      look for the first file                       */
/*--------------------------------------------------------------------*/

   inregs.h.ah = 0x4e;
   pathptr = (char far *)pathname;
   segregs.ds = FP_SEG(pathptr);
   inregs.x.dx = FP_OFF(pathptr);
   inregs.x.cx = 0;   /* attribute */
   intdosx(&inregs, &outregs, &segregs);

   /* bad directory name? */
   if (outregs.x.cflag && (outregs.x.ax == 2 || outregs.x.ax == 3)) {
      free(thisDirP);
      return NULL;
   }

   thisDirP->dirfirst = outregs.x.cflag ? outregs.x.ax : 0;

   setdta((char far *)dtasave);
   strcpy(thisDirP->dirid, "DIR");

#ifdef UDEBUG
   printmsg(2,"opendir: Address is %p", thisDirP );
#endif

   openForBusiness = KWTrue;
   return thisDirP;

} /*opendir*/
Esempio n. 8
0
int ExtendedAbsReadWrite(int drive, int nsects, unsigned long lsect,
                         void* buffer, unsigned area)
{
    union  REGS inregs, outregs;
    struct SREGS sregs;
    struct DISKIO io;

    void far* fpBuffer = (void far*) buffer;
    struct DISKIO far* fpio = (struct DISKIO far*) &io;

    assert(nsects && buffer);

    io.diStartSector = lsect;
    io.diSectors     = nsects;
    io.diBuffer      = (unsigned long) fpBuffer;

    inregs.x.ax = 0x7305;
    inregs.x.cx = 0xFFFF;
    inregs.x.si = area;
    inregs.h.dl = (unsigned char) drive;
    inregs.x.bx = FP_OFF(fpio);
    sregs.ds    = FP_SEG(fpio);

    intdosx(&inregs, &outregs, &sregs);

    return (outregs.x.cflag) ? -1 : 0;
}
/* --------------------------------------------------------------------
   SCGetName: Gets the name into name of session.

   -------------------------------------------------------------------- */
int SCGetName( int session, char * name )
{
   union REGS regs;
   struct SREGS segregs;

   regs.h.ah = 0xDF;
   regs.x.di = 0x534C;
   regs.x.dx = 0x534C;

   regs.h.al = 0x04;
   regs.h.bl = session;


   intdosx( &regs, &regs, &segregs);
   {
      int rc;
      if (regs.h.al == 1) {
         if (regs.x.cx) {
            char far *aux = (char far *)name; /* Power C workaround */
            movedata(segregs.es,regs.x.bx,
                     FP_SEG(aux),FP_OFF(aux),
                     regs.x.cx);
            name[regs.x.cx] = '\0';
         } else {
            sprintf(name, "Work Area Number %d",session);
         }
         rc = 0;
      }
      else rc = regs.h.ah;
      return(rc);
   }
}
Esempio n. 10
0
int valid_drive(char *s)
{
    char buf1[128],buf2[128];
    struct SREGS sregs;
    union REGS regs;

    if (s[1] != ':')
        return(0);

    *TempDrive = *s;

    /* Make sure this is a valid drive. */
    con_fcb[fcbDRIVE] = *TempDrive-'A'+1;
    regs.x.ax = 0x0f00;
    regs.x.dx = (unsigned)con_fcb; /* needs NEAR POINTER */
    intdos(&regs, &regs);
    if (regs.h.al)
        {
        myprintf("Not a valid drive\r\n",0);
        /* printf("Not a valid drive\n") */
        exit(1);
        } /* end if. */

    regs.x.ax = 0x1000;
    regs.x.dx = (unsigned)con_fcb; /* needs NEAR POINTER */
    intdos(&regs, &regs);                 /* Now close the file. */

    /* Make sure user is not trying to label a network drive. */
    regs.h.ah = IOCTL;
    regs.h.al = REMOTE;
    regs.h.bl = (char)(*TempDrive-'A'+1);
    intdos(&regs, &regs);
    if (regs.x.dx & 0x1000)
        {
        myprintf("You cannot label a network drive\r\n",0);
        /* printf("You cannot label a network drive\n"); */
        exit(5);
        } /* end if. */

    /* Make sure the user is not trying to label a drive which has */
    /* been ASSIGNed, JOINed, or SUBSTed. */
    strcpy(buf1, TempDrive);
    strcat(buf1, "\\");
    segread(&sregs);
    regs.x.si = (unsigned)buf1; /* needs NEAR POINTER */
    regs.x.di = (unsigned)buf2; /* needs NEAR POINTER */
    regs.x.ax = 0x6000;
    intdosx(&regs, &regs, &sregs);
    if (*buf1 != *buf2)
        {
        myprintf("You cannot label a drive which has\r\n",0);
        myprintf("been ASSIGNed, JOINed, or SUBSTed.\r\n",0);
        exit(5);
        } /* end if. */

    return(1);

} /* end valid_drive. */
Esempio n. 11
0
/* Get the attributes for a file */
int getattr(const char *file) {
    union REGS r;
    struct SREGS s;
    r.x.ax = 0x4300;
    s.ds = FP_SEG(file);
    r.x.dx = FP_OFF(file);
    intdosx(&r, &r, &s);
    return (r.x.cflag) ? -1 : (int)r.x.cx;
}
Esempio n. 12
0
File: init.c Progetto: FDOS/format
void Setup_DDPT(void)
{
  /* Get the location of the DDPT */

    regs.h.ah =0x35;
    regs.h.al =0x1e;
    intdosx(&regs, &regs, &sregs);

    ddpt = MK_FP(sregs.es, regs.x.bx);
}
Esempio n. 13
0
/**
 * [DosInit description]
 */
void DosInit()
{
    union REGS regs;
    struct SREGS segregs;
    regs.h.ah = GET_INDOS;
    intdosx(&regs, &regs, &segregs);  
    indosPtr = MK_FP(segregs.es, regs.x.bx);  
   
    if(_osmajor < 3)
        critErrPtr = indosPtr + 1;  
    else if(_osmajor == 3 && _osminor == 0)
        critErrPtr = indosPtr - 1;
    else
    {
        regs.x.ax = GET_CRIT_ERR;
        intdosx(&regs, &regs, &segregs);
        critErrPtr = MK_FP(segregs.ds, regs.x.si);
    }
}
Esempio n. 14
0
void setdta( char far *dtaptr )
{
   union REGS inregs, outregs;
   struct SREGS segregs;

   /* set DTA address to our buffer */
   inregs.h.ah = 0x1a;
   segregs.ds = FP_SEG(dtaptr);
   inregs.x.dx = FP_OFF(dtaptr);
   intdosx(&inregs, &outregs, &segregs);
} /* setdta */
Esempio n. 15
0
int dosx(unsigned char fn)
   {
   r.h.ah = fn;
   intdosx(&r, &r, &s);
   if (r.x.cflag) {
      errno = _doserrno;		/* Note: DOS error number, not errno.h number! */
      return -1;
      }
   else
      return 0;
   }
Esempio n. 16
0
void put_dta(char *p_dta) {	/* Set the MS-DOS Disk Transfer Address */
  union REGS inreg;
  union REGS outreg;
  struct SREGS sregs;

  inreg.h.ah = 0x1a;
  inreg.x.dx = OFFSET_OF(p_dta);
  sregs.ds = SEGMENT_OF(p_dta);

  intdosx(&inreg, &outreg, &sregs);
}
Esempio n. 17
0
File: KITTEN.C Progetto: FDOS/fc
int dos_read(int file, void *ptr, unsigned count)
{
	union REGS r;
        struct SREGS s;
	r.h.ah = 0x3f;
	r.x.bx = file;
	r.x.cx = count;
	r.x.dx = FP_OFF(ptr);
        s.ds = FP_SEG(ptr);
	intdosx(&r,&r,&s);
	return ( (r.x.cflag) ? 0 : r.x.ax );
}
Esempio n. 18
0
File: KITTEN.C Progetto: FDOS/fc
int dos_open(char *filename, int mode)
{
	union REGS r;
        struct SREGS s;
	if (mode);		/* mode ignored - readonly supported */
	r.h.ah = 0x3d;
	r.h.al = 0;		/* read mode only supoported now !! */
	r.x.dx = FP_OFF(filename);
        s.ds = FP_SEG(filename);
	intdosx(&r,&r,&s);
	return ( (r.x.cflag) ? -1 : r.x.ax );
}
Esempio n. 19
0
void disp_label()
{
    unsigned char serialbuf[26];
    union REGS regs;
    struct SREGS sregs;

    /* First set the dta to be fcb so information returned is put there. */
    regs.x.ax = 0x1a00;
    regs.x.dx = (unsigned)fcb; /* needs NEAR POINTER */
    intdos(&regs, &regs);

    /* Now try to find the volume label. */
    fcb[fcbDRIVE] = *Drive-'A'+1;
    regs.x.ax = 0x1100;
    regs.x.dx = (unsigned)fcb; /* needs NEAR POINTER */
    intdos(&regs, &regs);
    if (regs.h.al)
        {
        myprintf("Volume in drive ",0);
        myprintf(Drive,1);
        myprintf(" has no label\r\n",0);
        } /* end if. */
    else
        {
        NoLabel = 0;
        fcb[ENDNAME] = '\0';
        myprintf("Volume in drive ",0);
        myprintf(Drive,1);
        myprintf(" is ",0);
        myprintf(&fcb[NAME],0);
        myprintf("\r\n",0);
        } /* end else. */

    /* Now print out the volume serial number, if it exists. */
    segread(&sregs);
    regs.x.ax = 0x6900;
    regs.h.bl = *Drive-'A'+1;
    regs.x.dx = (unsigned)serialbuf; /* needs NEAR POINTER */
    intdosx(&regs, &regs, &sregs);
    if (!regs.x.cflag)
        {
        myprintf("Volume serial number is ",0);
        hexprint(serialbuf[5]);
        hexprint(serialbuf[4]);
        myprintf("-",0);
        hexprint(serialbuf[3]);
        hexprint(serialbuf[2]);
        myprintf("\r\n",0);
        } /* end if. */

} /* end disp_label. */
Esempio n. 20
0
/*
 * newIntVect - set a new 32-bit interrupt vector
 */
static void newIntVect( int vect, void far *rtn )
{
    union REGS          inregs, outregs;
    struct SREGS        segregs;

    segread( &segregs );

    inregs.w.ax = 0x2506;  /* always gain control in prot. mode */
    inregs.h.cl = vect;
    segregs.ds = FP_SEG( rtn );
    inregs.x.edx = FP_OFF( rtn );
    intdosx( &inregs, &outregs, &segregs );

} /* newIntVect */
/* --------------------------------------------------------------------
  SCQuit:             Terminate SC

   -------------------------------------------------------------------- */
void SCQuit( int type )
{
    union REGS regs;
    struct SREGS segregs;

    regs.h.ah = 0xDF;
    regs.x.di = 0x534C;
    regs.x.dx = 0x534C;

    regs.h.al = 14;
    regs.h.bl = type;

    intdosx( &regs, &regs, &segregs);
}
Esempio n. 22
0
main()
{
      int i;
      int unsigned result;
      int drivestatus[26];
      unsigned char FAR *DPB;
      union REGS regs;
      struct SREGS sregs;


      /* routine checks for all valid drive possibilities from A to Z  */

      /*
      **    if removable media drive ie. floppy drive A: has a latch door
      **    open you will get "Abort Retry" panic message
      */

      for (i = 0; i < 26; i++)
      {
            /* drive number (0=default, 1=A, 2=B,etc.)*/

            regs.h.dl = (unsigned char)(i + 1);
            segread(&sregs);

            regs.h.ah=0x32;         /* DOS interrupt 32H */
                                    /* was undocumented for DOS release 3.2 */

            intdosx(&regs,&regs, &sregs);

            result=regs.h.al;
            DPB = MK_FP(sregs.ds, regs.x.bx);

            /*
            **  result =0  then valid drive
            **         =255 or ff hex then invalid or non-existent drive
            */

            if (0 == result && *DPB != (unsigned char)i)
                  drivestatus[i] = 1;
            else  drivestatus[i]=result;
      }

      for (i = 0; i < 26; i = i + 2)
      {
            printf("drive %c: status code =%3d drive %c: status code =%3d\n",
                  'A' + i,drivestatus[i],'B' + i,drivestatus[i+1]);
      }
      return 0;
}
Esempio n. 23
0
/*
 * resetIntVect - reset a 32-bit interrupt vector
 */
static void resetIntVect( int vect, int_vect_32 *vinfo )
{
    union REGS          inregs, outregs;
    struct SREGS        segregs;

    segread( &segregs );

    inregs.w.ax = 0x2507;   /* set prot. and real mode vect */
    inregs.h.cl = vect;
    segregs.ds = FP_SEG( vinfo->prot );
    inregs.x.edx = FP_OFF( vinfo->prot );
    inregs.x.ebx = (unsigned long) vinfo->real;
    intdosx( &inregs, &outregs, &segregs );

} /* resetIntVect */
Esempio n. 24
0
/*
 * getIntVect - get a 32-bit interrupt vector
 */
static void getIntVect( int vect, int_vect_32 *vinfo )
{
    union REGS          inregs, outregs;
    struct SREGS        segregs;

    segread( &segregs );

    inregs.w.ax = 0x2502;   /* get prot. mode vect */
    inregs.h.cl = vect;
    intdosx( &inregs, &outregs, &segregs );
    vinfo->prot = MK_FP( segregs.es, outregs.x.ebx );

    inregs.w.ax = 0x2503;   /* get real mode vect */
    inregs.h.cl = vect;
    intdos( &inregs, &outregs );
    vinfo->real = (void *) outregs.x.ebx;

} /* getIntVect */
Esempio n. 25
0
void main()
  {
    union REGS r;
    struct SREGS s;

#if defined(__386__)
    s.ds = s.es = s.fs = s.gs = FP_SEG( &s );
#endif
    r.h.ah = 0x35;  /* get vector */
    r.h.al = 0x33;  /* vector 0x33 */
    intdosx( &r, &r, &s );
#if defined(__386__)
    printf( "mouse handler address=%4.4x:%lx\n",
            s.es, r.x.ebx );
#else
    printf( "mouse handler address=%4.4x:%4.4x\n",
            s.es, r.x.bx );
#endif
  }
Esempio n. 26
0
int get_file_attributes(const char *name, unsigned *pAttr) {	/* Get File Attributes */
  union REGS inreg;
  union REGS outreg;
  struct SREGS sregs;

  inreg.x.ax = 0x4300;
  inreg.x.dx = OFFSET_OF(name);
  sregs.ds = SEGMENT_OF(name);

  intdosx(&inreg, &outreg, &sregs);

  if (CF & outreg.x.cflag) {
    errno = outreg.x.ax;
    return errno;
  }

  *pAttr = outreg.x.cx;
  return 0;
}
Esempio n. 27
0
File: xcopy.c Progetto: FDOS/xcopy
void _fullpath(char * truename, char * rawname, unsigned int namelen)
{
  union REGS regs;
  struct SREGS sregs;
  if (namelen < 128)
  {
    truename[0] = '\0';
    return;
  }
  regs.x.ax = 0x6000;   /* truename */
  regs.x.si = FP_OFF(rawname);
  sregs.ds = FP_SEG(rawname);
  regs.x.di = FP_OFF(truename);
  sregs.es = FP_SEG(truename);
  intdosx(&regs, &regs, &sregs);
  if (regs.x.cflag != 0)
  {
    truename[0] = '\0';
  }
}
int main()
{union REGS inregs, outregs;
 struct SREGS segs;
 char *filename="d:\\abc\\a.txt";
 int handle;
 inregs.h.ah=0x3d;
 inregs.h.al=0;
 inregs.x.dx=(unsigned)filename;
 segread(&segs);
 intdosx(&inregs,&outregs, &segs);
 if(outregs.x.cflag)
   printf("Error:%d\n",outregs.x.ax);
 else
   {handle=outregs.x.ax;
    printf("Success! handle=%d\n",handle);

   }
 getch();
 return 0;
}
Esempio n. 29
0
char *Truename(char *dst, char *src)
{
      union REGS rg;
      struct SREGS rs;

      if (!src || !*src || !dst)
            return NULL;

      src = trim(src);

      rg.h.ah = 0x60;
      rg.x.si = FP_OFF(src);
      rg.x.di = FP_OFF(dst);
      rs.ds   = FP_SEG(src);
      rs.es   = FP_SEG(dst);

      intdosx(&rg, &rg, &rs);

      return (rg.x.cflag) ? NULL : dst;
}
int EmsCheck(void)
{
   static char DriverName[] = { 'E', 'M', 'M', 'X', 'X', 'X', 'X', '0' };

   union REGS   regs;
   struct SREGS sregs;
   char far *s;
   int i;

   /* retrieve pointer to driver header */
   regs.x.ax = 0x3567;

   intdosx(&regs, &regs, &sregs); /* getvect */
   s = (char far *)MK_FP(sregs.es, 10); /* build far pointer */

   /* now compare with what it should be */
   for(i = 0; i < sizeof(DriverName); i++) {
      if(s[i] != DriverName[i]) break;
   }
   return i == sizeof(DriverName);
}