home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ibmtool.zip / iotmp.c < prev    next >
Text File  |  1997-11-07  |  2KB  |  89 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*      FILE: IOCTL.C                                                         */
  4. /*                                                                            */
  5. /*   PURPOSE: This file contains Ioctl specific code.                         */
  6. /*                                                                            */
  7. /* FUNCTIONS: Version                                                         */
  8. /*            GenIoctl                                                        */
  9. /*                                                                            */
  10. /******************************************************************************/
  11.  
  12. #define INCL_SUB
  13. #define INCL_BASE
  14. #define INCL_DOS
  15. #include <os2.h>
  16. #include <stdio.h>
  17. #include <stdarg.h>
  18. #include <malloc.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <ctype.h>
  22. #include "ndis.h"
  23. #include "ibmtool.h"
  24. #include "ioctl.h"
  25.  
  26. // Fix for faulty include file.  Here is prototype for some API functions.
  27. USHORT APIENTRY DosGetVersion (PUSHORT pVer);
  28. USHORT APIENTRY DosDevIOCtl   (PVOID pData, PVOID pParms, USHORT usFun,
  29.                                USHORT usCategory, HFILE hDev);
  30.  
  31. USHORT DOSVersion;
  32.  
  33. void Version ()
  34. {
  35.   /* Determine whether this is DOS or OS/2 */
  36.   if (DosGetVersion (&DOSVersion))
  37.     {
  38.      printf ("Error determining DOS version.\n");
  39.      exit (-1);
  40.     }
  41.  
  42.   if ((DOSVersion >> 8) == 10)
  43.      DOSVersion = OS2;
  44.   else
  45.     {
  46.      DOSVersion = DOS;
  47.      WedgeCommon->UseGDT = TRUE;
  48.     }
  49. }
  50.  
  51.  int GenIoctl (void far *IoctlDataPtr, ULONG device_fd)
  52. {
  53.   int rc;
  54.  
  55.   if (DOSVersion == OS2)
  56.     {
  57.      rc = DosDevIOCtl (IoctlDataPtr,
  58.                        0L,
  59.                        DIAG_BIND,
  60.                        WEDGE_CATEGORY,
  61.                        (USHORT) device_fd);
  62.     }
  63.   else
  64.     {  
  65.      _asm {
  66.             push    ds
  67.  
  68.             mov     bx, device_fd
  69.             mov     ah, 044h
  70.             mov     al, 003h
  71.             mov     cx, 1
  72.             mov     dx, word ptr IoctlDataPtr
  73.             mov     ds, word ptr IoctlDataPtr+2
  74.             int     21h
  75.  
  76.             pop     ds
  77.             jc      notok
  78.             xor     ax, ax
  79.             notok:
  80.             mov     rc, ax
  81.  
  82.            }
  83.     }
  84.  
  85.   return rc;
  86.  
  87. }
  88.  
  89.