home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_03 / 3n03024b < prev    next >
Text File  |  1992-02-08  |  1KB  |  45 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <fcntl.h>
  4.  
  5. #pragma pack(1)
  6.  
  7.  
  8.  
  9. void main(int argc, char **argv)
  10.  
  11. {
  12. int handle;
  13. union REGS regs;
  14. struct {        // control block for READ IOCTL
  15.        unsigned char cmd;
  16.        unsigned int adr_off;
  17.        unsigned int adr_seg;
  18.        } addrbuf;
  19.  
  20. if (argc >= 2)
  21.    {           // open device specified
  22.    if (!_dos_open(argv[1], O_RDONLY, &handle))
  23.       {
  24.       addrbuf.cmd = 0;             // ioctl command 0
  25.       regs.x.ax = 0x4402;          // ioctl read
  26.       regs.x.cx = sizeof addrbuf;  // length to read
  27.       regs.x.dx = (unsigned) &addrbuf;  // buffer to fill
  28.       regs.x.bx = handle;          // open device handle
  29.       intdos(®s, ®s);        // do IOCTL read
  30.       if (!regs.x.cflag)
  31.          <%-2>printf("Device header addr for %s is %04X:%04X\n",<%0>
  32.                argv[1], addrbuf.adr_seg, addrbuf.adr_off);
  33.       else
  34.          printf("Error on IOCTL read\n");
  35.       }
  36.    else
  37.       printf("Unable to open device %s\n", argv[1]);
  38.    }
  39. else
  40.    printf("Please enter name of device driver\n");
  41. }
  42.  
  43. /* End of File */ 
  44.  
  45.